Mercurial > dive4elements > river
changeset 3553:5da58c5c1517
FLYSArtifact: Some code simplifications.
flys-artifacts/trunk@5147 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Sat, 28 Jul 2012 20:38:27 +0000 |
parents | 1df6984628c3 |
children | 9b356ed24411 |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java |
diffstat | 2 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Fri Jul 27 12:36:09 2012 +0000 +++ b/flys-artifacts/ChangeLog Sat Jul 28 20:38:27 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> + + * src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java: + Some code simplifications. + 2012-07-27 Sascha L. Teichmann <sascha.teichmann@intevation.de> Extented the result data model of the S/Q calculation to
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Fri Jul 27 12:36:09 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Sat Jul 28 20:38:27 2012 +0000 @@ -383,7 +383,7 @@ doc.appendChild(result); try { - saveData(target, XPATH_FEED_INPUT, context); + saveData(target, context); compute(context, ComputeType.FEED, true); @@ -850,12 +850,8 @@ public List<Facet> getFacets() { List<Facet> all = new ArrayList<Facet>(); - Set<Map.Entry<String, List<Facet>>> entries = facets.entrySet(); - for (Map.Entry<String, List<Facet>> entry: entries) { - List<Facet> fs = entry.getValue(); - for (Facet f: fs) { - all.add(f); - } + for (List<Facet> fs: facets.values()) { + all.addAll(fs); } return all; @@ -872,8 +868,8 @@ String name = facet.getName(); int index = facet.getIndex(); - for (Map.Entry<String, List<Facet>> facetList: facets.entrySet()) { - for (Facet f: facetList.getValue()) { + for (List<Facet> fs: facets.values()) { + for (Facet f: fs) { if (f.getIndex() == index && f.getName().equals(name)) { return f; } @@ -891,16 +887,16 @@ * @param feed The FEED document. * @param xpath The XPath that points to the data nodes. */ - public void saveData(Document feed, String xpath, CallContext context) + public void saveData(Document feed, CallContext context) throws IllegalArgumentException { - if (feed == null || xpath == null || xpath.length() == 0) { + if (feed == null) { throw new IllegalArgumentException("error_feed_no_data"); } NodeList nodes = (NodeList) XMLUtils.xpath( feed, - xpath, + XPATH_FEED_INPUT, XPathConstants.NODESET, ArtifactNamespaceContext.INSTANCE); @@ -985,12 +981,7 @@ protected boolean isPreviousState(String stateId, Object context) { logger.debug("Determine if the state '" + stateId + "' is old."); - List<String> prevs = getPreviousStateIds(); - if (prevs.contains(stateId)) { - return true; - } - - return false; + return getPreviousStateIds().contains(stateId); }