Mercurial > dive4elements > river
diff 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 |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java Tue Oct 01 17:10:55 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/SQRelationArtifact.java Wed Oct 02 17:04:23 2013 +0200 @@ -17,6 +17,7 @@ import org.dive4elements.artifactdatabase.data.DefaultStateData; import org.dive4elements.artifactdatabase.state.DefaultOutput; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.Artifact; import org.dive4elements.artifacts.ArtifactFactory; import org.dive4elements.artifacts.ArtifactNamespaceContext; import org.dive4elements.artifacts.CallMeta; @@ -28,7 +29,7 @@ public class SQRelationArtifact -extends AbstractStaticStateArtifact +extends StaticD4EArtifact { private static final Logger logger = Logger.getLogger(SQRelationArtifact.class); @@ -57,6 +58,17 @@ ) { logger.debug("SQRelationArtifact.setup()"); + String code = getDatacageIDValue(data); + + logger.debug("SQRelationDCArtifact.setup Id: " + code); + + if (code != null && !code.isEmpty()) { + /* Case that we were instantiated from the datacage */ + addStringData("ids", code); + super.setup(identifier, factory, context, callmeta, data); + return; + } + String river = XMLUtils.xpathString( data, XPATH_RIVER, @@ -81,14 +93,26 @@ "String", station)); super.setup(identifier, factory, context, callmeta, data); + // When we are in this case we did not come from the datacage + // e.g. had an ID string set. So we also did not have a template + // set and initialize is not called. So we have to do this ourself. + initialize(this, context, callmeta); } @Override - protected void initStaticState() { + protected void initialize( + Artifact artifact, + Object context, + CallMeta callMeta + ) { StaticState state = new SQStaticState(STATIC_STATE_NAME); List<Facet> fs = new ArrayList<Facet>(); - state.staticCompute(fs, this); + state.computeInit(this, hash(), context, callMeta, fs); + logger.debug("Init static state computed facets"); + for (Facet face: fs) { + logger.debug("Got a facet with name: " + face.getName()); + } if (hasParameter(StaticSQRelation.Parameter.A, fs)) { DefaultOutput outputA = new DefaultOutput( @@ -145,8 +169,6 @@ state.addOutput(outputF); } addFacets(STATIC_STATE_NAME, fs); - state.setUIProvider(UIPROVIDER); - setStaticState(state); } @Override