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 |
|
|
208 |
DatabaseLayerImplementation db = new DatabaseLayerImplementation(); |
DatabaseLayerImplementation db = new DatabaseLayerImplementation(); |
209 |
|
|
210 |
db.updateAddresses(updates); |
db.updateAddresses(updates); |
211 |
|
db.saveNewAddresses(inserts); |
212 |
|
|
213 |
|
|
214 |
|
|
227 |
private void visitSingle(AddressSourceEntry entry) { |
private void visitSingle(AddressSourceEntry entry) { |
228 |
TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid ); |
TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid ); |
229 |
if (gade == null) { |
if (gade == null) { |
230 |
|
unknownStreets.putIfAbsent(entry.gadeid, entry.vejnavn); |
231 |
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 |
232 |
return; |
return; |
233 |
} |
} |
237 |
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 |
238 |
return; |
return; |
239 |
} |
} |
240 |
|
boolean found = false; |
241 |
for (Address addr : litraList) { |
for (Address addr : litraList) { |
242 |
if (addr.husnrbogstav.equals(entry.litra) ) { |
if (addr.husnrbogstav.equals(entry.litra) ) { |
243 |
updateAddress(addr, entry); |
updateAddress(addr, entry); |
244 |
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 |
245 |
|
//when the issue with duplicates is resolved this should be reverted to a return or break |
246 |
} |
} |
247 |
} |
} |
248 |
|
if (found == false) { |
249 |
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 |
250 |
|
} |
251 |
} |
} |
252 |
|
|
253 |
private void visitRange(AddressSourceEntry entry) { |
private void visitRange(AddressSourceEntry entry) { |
254 |
|
|
255 |
TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid ); |
TreeMap<Short, ArrayList<Address>> gade = searchStructure.get( entry.gadeid ); |
256 |
if (gade == null) { |
if (gade == null) { |
257 |
|
unknownStreets.putIfAbsent(entry.gadeid, entry.vejnavn); |
258 |
System.out.println("[Range] Ukendt gadeID " + entry); |
System.out.println("[Range] Ukendt gadeID " + entry); |
259 |
return; |
return; |
260 |
} |
} |
294 |
|
|
295 |
private void updateAddress(Address addr, AddressSourceEntry entry) { |
private void updateAddress(Address addr, AddressSourceEntry entry) { |
296 |
if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) { |
if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) { |
297 |
afvisteEntries.add(entry); |
rejectedEntries.add(entry); |
298 |
System.out.println("Afviser " + entry); |
System.out.println("Afviser " + entry); |
299 |
return; |
return; |
300 |
} |
} |
451 |
|
|
452 |
|
|
453 |
|
|
454 |
addr.visited = true; |
//addr.visited = true; |
455 |
if (addr.state == AddressState.NOT_CHANGED) { |
if (addr.state == AddressState.NOT_CHANGED) { |
456 |
if (addr.distributor == null) { |
if (addr.distributor == null) { |
457 |
addr.state = AddressState.OPENED; |
addr.state = AddressState.OPENED; |
479 |
if (entry.kommunekode == 0 || entry.vejkode == 0) { |
if (entry.kommunekode == 0 || entry.vejkode == 0) { |
480 |
return; |
return; |
481 |
} |
} |
482 |
|
if (entry.kommunekode < 100) { |
483 |
|
return; |
484 |
|
} |
485 |
|
|
486 |
|
String gadeidStr = Integer.toString(entry.gadeid); |
487 |
|
if (gadeidStr.length() != 9) { |
488 |
|
return; |
489 |
|
} |
490 |
|
if (Short.parseShort(gadeidStr.substring(0, 4)) != entry.postnr) { |
491 |
|
return; //gadeid / postnr mismatch |
492 |
|
} |
493 |
|
|
494 |
|
|
495 |
|
|
496 |
System.out.println("Opretter adresse ud fra " + entry); |
System.out.println("Opretter adresse ud fra " + entry); |
506 |
a.husnr = entry.husnr; |
a.husnr = entry.husnr; |
507 |
a.husnrbogstav = entry.litra; |
a.husnrbogstav = entry.litra; |
508 |
a.postnr = entry.postnr; |
a.postnr = entry.postnr; |
509 |
a.visited = true; |
//a.visited = true; |
510 |
|
|
511 |
if (entry.ugedage.mandag) { |
if (entry.ugedage.mandag) { |
512 |
a.ruteMandag = entry.rute; |
a.ruteMandag = entry.rute; |
605 |
break; |
break; |
606 |
case "NS": |
case "NS": |
607 |
bane = 204; |
bane = 204; |
608 |
break; |
break; |
609 |
|
default: |
610 |
|
throw new RuntimeException("Ukendt distributor" + a.distributor); //Silence findBugs |
611 |
} |
} |
612 |
|
|
613 |
if (bane == null) { |
if (bane == null) { |
626 |
return Collections.unmodifiableList(addressList); |
return Collections.unmodifiableList(addressList); |
627 |
} |
} |
628 |
|
|
629 |
|
public Map<Integer,String> getUnknownStreets() { |
630 |
|
return Collections.unmodifiableMap( unknownStreets ); |
631 |
|
} |
632 |
|
|
633 |
|
|
634 |
|
|
635 |
public int getAfvistAntal() { |
public int getRejectedCount() { |
636 |
return afvisteEntries.size(); |
return rejectedEntries.size(); |
637 |
} |
} |
638 |
|
|
639 |
} |
} |