/[projects]/dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AdressSearch.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/dk/daoas/daoadresseservice/AdressSearch.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2283 by torben, Fri Feb 13 15:45:24 2015 UTC revision 2289 by torben, Sat Feb 14 08:43:45 2015 UTC
# Line 21  public class AdressSearch { Line 21  public class AdressSearch {
21    
22          List<Address> alleAdresser;          List<Address> alleAdresser;
23                    
         /* Mapper mellem db Row ID og adresse noden */  
         Map<Integer,Address> idAddressMap;  
           
24                    
25          Map<Integer,HundredePctBean> hundredePct;          Map<Integer,HundredePctBean> hundredePct;
26                    
27                    
28          public SearchResult search(String postnrStr, String adresse)  {          public SearchResult search(String postnrStr, String adresse)  {
29    //long start1 = System.currentTimeMillis();
30                    
31                  int postnr=0;                  int postnr=0;
32                                    
33                  try {                  try {
# Line 36  public class AdressSearch { Line 35  public class AdressSearch {
35                  } catch (Exception E) {                  } catch (Exception E) {
36                          return new SearchResult(Status.ERROR_UNKNOWN_POSTAL);                          return new SearchResult(Status.ERROR_UNKNOWN_POSTAL);
37                  }                                }              
38    //long start2 = System.currentTimeMillis();
39                                    
40                  Map<String,Long> postnrVeje = searchPostnrVejnavnGadeid.get(postnr);                                      Map<String,Long> postnrVeje = searchPostnrVejnavnGadeid.get(postnr);                    
41                                    
# Line 43  public class AdressSearch { Line 43  public class AdressSearch {
43                          return new SearchResult(Status.ERROR_UNKNOWN_POSTAL);                          return new SearchResult(Status.ERROR_UNKNOWN_POSTAL);
44                  }                  }
45                                    
46    //long start3 = System.currentTimeMillis();
47                    
48                  SplitResult split = AddressUtils.splitAdresse(adresse);                  SplitResult split = AddressUtils.splitAdresse(adresse);
49                  String vasketVejnavn = AddressUtils.vaskVejnavn( split.vej );                  String vasketVejnavn = AddressUtils.vaskVejnavn( split.vej );                          
50                                    
51                  if (split.husnr.length() == 0) {                  if (split.husnr.length() == 0) {
52                          return new SearchResult(Status.ERROR_MISSING_HOUSENUMBER);                                                return new SearchResult(Status.ERROR_MISSING_HOUSENUMBER);                      
53                  }                  }
54    //long start4 = System.currentTimeMillis();
55                                    
56                  Long gadeident =  postnrVeje.get(vasketVejnavn);                  Long gadeident =  postnrVeje.get(vasketVejnavn);
57                  if (gadeident == null) {                  if (gadeident == null) {
58                          return new SearchResult(Status.ERROR_UNKNOWN_STREETNAME);                          return new SearchResult(Status.ERROR_UNKNOWN_STREETNAME);
59                  }                        }
60    //long start5 = System.currentTimeMillis();
61                                    
62                  Map<String, Address> gade =  searchGadeidentAdresser.get(gadeident); //Denne søgning må ikke fejle                  Map<String, Address> gade =  searchGadeidentAdresser.get(gadeident); //Denne søgning må ikke fejle
63                                    
64    //long start6 = System.currentTimeMillis();
65                                    
66                  String husnrSearch = "" + split.husnr + split.litra;                  String husnrSearch = "" + split.husnr + split.litra;
67                  Address addr = gade.get(husnrSearch);                  Address addr = gade.get(husnrSearch);
68    //long start7 = System.currentTimeMillis();
69                  if (addr == null) {                  if (addr == null) {
70                          return new SearchResult(Status.ERROR_UNKNOWN_ADDRESSPOINT);                          return new SearchResult(Status.ERROR_UNKNOWN_ADDRESSPOINT);
71                  }                  }
# Line 71  public class AdressSearch { Line 77  public class AdressSearch {
77                  if (addr.distributor.equals("LUKKET")) {                  if (addr.distributor.equals("LUKKET")) {
78                          return new SearchResult(Status.STATUS_NOT_COVERED); //Skal vi have en special status til Lukkede adresser ?                          return new SearchResult(Status.STATUS_NOT_COVERED); //Skal vi have en special status til Lukkede adresser ?
79                  }                  }
80                    
81    /*
82    System.out.println("Search2: " + (start2-start1) );
83    System.out.println("Search3: " + (start3-start1) );
84    System.out.println("Search4: " + (start4-start1) );
85    System.out.println("Search5: " + (start5-start1) );
86    System.out.println("Search6: " + (start6-start1) );
87    System.out.println("Search7: " + (start7-start1) );
88    */
89    
90                                                                    
91                                    
92                  return new SearchResult(addr);                  return new SearchResult(addr);
# Line 80  public class AdressSearch { Line 96  public class AdressSearch {
96          public void buildSearchStructures() throws SQLException{          public void buildSearchStructures() throws SQLException{
97                  searchPostnrVejnavnGadeid = new HashMap<Integer, Map<String,Long>>();                  searchPostnrVejnavnGadeid = new HashMap<Integer, Map<String,Long>>();
98                  searchGadeidentAdresser = new HashMap<Long,  Map<String,Address>>();                  searchGadeidentAdresser = new HashMap<Long,  Map<String,Address>>();
99                  idAddressMap = new HashMap<Integer,Address>();                                  
                   
100                  System.out.println("Build -- stage 1");                  System.out.println("Build -- stage 1");
101                                    
102                  alleAdresser = DatabaseLayer.getAllAdresses();                  alleAdresser = DatabaseLayer.getAllAdresses();
103                                    
104                    
105                    /* Mapper mellem db Row ID og adresse noden */
106                    Map<Integer,Address> idAddressMap = new HashMap<Integer,Address>( alleAdresser.size() );
107                    
108                  for (Address a : alleAdresser) {                  for (Address a : alleAdresser) {
109                          idAddressMap.put(a.id, a);                          idAddressMap.put(a.id, a);
110                                                    
# Line 108  public class AdressSearch { Line 127  public class AdressSearch {
127                                  searchGadeidentAdresser.put(a.gadeid, gade);                                  searchGadeidentAdresser.put(a.gadeid, gade);
128                          }                          }
129                          String husnrSearch = "" + a.husnr + a.husnrbogstav;                          String husnrSearch = "" + a.husnr + a.husnrbogstav;
130                          gade.put(husnrSearch, a);                          gade.put(husnrSearch, a);                      
131                  }                  }
132                                    
133                                    
# Line 164  public class AdressSearch { Line 183  public class AdressSearch {
183                                                                    
184                                  orgAddress.distributor = targetAddress.distributor;                                  orgAddress.distributor = targetAddress.distributor;
185                          }                          }
   
                           
186                  }                  }
187                    
188                    // nu skal vi ikke bruge idAddressMap længere
189                    idAddressMap = null;
190                    
191                  //////////////////////////////////////////////////////////////////////////////////////                  //////////////////////////////////////////////////////////////////////////////////////
192                  System.out.println("Build -- stage 3 - 100pct");                  System.out.println("Build -- stage 3 - 100pct");
193                                    
194                  hundredePct = DatabaseLayer.get100PctList();                  hundredePct = DatabaseLayer.get100PctList();
195                  for (Address addr : alleAdresser) {                  for (Address addr : alleAdresser) {
196                          if (addr.daekningsType != DaekningsType.DAEKNING_IKKEDAEKKET) {                          if (addr.daekningsType != DaekningsType.DAEKNING_IKKEDAEKKET) {                        
197                                  continue;                                  continue;
198                          }                          }
199                                                    
# Line 193  public class AdressSearch { Line 214  public class AdressSearch {
214                          addr.distributor = bean.distributor;                          addr.distributor = bean.distributor;
215                  }                  }
216                                    
217                    ////////////////////////////////////////////////////////////////////////////////////
218                    System.out.println("Build -- Gathering statistics");
219                    
220                    int direkteCount = 0;
221                    int extendedCount = 0;
222                    int hundredePctCount = 0;
223                    int ikkeDaekketCount = 0;
224                    
225                    for (Address addr : alleAdresser) {
226                            switch (addr.daekningsType) {
227                            case DAEKNING_DIREKTE:
228                                    direkteCount++;
229                                    break;
230                            case DAEKNING_UDVIDET:
231                                    extendedCount++;
232                                    break;
233                            case DAEKNING_100PCT:
234                                    hundredePctCount++;
235                                    break;
236                            default:
237                                    ikkeDaekketCount++;
238                            }
239                    }
240                    
241                    System.out.println("Build: direkteCount: " + direkteCount);
242                    System.out.println("Build: extendedCount: " + extendedCount);
243                    System.out.println("Build: hundredePctCount: " + hundredePctCount);
244                    System.out.println("Build: ikkeDaekketCount: " + ikkeDaekketCount);
245                    
246                  System.out.println("Build Completed");                  System.out.println("Build Completed");
247                                    
248          }          }

Legend:
Removed from v.2283  
changed lines
  Added in v.2289

  ViewVC Help
Powered by ViewVC 1.1.20