comparison artifacts/src/main/java/org/dive4elements/river/artifacts/model/minfo/PorosityFacet.java @ 7846:e84726b48484

New Facet, datatype and data factory for porosities.
author Raimund Renkert <rrenkert@intevation.de>
date Wed, 30 Apr 2014 15:20:11 +0200
parents
children f9e3ef5d38d0 42076d94977e
comparison
equal deleted inserted replaced
7845:4e264d6c6e06 7846:e84726b48484
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
2 * Software engineering by Intevation GmbH
3 *
4 * This file is Free Software under the GNU AGPL (>=v3)
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the
6 * documentation coming with Dive4Elements River for details.
7 */
8
9 package org.dive4elements.river.artifacts.model.minfo;
10
11 import org.apache.log4j.Logger;
12
13 import org.dive4elements.artifactdatabase.state.Facet;
14 import org.dive4elements.artifactdatabase.state.StaticFacet;
15 import org.dive4elements.artifacts.Artifact;
16 import org.dive4elements.artifacts.CallContext;
17 import org.dive4elements.artifacts.CallMeta;
18 import org.dive4elements.artifacts.common.utils.XMLUtils;
19 import org.dive4elements.river.artifacts.D4EArtifact;
20 import org.dive4elements.river.artifacts.model.DataFacet;
21 import org.dive4elements.river.artifacts.model.FacetTypes;
22 import org.dive4elements.river.artifacts.resources.Resources;
23 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType;
24 import org.w3c.dom.Document;
25
26
27 public class PorosityFacet
28 extends DataFacet
29 implements FacetTypes, StaticFacet
30 {
31 private static Logger logger = Logger.getLogger(PorosityFacet.class);
32
33 private static final String NAME = "porosity";
34
35 public PorosityFacet() {
36 }
37
38 public PorosityFacet(String facetName, String description) {
39 super(facetName, description);
40 }
41
42 public PorosityFacet(int idx, String name, String description,
43 ComputeType type, String stateId, String hash) {
44 super(idx, name, description, type, hash, stateId);
45 }
46
47 public Object getData(Artifact artifact, CallContext context) {
48
49 D4EArtifact flys = (D4EArtifact) artifact;
50 String porosity_id = flys.getDataAsString("porosity_id");
51
52 Porosity porosity =
53 PorosityFactory.getPorosity(Integer.valueOf(porosity_id));
54
55 return porosity;
56 }
57
58 /** Copy deeply. */
59 @Override
60 public Facet deepCopy() {
61 PorosityFacet copy = new PorosityFacet();
62 copy.set(this);
63 copy.type = type;
64 copy.hash = hash;
65 copy.stateId = stateId;
66 return copy;
67 }
68
69 @Override
70 public void setup(Artifact artifact, Document data, CallMeta callMeta) {
71 logger.debug("setup");
72
73 if (logger.isDebugEnabled()) {
74 logger.debug(XMLUtils.toString(data));
75 }
76
77 String code = D4EArtifact.getDatacageIDValue(data);
78
79 if (code != null) {
80 this.name = NAME;
81 this.description = Resources.getMsg(
82 callMeta,
83 "facet.porosity",
84 "Porosity");
85 D4EArtifact d4e = (D4EArtifact) artifact;
86 d4e.addStringData("porosity_id", code);
87 }
88 }
89 }

http://dive4elements.wald.intevation.org