Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/DefaultVegetationZoneXPathFunction.java @ 9482:e5cb5efbc43e
standard veg'zone data cage fix
author | gernotbelger |
---|---|
date | Wed, 12 Sep 2018 12:50:28 +0200 |
parents | e2da9c8a7c57 |
children | 853f2dafc16e |
rev | line source |
---|---|
9299 | 1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde |
2 * Software engineering by | |
3 * Björnsen Beratende Ingenieure GmbH | |
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt | |
5 * | |
6 * This file is Free Software under the GNU AGPL (>=v3) | |
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the | |
8 * documentation coming with Dive4Elements River for details. | |
9 */ | |
10 package org.dive4elements.river.artifacts.datacage.templating; | |
11 | |
12 import java.util.List; | |
13 | |
14 import javax.xml.xpath.XPathFunction; | |
15 import javax.xml.xpath.XPathFunctionException; | |
16 | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
17 import org.dive4elements.artifacts.CallContext; |
9482 | 18 import org.dive4elements.river.artifacts.model.RiverFactory; |
9403 | 19 import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZoneServerClientXChange; |
9482 | 20 import org.dive4elements.river.model.River; |
9299 | 21 |
22 /** | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
23 * Very specialized function that fetches the default vegetation zones for the river specified by an artifact |
9299 | 24 * |
25 * @author Gernot Belger | |
26 */ | |
27 public class DefaultVegetationZoneXPathFunction implements XPathFunction { | |
28 | |
29 public static final String ID = "defaultvegetationzone"; | |
30 | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
31 public static final int ARITY = 1; |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
32 |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
33 private final CallContext context; |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
34 |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
35 public DefaultVegetationZoneXPathFunction(final CallContext context) { |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
36 this.context = context; |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
37 } |
9299 | 38 |
39 @Override | |
40 public Object evaluate(final List args) throws XPathFunctionException { | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
41 |
9482 | 42 final String rivername = (String) args.get(0); |
43 if (rivername == null) | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
44 return null; |
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
45 |
9482 | 46 final River river = RiverFactory.getRiver(rivername); |
47 if (river == null) | |
48 return null; | |
9402
e511eb935ccd
Changed hard coded standard vegetation zone table to fetching it from the database, i18n for the standard zone names
mschaefer
parents:
9299
diff
changeset
|
49 |
9482 | 50 return VegetationZoneServerClientXChange.parseListToDataString(VegetationZoneServerClientXChange.getStandardList(river, this.context)); |
9299 | 51 } |
52 } |