[Dive4elements-commits] [PATCH] Move the access to artifact data to the Access object
Wald Commits
scm-commit at wald.intevation.org
Tue Dec 11 09:44:09 CET 2012
# HG changeset patch
# User Björn Ricks <bjoern.ricks at intevation.de>
# Date 1355215444 -3600
# Node ID cd44d28d0fbc03db1076c509ae715f9d94c42067
# Parent 861c47e0a8a0468a5bba04a930123468736ff77c
Move the access to artifact data to the Access object
Use BedHeightAccess class to receive the data from the artifact. This abstracts
the data access from the actual artifact.
diff -r 861c47e0a8a0 -r cd44d28d0fbc flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java Sat Dec 08 00:19:29 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java Tue Dec 11 09:44:04 2012 +0100
@@ -13,12 +13,9 @@
import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallMeta;
import de.intevation.artifacts.common.utils.XMLUtils;
-import de.intevation.flys.artifacts.model.minfo.BedHeight;
import de.intevation.flys.artifacts.model.minfo.BedHeightFacet;
import de.intevation.flys.artifacts.model.minfo.BedHeightFactory;
import de.intevation.flys.artifacts.states.StaticState;
-import de.intevation.flys.model.BedHeightSingle;
-import de.intevation.flys.model.BedHeightSingleValue;
public class BedHeightsArtifact
extends AbstractStaticStateArtifact
@@ -106,24 +103,6 @@
super.setup(identifier, factory, context, callMeta, data);
}
- /**
- */
- public BedHeight getHeight() {
- return BedHeightFactory.getHeight(
- getDataAsString("type"),
- Integer.parseInt(getDataAsString("height_id")),
- Integer.parseInt(getDataAsString("time")));
- }
-
- public List<BedHeightSingleValue> getSingleValues() {
- logger.debug("getSingleValues");
- BedHeightSingle single = BedHeightSingle.getBedHeightSingleById(
- getDataAsInteger("height_id"));
- return BedHeightSingleValue.getBedHeightSingleValues(single,
- getDataAsDouble("ld_from"),
- getDataAsDouble("ld_to"));
- }
-
@Override
protected void initStaticState() {
diff -r 861c47e0a8a0 -r cd44d28d0fbc flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java Sat Dec 08 00:19:29 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java Tue Dec 11 09:44:04 2012 +0100
@@ -1,7 +1,13 @@
package de.intevation.flys.artifacts.access;
+import java.util.List;
+
import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.model.minfo.BedHeight;
+import de.intevation.flys.artifacts.model.minfo.BedHeightFactory;
import de.intevation.flys.artifacts.states.SoundingsSelect;
+import de.intevation.flys.model.BedHeightSingle;
+import de.intevation.flys.model.BedHeightSingleValue;
import gnu.trove.TIntArrayList;
@@ -121,5 +127,31 @@
return epochIDs;
}
+
+ /**
+ * Return the {@link BedHeight} at the height_id and time of the artifact
+ * @return {@link BedHeight}
+ */
+ public BedHeight getHeight() {
+ logger.debug("getHeight");
+ return BedHeightFactory.getHeight(
+ artifact.getDataAsString("type"),
+ Integer.parseInt(artifact.getDataAsString("height_id")),
+ Integer.parseInt(artifact.getDataAsString("time")));
+ }
+
+ /**
+ * Return a {@link List} of {@link BedHeightSingleValue}s
+ * at the range of the artifact
+ * @return List of {@link BedHeightSingleValue}s
+ */
+ public List<BedHeightSingleValue> getSingleValues() {
+ logger.debug("getSingleValues");
+ BedHeightSingle single = BedHeightSingle.getBedHeightSingleById(
+ artifact.getDataAsInteger("height_id"));
+ return BedHeightSingleValue.getBedHeightSingleValues(single,
+ artifact.getDataAsDouble("ld_from"),
+ artifact.getDataAsDouble("ld_to"));
+ }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
diff -r 861c47e0a8a0 -r cd44d28d0fbc flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java Sat Dec 08 00:19:29 2012 +0100
+++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java Tue Dec 11 09:44:04 2012 +0100
@@ -2,7 +2,8 @@
import de.intevation.artifacts.Artifact;
import de.intevation.artifacts.CallContext;
-import de.intevation.flys.artifacts.BedHeightsArtifact;
+import de.intevation.flys.artifacts.FLYSArtifact;
+import de.intevation.flys.artifacts.access.BedHeightAccess;
import de.intevation.flys.artifacts.model.BlackboardDataFacet;
import de.intevation.flys.artifacts.model.FacetTypes;
@@ -29,12 +30,11 @@
*/
@Override
public Object getData(Artifact artifact, CallContext context) {
- BedHeightsArtifact staticData =
- (BedHeightsArtifact) artifact;
+ BedHeightAccess access = new BedHeightAccess((FLYSArtifact)artifact);
if (type.equals("singlevalues")) {
- return staticData.getSingleValues();
+ return access.getSingleValues();
}
- return staticData.getHeight();
+ return access.getHeight();
}
/**
* Create a deep copy of this Facet.
More information about the Dive4elements-commits
mailing list