Mercurial > dive4elements > river
changeset 1726:e3b9164a85fe
Fetch name of static WKms.
flys-artifacts/trunk@3008 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 18 Oct 2011 14:03:43 +0000 |
parents | d9afb16d1fd4 |
children | cee5a292754f |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java |
diffstat | 3 files changed, 35 insertions(+), 21 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Oct 18 13:28:39 2011 +0000 +++ b/flys-artifacts/ChangeLog Tue Oct 18 14:03:43 2011 +0000 @@ -1,3 +1,13 @@ +2011-10-18 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Fetch name of static WKms. + + * src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java: + Removed dependence on "kind", but fetch name for created WKms. + + * src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java: + Remove dependence on Kind. + 2011-10-18 Felix Wolfsteller <felix.wolfsteller@intevation.de> Store parameterization in data, not in Artifact.
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Tue Oct 18 13:28:39 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/StaticWKmsArtifact.java Tue Oct 18 14:03:43 2011 +0000 @@ -201,9 +201,7 @@ public WKms getWKms(int idx) { logger.debug("StaticWKmsArtifact.getWKms"); - // TODO KIND is not needed. return WKmsFactory.getWKms( - WKmsFactory.KIND_PROTECTION, Integer.valueOf(getDataAsString("col_pos")), Integer.valueOf(getDataAsString("wst_id"))); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java Tue Oct 18 13:28:39 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/WKmsFactory.java Tue Oct 18 14:03:43 2011 +0000 @@ -27,23 +27,16 @@ { private static Logger log = Logger.getLogger(WKmsFactory.class); - /** - * Value for wsts 'kind' typically used for "additional - * longitudinal sections. - */ - public static final int KIND_ZUS = 1; - - /** - * Value for wsts 'kind' typically used for flood protection measures - * (e.g. dikes). - */ - public static final int KIND_PROTECTION = 5; - /** Query to get km and ws for wst_id and column_pos. */ public static final String SQL_SELECT_WS = "SELECT km, w FROM wst_w_values " + "WHERE wst_id = :wst_id AND column_pos = :column_pos"; + public static final String SQL_SELECT_NAME = + "SELECT name " + + "FROM wst_columns "+ + "WHERE wst_id = :wst_id AND position = :column_pos"; + private WKmsFactory() { } @@ -52,7 +45,7 @@ /** * Get WKms for given column and wst_id, caring about the cache. */ - public static WKms getWKms(int kind, int column, int wst_id) { + public static WKms getWKms(int column, int wst_id) { log.debug("WKmsFactory.getWKms"); Cache cache = CacheFactory.getCache(StaticWKmsCacheKey.CACHE_NAME); @@ -70,7 +63,7 @@ cacheKey = null; } - WKms values = getWKmsUncached(kind, column, wst_id); + WKms values = getWKmsUncached(column, wst_id); if (values != null && cacheKey != null) { log.debug("Store static wst values in cache."); @@ -83,11 +76,28 @@ /** * Get WKms from db. + * @param column the position columns value + * @param wst_id database id of the wst + * @return according WKms. */ - public static WKms getWKmsUncached(int kind, int column, int wst_id) { + public static WKms getWKmsUncached(int column, int wst_id) { log.debug("WKmsFactory.getWKmsUncached c/" + column + ", wst_id/" + wst_id); Session session = SessionHolder.HOLDER.get(); + String name = "todo"; + + SQLQuery nameQuery = session.createSQLQuery(SQL_SELECT_NAME) + .addScalar("name", StandardBasicTypes.STRING); + nameQuery.setInteger("wst_id", wst_id); + nameQuery.setInteger("column_pos", column); + + List<String> names = nameQuery.list(); + if (names.size() >= 1) { + name = names.get(0); + } + + WKmsImpl wkms = new WKmsImpl(name); + SQLQuery sqlQuery = session.createSQLQuery(SQL_SELECT_WS) .addScalar("km", StandardBasicTypes.DOUBLE) .addScalar("w", StandardBasicTypes.DOUBLE); @@ -96,10 +106,6 @@ List<Object []> results = sqlQuery.list(); - // TODO Fetch name in a separate query. - String name = "todo"; - - WKmsImpl wkms = new WKmsImpl(name); double kms [] = new double[results.size()]; double ws [] = new double[results.size()];