# HG changeset patch # User Sascha L. Teichmann # Date 1343561979 0 # Node ID c3cd414982fe470c43ebfaab96a9e5e29dd59e3d # Parent f1f798b5f14a4e94c6c826ed2c454daf5b2135c9 Adjusted to follow the Chain-of-responsibility pattern in figuring out facet activities. flys-artifacts/trunk@5155 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r f1f798b5f14a -r c3cd414982fe flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Sun Jul 29 11:11:51 2012 +0000 +++ b/flys-artifacts/ChangeLog Sun Jul 29 11:39:39 2012 +0000 @@ -1,3 +1,12 @@ +2012-07-29 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/collections/AttributeWriter.java, + src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java, + src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java, + src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java: + Refactored to use the new Chain-of-responsibility pattern in facet + activation. + 2012-07-29 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/services/GaugeInfoService.java: diff -r f1f798b5f14a -r c3cd414982fe flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Sun Jul 29 11:11:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/CrossSectionArtifact.java Sun Jul 29 11:39:39 2012 +0000 @@ -71,7 +71,7 @@ CS_ARTIFACT_NAME, new FacetActivity() { @Override - public boolean isInitialActive( + public Boolean isInitialActive( Artifact artifact, Facet facet, String outputName @@ -81,7 +81,7 @@ String data = flys.getDataAsString(DATA_IS_NEWEST); return data != null && data.equals("1"); } - return false; + return null; } }); } diff -r f1f798b5f14a -r c3cd414982fe flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Sun Jul 29 11:11:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/MainValuesArtifact.java Sun Jul 29 11:39:39 2012 +0000 @@ -57,6 +57,23 @@ protected transient State state = null; + static { + // TODO: Move to configuration. + FacetActivity.Registry.getInstance().register( + ARTIFACT_NAME, + new FacetActivity() { + @Override + public Boolean isInitialActive( + Artifact artifact, + Facet facet, + String outputName + ) { + return outputName.equals("computed_discharge_curve") + || outputName.equals("duration_curve"); + } + }); + } + /** * Trivial Constructor. */ @@ -316,22 +333,5 @@ } return filteredList; } - - static { - // TODO: Move to configuration. - FacetActivity.Registry.getInstance().register( - ARTIFACT_NAME, - new FacetActivity() { - @Override - public boolean isInitialActive( - Artifact artifact, - Facet facet, - String outputName - ) { - return outputName.equals("computed_discharge_curve") - || outputName.equals("duration_curve"); - } - }); - } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r f1f798b5f14a -r c3cd414982fe flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sun Jul 29 11:11:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Sun Jul 29 11:39:39 2012 +0000 @@ -90,7 +90,7 @@ ARTIFACT_NAME, new FacetActivity() { @Override - public boolean isInitialActive( + public Boolean isInitialActive( Artifact artifact, Facet facet, String outputName @@ -99,7 +99,7 @@ if ((fname.equals(COMPUTED_DISCHARGE_MAINVALUES_Q) || fname.equals(COMPUTED_DISCHARGE_MAINVALUES_W)) && outputName.equals("computed_discharge_curve")) { - return false; + return Boolean.FALSE; } return !StringUtils.contains(fname, INACTIVES); diff -r f1f798b5f14a -r c3cd414982fe flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Sun Jul 29 11:11:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/collections/AttributeWriter.java Sun Jul 29 11:39:39 2012 +0000 @@ -207,10 +207,8 @@ FLYSArtifact flys = (FLYSArtifact)db.getRawArtifact(newMF.getArtifact()); - FacetActivity activity = registry.getActivity(flys.getName()); - - boolean isActive = activity.isInitialActive( - flys, newMF, outputName); + boolean isActive = registry.isInitialActive( + flys.getName(), flys, newMF, outputName); newMF.setActive(isActive ? 1 : 0); }