Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/collections/FLYSArtifactCollection.java @ 1668:6566c7868456
Added facet and index information to theme which are stored at CollectionItems.
flys-artifacts/trunk@2880 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 04 Oct 2011 11:28:37 +0000 |
parents | 16c74ca3586e |
children | bdb05dc9b763 |
comparison
equal
deleted
inserted
replaced
1667:f1af0c07a6ee | 1668:6566c7868456 |
---|---|
289 theme, | 289 theme, |
290 getFacetThemeFromAttribute( | 290 getFacetThemeFromAttribute( |
291 art, | 291 art, |
292 outName, | 292 outName, |
293 facetName, | 293 facetName, |
294 theme.getIndex(), | |
294 context)); | 295 context)); |
295 } | 296 } |
296 } | 297 } |
297 catch (ArtifactDatabaseException ade) { | 298 catch (ArtifactDatabaseException ade) { |
298 log.error(ade, ade); | 299 log.error(ade, ade); |
455 */ | 456 */ |
456 protected Document getFacetThemeFromAttribute( | 457 protected Document getFacetThemeFromAttribute( |
457 String uuid, | 458 String uuid, |
458 String outName, | 459 String outName, |
459 String facet, | 460 String facet, |
461 int index, | |
460 CallContext context) | 462 CallContext context) |
461 throws ArtifactDatabaseException | 463 throws ArtifactDatabaseException |
462 { | 464 { |
463 log.debug("FLYSArtifactCollection.getFacetThemeFromAttribute"); | 465 log.debug("FLYSArtifactCollection.getFacetThemeFromAttribute"); |
464 | 466 |
475 String themeName = mappings.get(facet); | 477 String themeName = mappings.get(facet); |
476 | 478 |
477 Document attr = db.getCollectionItemAttribute(identifier(), uuid, meta); | 479 Document attr = db.getCollectionItemAttribute(identifier(), uuid, meta); |
478 | 480 |
479 if (attr == null) { | 481 if (attr == null) { |
480 attr = initItemAttribute(uuid, facet, context); | 482 attr = initItemAttribute(uuid, facet, index, context); |
481 | 483 |
482 if (attr == null) { | 484 if (attr == null) { |
483 return null; | 485 return null; |
484 } | 486 } |
485 } | 487 } |
499 | 501 |
500 log.debug("Search theme '" + themeName + "' in attribute."); | 502 log.debug("Search theme '" + themeName + "' in attribute."); |
501 | 503 |
502 Node theme = (Node) XMLUtils.xpath( | 504 Node theme = (Node) XMLUtils.xpath( |
503 tmp, | 505 tmp, |
504 "art:themes/theme[@name='" + themeName + "']", | 506 "art:themes/theme[@facet='" + facet + |
507 "' and @index='" + String.valueOf(index) + "']", | |
505 XPathConstants.NODE, | 508 XPathConstants.NODE, |
506 ArtifactNamespaceContext.INSTANCE); | 509 ArtifactNamespaceContext.INSTANCE); |
507 | 510 |
508 if (theme == null) { | 511 if (theme == null) { |
509 log.warn("Could not find the theme in attribute of: " + uuid); | 512 log.warn("Could not find the theme in attribute of: " + uuid); |
510 | 513 |
511 Theme t = getThemeForFacet(uuid, facet, context); | 514 Theme t = getThemeForFacet(uuid, facet, index, context); |
512 | 515 |
513 if (t == null) { | 516 if (t == null) { |
514 log.warn("No theme found for facet: " + facet); | 517 log.warn("No theme found for facet: " + facet); |
515 return null; | 518 return null; |
516 } | 519 } |
599 * @param the new attribute. | 602 * @param the new attribute. |
600 */ | 603 */ |
601 protected Document initItemAttribute( | 604 protected Document initItemAttribute( |
602 String uuid, | 605 String uuid, |
603 String facet, | 606 String facet, |
607 int index, | |
604 CallContext context) | 608 CallContext context) |
605 { | 609 { |
606 log.info("FLYSArtifactCollection.initItemAttribute"); | 610 log.info("FLYSArtifactCollection.initItemAttribute"); |
607 | 611 |
608 Theme t = getThemeForFacet(uuid, facet, context); | 612 Theme t = getThemeForFacet(uuid, facet, index, context); |
609 | 613 |
610 if (t == null) { | 614 if (t == null) { |
611 log.info("Could not find theme for facet. Cancel initialization."); | 615 log.info("Could not find theme for facet. Cancel initialization."); |
612 return null; | 616 return null; |
613 } | 617 } |
660 * @return the desired theme. | 664 * @return the desired theme. |
661 */ | 665 */ |
662 protected Theme getThemeForFacet( | 666 protected Theme getThemeForFacet( |
663 String uuid, | 667 String uuid, |
664 String facet, | 668 String facet, |
669 int index, | |
665 CallContext context) | 670 CallContext context) |
666 { | 671 { |
667 log.info("FLYSArtifactCollection.getThemeForFacet: " + facet); | 672 log.info("FLYSArtifactCollection.getThemeForFacet: " + facet); |
668 | 673 |
669 FLYSContext flysContext = context instanceof FLYSContext | 674 FLYSContext flysContext = context instanceof FLYSContext |
670 ? (FLYSContext) context | 675 ? (FLYSContext) context |
671 : (FLYSContext) context.globalContext(); | 676 : (FLYSContext) context.globalContext(); |
672 | 677 |
673 return ThemeFactory.getTheme(flysContext, facet); | 678 Theme t = ThemeFactory.getTheme(flysContext, facet); |
679 | |
680 if (t != null) { | |
681 t.setFacet(facet); | |
682 t.setIndex(index); | |
683 } | |
684 | |
685 return t; | |
674 } | 686 } |
675 | 687 |
676 | 688 |
677 /** | 689 /** |
678 * Returns the OutGenerator for a specified <i>type</i>. | 690 * Returns the OutGenerator for a specified <i>type</i>. |