# HG changeset patch # User Felix Wolfsteller # Date 1381912965 -7200 # Node ID 9d3e44ab25f2321cecd6db30abe4886cca323e41 # Parent 534850c9fabc32db40cc81f00cc608574297eca8 Refactoring: Move functionality of BedHeightAccess into BedHeightFacet for now. Idea is that Artifact and Access are lightweight. Access access the 'data' ('parameterization') attached to artifact, not the data delivered by means of artifact and its parameterization. diff -r 534850c9fabc -r 9d3e44ab25f2 artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java Wed Oct 16 10:33:09 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/access/BedHeightAccess.java Wed Oct 16 10:42:45 2013 +0200 @@ -11,11 +11,7 @@ import java.util.List; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.model.minfo.BedHeight; -import org.dive4elements.river.artifacts.model.minfo.BedHeightFactory; import org.dive4elements.river.artifacts.states.SoundingsSelect; -import org.dive4elements.river.model.BedHeightSingle; -import org.dive4elements.river.model.BedHeightSingleValue; import gnu.trove.TIntArrayList; @@ -33,8 +29,12 @@ private String yearEpoch; + private String type; + private Integer heightId; + private Integer time; + public BedHeightAccess(D4EArtifact artifact) { super(artifact); } @@ -91,11 +91,11 @@ } - public String getYearEpoch() { - if (yearEpoch == null) { - yearEpoch = getString("ye_select"); + public String getType() { + if (type == null) { + type = getString("type"); } - return yearEpoch; + return type; } public String getYearEpoch() { @@ -138,30 +138,18 @@ 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"))); + public Integer getHeightId() { + if (heightId == null) { + heightId = getInteger("height_id"); + } + return heightId; } - /** - * Return a {@link List} of {@link BedHeightSingleValue}s - * at the range of the artifact - * @return List of {@link BedHeightSingleValue}s - */ - public List getSingleValues() { - logger.debug("getSingleValues"); - BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( - artifact.getDataAsInteger("height_id")); - return BedHeightSingleValue.getBedHeightSingleValues(single, - getFrom(), - getTo()); + public Integer getTime() { + if (time == null) { + time = getInteger("time"); + } + return time; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 534850c9fabc -r 9d3e44ab25f2 artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java --- a/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Wed Oct 16 10:33:09 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/BedHeightFacet.java Wed Oct 16 10:42:45 2013 +0200 @@ -13,7 +13,11 @@ import org.dive4elements.river.artifacts.D4EArtifact; import org.dive4elements.river.artifacts.access.BedHeightAccess; import org.dive4elements.river.artifacts.model.BlackboardDataFacet; +import org.dive4elements.river.artifacts.model.minfo.BedHeight; +import org.dive4elements.river.artifacts.model.minfo.BedHeightFactory; import org.dive4elements.river.artifacts.model.FacetTypes; +import org.dive4elements.river.model.BedHeightSingle; +import org.dive4elements.river.model.BedHeightSingleValue; public class BedHeightFacet extends BlackboardDataFacet @@ -40,10 +44,29 @@ public Object getData(Artifact artifact, CallContext context) { BedHeightAccess access = new BedHeightAccess((D4EArtifact)artifact); if (type.equals("singlevalues")) { - return access.getSingleValues(); + /* Former doc (from BedHeightAccess): + * Return a {@link List} of {@link BedHeightSingleValue}s + * at the range of the artifact + * @return List of {@link BedHeightSingleValue}s + */ + BedHeightSingle single = BedHeightSingle.getBedHeightSingleById( + access.getHeightId()); + return BedHeightSingleValue.getBedHeightSingleValues(single, + access.getFrom(), + access.getTo()); } - return access.getHeight(); + else { + /* Former doc (from BedHeightAccess): + * Return the {@link BedHeight} at the height_id and time of the artifact + * @return {@link BedHeight} + */ + return BedHeightFactory.getHeight( + access.getType(), + access.getHeightId(), + access.getTime()); + } } + /** * Create a deep copy of this Facet. * @return a deep copy.