ingo@696: package de.intevation.flys.artifacts.model;
ingo@696: 
ingo@696: import org.apache.log4j.Logger;
ingo@696: 
ingo@696: import de.intevation.artifacts.Artifact;
ingo@696: import de.intevation.artifacts.CallContext;
ingo@696: 
ingo@696: import de.intevation.artifactdatabase.state.DefaultFacet;
sascha@1061: import de.intevation.artifactdatabase.state.Facet;
ingo@696: 
ingo@696: import de.intevation.flys.artifacts.WINFOArtifact;
ingo@696: 
sascha@697: import de.intevation.flys.artifacts.states.DefaultState.ComputeType;
ingo@696: 
felix@1721: /**
felix@1721:  * Facet of a Waterlevel (WQKms).
felix@1721:  */
ingo@696: public class WaterlevelFacet extends DefaultFacet {
ingo@696: 
ingo@696:     private static Logger logger = Logger.getLogger(WaterlevelFacet.class);
ingo@696: 
sascha@722:     protected ComputeType type;
sascha@722:     protected String      stateID;
sascha@722:     protected String      hash;
ingo@696: 
felix@1136: 
ingo@696:     public WaterlevelFacet(int index, String name, String description) {
sascha@722:         this(index, name, description, ComputeType.ADVANCE, null, null);
ingo@696:     }
ingo@696: 
felix@1136: 
sascha@1061:     public WaterlevelFacet() {
sascha@1061:     }
sascha@1061: 
felix@1136: 
sascha@722:     public WaterlevelFacet(
sascha@742:         int         index,
sascha@742:         String      name,
sascha@722:         String      description,
sascha@722:         ComputeType type,
sascha@722:         String      stateID,
sascha@722:         String      hash
sascha@722: 
sascha@722:     ) {
sascha@722:         super(index, name, description);
sascha@722:         this.type    = type;
sascha@722:         this.stateID = stateID;
sascha@722:         this.hash    = hash;
sascha@722:     }
ingo@696: 
felix@1136: 
felix@1136:     /**
felix@1136:      * Get waterlevel data.
felix@1136:      * @return a WQKms at given index.
felix@1136:      */
ingo@696:     public Object getData(Artifact artifact, CallContext context) {
ingo@696:         logger.debug("Get data for waterlevels at index: " + index);
ingo@696: 
sascha@709:         WINFOArtifact winfo = (WINFOArtifact)artifact;
ingo@696: 
sascha@709:         CalculationResult res = (CalculationResult)
ingo@1117:             winfo.compute(context, hash, stateID, type, false);
sascha@709: 
sascha@709:         WQKms [] wqkms = (WQKms [])res.getData();
ingo@696: 
ingo@696:         return wqkms[index];
ingo@696:     }
sascha@1061: 
felix@1136: 
felix@1136:     /** Copy deeply. */
felix@1136:     @Override
sascha@1061:     public Facet deepCopy() {
sascha@1061:         WaterlevelFacet copy = new WaterlevelFacet();
sascha@1061:         copy.set(this);
sascha@1061:         copy.type    = type;
sascha@1061:         copy.stateID = stateID;
sascha@1061:         copy.hash    = hash;
sascha@1061:         return copy;
sascha@1061:     }
ingo@696: }
ingo@696: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :