teichmann@5863: /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde teichmann@5863: * Software engineering by Intevation GmbH teichmann@5863: * teichmann@5994: * This file is Free Software under the GNU AGPL (>=v3) teichmann@5863: * and comes with ABSOLUTELY NO WARRANTY! Check out the teichmann@5994: * documentation coming with Dive4Elements River for details. teichmann@5863: */ teichmann@5863: teichmann@5831: package org.dive4elements.river.artifacts.states; felix@2131: felix@2131: import java.util.List; felix@2131: felix@2131: import org.apache.log4j.Logger; felix@2131: teichmann@5831: import org.dive4elements.artifacts.CallContext; teichmann@5831: import org.dive4elements.artifacts.CallMeta; felix@2131: teichmann@5831: import org.dive4elements.artifactdatabase.state.Facet; felix@2131: teichmann@5867: import org.dive4elements.river.artifacts.D4EArtifact; teichmann@5831: import org.dive4elements.river.artifacts.HYKArtifact; teichmann@5831: teichmann@5831: import org.dive4elements.river.artifacts.model.FacetTypes; teichmann@5831: import org.dive4elements.river.artifacts.model.HYKFacet; teichmann@5831: import org.dive4elements.river.artifacts.model.HYKFactory; felix@2131: felix@2131: /** felix@2131: * Only state of a HYKArtifact. felix@2131: */ felix@2131: public class StaticHYKState felix@2131: extends DefaultState felix@2131: implements FacetTypes felix@2131: { teichmann@8202: /** The log that is used in this state. */ teichmann@8202: transient private static final Logger log = Logger.getLogger(StaticHYKState.class); felix@2131: felix@2131: felix@2131: /** felix@2131: * From this state can not be continued. felix@2131: */ felix@2131: @Override felix@2131: protected String getUIProvider() { felix@2131: return "noinput"; felix@2131: } felix@2131: felix@2131: felix@2131: /** felix@2131: * Compute, create Facets, do the same stuff as all the other states do. felix@2131: */ felix@2131: protected Object compute( felix@2131: HYKArtifact hyk, felix@2131: CallMeta metaLocale, felix@2131: String hash, felix@2131: List facets, felix@2131: Object old felix@2131: ) { teichmann@8202: log.debug("StaticHYKState.compute"); felix@2131: String id = getID(); felix@2131: felix@2151: // Prepare comparison against cached result. felix@2151: List resZones = old instanceof List felix@2151: ? (List)old felix@2151: : null; felix@2131: felix@2151: // TODO Compare against cached object. felix@2131: felix@2151: // Get Zones from HYKFactory felix@2131: List zones = (List) felix@2139: HYKFactory.getHYKs(hyk.getHykId(), hyk.getKm()); felix@2131: felix@2131: if (facets == null) { teichmann@8202: log.debug("StaticHYKState.compute no facets"); felix@2131: return zones; felix@2131: } felix@2131: felix@2151: // Spawn Facets. felix@2139: Facet facet = new HYKFacet(0, HYKFactory.getHykName(hyk.getHykId())); felix@2131: facets.add(facet); felix@2131: felix@2131: return zones; felix@2131: } felix@2131: felix@2131: felix@2131: /** felix@2131: * Get data, create the facets. felix@2131: * felix@2131: * @param context Ignored. felix@2131: */ felix@2131: @Override felix@2131: public Object computeFeed( teichmann@5867: D4EArtifact artifact, felix@2131: String hash, felix@2131: CallContext context, felix@2131: List facets, felix@2131: Object old felix@2131: ) { felix@2131: return compute((HYKArtifact) artifact, context.getMeta(), felix@2131: hash, facets, old); felix@2131: } felix@2131: felix@2131: felix@2131: /** felix@2131: * Create the facets. felix@2131: * @param context Ignored. felix@2131: */ felix@2131: @Override felix@2131: public Object computeInit( teichmann@5867: D4EArtifact artifact, felix@2131: String hash, felix@2131: Object context, felix@2131: CallMeta meta, felix@2131: List facets felix@2131: ) { felix@2131: return compute((HYKArtifact) artifact, meta, hash, facets, felix@2131: null); felix@2131: } felix@2131: } felix@2131: // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :