comparison flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java @ 714:2f25ca828efd

Only generate 'outs' if they have facets. flys-artifacts/trunk@2180 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 21 Jun 2011 16:22:28 +0000
parents cded0924193d
children 7298d58a1f5a
comparison
equal deleted inserted replaced
713:dc3a8c45349b 714:2f25ca828efd
210 List<Facet> fs = facets.get(cur.getID()); 210 List<Facet> fs = facets.get(cur.getID());
211 if (fs != null && fs.size() > 0) { 211 if (fs != null && fs.size() > 0) {
212 List<Output> generated = generateOutputs(list, fs); 212 List<Output> generated = generateOutputs(list, fs);
213 213
214 logger.debug("Found " + fs.size() + " current facets."); 214 logger.debug("Found " + fs.size() + " current facets.");
215 215 if (!generated.isEmpty()) {
216 ProtocolUtils.appendOutputModes( 216 ProtocolUtils.appendOutputModes(
217 creator, outs, generated); 217 creator, outs, generated);
218 }
218 } 219 }
219 else { 220 else {
220 logger.debug("No facets found for the current state."); 221 logger.debug("No facets found for the current state.");
221 } 222 }
222 223
229 } 230 }
230 231
231 232
232 protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) { 233 protected List<Output> generateOutputs(List<Output> list, List<Facet> fs) {
233 List<Output> generated = new ArrayList<Output>(); 234 List<Output> generated = new ArrayList<Output>();
235
236 boolean debug = logger.isDebugEnabled();
234 237
235 for (Output out: list) { 238 for (Output out: list) {
236 Output o = new DefaultOutput( 239 Output o = new DefaultOutput(
237 out.getName(), 240 out.getName(),
238 out.getDescription(), 241 out.getDescription(),
239 out.getMimeType()); 242 out.getMimeType());
240 243
241 Set<String> outTypes = new HashSet<String>(); 244 Set<String> outTypes = new HashSet<String>();
242 245
243 for (Facet f: out.getFacets()) { 246 for (Facet f: out.getFacets()) {
244 outTypes.add(f.getName()); 247 if (outTypes.add(f.getName()) && debug) {
245 } 248 logger.debug("configured facet " + f);
246 249 }
250 }
251
252 boolean facetAdded = false;
247 for (Facet f: fs) { 253 for (Facet f: fs) {
248 String type = f.getName(); 254 String type = f.getName();
249 255
250 if (outTypes.contains(type)) { 256 if (outTypes.contains(type)) {
257 if (debug) {
258 logger.debug("Add facet " + f);
259 }
260 facetAdded = true;
251 o.addFacet(f); 261 o.addFacet(f);
252 } 262 }
253 } 263 }
254 264
255 generated.add(o); 265 if (facetAdded) {
266 generated.add(o);
267 }
256 } 268 }
257 269
258 return generated; 270 return generated;
259 } 271 }
260 272

http://dive4elements.wald.intevation.org