comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/StaticHYKState.java @ 3786:4adc35aa655c

merged flys-artifacts/2.9.1
author Thomas Arendsen Hein <thomas@intevation.de>
date Fri, 28 Sep 2012 12:14:47 +0200
parents eb1a676c0d6e
children
comparison
equal deleted inserted replaced
3719:e82acd5c86f7 3786:4adc35aa655c
1 package de.intevation.flys.artifacts.states;
2
3 import java.util.List;
4
5 import org.apache.log4j.Logger;
6
7 import de.intevation.artifacts.CallContext;
8 import de.intevation.artifacts.CallMeta;
9
10 import de.intevation.artifactdatabase.state.Facet;
11
12 import de.intevation.flys.artifacts.FLYSArtifact;
13 import de.intevation.flys.artifacts.HYKArtifact;
14
15 import de.intevation.flys.artifacts.model.FacetTypes;
16 import de.intevation.flys.artifacts.model.HYKFacet;
17 import de.intevation.flys.artifacts.model.HYKFactory;
18
19 /**
20 * Only state of a HYKArtifact.
21 */
22 public class StaticHYKState
23 extends DefaultState
24 implements FacetTypes
25 {
26 /** The logger that is used in this state. */
27 transient private static final Logger logger = Logger.getLogger(StaticHYKState.class);
28
29
30 /**
31 * From this state can not be continued.
32 */
33 @Override
34 protected String getUIProvider() {
35 return "noinput";
36 }
37
38
39 /**
40 * Compute, create Facets, do the same stuff as all the other states do.
41 */
42 protected Object compute(
43 HYKArtifact hyk,
44 CallMeta metaLocale,
45 String hash,
46 List<Facet> facets,
47 Object old
48 ) {
49 logger.debug("StaticHYKState.compute");
50 String id = getID();
51
52 // Prepare comparison against cached result.
53 List<HYKFactory.Zone> resZones = old instanceof List
54 ? (List<HYKFactory.Zone>)old
55 : null;
56
57 // TODO Compare against cached object.
58
59 // Get Zones from HYKFactory
60 List<HYKFactory.Zone> zones = (List<HYKFactory.Zone>)
61 HYKFactory.getHYKs(hyk.getHykId(), hyk.getKm());
62
63 if (facets == null) {
64 logger.debug("StaticHYKState.compute no facets");
65 return zones;
66 }
67
68 // Spawn Facets.
69 Facet facet = new HYKFacet(0, HYKFactory.getHykName(hyk.getHykId()));
70 facets.add(facet);
71
72 return zones;
73 }
74
75
76 /**
77 * Get data, create the facets.
78 *
79 * @param context Ignored.
80 */
81 @Override
82 public Object computeFeed(
83 FLYSArtifact artifact,
84 String hash,
85 CallContext context,
86 List<Facet> facets,
87 Object old
88 ) {
89 return compute((HYKArtifact) artifact, context.getMeta(),
90 hash, facets, old);
91 }
92
93
94 /**
95 * Create the facets.
96 * @param context Ignored.
97 */
98 @Override
99 public Object computeInit(
100 FLYSArtifact artifact,
101 String hash,
102 Object context,
103 CallMeta meta,
104 List<Facet> facets
105 ) {
106 return compute((HYKArtifact) artifact, meta, hash, facets,
107 null);
108 }
109 }
110 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :

http://dive4elements.wald.intevation.org