comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java @ 1729:2e5ebdeb8af9

Give StaticWKmsArtifacts proper names, and pre-deselect them. flys-artifacts/trunk@3013 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 18 Oct 2011 15:00:43 +0000
parents e3b9164a85fe
children ae6ace900c07
comparison
equal deleted inserted replaced
1728:6068b6c90a19 1729:2e5ebdeb8af9
30 /** Query to get km and ws for wst_id and column_pos. */ 30 /** Query to get km and ws for wst_id and column_pos. */
31 public static final String SQL_SELECT_WS = 31 public static final String SQL_SELECT_WS =
32 "SELECT km, w FROM wst_w_values " + 32 "SELECT km, w FROM wst_w_values " +
33 "WHERE wst_id = :wst_id AND column_pos = :column_pos"; 33 "WHERE wst_id = :wst_id AND column_pos = :column_pos";
34 34
35 /** Query to get name for wst_id and column_pos. */
35 public static final String SQL_SELECT_NAME = 36 public static final String SQL_SELECT_NAME =
36 "SELECT name " + 37 "SELECT name " +
37 "FROM wst_columns "+ 38 "FROM wst_columns "+
38 "WHERE wst_id = :wst_id AND position = :column_pos"; 39 "WHERE wst_id = :wst_id AND position = :column_pos";
39 40
72 } 73 }
73 return values; 74 return values;
74 } 75 }
75 76
76 77
77 /** 78 /** Get name for a WKms. */
78 * Get WKms from db. 79 public static String getWKmsName(int column, int wst_id) {
79 * @param column the position columns value 80 log.debug("WKmsFactory.getWKmsName c/" + column + ", wst_id/" + wst_id);
80 * @param wst_id database id of the wst 81
81 * @return according WKms. 82 String name = null;
82 */
83 public static WKms getWKmsUncached(int column, int wst_id) {
84 log.debug("WKmsFactory.getWKmsUncached c/" + column + ", wst_id/" + wst_id);
85 Session session = SessionHolder.HOLDER.get(); 83 Session session = SessionHolder.HOLDER.get();
86
87 String name = "todo";
88 84
89 SQLQuery nameQuery = session.createSQLQuery(SQL_SELECT_NAME) 85 SQLQuery nameQuery = session.createSQLQuery(SQL_SELECT_NAME)
90 .addScalar("name", StandardBasicTypes.STRING); 86 .addScalar("name", StandardBasicTypes.STRING);
91 nameQuery.setInteger("wst_id", wst_id); 87 nameQuery.setInteger("wst_id", wst_id);
92 nameQuery.setInteger("column_pos", column); 88 nameQuery.setInteger("column_pos", column);
94 List<String> names = nameQuery.list(); 90 List<String> names = nameQuery.list();
95 if (names.size() >= 1) { 91 if (names.size() >= 1) {
96 name = names.get(0); 92 name = names.get(0);
97 } 93 }
98 94
99 WKmsImpl wkms = new WKmsImpl(name); 95 return name;
96 }
100 97
98
99 /**
100 * Get WKms from db.
101 * @param column the position columns value
102 * @param wst_id database id of the wst
103 * @return according WKms.
104 */
105 public static WKms getWKmsUncached(int column, int wst_id) {
106 log.debug("WKmsFactory.getWKmsUncached c/" + column + ", wst_id/" + wst_id);
107
108 WKmsImpl wkms = new WKmsImpl(getWKmsName(column, wst_id));
109
110 Session session = SessionHolder.HOLDER.get();
101 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS) 111 SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS)
102 .addScalar("km", StandardBasicTypes.DOUBLE) 112 .addScalar("km", StandardBasicTypes.DOUBLE)
103 .addScalar("w", StandardBasicTypes.DOUBLE); 113 .addScalar("w", StandardBasicTypes.DOUBLE);
104 sqlQuery.setInteger("wst_id", wst_id); 114 sqlQuery.setInteger("wst_id", wst_id);
105 sqlQuery.setInteger("column_pos", column); 115 sqlQuery.setInteger("column_pos", column);

http://dive4elements.wald.intevation.org