13 |
|
|
14 |
import dk.daoas.daoadresseservice.DaekningsType; |
import dk.daoas.daoadresseservice.DaekningsType; |
15 |
import dk.daoas.daoadresseservice.beans.Address; |
import dk.daoas.daoadresseservice.beans.Address; |
16 |
|
import dk.daoas.daoadresseservice.beans.AliasBean; |
17 |
import dk.daoas.daoadresseservice.beans.ExtendedBean; |
import dk.daoas.daoadresseservice.beans.ExtendedBean; |
18 |
import dk.daoas.daoadresseservice.beans.HundredePctBean; |
import dk.daoas.daoadresseservice.beans.HundredePctBean; |
19 |
|
import dk.daoas.daoadresseservice.beans.LoggedAddress; |
20 |
import dk.daoas.daoadresseservice.beans.SearchResult; |
import dk.daoas.daoadresseservice.beans.SearchResult; |
21 |
import dk.daoas.daoadresseservice.util.DeduplicateHelper; |
import dk.daoas.daoadresseservice.util.DeduplicateHelper; |
22 |
|
|
84 |
} |
} |
85 |
} |
} |
86 |
|
|
87 |
|
public static List<AliasBean> getAliasList() throws SQLException { |
88 |
|
|
89 |
|
|
90 |
|
String sql = "SELECT postnr,vejnavn,aliasvejnavn " + |
91 |
|
"FROM bogleveringer.vejtabelprod " |
92 |
|
; |
93 |
|
|
94 |
|
try ( Connection conn = DBConnection.getConnection(); |
95 |
|
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); |
96 |
|
) { |
97 |
|
|
98 |
|
stmt.setFetchSize(Integer.MIN_VALUE); |
99 |
|
|
100 |
|
ResultSet res = stmt.executeQuery(sql); |
101 |
|
|
102 |
|
DeduplicateHelper<String> vejCache = new DeduplicateHelper<String>(); |
103 |
|
|
104 |
|
List<AliasBean> list = new ArrayList<AliasBean>( 5000); |
105 |
|
while (res.next()) { |
106 |
|
|
107 |
|
AliasBean ab = new AliasBean(); |
108 |
|
ab.postnr = res.getInt(1); |
109 |
|
ab.vejnavn = vejCache.getInstance( res.getString(2) ); |
110 |
|
ab.aliasVejnavn = vejCache.getInstance( res.getString(3) ); |
111 |
|
|
112 |
|
list.add(ab); |
113 |
|
} |
114 |
|
|
115 |
|
res.close(); |
116 |
|
|
117 |
|
System.out.println("Loaded " + list.size() + " aliase beans"); |
118 |
|
|
119 |
|
return list; |
120 |
|
} |
121 |
|
|
122 |
|
} |
123 |
|
|
124 |
public static List<ExtendedBean> getExtendedAdresslist() throws SQLException { |
public static List<ExtendedBean> getExtendedAdresslist() throws SQLException { |
125 |
String debugFilter1 = DatabaseLayer.DEBUG ? " WHERE orgPostnr = 8700 " : ""; |
String debugFilter1 = DatabaseLayer.DEBUG ? " WHERE orgPostnr = 8700 " : ""; |
126 |
String debugFilter2 = DatabaseLayer.DEBUG ? " AND orgPostnr = 8700 " : ""; |
String debugFilter2 = DatabaseLayer.DEBUG ? " AND orgPostnr = 8700 " : ""; |
234 |
} |
} |
235 |
} |
} |
236 |
|
|
237 |
|
/* |
238 |
|
* Bruges til at sammenligne gammel og ny adresse service - kan fjernes engang efter at vi er skiftet til ny service |
239 |
|
*/ |
240 |
|
public static List<LoggedAddress> getLoggedAdresses(int antaldage) throws SQLException { |
241 |
|
String sql = "select postnr,adresse,status from logs.hentruteinformation where indlast>=date_sub(curdate(), interval " + antaldage + " day) " + |
242 |
|
"and status IN (10,11,12) " + |
243 |
|
"group by postnr,adresse " |
244 |
|
; |
245 |
|
|
246 |
|
try ( Connection conn = DBConnection.getConnection(); |
247 |
|
Statement stmt = conn.createStatement(java.sql.ResultSet.TYPE_FORWARD_ONLY, java.sql.ResultSet.CONCUR_READ_ONLY); |
248 |
|
) { |
249 |
|
|
250 |
|
|
251 |
|
stmt.setFetchSize(Integer.MIN_VALUE); |
252 |
|
|
253 |
|
ResultSet res = stmt.executeQuery(sql); |
254 |
|
|
255 |
|
List<LoggedAddress> result = new ArrayList<LoggedAddress>(); |
256 |
|
|
257 |
|
while (res.next()) { |
258 |
|
LoggedAddress a = new LoggedAddress(); |
259 |
|
a.postnr = res.getInt(1); |
260 |
|
a.adresse = res.getString(2); |
261 |
|
a.status = res.getInt(3); |
262 |
|
|
263 |
|
result.add(a); |
264 |
|
} |
265 |
|
|
266 |
|
res.close(); |
267 |
|
|
268 |
|
return result; |
269 |
|
} |
270 |
|
} |
271 |
|
|
272 |
private static int getStatusInt(SearchResult.Status status) { |
private static int getStatusInt(SearchResult.Status status) { |
273 |
|
|
274 |
switch (status) { |
switch (status) { |