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 |
|
|
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 |
} |
} |
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 |
} |
} |
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 |
} |
} |
450 |
|
|
451 |
|
|
452 |
|
|
453 |
addr.visited = true; |
//addr.visited = true; |
454 |
if (addr.state == AddressState.NOT_CHANGED) { |
if (addr.state == AddressState.NOT_CHANGED) { |
455 |
if (addr.distributor == null) { |
if (addr.distributor == null) { |
456 |
addr.state = AddressState.OPENED; |
addr.state = AddressState.OPENED; |
500 |
a.husnr = entry.husnr; |
a.husnr = entry.husnr; |
501 |
a.husnrbogstav = entry.litra; |
a.husnrbogstav = entry.litra; |
502 |
a.postnr = entry.postnr; |
a.postnr = entry.postnr; |
503 |
a.visited = true; |
//a.visited = true; |
504 |
|
|
505 |
if (entry.ugedage.mandag) { |
if (entry.ugedage.mandag) { |
506 |
a.ruteMandag = entry.rute; |
a.ruteMandag = entry.rute; |
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) { |
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 |
} |
} |