Mercurial > dive4elements > river
changeset 4655:cd44d28d0fbc
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.
author | Björn Ricks <bjoern.ricks@intevation.de> |
---|---|
date | Tue, 11 Dec 2012 09:44:04 +0100 |
parents | 861c47e0a8a0 |
children | 442fbb290fa8 |
files | flys-artifacts/src/main/java/de/intevation/flys/artifacts/BedHeightsArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/access/BedHeightAccess.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/minfo/BedHeightFacet.java |
diffstat | 3 files changed, 37 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- 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() {
--- 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 :
--- 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.