felix@2001: package de.intevation.flys.artifacts.states;
felix@2001: 
felix@2001: import java.util.List;
felix@2001: 
felix@2001: import org.apache.log4j.Logger;
felix@2001: 
felix@2001: import de.intevation.artifacts.CallContext;
felix@2001: 
felix@2001: import de.intevation.flys.artifacts.model.AreaFacet;
felix@2001: 
felix@2001: import de.intevation.artifactdatabase.state.Facet;
felix@2001: 
felix@2001: import de.intevation.flys.artifacts.FLYSArtifact;
felix@2010: import de.intevation.flys.artifacts.AreaArtifact;
felix@2001: import de.intevation.flys.artifacts.model.FacetTypes;
felix@2001: 
felix@2001: 
felix@2022: /** Trivial state to create areafacets, no caching. */
felix@2001: public class AreaCreationState
felix@2001: extends      DefaultState
felix@2001: implements   FacetTypes
felix@2001: {
felix@2001:     /** The logger that is used in this state. */
felix@2001:     private static Logger logger = Logger.getLogger(AreaCreationState.class);
felix@2001: 
felix@2001: 
felix@2001:     /**
felix@2001:      * From this state can only be continued trivially.
felix@2001:      */
felix@2001:     @Override
felix@2001:     protected String getUIProvider() {
felix@2001:         return "continue";
felix@2001:     }
felix@2001: 
felix@2001: 
felix@2010:     /** Just reproduce the Facet. */
felix@2001:     protected Object compute(
felix@2010:         FLYSArtifact  areaArtifact,
felix@2001:         CallContext   cc,
felix@2001:         String        hash,
felix@2001:         List<Facet>   facets,
felix@2001:         Object        old
felix@2001:     ) {
felix@2001:         logger.debug("AreaCreationState.compute");
felix@2010: 
felix@2001:         if (facets != null) {
felix@2018:             AreaArtifact aArt = (AreaArtifact) areaArtifact;
felix@2018: 
felix@2018:             facets.add(new AreaFacet(0, aArt.getFacetName(), aArt.getAreaName()));
felix@2001:         }
felix@2001: 
felix@2001:         // TODO use compute to exploit caching strategies.
felix@2001: 
felix@2001:         return null;
felix@2001:     }
felix@2001: 
felix@2001: 
felix@2001:     /**
felix@2001:      */
felix@2001:     @Override
felix@2001:     public Object computeFeed(
felix@2001:         FLYSArtifact artifact,
felix@2001:         String       hash,
felix@2001:         CallContext  context,
felix@2001:         List<Facet>  facets,
felix@2001:         Object       old
felix@2001:     ) {
felix@2001:         return compute((FLYSArtifact) artifact, context, hash, facets, old);
felix@2001:     }
felix@2001: 
felix@2001: 
felix@2001:     /**
felix@2001:      *
felix@2001:      */
felix@2001:     @Override
felix@2001:     public Object computeAdvance(
felix@2001:         FLYSArtifact artifact,
felix@2001:         String       hash,
felix@2001:         CallContext  context,
felix@2001:         List<Facet>  facets,
felix@2001:         Object       old
felix@2001:     ) {
felix@2001:         return compute((FLYSArtifact) artifact, context, hash, facets, old);
felix@2001:     }
felix@2001: }
felix@2001: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :