/[projects]/dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/db/DatabaseLayer.java
ViewVC logotype

Diff of /dao/DaoAdresseService/src/main/java/dk/daoas/daoadresseservice/db/DatabaseLayer.java

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

revision 2320 by torben, Tue Feb 17 08:58:41 2015 UTC revision 2337 by torben, Mon Feb 23 12:30:41 2015 UTC
# Line 18  import dk.daoas.daoadresseservice.util.D Line 18  import dk.daoas.daoadresseservice.util.D
18    
19  public class DatabaseLayer {  public class DatabaseLayer {
20                    
21            static boolean DEBUG = false;
22            
23          public static List<Address> getAllAdresses() throws SQLException {          public static List<Address> getAllAdresses() throws SQLException {
24                    String debugFilter = DatabaseLayer.DEBUG ? " AND postnr = 8700 " : "";
25                                    
26                  String sql = "SELECT id,vejnavn,husnr,husnrbogstav,kommunekode,vejkode,postnr,gadeid,upper(distributor) AS distributor,dbkbane,koreliste,rute "                  String sql = "SELECT id,vejnavn,husnr,husnrbogstav,kommunekode,vejkode,postnr,gadeid,upper(distributor) AS distributor,dbkbane,koreliste,rute "
27                                  + "FROM fulddaekning.adressetabel "                                  + "FROM fulddaekning.adressetabel "
28                                  + "WHERE gadeid IS NOT NULL "                                  + "WHERE gadeid IS NOT NULL "
29                                  //+ "AND postnr = 8700" //DEBUG only                                  + debugFilter
30                                  ;                                  ;
31                                    
32                  Connection conn = DBConnection.getConnection();                          Connection conn = DBConnection.getConnection();        
# Line 34  public class DatabaseLayer { Line 37  public class DatabaseLayer {
37                  List<Address> list = new ArrayList<Address>(2600000);//initial capacity 2.6 mio                  List<Address> list = new ArrayList<Address>(2600000);//initial capacity 2.6 mio
38                                    
39                  DeduplicateHelper<String> vejnavnCache = new DeduplicateHelper<String>();                  DeduplicateHelper<String> vejnavnCache = new DeduplicateHelper<String>();
40                    DeduplicateHelper<String> husnrbogstavCache = new DeduplicateHelper<String>();
41                  DeduplicateHelper<String> distributorCache = new DeduplicateHelper<String>();                  DeduplicateHelper<String> distributorCache = new DeduplicateHelper<String>();
42                  DeduplicateHelper<String> korelisteCache = new DeduplicateHelper<String>();                  DeduplicateHelper<String> korelisteCache = new DeduplicateHelper<String>();
43                  DeduplicateHelper<String> ruteCache = new DeduplicateHelper<String>();                  DeduplicateHelper<String> ruteCache = new DeduplicateHelper<String>();
# Line 45  public class DatabaseLayer { Line 49  public class DatabaseLayer {
49                          a.id = res.getInt(1);                          a.id = res.getInt(1);
50                          a.vejnavn = vejnavnCache.getInstance( res.getString(2) );                          a.vejnavn = vejnavnCache.getInstance( res.getString(2) );
51                          a.husnr = res.getInt(3);                          a.husnr = res.getInt(3);
52                          a.husnrbogstav = res.getString(4);                          a.husnrbogstav = husnrbogstavCache.getInstance( res.getString(4) );
53                          a.kommunekode = res.getInt(5);                          a.kommunekode = res.getInt(5);
54                          a.vejkode = res.getInt(6);                          a.vejkode = res.getInt(6);
55                          a.postnr = res.getInt(7);                          a.postnr = res.getInt(7);
# Line 75  public class DatabaseLayer { Line 79  public class DatabaseLayer {
79          }          }
80                    
81          public static List<ExtendedBean> getExtendedAdresslist() throws SQLException {          public static List<ExtendedBean> getExtendedAdresslist() throws SQLException {
82                    String debugFilter1 = DatabaseLayer.DEBUG ? " WHERE orgPostnr = 8700 " : "";
83                    String debugFilter2 = DatabaseLayer.DEBUG ? " AND orgPostnr = 8700 " : "";
84                    
85                                    
86                  String sql = "select orgid, a.id as targetid, afstand, LOWER(type) as type from fulddaekning.afstand_anden_rute a " +                  String sql = "select orgid, a.id as targetid, afstand, LOWER(type) as type from fulddaekning.afstand_anden_rute a " +
87                                          "join odbc.transporttype t " +                                          "join odbc.transporttype t " +
88                                          "on t.Art = 'Transpost' " +                                          "on t.Art = 'Transpost' " +
89                                          "and ( (t.Type = 'Cykel' and a.Afstand < 1.001) or (t.Type = 'Scooter' and a.Afstand < 1.201) or (t.Type = 'Bil' and a.Afstand < 2.601) ) " +                                          "and ( (t.Type = 'Cykel' and a.Afstand < 1.001) or (t.Type = 'Scooter' and a.Afstand < 1.201) or (t.Type = 'Bil' and a.Afstand < 2.601) ) " +
90                                          "and t.Rute = a.Rute " +                                          "and t.Rute = a.Rute " +
91                                            debugFilter1 +
92                                                                                    
93                                          "UNION ALL " +                                          "UNION ALL " +
94                                                                                    
95                                          "SELECT orgid, a.id as targetid, afstand,'' as type FROM  fulddaekning.afstand_anden_rute_bk a " +                                          "SELECT orgid, a.id as targetid, afstand,'' as type FROM  fulddaekning.afstand_anden_rute_bk a " +
96                                          "left join bogleveringer.postnummerdistributor d on d.PostNr = a.orgPostnr " +                                          "left join bogleveringer.postnummerdistributor d on d.PostNr = a.orgPostnr " +
97                                          "WHERE d.Distributor <> 10057"                                          "WHERE d.Distributor <> 10057 " +
98                                            debugFilter2
99                                          ;                                          ;
100                                    
101                  Connection conn = DBConnection.getConnection();                          Connection conn = DBConnection.getConnection();        

Legend:
Removed from v.2320  
changed lines
  Added in v.2337

  ViewVC Help
Powered by ViewVC 1.1.20