annotate flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/ScenarioSelect.java @ 2639:a78dafdd8590

Issue 657. Added file upload service to load a user defined shapefile. User the shapefile for wsplgen calculation and display a new layer. flys-artifacts/trunk@4292 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Raimund Renkert <raimund.renkert@intevation.de>
date Wed, 25 Apr 2012 07:45:00 +0000
parents 1aba1a75beb2
children c11da3540b70
rev   line source
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
1 package de.intevation.flys.artifacts.states;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
2
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
3 import java.util.List;
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
4 import java.io.File;
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
5
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
6 import org.apache.log4j.Logger;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
7
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
8 import org.w3c.dom.Element;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
9
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
10 import de.intevation.artifacts.Artifact;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
11 import de.intevation.artifacts.CallContext;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
12 import de.intevation.artifacts.CallMeta;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
13
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
14 import de.intevation.artifacts.common.utils.XMLUtils;
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
15 import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator;
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
16 import de.intevation.artifacts.common.utils.FileTools;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
17
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
18 import de.intevation.artifactdatabase.ProtocolUtils;
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
19 import de.intevation.artifactdatabase.state.Facet;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
20
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
21 import de.intevation.flys.artifacts.FLYSArtifact;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
22 import de.intevation.flys.artifacts.resources.Resources;
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
23 import de.intevation.flys.utils.FLYSUtils;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
24
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
25 /**
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
26 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
27 */
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
28 public class ScenarioSelect extends DefaultState {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
29
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
30 /** The logger that is used in this class.*/
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
31 private static Logger logger = Logger.getLogger(ScenarioSelect.class);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
32
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
33
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
34 public static final String FIELD_MODE = "scenario";
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
35 public static final String FIELD_BARRIERS = "uesk.barriers";
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
36
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
37 public static final String SCENARIO_CURRENT = "scenario.current";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
38 public static final String SCENARIO_POTENTIEL = "scenario.potentiel";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
39 public static final String SCENARIO_SCENRAIO = "scenario.scenario";
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
40
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
41 public static final String[] SCENARIOS = {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
42 SCENARIO_CURRENT,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
43 SCENARIO_POTENTIEL,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
44 SCENARIO_SCENRAIO };
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
45
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
46
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
47
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
48 @Override
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
49 protected String getUIProvider() {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
50 return "map_digitize";
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
51 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
52
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
53
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
54 @Override
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
55 protected void appendStaticData(
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
56 FLYSArtifact flys,
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
57 CallContext cc,
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
58 ElementCreator creator,
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
59 Element ui,
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
60 String name
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
61 ) {
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
62 if (name != null && name.equals(FIELD_BARRIERS)) {
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
63 return;
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
64 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
65 else {
1180
1aba1a75beb2 Write the name of the selected waterlevels (used for the floodmap) into the static DESCRIBE.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1159
diff changeset
66 super.appendStaticData(flys, cc, creator, ui, name);
1159
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
67 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
68 }
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
69
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
70
fb5a7ff9feb8 Suppress the GeoJSON string for the FloodMap creation to be included in the static DESCRIBE part.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1064
diff changeset
71 @Override
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
72 protected Element[] createItems(
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
73 XMLUtils.ElementCreator cr,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
74 Artifact artifact,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
75 String name,
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
76 CallContext context)
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
77 {
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
78 CallMeta meta = context.getMeta();
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
79
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
80 if (name.equals(FIELD_MODE)) {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
81 Element[] scenarios = new Element[SCENARIOS.length];
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
82
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
83 int i = 0;
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
84
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
85 for (String scenario: SCENARIOS) {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
86 scenarios[i++] = createItem(
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
87 cr, new String[] {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
88 Resources.getMsg(meta, scenario, scenario),
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
89 scenario
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
90 });
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
91 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
92
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
93 return scenarios;
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
94 }
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
95 else {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
96 FLYSArtifact flys = (FLYSArtifact) artifact;
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
97 String data = flys.getDataAsString(name);
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
98
1064
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
99 return new Element[] { createItem(
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
100 cr,
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
101 new String[] {
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
102 Resources.getMsg(meta, name, name),
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
103 data
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
104 }
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
105 )};
13784581ab0c Moved the input of user defined barriers for the floodmap to an earlier state.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents: 1050
diff changeset
106 }
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
107 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
108
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
109
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
110 protected Element createItem(XMLUtils.ElementCreator cr, Object obj) {
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
111 Element item = ProtocolUtils.createArtNode(cr, "item", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
112 Element label = ProtocolUtils.createArtNode(cr, "label", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
113 Element value = ProtocolUtils.createArtNode(cr, "value", null, null);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
114
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
115 String[] arr = (String[]) obj;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
116
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
117 label.setTextContent(arr[0]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
118 value.setTextContent(arr[1]);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
119
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
120 item.appendChild(label);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
121 item.appendChild(value);
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
122
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
123 return item;
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
124 }
2639
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
125
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
126
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
127
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
128 @Override
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
129 public void endOfLife(Artifact artifact, Object callContext) {
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
130 super.endOfLife(artifact, callContext);
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
131 logger.info("ScenarioSelect.endOfLife: " + artifact.identifier());
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
132
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
133 FLYSArtifact flys = (FLYSArtifact) artifact;
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
134 removeDirectory(flys);
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
135 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
136
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
137
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
138 /**
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
139 * Removes the directory and all its content where the required data and the
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
140 * results of WSPLGEN are stored. Should be called in endOfLife().
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
141 */
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
142 protected void removeDirectory(FLYSArtifact artifact) {
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
143 String shapePath = FLYSUtils.getXPathString(
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
144 FLYSUtils.XPATH_SHAPEFILE_DIR);
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
145
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
146 File artifactDir = new File(shapePath, artifact.identifier());
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
147
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
148 if (artifactDir.exists()) {
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
149 logger.info("Delete directory: " + artifactDir.getAbsolutePath());
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
150 boolean success = FileTools.deleteRecursive(artifactDir);
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
151 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
152 else {
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
153 logger.debug("There is no directory to remove.");
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
154 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
155 }
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
156
a78dafdd8590 Issue 657.
Raimund Renkert <raimund.renkert@intevation.de>
parents: 1180
diff changeset
157
927
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
158 }
53a2be494765 Enhanced the transition model to continue the parameterization in the waterlevel state to compute flood maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff changeset
159 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org