/[projects]/dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/coveragefileupload/AddressManager.java
ViewVC logotype

Diff of /dao/DaoAdresseVedligehold/src/main/java/dk/daoas/adressevedligehold/coveragefileupload/AddressManager.java

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

revision 2862 by torben, Thu Jan 28 11:07:07 2016 UTC revision 2873 by torben, Thu Jan 28 17:04:34 2016 UTC
# Line 33  public class AddressManager { Line 33  public class AddressManager {
33                    
34          Map<Integer, TreeMap<Short, ArrayList<Address>> > searchStructure;          Map<Integer, TreeMap<Short, ArrayList<Address>> > searchStructure;
35                    
36          ArrayList<AddressSourceEntry> afvisteEntries = new ArrayList<AddressSourceEntry>();          ArrayList<AddressSourceEntry> rejectedEntries = new ArrayList<AddressSourceEntry>();
37            
38            Map<Integer,String> unknownStreets = new TreeMap<Integer, String>();
39                    
40          Map<Short,Short> dbkBaneMap = new TreeMap<Short,Short>();          Map<Short,Short> dbkBaneMap = new TreeMap<Short,Short>();
41                    
# Line 224  public class AddressManager { Line 226  public class AddressManager {
226          private void visitSingle(AddressSourceEntry entry) {          private void visitSingle(AddressSourceEntry entry) {
227                  TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid );                  TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid );
228                  if (gade == null) {                  if (gade == null) {
229                            unknownStreets.putIfAbsent(entry.gadeid, entry.vejnavn);
230                          createFromEntry(entry); // if we get here there was no match - so we need to create it                          createFromEntry(entry); // if we get here there was no match - so we need to create it
231                          return;                          return;
232                  }                  }
# Line 233  public class AddressManager { Line 236  public class AddressManager {
236                          createFromEntry(entry); // if we get here there was no match - so we need to create it                          createFromEntry(entry); // if we get here there was no match - so we need to create it
237                          return;                          return;
238                  }                  }
239                                    boolean found = false;
240                  for (Address addr : litraList) {                  for (Address addr : litraList) {
241                          if (addr.husnrbogstav.equals(entry.litra) ) {                          if (addr.husnrbogstav.equals(entry.litra) ) {
242                                  updateAddress(addr, entry);                                  updateAddress(addr, entry);
243                                  return; //Done for now - no need to look at the rest of the list                                  found = true; // 1 visit should be enough but as long as there's duplicates on gadeid+husnr+litra we will visit them all
244                                    //when the issue with duplicates is resolved this should be reverted to a return or break
245                          }                          }
246                  }                  }
247                                    if (found == false) {
248                  createFromEntry(entry); // if we get here there was no match - so we need to create it                          createFromEntry(entry); // if we get here there was no match - so we need to create it
249                    }
250          }          }
251                    
252          private void visitRange(AddressSourceEntry entry) {          private void visitRange(AddressSourceEntry entry) {
253                                    
254                  TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid );                  TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid );
255                  if (gade == null) {                  if (gade == null) {
256                            unknownStreets.putIfAbsent(entry.gadeid, entry.vejnavn);
257                          System.out.println("[Range] Ukendt gadeID " + entry);                          System.out.println("[Range] Ukendt gadeID " + entry);
258                          return;                          return;
259                  }                  }
# Line 287  public class AddressManager { Line 293  public class AddressManager {
293                    
294          private void updateAddress(Address addr, AddressSourceEntry entry) {          private void updateAddress(Address addr, AddressSourceEntry entry) {
295                  if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) {                  if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) {
296                          afvisteEntries.add(entry);                          rejectedEntries.add(entry);
297                          System.out.println("Afviser " + entry);                          System.out.println("Afviser " + entry);
298                          return;                          return;
299                  }                  }
# Line 593  public class AddressManager { Line 599  public class AddressManager {
599                          break;                          break;
600                  case "NS":                  case "NS":
601                          bane = 204;                          bane = 204;
602                          break;                                            break;
603                    default:
604                            throw new RuntimeException("Ukendt distributor" + a.distributor); //Silence findBugs
605                  }                  }
606                                    
607                  if (bane == null) {                  if (bane == null) {
# Line 612  public class AddressManager { Line 620  public class AddressManager {
620                  return Collections.unmodifiableList(addressList);                  return Collections.unmodifiableList(addressList);
621          }          }
622                    
623            public Map<Integer,String> getUnknownStreets() {
624                    return Collections.unmodifiableMap( unknownStreets );
625            }
626            
627                    
628                    
629          public int getAfvistAntal() {          public int getRejectedCount() {
630                  return afvisteEntries.size();                  return rejectedEntries.size();
631          }          }
632                    
633  }  }

Legend:
Removed from v.2862  
changed lines
  Added in v.2873

  ViewVC Help
Powered by ViewVC 1.1.20