Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java @ 7236:a9bd4a23a852
(issue1474) Add datacage loading for SQ Relations
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Wed, 02 Oct 2013 17:04:23 +0200 |
parents | af13ceeba52a |
children | 8d5ca5175038 |
comparison
equal
deleted
inserted
replaced
7235:03201eaf594f | 7236:a9bd4a23a852 |
---|---|
15 import org.w3c.dom.Document; | 15 import org.w3c.dom.Document; |
16 | 16 |
17 import org.dive4elements.artifactdatabase.data.DefaultStateData; | 17 import org.dive4elements.artifactdatabase.data.DefaultStateData; |
18 import org.dive4elements.artifactdatabase.state.DefaultOutput; | 18 import org.dive4elements.artifactdatabase.state.DefaultOutput; |
19 import org.dive4elements.artifactdatabase.state.Facet; | 19 import org.dive4elements.artifactdatabase.state.Facet; |
20 import org.dive4elements.artifacts.Artifact; | |
20 import org.dive4elements.artifacts.ArtifactFactory; | 21 import org.dive4elements.artifacts.ArtifactFactory; |
21 import org.dive4elements.artifacts.ArtifactNamespaceContext; | 22 import org.dive4elements.artifacts.ArtifactNamespaceContext; |
22 import org.dive4elements.artifacts.CallMeta; | 23 import org.dive4elements.artifacts.CallMeta; |
23 import org.dive4elements.artifacts.common.utils.XMLUtils; | 24 import org.dive4elements.artifacts.common.utils.XMLUtils; |
24 import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; | 25 import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; |
26 import org.dive4elements.river.artifacts.states.StaticState; | 27 import org.dive4elements.river.artifacts.states.StaticState; |
27 import org.dive4elements.river.artifacts.states.sq.SQStaticState; | 28 import org.dive4elements.river.artifacts.states.sq.SQStaticState; |
28 | 29 |
29 | 30 |
30 public class SQRelationArtifact | 31 public class SQRelationArtifact |
31 extends AbstractStaticStateArtifact | 32 extends StaticD4EArtifact |
32 { | 33 { |
33 private static final Logger logger = | 34 private static final Logger logger = |
34 Logger.getLogger(SQRelationArtifact.class); | 35 Logger.getLogger(SQRelationArtifact.class); |
35 | 36 |
36 public static final String XPATH_RIVER = "/art:action/art:river/@art:name"; | 37 public static final String XPATH_RIVER = "/art:action/art:river/@art:name"; |
55 CallMeta callmeta, | 56 CallMeta callmeta, |
56 Document data | 57 Document data |
57 ) { | 58 ) { |
58 logger.debug("SQRelationArtifact.setup()"); | 59 logger.debug("SQRelationArtifact.setup()"); |
59 | 60 |
61 String code = getDatacageIDValue(data); | |
62 | |
63 logger.debug("SQRelationDCArtifact.setup Id: " + code); | |
64 | |
65 if (code != null && !code.isEmpty()) { | |
66 /* Case that we were instantiated from the datacage */ | |
67 addStringData("ids", code); | |
68 super.setup(identifier, factory, context, callmeta, data); | |
69 return; | |
70 } | |
71 | |
60 String river = XMLUtils.xpathString( | 72 String river = XMLUtils.xpathString( |
61 data, | 73 data, |
62 XPATH_RIVER, | 74 XPATH_RIVER, |
63 ArtifactNamespaceContext.INSTANCE); | 75 ArtifactNamespaceContext.INSTANCE); |
64 String station = XMLUtils.xpathString( | 76 String station = XMLUtils.xpathString( |
79 "station", | 91 "station", |
80 Resources.getMsg(callmeta, "static.sq.station", "Station"), | 92 Resources.getMsg(callmeta, "static.sq.station", "Station"), |
81 "String", | 93 "String", |
82 station)); | 94 station)); |
83 super.setup(identifier, factory, context, callmeta, data); | 95 super.setup(identifier, factory, context, callmeta, data); |
96 // When we are in this case we did not come from the datacage | |
97 // e.g. had an ID string set. So we also did not have a template | |
98 // set and initialize is not called. So we have to do this ourself. | |
99 initialize(this, context, callmeta); | |
84 } | 100 } |
85 | 101 |
86 @Override | 102 @Override |
87 protected void initStaticState() { | 103 protected void initialize( |
104 Artifact artifact, | |
105 Object context, | |
106 CallMeta callMeta | |
107 ) { | |
88 StaticState state = new SQStaticState(STATIC_STATE_NAME); | 108 StaticState state = new SQStaticState(STATIC_STATE_NAME); |
89 | 109 |
90 List<Facet> fs = new ArrayList<Facet>(); | 110 List<Facet> fs = new ArrayList<Facet>(); |
91 state.staticCompute(fs, this); | 111 state.computeInit(this, hash(), context, callMeta, fs); |
112 logger.debug("Init static state computed facets"); | |
113 for (Facet face: fs) { | |
114 logger.debug("Got a facet with name: " + face.getName()); | |
115 } | |
92 | 116 |
93 if (hasParameter(StaticSQRelation.Parameter.A, fs)) { | 117 if (hasParameter(StaticSQRelation.Parameter.A, fs)) { |
94 DefaultOutput outputA = new DefaultOutput( | 118 DefaultOutput outputA = new DefaultOutput( |
95 SQ_RELATION_OUT_A, | 119 SQ_RELATION_OUT_A, |
96 "output.static.sqrelation.a", | 120 "output.static.sqrelation.a", |
143 fs, | 167 fs, |
144 "chart"); | 168 "chart"); |
145 state.addOutput(outputF); | 169 state.addOutput(outputF); |
146 } | 170 } |
147 addFacets(STATIC_STATE_NAME, fs); | 171 addFacets(STATIC_STATE_NAME, fs); |
148 state.setUIProvider(UIPROVIDER); | |
149 setStaticState(state); | |
150 } | 172 } |
151 | 173 |
152 @Override | 174 @Override |
153 public String getName() { | 175 public String getName() { |
154 return NAME; | 176 return NAME; |