# HG changeset patch # User Raimund Renkert # Date 1411552789 -7200 # Node ID 9f5059f4f01a8bd5a9e7aa6d7cb78a0e5fc185bb # Parent 7b282a3f50f09c717bbca27e9cf36872497d6d71 Configured "static" sq relation to use a default D4EArtifact and two states to hold the parameters and outs. * Updated configuration * Added new state diff -r 7b282a3f50f0 -r 9f5059f4f01a artifacts/doc/conf/artifacts/sqrelation.xml --- a/artifacts/doc/conf/artifacts/sqrelation.xml Wed Sep 24 11:56:03 2014 +0200 +++ b/artifacts/doc/conf/artifacts/sqrelation.xml Wed Sep 24 11:59:49 2014 +0200 @@ -1,9 +1,16 @@ + + + + + + + + + - - @@ -47,17 +54,6 @@ - - - - - - - - - - - diff -r 7b282a3f50f0 -r 9f5059f4f01a artifacts/doc/conf/conf.xml --- a/artifacts/doc/conf/conf.xml Wed Sep 24 11:56:03 2014 +0200 +++ b/artifacts/doc/conf/conf.xml Wed Sep 24 11:59:49 2014 +0200 @@ -12,6 +12,7 @@ + @@ -140,7 +141,7 @@ artifact="org.dive4elements.river.artifacts.BedHeightsArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory org.dive4elements.artifactdatabase.DefaultArtifactFactory + artifact="org.dive4elements.river.artifacts.D4EArtifact">org.dive4elements.artifactdatabase.DefaultArtifactFactory org.dive4elements.artifactdatabase.DefaultArtifactFactory @@ -291,7 +292,7 @@ - + &sqrelation-artifact; &porosity-artifact; &gaugedischargecurve-artifact; &sedimentload-artifact; diff -r 7b282a3f50f0 -r 9f5059f4f01a artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQInitState.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQInitState.java Wed Sep 24 11:59:49 2014 +0200 @@ -0,0 +1,14 @@ +package org.dive4elements.river.artifacts.states.sq; + +import org.dive4elements.river.artifacts.states.DefaultState; + + +public class SQInitState +extends DefaultState +{ + + @Override + protected String getUIProvider() { + return "static_data"; + } +} diff -r 7b282a3f50f0 -r 9f5059f4f01a artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java Wed Sep 24 11:56:03 2014 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/states/sq/SQStaticState.java Wed Sep 24 11:59:49 2014 +0200 @@ -15,9 +15,12 @@ import org.apache.log4j.Logger; import org.dive4elements.artifactdatabase.state.Facet; +import org.dive4elements.artifacts.CallContext; import org.dive4elements.artifacts.CallMeta; import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.StaticSQRelationAccess; +import org.dive4elements.river.artifacts.model.DataFacet; +import org.dive4elements.river.artifacts.model.FacetTypes; import org.dive4elements.river.artifacts.model.sq.StaticSQContainer; import org.dive4elements.river.artifacts.model.sq.StaticSQFactory; import org.dive4elements.river.artifacts.model.sq.StaticSQRelation; @@ -27,6 +30,7 @@ public class SQStaticState extends StaticState +implements FacetTypes { private static final Logger log = @@ -44,6 +48,61 @@ } @Override + public Object computeAdvance( + D4EArtifact artifact, + String hash, + CallContext context, + List facets, + Object old) { + StaticSQContainer sqRelations; + StaticSQRelationAccess access = new StaticSQRelationAccess(artifact); + String river = access.getRiverName(); + String measurementStation = access.getMeasurementStation(); + + int ms = -1; + try { + ms = Integer.parseInt(measurementStation); + } + catch (NumberFormatException nfe) { + log.error("Unparseable measurement station: " + measurementStation); + return null; + } + log.debug("Parsed measurement station: " + ms); + + sqRelations = StaticSQFactory.getSQRelations(river, ms); + DateFormat df = new SimpleDateFormat("yyyy"); + + for (StaticSQRelation.Parameter p: StaticSQRelation.Parameter.values()) { + log.debug("parameter: " + p.toString()); + List relations = + sqRelations.getRelationsByParameter(p); + + if (!relations.isEmpty()) { + int count = 0; + + for (StaticSQRelation relation : relations) { + log.debug("add facet for " + p.toString().toLowerCase()); + String name = "sq_" + p.toString().toLowerCase() + "_curve"; + String desc = + Resources.getMsg(context.getMeta(), + FACET_DESCRIPTION, + FACET_DESCRIPTION, + new Object[] { + df.format(relation.getStartTime()), + df.format(relation.getStopTime())}); + facets.add(new StaticSQRelationFacet( + count, + name, + desc, + relation)); + count++; + } + } + } + return null; + } + + @Override public Object computeInit( D4EArtifact artifact, String hash,