Mercurial > dive4elements > river
comparison artifacts/src/main/java/org/dive4elements/river/artifacts/D4EArtifact.java @ 7227:744df5a03337
Use diagram configuration and there processors to define compatible facets in loaded data.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Wed, 02 Oct 2013 19:24:43 +0200 |
parents | 12248d9eb326 |
children | 737dd43e32d6 |
comparison
equal
deleted
inserted
replaced
7226:8ab618dda850 | 7227:744df5a03337 |
---|---|
50 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; | 50 import org.dive4elements.artifacts.common.ArtifactNamespaceContext; |
51 import org.dive4elements.artifacts.common.utils.XMLUtils; | 51 import org.dive4elements.artifacts.common.utils.XMLUtils; |
52 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; | 52 import org.dive4elements.artifacts.common.utils.XMLUtils.ElementCreator; |
53 import org.dive4elements.river.artifacts.cache.CacheFactory; | 53 import org.dive4elements.river.artifacts.cache.CacheFactory; |
54 import org.dive4elements.river.artifacts.context.RiverContext; | 54 import org.dive4elements.river.artifacts.context.RiverContext; |
55 import org.dive4elements.river.artifacts.context.RiverContextFactory; | |
55 import org.dive4elements.river.artifacts.model.CalculationMessage; | 56 import org.dive4elements.river.artifacts.model.CalculationMessage; |
56 import org.dive4elements.river.artifacts.states.DefaultState; | 57 import org.dive4elements.river.artifacts.states.DefaultState; |
57 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; | 58 import org.dive4elements.river.artifacts.states.DefaultState.ComputeType; |
58 import org.dive4elements.river.utils.RiverUtils; | 59 import org.dive4elements.river.utils.RiverUtils; |
59 | 60 |
116 * filter in output of collection); out -> facets. | 117 * filter in output of collection); out -> facets. |
117 */ | 118 */ |
118 protected Map<String, List<Facet>> filterFacets; | 119 protected Map<String, List<Facet>> filterFacets; |
119 | 120 |
120 private String boundToOut; | 121 private String boundToOut; |
122 | |
123 /** | |
124 * Interface to a global facet filter. | |
125 */ | |
126 public interface FacetFilter { | |
127 boolean accept(String outName, String facetName); | |
128 } // interface FacetFilter | |
121 | 129 |
122 | 130 |
123 /** | 131 /** |
124 * The default constructor that creates an empty D4EArtifact. | 132 * The default constructor that creates an empty D4EArtifact. |
125 */ | 133 */ |
1277 } | 1285 } |
1278 if (debug) { | 1286 if (debug) { |
1279 log.debug("State '" + stateId + "' has facets " + fs); | 1287 log.debug("State '" + stateId + "' has facets " + fs); |
1280 } | 1288 } |
1281 | 1289 |
1282 List<Output> gen = generateOutputs(list, fs); | 1290 List<Output> gen = generateOutputs(list, filterFacets(fs)); |
1283 | 1291 |
1284 if (debug) { | 1292 if (debug) { |
1285 log.debug("State '" + stateId + "' has " + gen.size() + " outs"); | 1293 log.debug("State '" + stateId + "' has " + gen.size() + " outs"); |
1286 } | 1294 } |
1287 | 1295 |
1288 return gen; | 1296 return gen; |
1289 } | 1297 } |
1290 | 1298 |
1299 /** If a global facet filter and a bounded out are defined | |
1300 * use them to eliminate unwished facets. | |
1301 */ | |
1302 protected List<Facet> filterFacets(List<Facet> facets) { | |
1303 if (boundToOut == null || boundToOut.isEmpty()) { | |
1304 return facets; | |
1305 } | |
1306 | |
1307 FacetFilter facetFilter = | |
1308 (FacetFilter)RiverContextFactory.getGlobalContext() | |
1309 .get(RiverContext.FACETFILTER_KEY); | |
1310 if (facetFilter == null) { | |
1311 return facets; | |
1312 } | |
1313 | |
1314 List<Facet> result = new ArrayList<Facet>(facets.size()); | |
1315 for (Facet facet: facets) { | |
1316 if (facetFilter.accept(boundToOut, facet.getName())) { | |
1317 result.add(facet); | |
1318 } | |
1319 } | |
1320 return result; | |
1321 } | |
1291 | 1322 |
1292 /** | 1323 /** |
1293 * Generate a list of outputs with facets from fs if type is found in list | 1324 * Generate a list of outputs with facets from fs if type is found in list |
1294 * of output. | 1325 * of output. |
1295 * | 1326 * |