comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/DischargeLongitudinalSection.java @ 697:b972eba2ed8a facets-slt

Removed ComputeCallback because this was thought too complicated. Fixed issue with facets not be re-generated if same state is entered again. flys-artifacts/branches/facets-slt@2143 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Fri, 17 Jun 2011 10:40:54 +0000
parents 708b270dfd30
children af3b5d9e91a4
comparison
equal deleted inserted replaced
696:708b270dfd30 697:b972eba2ed8a
8 8
9 import de.intevation.artifactdatabase.state.Facet; 9 import de.intevation.artifactdatabase.state.Facet;
10 10
11 import de.intevation.flys.artifacts.FLYSArtifact; 11 import de.intevation.flys.artifacts.FLYSArtifact;
12 import de.intevation.flys.artifacts.WINFOArtifact; 12 import de.intevation.flys.artifacts.WINFOArtifact;
13 import de.intevation.flys.artifacts.model.ComputeCallback;
14 import de.intevation.flys.artifacts.model.ComputeCallbackAdapter;
15 import de.intevation.flys.artifacts.model.FacetTypes; 13 import de.intevation.flys.artifacts.model.FacetTypes;
16 import de.intevation.flys.artifacts.model.WaterlevelFacet; 14 import de.intevation.flys.artifacts.model.WaterlevelFacet;
17 import de.intevation.flys.artifacts.model.WQKms; 15 import de.intevation.flys.artifacts.model.WQKms;
18 import de.intevation.flys.artifacts.model.WQCKms; 16 import de.intevation.flys.artifacts.model.WQCKms;
19 17
24 private static Logger logger = 22 private static Logger logger =
25 Logger.getLogger(DischargeLongitudinalSection.class); 23 Logger.getLogger(DischargeLongitudinalSection.class);
26 24
27 25
28 @Override 26 @Override
29 public ComputeCallback createComputeCallback( 27 public Object computeAdvance(
30 String hash, FLYSArtifact flys) 28 FLYSArtifact artifact,
31 { 29 String hash,
32 final WINFOArtifact winfo = (WINFOArtifact) flys; 30 CallContext context,
31 List<Facet> facets,
32 Object old
33 ) {
34 WQKms [] res;
33 35
34 return new ComputeCallbackAdapter() { 36 WINFOArtifact winfo = (WINFOArtifact)artifact;
35 37
36 @Override 38 if (old instanceof WQCKms []) {
37 public Object computeAdvance( 39 res = (WQCKms [])old;
38 CallContext context, 40 }
39 List<Facet> facets) 41 else {
40 { 42 res = winfo.getDischargeLongitudinalSectionData();
41 WQKms res[] = winfo.getDischargeLongitudinalSectionData();
42 43
43 if (res == null) { 44 if (res == null) {
44 logger.debug("No results given."); 45 logger.debug("No results given.");
45 return null; 46 return null;
46 } 47 }
48 }
47 49
48 for (int i = 0; i < res.length; i++) { 50 for (int i = 0; i < res.length; i++) {
49 String nameW = null; 51 String nameW = null;
50 String nameQ = null; 52 String nameQ = null;
51 53
52 if (winfo.isQ()) { 54 if (winfo.isQ()) {
53 nameQ = res[i].getName(); 55 nameQ = res[i].getName();
54 nameW = "W(" + nameQ + ")"; 56 nameW = "W(" + nameQ + ")";
55 } 57 }
56 else { 58 else {
57 nameW = res[i].getName(); 59 nameW = res[i].getName();
58 nameQ = "Q(" + nameQ + ")"; 60 nameQ = "Q(" + nameQ + ")";
59 } 61 }
60 62
61 Facet w = new WaterlevelFacet( 63 Facet w = new WaterlevelFacet(
62 i, DISCHARGE_LONGITUDINAL_W, nameW); 64 i, DISCHARGE_LONGITUDINAL_W, nameW);
63 65
64 Facet q = new WaterlevelFacet( 66 Facet q = new WaterlevelFacet(
65 i, DISCHARGE_LONGITUDINAL_Q, nameQ); 67 i, DISCHARGE_LONGITUDINAL_Q, nameQ);
66 68
67 facets.add(w); 69 facets.add(w);
68 facets.add(q); 70 facets.add(q);
69 71
70 if (res[i] instanceof WQCKms) { 72 if (res[i] instanceof WQCKms) {
71 // TODO DO i18n 73 // TODO DO i18n
72 74
73 String nameC = nameW.replace( 75 String nameC = nameW.replace(
74 "Benutzerdefiniert", 76 "Benutzerdefiniert",
75 "Benutzerdefiniert [korrigiert]"); 77 "Benutzerdefiniert [korrigiert]");
76 78
77 Facet c = new WaterlevelFacet( 79 Facet c = new WaterlevelFacet(
78 i, DISCHARGE_LONGITUDINAL_C, nameC); 80 i, DISCHARGE_LONGITUDINAL_C, nameC);
79 81
80 facets.add(c); 82 facets.add(c);
81 } 83 }
82 } 84 }
83 85
84 return res; 86 return res;
85 }
86 };
87
88 } 87 }
89 } 88 }
90 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : 89 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org