Project

General

Profile

Revision f073606c

IDf073606c71168b8edf330f062633265fda03bb48
Parent 80d86f0e
Child d81a4119

Added by Patrick Plitzner about 4 years ago

Fix titlecache issues for specimen table in data portal
- Use Link class for every link
- Open all links in new window

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/OccurrenceServiceImpl.java
524 524
        }
525 525
        if(CdmUtils.isBlank(identifier)){
526 526
        	identifier = derivedUnit.getTitleCache();
527
        	if(CdmUtils.isBlank(identifier) && !derivedUnit.isProtectedTitleCache()){
528
        		//regenerate title cache if it is empty
529
        		derivedUnit.setTitleCache(null);
530
        		identifier = derivedUnit.getTitleCache();
531
        	}
532
        }
533
        if(CdmUtils.isBlank(identifier)){
534
        	//default fallback UUID
535
        	identifier = derivedUnit.getUuid().toString();
527 536
        }
528 537
        preservedSpecimenDTO.setAccessionNumber(identifier);
529 538
        preservedSpecimenDTO.setUuid(derivedUnit.getUuid().toString());
......
653 662
            else if (childDerivate.isInstanceOf(MediaSpecimen.class)) {
654 663
                MediaSpecimen media = HibernateProxyHelper.deproxy(childDerivate, MediaSpecimen.class);
655 664

  
656
                String mediaUriString = getMediaUriString(media);
665
                URI mediaUri = getMediaUri(media);
657 666
                if (media.getKindOfUnit() != null) {
658 667
                    // specimen scan
659 668
                    if (media.getKindOfUnit().getUuid().equals(UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03"))) {
......
663 672
                        if (derivateDTO instanceof PreservedSpecimenDTO && ((PreservedSpecimenDTO) derivateDTO).getAccessionNumber() != null) {
664 673
                            imageLinkText = ((PreservedSpecimenDTO) derivateDTO).getAccessionNumber();
665 674
                        }
666
                        derivateDataDTO.addSpecimenScan(mediaUriString == null ? "" : mediaUriString, imageLinkText);
675
                        derivateDataDTO.addSpecimenScan(mediaUri, imageLinkText);
667 676
                    }
668 677
                    // detail image
669 678
                    else if (media.getKindOfUnit().getUuid().equals(UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34"))) {
670 679
                        derivateDataDTO.addDetailImageUuid(media.getMediaSpecimen().getUuid());
671 680
                        derivateDTO.setHasDetailImage(true);
672
                        String motif = "";
673
                        if (media.getMediaSpecimen() != null && media.getMediaSpecimen().getTitle() != null) {
674
                            motif = media.getMediaSpecimen().getTitle().getText();
681
                        String motif = "detail image";
682
                        if (media.getMediaSpecimen()!=null){
683
                        	if(CdmUtils.isNotBlank(media.getMediaSpecimen().getTitleCache())) {
684
                        		motif = media.getMediaSpecimen().getTitleCache();
685
                        	}
675 686
                        }
676
                        derivateDataDTO.addDetailImage(mediaUriString == null ? "" : mediaUriString, motif != null ? motif : "[no motif]");
687
                        derivateDataDTO.addDetailImage(mediaUri, motif != null ? motif : "[no motif]");
677 688
                    }
678 689
                }
679 690
            }
......
688 699
        return string;
689 700
    }
690 701

  
691
    private String getMediaUriString(MediaSpecimen mediaSpecimen) {
692
        String mediaUri = null;
702
    private URI getMediaUri(MediaSpecimen mediaSpecimen) {
703
        URI mediaUri = null;
693 704
        Collection<MediaRepresentation> mediaRepresentations = mediaSpecimen.getMediaSpecimen().getRepresentations();
694 705
        if (mediaRepresentations != null && !mediaRepresentations.isEmpty()) {
695 706
            Collection<MediaRepresentationPart> mediaRepresentationParts = mediaRepresentations.iterator().next().getParts();
696 707
            if (mediaRepresentationParts != null && !mediaRepresentationParts.isEmpty()) {
697 708
                MediaRepresentationPart part = mediaRepresentationParts.iterator().next();
698 709
                if (part.getUri() != null) {
699
                    mediaUri = part.getUri().toASCIIString();
710
                    mediaUri = part.getUri();
700 711
                }
701 712
            }
702 713
        }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/dto/DerivateDataDTO.java
14 14
import java.util.List;
15 15
import java.util.UUID;
16 16

  
17
import org.hibernate.envers.tools.Pair;
18

  
19 17
/**
20 18
 * @author pplitzner
21 19
 * @date Mar 26, 2015
......
23 21
 */
24 22
public class DerivateDataDTO {
25 23

  
26
    private List<Pair<String, String>> specimenScans;
24
    private List<Link> specimenScans;
27 25
    private List<MolecularData> molecularDataList;
28
    private List<Pair<String, String>> detailImages;
26
    private List<Link> detailImages;
29 27
    private List<UUID> specimenScanUuids;
30 28
    private List<UUID> detailImageUuids;
31 29

  
......
48 46
    /**
49 47
     * @return the specimenScans
50 48
     */
51
    public List<Pair<String, String>> getSpecimenScans() {
49
    public List<Link> getSpecimenScans() {
52 50
        return specimenScans;
53 51
    }
54 52

  
55
    public void addSpecimenScan(String uri, String herbarium){
53
    public void addSpecimenScan(URI uri, String linkText){
56 54
        if(specimenScans==null){
57
            specimenScans = new ArrayList<Pair<String,String>>();
55
            specimenScans = new ArrayList<Link>();
58 56
        }
59
        specimenScans.add(new Pair<String, String>(uri, herbarium));
57
        specimenScans.add(new Link(uri, linkText));
60 58
    }
61 59

  
62 60
    /**
63 61
     * @return the detailImages
64 62
     */
65
    public List<Pair<String, String>> getDetailImages() {
63
    public List<Link> getDetailImages() {
66 64
        return detailImages;
67 65
    }
68 66

  
69
    public void addDetailImage(String uri, String motif){
67
    public void addDetailImage(URI uri, String motif){
70 68
        if(detailImages==null){
71
            detailImages = new ArrayList<Pair<String,String>>();
69
            detailImages = new ArrayList<Link>();
72 70
        }
73
        detailImages.add(new Pair<String, String>(uri, motif));
71
        detailImages.add(new Link(uri, motif));
74 72
    }
75 73

  
76 74
    /**

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)