/[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 2894 by torben, Mon Feb 1 07:15:15 2016 UTC revision 2924 by torben, Fri Feb 5 08:01:18 2016 UTC
# Line 15  import dk.daoas.adressevedligehold.Addre Line 15  import dk.daoas.adressevedligehold.Addre
15  import dk.daoas.adressevedligehold.beans.Address;  import dk.daoas.adressevedligehold.beans.Address;
16  import dk.daoas.adressevedligehold.beans.Address.AddressState;  import dk.daoas.adressevedligehold.beans.Address.AddressState;
17  import dk.daoas.adressevedligehold.db.DatabaseLayerImplementation;  import dk.daoas.adressevedligehold.db.DatabaseLayerImplementation;
18    import dk.daoas.adressevedligehold.tasks.TaskLogger;
19  import dk.daoas.adressevedligehold.util.DeduplicateHelper;  import dk.daoas.adressevedligehold.util.DeduplicateHelper;
20  import dk.daoas.adressevedligehold.util.MiscUtils;  import dk.daoas.adressevedligehold.util.MiscUtils;
21  import dk.daoas.adressevedligehold.util.TimingHelper;  import dk.daoas.adressevedligehold.util.TimingHelper;
# Line 28  import dk.daoas.adressevedligehold.util. Line 29  import dk.daoas.adressevedligehold.util.
29    
30  public class AddressManager {  public class AddressManager {
31                    
32            private TaskLogger logger = TaskLogger.getInstance();
33            
34            private int duplicateCount;
35                    
36          List<Address> addressList;          List<Address> addressList;
37                    
# Line 84  public class AddressManager { Line 88  public class AddressManager {
88                          list.trimToSize();                          list.trimToSize();
89                  }                  }
90                                    
91                  System.out.println("AddressManager ready, elapsed " + timer.getElapsed() + "ms");                  logger.info("AddressManager ready, elapsed " + timer.getElapsed() + "ms");
92                                    
93                                    
94          }          }
# Line 181  public class AddressManager { Line 185  public class AddressManager {
185                                  continue;                                  continue;
186                          }                          }
187                                                    
188                          System.out.println(addr.state + ": " + addr.toStringExtended() );                          logger.info(addr.state + ": " + addr.toStringExtended() );
189                          System.out.println(addr.getRuteString() );                          logger.info(addr.getRuteString() );
190                                                    
191                          if (count++ > 50)                          if (count++ > 50)
192                                  return;                                  return;
# Line 190  public class AddressManager { Line 194  public class AddressManager {
194          }          }
195                    
196          public void writeBackChanges() {          public void writeBackChanges() {
197                  System.out.println("Writing back changes");                  logger.info("Writing back changes");
198                  TimingHelper timer = new TimingHelper();                  TimingHelper timer = new TimingHelper();
199                                    
200                  List<Address> updates = new ArrayList<Address>(1024*1024);                  List<Address> updates = new ArrayList<Address>(1024*1024);
# Line 212  public class AddressManager { Line 216  public class AddressManager {
216    
217                                    
218                                    
219                  System.out.println("Writeback done: elapsed " + timer.getElapsed() + "ms.");                  logger.info("Writeback done: elapsed " + timer.getElapsed() + "ms.");
220          }          }
221                    
222                    
# Line 261  public class AddressManager { Line 265  public class AddressManager {
265                                  unknownStreets.put(entry.gadeid, entry.vejnavn);                                                                  unknownStreets.put(entry.gadeid, entry.vejnavn);                                
266                          }                          }
267                                                    
268                          System.out.println("[Range] Ukendt gadeID " + entry);                          logger.info("[Range] Ukendt gadeID " + entry);
269                          return;                          return;
270                  }                  }
271                                    
# Line 301  public class AddressManager { Line 305  public class AddressManager {
305          private void updateAddress(Address addr, AddressSourceEntry entry) {          private void updateAddress(Address addr, AddressSourceEntry entry) {
306                  if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) {                  if ( addr.distributor != null && addr.distributor.equals(entry.distributor) == false) {
307                          rejectedEntries.add(entry);                          rejectedEntries.add(entry);
308                          System.out.println("Afviser " + entry);                          logger.info("Afviser " + entry);
309                          return;                          return;
310                  }                  }
311                                    
# Line 323  public class AddressManager { Line 327  public class AddressManager {
327                                          }                                          }
328                                  }                                                                }                              
329                          } else {                          } else {
330                                  System.out.println( "Double visit monday " + addr);                                  duplicateCount++;
331                                    logger.info( "Double visit monday " + addr);
332                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
333                          }                          }
334    
335                  }                  }
# Line 345  public class AddressManager { Line 351  public class AddressManager {
351                                          }                                          }
352                                  }                                  }
353                          } else {                          } else {
354                                  System.out.println( "Double visit tuesday " + addr);                                  duplicateCount++;
355                                    logger.info( "Double visit tuesday " + addr);
356                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
357                          }                                                        }                              
358                  }                  }
359    
# Line 365  public class AddressManager { Line 373  public class AddressManager {
373                                          }                                          }
374                                  }                                  }
375                          } else {                          } else {
376                                  System.out.println( "Double visit wednesday " + addr);                                  duplicateCount++;
377                                    logger.info( "Double visit wednesday " + addr);
378                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
379                          }                                        }              
380                  }                  }
381    
# Line 387  public class AddressManager { Line 397  public class AddressManager {
397                                          }                                          }
398                                  }                                  }
399                          } else {                          } else {
400                                  System.out.println( "Double visit thursday " + addr);                                  duplicateCount++;
401                                    logger.info( "Double visit thursday " + addr);
402                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
403                          }                                                                }                                      
404                  }                  }
405    
# Line 408  public class AddressManager { Line 420  public class AddressManager {
420                                          }                                          }
421                                  }                                  }
422                          } else {                          } else {
423                                  System.out.println( "Double visit friday " + addr);                                  duplicateCount++;
424                                    logger.info( "Double visit friday " + addr);
425                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
426                          }                                }      
427                  }                  }
428    
# Line 430  public class AddressManager { Line 444  public class AddressManager {
444                                          }                                          }
445                                  }                                  }
446                          } else {                          } else {
447                                  System.out.println( "Double visit saturday " + addr);                                  duplicateCount++;
448                                    logger.info( "Double visit saturday " + addr);
449                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
450                          }                                                                }                                      
451                  }                  }
452    
# Line 451  public class AddressManager { Line 467  public class AddressManager {
467                                          }                                          }
468                                  }                                  }
469                          } else {                          } else {
470                                  System.out.println( "Double visit sunday " + addr);                                  duplicateCount++;
471                                    logger.info( "Double visit sunday " + addr);
472                                    return; // if the entry is duplicate on one day that it covers - then it will be as well on all the othters
473                          }                                                                }                                      
474                  }                  }
475                                    
# Line 479  public class AddressManager { Line 497  public class AddressManager {
497                    
498                    
499          private void createFromEntry(AddressSourceEntry entry) {          private void createFromEntry(AddressSourceEntry entry) {
500                    if (entry.husnr >= 1000) { //husnumre i DK må kun være på 3 cifre
501                            return;
502                    }
503                    
504                  if (entry.husnr == 999) {                  if (entry.husnr == 999) {
505                          return;                          return;
506                  }                  }
507                    
508                    if (entry.litra.length() > 1) { //litra må kun være på 1 tegn
509                            return;
510                    }
511                    if (entry.litra.length() == 1) {
512                            char litra = entry.litra.charAt(0);
513                            if ( Character.isLetter(litra) == false ) {
514                                    return;
515                            }
516                            
517                    }
518                    
519                  if (entry.kommunekode == 0 || entry.vejkode == 0) {                  if (entry.kommunekode == 0 || entry.vejkode == 0) {
520                          return;                          return;
521                  }                  }
# Line 492  public class AddressManager { Line 526  public class AddressManager {
526                  if (entry.gadeid == 0) {                  if (entry.gadeid == 0) {
527                          return;                          return;
528                  }                  }
529                                                    
530                  String gadeidStr = Integer.toString(entry.gadeid);                  String gadeidStr = Integer.toString(entry.gadeid);
531                  if (gadeidStr.length() != 9) {                  if (gadeidStr.length() != 9) {
532                          return;                          return;
# Line 503  public class AddressManager { Line 537  public class AddressManager {
537                                    
538                                    
539                                    
540                  System.out.println("Opretter adresse ud fra " + entry);                  logger.info("Opretter adresse ud fra " + entry);
541                                    
542                  Address a = new Address();                  Address a = new Address();
543                  a.state = AddressState.CREATED;                  a.state = AddressState.CREATED;
# Line 617  public class AddressManager { Line 651  public class AddressManager {
651                          bane = 204;                          bane = 204;
652                          break;                          break;
653                  default:                  default:
654                          throw new RuntimeException("Ukendt distributor" + a.distributor); //Silence findBugs                          throw new RuntimeException("Ukendt distributor: " + a.distributor); //Silence findBugs
655                  }                  }
656                                    
657                  if (bane == null) {                  if (bane == null) {
658                          throw new RuntimeException("Ukendt bane for postnr" + a.postnr);                          throw new RuntimeException("Ukendt bane for postnr: " + a.postnr);
659                  }                  }
660                                    
661                  if (a.dbkBane != bane) {                  if (a.dbkBane != bane) {
# Line 640  public class AddressManager { Line 674  public class AddressManager {
674                  return Collections.unmodifiableMap( unknownStreets );                  return Collections.unmodifiableMap( unknownStreets );
675          }          }
676                    
677                    public int getDuplicateCount() {
678                    return duplicateCount;
679            }
680                    
681          public int getRejectedCount() {          public int getRejectedCount() {
682                  return rejectedEntries.size();                  return rejectedEntries.size();

Legend:
Removed from v.2894  
changed lines
  Added in v.2924

  ViewVC Help
Powered by ViewVC 1.1.20