Project

General

Profile

« Previous | Next » 

Revision 86b41121

Added by Andreas Kohlbecker almost 4 years ago

ref #8867 better presentation of licenses, copyright and access right

View differences:

cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/controller/iiif/ManifestController.java
304 304
                diversityInfo = "Same " + dataTypes + " for any Item:";
305 305
            }
306 306
            if(hasAttributions){
307
                List<String> attrs = new ArrayList<>(attributions.getValues());
308
                attrs = attrs.stream().sorted().distinct().collect(Collectors.toList());
307 309
                if(doJoinAttributions){
308
                    ArrayList<String> attrs = new ArrayList<>(attributions.getValues());
309 310
                    attrs.add(0, diversityInfo + "<br/>" + attrs.get(0));
310 311
                    attrs.remove(1);
311
                    manifest.addAttribution(attrs.stream().collect(Collectors.joining("; ")));
312
                    manifest.addAttribution(attrs.stream()
313
                            .sorted()
314
                            .distinct()
315
                            .collect(Collectors.joining("; ")));
312 316
                } else {
313
                    manifest.addAttribution(diversityInfo, attributions.getValues().toArray(
317
                    manifest.addAttribution(diversityInfo, attrs.toArray(
314 318
                            new String[attributions.getValues().size()]
315 319
                            ));
316 320
                }
......
339 343
    private List<MetadataEntry> deduplicateMetadata(List<MetadataEntry> mediaMetadata) {
340 344
        Map<String, MetadataEntry> dedupMap = new HashMap<>();
341 345
        mediaMetadata.stream().forEach(mde -> {
342
                dedupMap.put(mde.getLabelString() + ":" + mde.getValueString(), mde);
346
                String dedupKey = mde.getLabelString() + ":" + mde.getValueString();
347
                dedupMap.put(dedupKey, mde);
343 348
            }
344 349
        );
345 350
        return new ArrayList<MetadataEntry>(dedupMap.values());
......
445 450

  
446 451
        if(entity.getRights() != null && entity.getRights().size() > 0){
447 452
            for(Rights right : entity.getRights()){
448
                // TODO get localized texts
449 453
                String rightText = "";
450
                if(right.getText() != null){
451
                    rightText += right.getText();
452
                }
453
                if(rightText.isEmpty() && right.getAbbreviatedText() != null){
454
                    rightText += right.getAbbreviatedText();
455
                }
454
                // TODO get localized texts below
455
                // --- LICENSE
456 456
                if(right.getType().equals(RightsType.LICENSE())){
457
                    String licenseText = "";
458
                    String licenseAbbrev = "";
459
                    if(right.getText() != null){
460
                        licenseText = right.getText();
461
                    }
462
                    if(right.getAbbreviatedText() != null){
463
                        licenseAbbrev = right.getAbbreviatedText().trim();
464
                    }
457 465
                    if(right.getUri() != null){
458
                        rightText =  htmlLink(right.getUri(), rightText);
466
                        if(!licenseAbbrev.isEmpty()) {
467
                            licenseAbbrev =  htmlLink(right.getUri(), licenseAbbrev);
468
                        } else if(!licenseText.isEmpty()) {
469
                            licenseText =  htmlLink(right.getUri(), licenseText);
470
                        } else {
471
                            licenseText =  htmlLink(right.getUri(), right.getUri().toString());
472
                        }
459 473
                        license.add(right.getUri());
460 474
                    }
475
                    rightText = licenseAbbrev + (licenseText.isEmpty() ? "" : " ") + licenseText;
461 476
                }
462
                if(right.getAgent() != null){
463
                    // may only apply to RightsType.accessRights
464
                    rightText += " " + right.getAgent().getTitleCache();
477
                // --- COPYRIGHT
478
                if(right.getType().equals(RightsType.COPYRIGHT())){
479
                    // titleCache + agent
480
                    String copyRightText = "";
481
                    if(right.getText() != null){
482
                        copyRightText = right.getText();
483
                        //  sanitize potential '(c)' away
484
                        copyRightText.replace("(c)", "").trim();
485
                    }
486
                    if(right.getAgent() != null){
487
                        // may only apply to RightsType.accessRights
488
                        copyRightText += " " + right.getAgent().getTitleCache();
489
                    }
490
                    if(!copyRightText.isEmpty()){
491
                        copyRightText = "© " + copyRightText;
492
                    }
493
                    rightText = copyRightText;
494
                }
495
                if(right.getType().equals(RightsType.ACCESS_RIGHTS())){
496
                    // titleCache + agent
497
                    String accessRights = right.getText();
498
                    if(right.getAgent() != null){
499
                        // may only apply to RightsType.accessRights
500
                        accessRights = " " + right.getAgent().getTitleCache();
501
                    }
502
                    rightText = accessRights;
503
                }
504
                if(!rightText.isEmpty()){
505
                    rightsTexts.add(rightText);
465 506
                }
466
                rightsTexts.add(rightText);
467 507
            }
468 508
        }
469 509
        if(entity.getCredits() != null && entity.getCredits().size() > 0){

Also available in: Unified diff