felix@2124: package de.intevation.flys.artifacts.states;
felix@2124: 
felix@2124: import java.util.List;
felix@2124: 
felix@2124: import org.apache.log4j.Logger;
felix@2124: 
felix@2124: import de.intevation.artifacts.CallContext;
felix@2124: import de.intevation.artifacts.CallMeta;
felix@2124: 
felix@2124: import de.intevation.artifactdatabase.state.Facet;
felix@2124: 
felix@2124: import de.intevation.flys.artifacts.FLYSArtifact;
felix@2124: import de.intevation.flys.artifacts.StaticWQKmsArtifact;
felix@2124: 
felix@2124: import de.intevation.flys.artifacts.model.FacetTypes;
felix@2124: import de.intevation.flys.artifacts.model.WQKms;
felix@2124: import de.intevation.flys.artifacts.model.WQKmsFacet;
felix@2124: 
felix@2124: /**
felix@2124:  * Only state of WQKmsArtifact.
felix@2124:  */
felix@2124: public class StaticWQKmsState
felix@2124: extends      DefaultState
felix@2124: implements   FacetTypes
felix@2124: {
felix@2124:     /** The logger that is used in this state. */
felix@2124:     private static Logger logger = Logger.getLogger(StaticWQKmsState.class);
felix@2124: 
felix@2124: 
felix@2124:     /**
felix@2124:      * From this state can not be continued.
felix@2124:      */
felix@2124:     @Override
felix@2124:     protected String getUIProvider() {
felix@2124:         return "noinput";
felix@2124:     }
felix@2124: 
felix@2124: 
felix@2124:     /**
felix@2124:      * Compute, create Facets, do the same stuff as all the other states do.
felix@2124:      */
felix@2124:     protected Object compute(
felix@2124:         StaticWQKmsArtifact winfo,
felix@2124:         CallMeta      metaLocale,
felix@2124:         String        hash,
felix@2124:         List<Facet>   facets,
felix@2124:         Object        old
felix@2124:     ) {
felix@2124:         String id = getID();
felix@2124: 
felix@2124:         WQKms res = old instanceof WQKms
felix@2124:             ? (WQKms)old
felix@2124:             : winfo.getWQKms();
felix@2124: 
felix@2124:         WQKms wqkms = res;
felix@2124: 
felix@2124:         if (facets == null) {
felix@2124:             return res;
felix@2124:         }
felix@2124: 
felix@2124:         /*
felix@2124:          * TODO: re-enable HEIGHTMARKS_POINTS-thing
felix@2124: 
felix@2124:            String name;
felix@2124:            if (parts[0].equals(HEIGHTMARKS_POINTS)) {
felix@2124:                name = HEIGHTMARKS_POINTS;
felix@2124:            }
felix@2124:            else {
felix@2124:                name = STATIC_WQKMS;
felix@2124:            }
felix@2124:         */
felix@2124: 
felix@2124:         String wkmsName = wqkms.getName();
felix@2124:         Facet qfacet = new WQKmsFacet(
felix@2124:             STATIC_WQKMS_Q,
felix@2124:             wkmsName
felix@2124:             // TODO re-enable translations.
felix@2124:             /*
felix@2124:             Resources.getMsg(
felix@2124:                 metaLocale,
felix@2124:                 wkmsName,
felix@2124:                 wkmsName)*/);
felix@2124:         facets.add(qfacet);
felix@2124: 
felix@2124:         wkmsName = "W (" + wkmsName + ")";
felix@2124: 
felix@2124:         Facet wfacet = new WQKmsFacet(
felix@2124:             STATIC_WQKMS_W,
felix@2124:             wkmsName
felix@2124:             /*
felix@2124:             // TODO re-enable translations.
felix@2124:             Resources.getMsg(
felix@2124:                 metaLocale,
felix@2124:                 wkmsName,
felix@2124:                 wkmsName)*/);
felix@2124:         facets.add(wfacet);
felix@2124: 
felix@2124:         return res;
felix@2124:     }
felix@2124: 
felix@2124: 
felix@2124:     /**
felix@2124:      * Get data, create the facets.
felix@2124:      *
felix@2124:      * @param context Ignored.
felix@2124:      */
felix@2124:     @Override
felix@2124:     public Object computeFeed(
felix@2124:         FLYSArtifact artifact,
felix@2124:         String       hash,
felix@2124:         CallContext  context,
felix@2124:         List<Facet>  facets,
felix@2124:         Object       old
felix@2124:     ) {
felix@2124:         return compute((StaticWQKmsArtifact) artifact, context.getMeta(),
felix@2124:             hash, facets, old);
felix@2124:     }
felix@2124: 
felix@2124: 
felix@2124:     /**
felix@2124:      * Create the facets.
felix@2124:      * @param context Ignored.
felix@2124:      */
felix@2124:     @Override
felix@2124:     public Object computeInit(
felix@2124:         FLYSArtifact artifact,
felix@2124:         String       hash,
felix@2124:         Object       context,
felix@2124:         CallMeta     meta,
felix@2124:         List<Facet>  facets
felix@2124:     ) {
felix@2124:         return compute((StaticWQKmsArtifact) artifact, meta, hash, facets,
felix@2124:             null);
felix@2124:     }
felix@2124: }
felix@2124: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :