teichmann@5831: package org.dive4elements.river.artifacts.model; sascha@702: teichmann@5831: import org.dive4elements.artifacts.Artifact; teichmann@5831: import org.dive4elements.artifacts.CallContext; sascha@702: teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; sascha@702: teichmann@5831: import org.dive4elements.river.artifacts.FLYSArtifact; teichmann@5831: teichmann@5831: import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; sascha@702: sascha@702: public class DataFacet felix@2122: extends BlackboardDataFacet sascha@702: { sascha@702: protected ComputeType type; sascha@702: protected String hash; ingo@930: protected String stateId; sascha@702: felix@1160: felix@1160: /** Trivial constructor. */ sascha@1061: public DataFacet() { sascha@1061: } sascha@1061: felix@1160: /** felix@1160: * Defaults to ADVANCE Compute type. felix@1160: * @param name Name of the facet. felix@1160: * @param description maybe localized description of the facet. felix@1160: */ sascha@702: public DataFacet(String name, String description) { sascha@702: this(name, description, ComputeType.ADVANCE); sascha@702: } sascha@702: felix@2121: sascha@702: public DataFacet(String name, String description, ComputeType type) { sascha@702: this(name, description, type, null); sascha@702: } sascha@702: felix@2121: sascha@702: public DataFacet( sascha@702: String name, sascha@742: String description, sascha@702: ComputeType type, sascha@702: String hash sascha@702: ) { sascha@702: super(name, description); sascha@702: this.type = type; sascha@702: this.hash = hash; sascha@702: } sascha@702: ingo@930: ingo@930: public DataFacet( ingo@930: String name, ingo@930: String description, ingo@930: ComputeType type, ingo@930: String hash, ingo@930: String stateId ingo@930: ) { ingo@930: super(name, description); ingo@930: this.type = type; ingo@930: this.hash = hash; ingo@930: this.stateId = stateId; ingo@930: } ingo@930: felix@1160: felix@2121: public DataFacet( felix@2121: int index, felix@2121: String name, felix@2121: String description, felix@2121: ComputeType type, felix@2121: String hash, felix@2121: String stateId felix@2121: ) { felix@2121: super(index, name, description); felix@2121: this.type = type; felix@2121: this.hash = hash; felix@2121: this.stateId = stateId; felix@2121: } felix@2121: felix@2141: felix@1160: /** felix@1160: * Return computation result. felix@1160: */ sascha@1061: @Override sascha@702: public Object getData(Artifact artifact, CallContext context) { sascha@702: FLYSArtifact flys = (FLYSArtifact)artifact; felix@1070: String theHash = (hash != null) ? hash : flys.hash(); ingo@930: felix@1136: return (stateId != null && stateId.length() > 0) ingo@1117: ? flys.compute(context, theHash, stateId, type, false) ingo@930: : flys.compute(context, theHash, type, false); sascha@702: } sascha@1061: felix@1160: felix@1160: /** felix@1160: * Return a deep copy. felix@1160: */ sascha@1061: @Override sascha@1061: public Facet deepCopy() { sascha@1061: DataFacet copy = new DataFacet(); sascha@1061: copy.set(this); sascha@1061: copy.type = type; sascha@1061: copy.hash = hash; sascha@1061: copy.stateId = stateId; sascha@1061: return copy; sascha@1061: } sascha@702: } sascha@702: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :