Mercurial > dive4elements > river
view flys-artifacts/src/main/java/de/intevation/flys/artifacts/transitions/ValueCompareTransition.java @ 2792:fe987587ebc9
Merged revisions 4539-4540,4543,4545-4546 via svnmerge from
file:///home/clients/bsh/bsh-generischer-viewer/Material/SVN/flys-artifacts/trunk
........
r4539 | teichmann | 2012-05-27 20:02:13 +0200 (So, 27 Mai 2012) | 1 line
FixA: Added forgotten csv/report facets/generators to conf.
........
r4540 | teichmann | 2012-05-27 20:11:31 +0200 (So, 27 Mai 2012) | 1 line
FixA: Fixed class cast bug in report facet.
........
r4543 | teichmann | 2012-05-28 20:35:01 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Added facet to return delta w/t as CSV
........
r4545 | teichmann | 2012-05-28 22:59:27 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: Made Delta W/t calculation finally work
........
r4546 | teichmann | 2012-05-28 23:34:24 +0200 (Mo, 28 Mai 2012) | 1 line
FixA: corrected fitting (Q->W instead W->Q).
........
flys-artifacts/tags/2.7@4547 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 29 May 2012 04:58:29 +0000 |
parents | 22e9574c8b1b |
children | eb5564662e19 |
line wrap: on
line source
package de.intevation.flys.artifacts.transitions; import javax.xml.xpath.XPathConstants; import org.apache.log4j.Logger; import org.w3c.dom.Node; import de.intevation.artifacts.Artifact; import de.intevation.artifactdatabase.data.StateData; import de.intevation.artifactdatabase.state.State; import de.intevation.artifacts.common.utils.XMLUtils; import de.intevation.flys.artifacts.FLYSArtifact; /** * This transition compares data objects with a <i>equal</i> or <i>notequal</i> * operator. * * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ public class ValueCompareTransition extends DefaultTransition { /** The logger that is used in this transition.*/ private static Logger log = Logger.getLogger(ValueCompareTransition.class); /** XPath that points to the condition's operator.*/ public static final String XPATH_OPERATOR = "condition/@operator"; /** XPath that points to the condition's value.*/ public static final String XPATH_VALUE = "condition/@value"; /** XPath that points to the condition's dataname.*/ public static final String XPATH_DATANAME = "condition/@data"; /** The value of the 'equal' operator.*/ public static final String OPERATOR_EQUAL = "equal"; /** The value of the 'not equal' operator.*/ public static final String OPERATOR_NOTEQUAL = "notequal"; /** The operator.*/ protected String operator; /** The value used for comparison.*/ protected String value; /** The name of the data used for the comparison.*/ protected String dataname; public ValueCompareTransition() { } public ValueCompareTransition(String from, String to) { super(from, to); } @Override public void init(Node config) { log.debug("ValueCompareTransition.init"); String tmp = (String) XMLUtils.xpath( config, XPATH_OPERATOR, XPathConstants.STRING); operator = tmp.trim().toLowerCase(); value = (String) XMLUtils.xpath( config, XPATH_VALUE, XPathConstants.STRING); dataname = (String) XMLUtils.xpath( config, XPATH_DATANAME, XPathConstants.STRING); } @Override public boolean isValid(Artifact artifact, State a, State b) { log.debug("ValueCompareTransition.isValid"); FLYSArtifact flysArtifact = (FLYSArtifact) artifact; StateData dataObj = flysArtifact.getData(dataname); String dataVal = dataObj != null ? (String) dataObj.getValue() : ""; if (log.isDebugEnabled()) { log.debug("Compare settings:"); log.debug("-- dataname: " + dataname); log.debug("-- operator: " + operator); log.debug("-- compare value: " + value); log.debug("-- state value: " + dataVal); } if (operator.equals(OPERATOR_EQUAL)) { return value.equals(dataVal); } else if (operator.equals(OPERATOR_NOTEQUAL)) { return !(value.equals(dataVal)); } log.error("Wrong operator set! No comparison takes place."); return false; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :