Mercurial > dive4elements > river
annotate artifacts/src/main/java/org/dive4elements/river/artifacts/datacage/templating/DefaultVegetationZoneXPathFunction.java @ 9403:e2da9c8a7c57
VegetationZone umbenennen
author | gernotbelger |
---|---|
date | Wed, 15 Aug 2018 13:22:00 +0200 |
parents | e511eb935ccd |
children | e5cb5efbc43e |
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; | |
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
|
13 import java.util.UUID; |
9299 | 14 |
15 import javax.xml.xpath.XPathFunction; | |
16 import javax.xml.xpath.XPathFunctionException; | |
17 | |
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
|
18 import org.dive4elements.artifacts.CallContext; |
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
|
19 import org.dive4elements.river.artifacts.D4EArtifact; |
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
|
20 import org.dive4elements.river.artifacts.access.RiverAccess; |
9403 | 21 import org.dive4elements.river.artifacts.uinfo.vegetationzones.VegetationZoneServerClientXChange; |
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
|
22 import org.dive4elements.river.utils.RiverUtils; |
9299 | 23 |
24 /** | |
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
|
25 * Very specialized function that fetches the default vegetation zones for the river specified by an artifact |
9299 | 26 * |
27 * @author Gernot Belger | |
28 */ | |
29 public class DefaultVegetationZoneXPathFunction implements XPathFunction { | |
30 | |
31 public static final String ID = "defaultvegetationzone"; | |
32 | |
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
|
33 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
|
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 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
|
36 |
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 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
|
38 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
|
39 } |
9299 | 40 |
41 @Override | |
42 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
|
43 |
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 final UUID uuid = (UUID) args.get(0); |
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 if (uuid == 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
|
46 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
|
47 |
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
|
48 final D4EArtifact artifact = RiverUtils.getArtifact(uuid.toString(), this.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
|
49 |
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
|
50 final RiverAccess access = new RiverAccess(artifact); |
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
|
51 |
9403 | 52 return VegetationZoneServerClientXChange.parseListToDataString(VegetationZoneServerClientXChange.getStandardList(access.getRiver(), this.context)); |
9299 | 53 } |
54 } |