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
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
1 /** Copyright (C) 2017 by Bundesanstalt für Gewässerkunde
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
2 * Software engineering by
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
3 * Björnsen Beratende Ingenieure GmbH
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
4 * Dr. Schumacher Ingenieurbüro für Wasser und Umwelt
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
5 *
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
6 * This file is Free Software under the GNU AGPL (>=v3)
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
7 * and comes with ABSOLUTELY NO WARRANTY! Check out the
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
8 * documentation coming with Dive4Elements River for details.
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
9 */
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
10 package org.dive4elements.river.artifacts.datacage.templating;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
11
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
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
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
14
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
15 import javax.xml.xpath.XPathFunction;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
16 import javax.xml.xpath.XPathFunctionException;
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
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
e2da9c8a7c57 VegetationZone umbenennen
gernotbelger
parents: 9402
diff changeset
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
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
23
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
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
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
26 *
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
27 * @author Gernot Belger
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
28 */
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
29 public class DefaultVegetationZoneXPathFunction implements XPathFunction {
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
30
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
31 public static final String ID = "defaultvegetationzone";
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
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
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
40
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
41 @Override
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
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
e2da9c8a7c57 VegetationZone umbenennen
gernotbelger
parents: 9402
diff changeset
52 return VegetationZoneServerClientXChange.parseListToDataString(VegetationZoneServerClientXChange.getStandardList(access.getRiver(), this.context));
9299
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
53 }
4a6cc7c6716a uinfo.inundation_duration veg'zone select
gernotbelger
parents:
diff changeset
54 }

http://dive4elements.wald.intevation.org