Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java @ 689:f8ac04b2dbd0 facets-slt
Added two more compute() methods to ComputeCallback to distinguish between different phases of the artifact.
flys-artifacts/branches/facets-slt@2129 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Thu, 16 Jun 2011 08:43:58 +0000 |
parents | 06689035024c |
children | 3481cd37e609 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Jun 16 08:25:06 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/FLYSArtifact.java Thu Jun 16 08:43:58 2011 +0000 @@ -51,6 +51,7 @@ import de.intevation.flys.artifacts.model.Segment; import de.intevation.flys.artifacts.states.DefaultState; +import de.intevation.flys.artifacts.states.CalculationSelect; import de.intevation.flys.artifacts.states.LocationDistanceSelect; @@ -194,6 +195,9 @@ try { saveData(target, XPATH_FEED_INPUT, context); + + compute(context); + return describe(target, context); } catch (IllegalArgumentException iae) { @@ -257,6 +261,8 @@ setCurrentStateId(targetState); + compute(context); + return describe(target, context); } @@ -1038,6 +1044,45 @@ } + /** + * Dispatches the computation request to compute(CallContext context, String + * hash) with the current hash value of the artifact which is provided by + * hash(). + * + * @param context The CallContext. + */ + public Object compute(CallContext context) { + return compute(context, hash()); + } + + + /** + * Dispatches computation requests to the current state which needs to + * implement a createComputeCallback(String hash, FLYSArtifact artifact) + * method. + * + * @param context The CallContext. + * @param hash The hash value which is used to fetch computed data from + * cache. + * + * @return the computed data. + */ + public Object compute(CallContext context, String hash) { + String calc = (String) getData(CalculationSelect.FIELD_MODE).getValue(); + + DefaultState current = (DefaultState) getCurrentState(context); + + ComputeCallback callback = current.createComputeCallback(hash(), this); + + if (callback == null) { + logger.info("There is no data which needs to be computed."); + return null; + } + + return compute(hash, callback); + } + + public Object compute(String key, ComputeCallback callback) { Cache cache = CacheFactory.getCache(COMPUTING_CACHE);