|
|
@@ -1,43 +0,0 @@
|
|
1
|
|
-package se.citerus.routingteam;
|
|
2
|
|
-
|
|
3
|
|
-import org.springframework.jdbc.core.JdbcTemplate;
|
|
4
|
|
-import org.springframework.jdbc.core.RowCallbackHandler;
|
|
5
|
|
-
|
|
6
|
|
-import javax.sql.DataSource;
|
|
7
|
|
-import java.sql.ResultSet;
|
|
8
|
|
-import java.sql.SQLException;
|
|
9
|
|
-import java.util.ArrayList;
|
|
10
|
|
-import java.util.List;
|
|
11
|
|
-
|
|
12
|
|
-public class GraphDAO {
|
|
13
|
|
-
|
|
14
|
|
- private final JdbcTemplate jt;
|
|
15
|
|
-
|
|
16
|
|
- public GraphDAO(DataSource dataSource) {
|
|
17
|
|
- jt = new JdbcTemplate(dataSource);
|
|
18
|
|
- }
|
|
19
|
|
-
|
|
20
|
|
- public List<String> listLocations() {
|
|
21
|
|
- final List<String> result = new ArrayList();
|
|
22
|
|
-
|
|
23
|
|
- jt.query("select unlocode from location", new RowCallbackHandler() {
|
|
24
|
|
- public void processRow(ResultSet resultSet) throws SQLException {
|
|
25
|
|
- result.add(resultSet.getString("unlocode"));
|
|
26
|
|
- }
|
|
27
|
|
- });
|
|
28
|
|
-
|
|
29
|
|
- return result;
|
|
30
|
|
- }
|
|
31
|
|
-
|
|
32
|
|
- public void storeCarrierMovementId(String cmId, String from, String to) {
|
|
33
|
|
- final String locationSql = "select id from location where unlocode = ?";
|
|
34
|
|
-
|
|
35
|
|
- final Long fromId = jt.queryForLong(locationSql, new Object[]{ from });
|
|
36
|
|
- final Long toId = jt.queryForLong(locationSql, new Object[]{ to });
|
|
37
|
|
-
|
|
38
|
|
- final Object[] params = {cmId, fromId, toId};
|
|
39
|
|
- jt.update(
|
|
40
|
|
- "insert into CarrierMovement (carrier_movement_id,from_id,to_id) " +
|
|
41
|
|
- "values (?,?,?)", params);
|
|
42
|
|
- }
|
|
43
|
|
-}
|