Project

General

Profile

Revision 922939ec

ID922939ec45252c63dd25e2183fed32b1048c912d
Parent a2effde9
Child 64cd247e

Added by Andreas Müller over 2 years ago

cleanup

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/ImageFile.java
94 94
		return media;
95 95
	}
96 96

  
97
	// *********************** CONSTRUCTOR ****************************/
97 98

  
98 99
	protected ImageFile(){
99 100
		super();
......
113 114
		}
114 115
	}
115 116

  
117
	// *********************** GETTER /SETTER ****************************/
118

  
116 119
	public Integer getHeight(){
117 120
		return this.height;
118 121
	}
119

  
120
	/**
121
	 *
122
	 * @param height    height
123
	 */
124 122
	public void setHeight(Integer height){
125 123
		this.height = height;
126 124
	}
......
128 126
	public Integer getWidth(){
129 127
		return this.width;
130 128
	}
131

  
132
	/**
133
	 *
134
	 * @param width    width
135
	 */
136 129
	public void setWidth(Integer width){
137 130
		this.width = width;
138 131
	}
139

  
140 132
}
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/media/MediaUtils.java
28 28
     *
29 29
     *
30 30
     */
31
    public static MediaRepresentation findBestMatchingRepresentation(Media media, Class<? extends MediaRepresentationPart> representationPartType, Integer size, Integer height, Integer widthOrDuration, String[] mimeTypes){
31
    public static MediaRepresentation findBestMatchingRepresentation(Media media,
32
            Class<? extends MediaRepresentationPart> representationPartType, Integer size, Integer height,
33
            Integer widthOrDuration, String[] mimeTypes){
32 34
        // find best matching representations of each media
33 35
        SortedMap<Integer, MediaRepresentation> prefRepresentations
34
        = filterAndOrderMediaRepresentations(media.getRepresentations(), null, mimeTypes, size, widthOrDuration, height);
36
                = filterAndOrderMediaRepresentations(media.getRepresentations(), null, mimeTypes,
37
                        size, widthOrDuration, height);
35 38
        try {
36 39
            // take first one and remove all other representations
37 40
            MediaRepresentation prefOne = prefRepresentations.get(prefRepresentations.firstKey());
......
165 168
                candidateRepresentations.addAll(media.getRepresentations());
166 169

  
167 170
                SortedMap<Integer, MediaRepresentation> prefRepresentations
168
                    = filterAndOrderMediaRepresentations(candidateRepresentations, representationPartType, mimeTypes, size, widthOrDuration, height);
171
                    = filterAndOrderMediaRepresentations(candidateRepresentations, representationPartType,
172
                            mimeTypes, size, widthOrDuration, height);
169 173
                try {
170 174
                    if(prefRepresentations.size() > 0){
171 175
                        // Media.representations is a set
......
177 181
                    logger.debug(nse);
178 182
                    /* IGNORE */
179 183
                }
180

  
181 184
            }
182 185
        }
183 186
        else{
......
295 298
                        int sizeOfPart = part.getSize();
296 299
                        int distance = sizeOfPart - size;
297 300
                        if (distance < 0) {
298
                            distance*= -1;
301
                            distance *= -1;
299 302
                        }
300 303
                        dwa += distance;
301 304
                    }
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java
405 405
        }
406 406
        Integer numberOfResults = dao.countTaxaByName(clazz, uninomial, infragenericEpithet, specificEpithet, infraspecificEpithet, rank);
407 407

  
408
        List<TaxonBase> results = new ArrayList<TaxonBase>();
408
        List<TaxonBase> results = new ArrayList<>();
409 409
        if(numberOfResults > 0) { // no point checking again
410 410
            results = dao.findTaxaByName(clazz, uninomial, infragenericEpithet, specificEpithet, infraspecificEpithet, authorship, rank, pageSize, pageNumber);
411 411
        }
......
420 420
        }
421 421
        Integer numberOfResults = dao.countTaxaByName(clazz, uninomial, infragenericEpithet, specificEpithet, infraspecificEpithet, rank);
422 422

  
423
        List<TaxonBase> results = new ArrayList<TaxonBase>();
423
        List<TaxonBase> results = new ArrayList<>();
424 424
        if(numberOfResults > 0) { // no point checking again
425 425
            results = dao.findTaxaByName(clazz, uninomial, infragenericEpithet, specificEpithet, infraspecificEpithet, authorship, rank, pageSize, pageNumber);
426 426
        }
......
432 432
    public List<TaxonRelationship> listToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths){
433 433
        Integer numberOfResults = dao.countTaxonRelationships(taxon, type, TaxonRelationship.Direction.relatedTo);
434 434

  
435
        List<TaxonRelationship> results = new ArrayList<TaxonRelationship>();
435
        List<TaxonRelationship> results = new ArrayList<>();
436 436
        if(numberOfResults > 0) { // no point checking again
437 437
            results = dao.getTaxonRelationships(taxon, type, pageSize, pageNumber, orderHints, propertyPaths, TaxonRelationship.Direction.relatedTo);
438 438
        }
......
443 443
    public Pager<TaxonRelationship> pageToTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
444 444
        Integer numberOfResults = dao.countTaxonRelationships(taxon, type, TaxonRelationship.Direction.relatedTo);
445 445

  
446
        List<TaxonRelationship> results = new ArrayList<TaxonRelationship>();
446
        List<TaxonRelationship> results = new ArrayList<>();
447 447
        if(numberOfResults > 0) { // no point checking again
448 448
            results = dao.getTaxonRelationships(taxon, type, pageSize, pageNumber, orderHints, propertyPaths, TaxonRelationship.Direction.relatedTo);
449 449
        }
......
454 454
    public List<TaxonRelationship> listFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths){
455 455
        Integer numberOfResults = dao.countTaxonRelationships(taxon, type, TaxonRelationship.Direction.relatedFrom);
456 456

  
457
        List<TaxonRelationship> results = new ArrayList<TaxonRelationship>();
457
        List<TaxonRelationship> results = new ArrayList<>();
458 458
        if(numberOfResults > 0) { // no point checking again
459 459
            results = dao.getTaxonRelationships(taxon, type, pageSize, pageNumber, orderHints, propertyPaths, TaxonRelationship.Direction.relatedFrom);
460 460
        }
......
465 465
    public Pager<TaxonRelationship> pageFromTaxonRelationships(Taxon taxon, TaxonRelationshipType type, Integer pageSize, Integer pageNumber, List<OrderHint> orderHints, List<String> propertyPaths) {
466 466
        Integer numberOfResults = dao.countTaxonRelationships(taxon, type, TaxonRelationship.Direction.relatedFrom);
467 467

  
468
        List<TaxonRelationship> results = new ArrayList<TaxonRelationship>();
468
        List<TaxonRelationship> results = new ArrayList<>();
469 469
        if(numberOfResults > 0) { // no point checking again
470 470
            results = dao.getTaxonRelationships(taxon, type, pageSize, pageNumber, orderHints, propertyPaths, TaxonRelationship.Direction.relatedFrom);
471 471
        }
......
525 525
    public Set<Taxon> listRelatedTaxa(Taxon taxon, Set<TaxonRelationshipEdge> includeRelationships, Integer maxDepth,
526 526
            Integer limit, Integer start, List<String> propertyPaths) {
527 527

  
528
        Set<Taxon> relatedTaxa = collectRelatedTaxa(taxon, includeRelationships, new HashSet<Taxon>(), maxDepth);
528
        Set<Taxon> relatedTaxa = collectRelatedTaxa(taxon, includeRelationships, new HashSet<>(), maxDepth);
529 529
        relatedTaxa.remove(taxon);
530 530
        beanInitializer.initializeAll(relatedTaxa, propertyPaths);
531 531
        return relatedTaxa;
......
731 731

  
732 732
    @Override
733 733
    public List<MediaRepresentation> getAllMedia(Taxon taxon, int size, int height, int widthOrDuration, String[] mimeTypes){
734
        List<MediaRepresentation> medRep = new ArrayList<MediaRepresentation>();
734
        List<MediaRepresentation> medRep = new ArrayList<>();
735 735
        taxon = (Taxon)dao.load(taxon.getUuid());
736 736
        Set<TaxonDescription> descriptions = taxon.getDescriptions();
737 737
        for (TaxonDescription taxDesc: descriptions){
......
763 763

  
764 764
        logger.trace("listMedia() - START");
765 765

  
766
        Set<Taxon> taxa = new HashSet<Taxon>();
767
        List<Media> taxonMedia = new ArrayList<Media>();
768
        List<Media> nonImageGalleryImages = new ArrayList<Media>();
766
        Set<Taxon> taxa = new HashSet<>();
767
        List<Media> taxonMedia = new ArrayList<>();
768
        List<Media> nonImageGalleryImages = new ArrayList<>();
769 769

  
770 770
        if (limitToGalleries == null) {
771 771
            limitToGalleries = false;
......
781 781

  
782 782
        if(includeTaxonDescriptions != null && includeTaxonDescriptions){
783 783
            logger.trace("listMedia() - includeTaxonDescriptions");
784
            List<TaxonDescription> taxonDescriptions = new ArrayList<TaxonDescription>();
784
            List<TaxonDescription> taxonDescriptions = new ArrayList<>();
785 785
            // --- TaxonDescriptions
786 786
            for (Taxon t : taxa) {
787 787
                taxonDescriptions.addAll(descriptionService.listTaxonDescriptions(t, null, null, null, null, propertyPath));
......
807 807

  
808 808
        if(includeOccurrences != null && includeOccurrences) {
809 809
            logger.trace("listMedia() - includeOccurrences");
810
            Set<SpecimenOrObservationBase> specimensOrObservations = new HashSet<SpecimenOrObservationBase>();
810
            Set<SpecimenOrObservationBase> specimensOrObservations = new HashSet<>();
811 811
            // --- Specimens
812 812
            for (Taxon t : taxa) {
813 813
                specimensOrObservations.addAll(occurrenceDao.listByAssociatedTaxon(null, t, null, null, null, null));
......
846 846
        if(includeTaxonNameDescriptions != null && includeTaxonNameDescriptions) {
847 847
            logger.trace("listMedia() - includeTaxonNameDescriptions");
848 848
            // --- TaxonNameDescription
849
            Set<TaxonNameDescription> nameDescriptions = new HashSet<TaxonNameDescription>();
849
            Set<TaxonNameDescription> nameDescriptions = new HashSet<>();
850 850
            for (Taxon t : taxa) {
851 851
                nameDescriptions .addAll(t.getName().getDescriptions());
852 852
            }
......
1455 1455
            throw luceneParseException;
1456 1456
        }
1457 1457

  
1458
        Map<CdmBaseType, String> idFieldMap = new HashMap<CdmBaseType, String>();
1458
        Map<CdmBaseType, String> idFieldMap = new HashMap<>();
1459 1459
        idFieldMap.put(CdmBaseType.TAXON, "id");
1460 1460

  
1461 1461
        // ---  initialize taxa, thighlight matches ....
......
1485 1485
            throw luceneParseException;
1486 1486
        }
1487 1487

  
1488
        Map<CdmBaseType, String> idFieldMap = new HashMap<CdmBaseType, String>();
1488
        Map<CdmBaseType, String> idFieldMap = new HashMap<>();
1489 1489
        idFieldMap.put(CdmBaseType.TAXON, "id");
1490 1490

  
1491 1491
        // ---  initialize taxa, thighlight matches ....
......
1664 1664
        boolean addDistributionFilter = namedAreas != null && namedAreas.size() > 0;
1665 1665

  
1666 1666
        List<LuceneSearch> luceneSearches = new ArrayList<LuceneSearch>();
1667
        Map<CdmBaseType, String> idFieldMap = new HashMap<CdmBaseType, String>();
1667
        Map<CdmBaseType, String> idFieldMap = new HashMap<>();
1668 1668

  
1669 1669
        /*
1670 1670
          ======== filtering by distribution , HOWTO ========
......
1764 1764
            byCommonNameSearch.setSortFields(sortFields);
1765 1765

  
1766 1766
            DuplicateFilter df = new DuplicateFilter("inDescription.taxon.id");
1767
            HashSet<String> results=new HashSet();
1767
            Set<String> results=new HashSet<>();
1768 1768
//            ScoreDoc[] hits = searcher.search(tq,df, 1000).scoreDocs;
1769 1769
//
1770 1770
//            byCommonNameSearch.setFilter(df);
......
2001 2001
            throw luceneParseException;
2002 2002
        }
2003 2003

  
2004
        Map<CdmBaseType, String> idFieldMap = new HashMap<CdmBaseType, String>();
2004
        Map<CdmBaseType, String> idFieldMap = new HashMap<>();
2005 2005
        idFieldMap.put(CdmBaseType.DESCRIPTION_ELEMENT, "inDescription.taxon.id");
2006 2006

  
2007 2007
        // --- initialize taxa, highlight matches ....
......
2039 2039
        // --- initialize taxa, highlight matches ....
2040 2040
        ISearchResultBuilder searchResultBuilder = new SearchResultBuilder(multiSearch, multiSearch.getQuery());
2041 2041

  
2042
        Map<CdmBaseType, String> idFieldMap = new HashMap<CdmBaseType, String>();
2042
        Map<CdmBaseType, String> idFieldMap = new HashMap<>();
2043 2043
        idFieldMap.put(CdmBaseType.TAXON, "id");
2044 2044
        idFieldMap.put(CdmBaseType.DESCRIPTION_ELEMENT, "inDescription.taxon.id");
2045 2045

  
......
2202 2202
        List<String> taxonNames = new ArrayList<String>();
2203 2203

  
2204 2204
        for (TaxonNode node: nodes){
2205
           // HashMap<String, String> synonymsGenus = new HashMap<String, String>(); // Changed this to be able to store the idInSource to a genusName
2206
           // List<String> synonymsEpithet = new ArrayList<String>();
2205
           // Map<String, String> synonymsGenus = new HashMap<>(); // Changed this to be able to store the idInSource to a genusName
2206
           // List<String> synonymsEpithet = new ArrayList<>();
2207 2207

  
2208 2208
            if (node.getClassification().equals(classification)){
2209 2209
                if (!node.isTopmostNode()){
......
2482 2482
    private Synonym createPotentialCombination(String idInSourceParent,
2483 2483
            IZoologicalName parentSynZooName, 	IZoologicalName zooSynName, String synParentGenus,
2484 2484
            String synParentInfragenericName, String synParentSpecificEpithet,
2485
            TaxonBase syn, HashMap<UUID, IZoologicalName> zooHashMap) {
2485
            TaxonBase syn, Map<UUID, IZoologicalName> zooHashMap) {
2486 2486
        Synonym potentialCombination;
2487 2487
        Reference sourceReference;
2488 2488
        IZoologicalName inferredSynName;
......
2550 2550
    }
2551 2551

  
2552 2552
    private Synonym createInferredGenus(Taxon taxon,
2553
            HashMap<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
2553
            Map<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
2554 2554
            String epithetOfTaxon, String genusOfTaxon,
2555 2555
            List<String> taxonNames, IZoologicalName zooParentName,
2556 2556
            TaxonBase syn) {
......
2628 2628
    }
2629 2629

  
2630 2630
    private Synonym createInferredEpithets(Taxon taxon,
2631
            HashMap<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
2631
            Map<UUID, IZoologicalName> zooHashMap, IZoologicalName taxonName,
2632 2632
            String epithetOfTaxon, String infragenericEpithetOfTaxon,
2633 2633
            String infraspecificEpithetOfTaxon, List<String> taxonNames,
2634 2634
            TaxonName parentName, TaxonBase syn) {
......
2728 2728
     * @param zooHashMap
2729 2729
     * @return
2730 2730
     */
2731
    private IZoologicalName getZoologicalName(UUID uuid, HashMap <UUID, IZoologicalName> zooHashMap) {
2731
    private IZoologicalName getZoologicalName(UUID uuid, Map <UUID, IZoologicalName> zooHashMap) {
2732 2732
        IZoologicalName taxonName =nameDao.findZoologicalNameByUUID(uuid);
2733 2733
        if (taxonName == null) {
2734 2734
            taxonName = zooHashMap.get(uuid);
......
2801 2801
    public List<Classification> listClassifications(TaxonBase taxonBase, Integer limit, Integer start, List<String> propertyPaths) {
2802 2802

  
2803 2803
        // TODO quickly implemented, create according dao !!!!
2804
        Set<TaxonNode> nodes = new HashSet<TaxonNode>();
2804
        Set<TaxonNode> nodes = new HashSet<>();
2805 2805
        Set<Classification> classifications = new HashSet<>();
2806 2806
        List<Classification> list = new ArrayList<>();
2807 2807

  
......
2971 2971

  
2972 2972
        //preliminary implementation
2973 2973

  
2974
        Set<Taxon> taxa = new HashSet<Taxon>();
2974
        Set<Taxon> taxa = new HashSet<>();
2975 2975
        TaxonBase taxonBase = find(taxonUuid);
2976 2976
        if (taxonBase == null){
2977 2977
            return new IncludedTaxaDTO();
......
3010 3010
    private Set<Taxon> makeRelatedIncluded(Set<Taxon> uncheckedTaxa, IncludedTaxaDTO existingTaxa, IncludedTaxonConfiguration config) {
3011 3011

  
3012 3012
        //children
3013
        Set<TaxonNode> taxonNodes = new HashSet<TaxonNode>();
3013
        Set<TaxonNode> taxonNodes = new HashSet<>();
3014 3014
        for (Taxon taxon: uncheckedTaxa){
3015 3015
            taxonNodes.addAll(taxon.getTaxonNodes());
3016 3016
        }
3017 3017

  
3018
        Set<Taxon> children = new HashSet<Taxon>();
3018
        Set<Taxon> children = new HashSet<>();
3019 3019
        if (! config.onlyCongruent){
3020 3020
            for (TaxonNode node: taxonNodes){
3021 3021
                List<TaxonNode> childNodes = nodeService.loadChildNodesOfTaxonNode(node, null, true, null);
......
3032 3032
            if (existingTaxa.contains(uuid)){
3033 3033
                it.remove();
3034 3034
            }else{
3035
                existingTaxa.addIncludedTaxon(uuid, new ArrayList<UUID>(), false);
3035
                existingTaxa.addIncludedTaxon(uuid, new ArrayList<>(), false);
3036 3036
            }
3037 3037
        }
3038 3038

  
3039 3039
        //concept relations
3040
        Set<Taxon> uncheckedAndChildren = new HashSet<Taxon>(uncheckedTaxa);
3040
        Set<Taxon> uncheckedAndChildren = new HashSet<>(uncheckedTaxa);
3041 3041
        uncheckedAndChildren.addAll(children);
3042 3042

  
3043 3043
        Set<Taxon> relatedTaxa = makeConceptIncludedTaxa(uncheckedAndChildren, existingTaxa, config);
3044 3044

  
3045 3045

  
3046
        Set<Taxon> result = new HashSet<Taxon>(relatedTaxa);
3046
        Set<Taxon> result = new HashSet<>(relatedTaxa);
3047 3047
        return result;
3048 3048
    }
3049 3049

  
......
3052 3052
     * @return the set of these computed taxa
3053 3053
     */
3054 3054
    private Set<Taxon> makeConceptIncludedTaxa(Set<Taxon> unchecked, IncludedTaxaDTO existingTaxa, IncludedTaxonConfiguration config) {
3055
        Set<Taxon> result = new HashSet<Taxon>();
3055
        Set<Taxon> result = new HashSet<>();
3056 3056

  
3057 3057
        for (Taxon taxon : unchecked){
3058 3058
            Set<TaxonRelationship> fromRelations = taxon.getRelationsFromThisTaxon();
......
3086 3086
            if (existingTaxa.contains(uuid)){
3087 3087
                it.remove();
3088 3088
            }else{
3089
                existingTaxa.addIncludedTaxon(uuid, new ArrayList<UUID>(), false);
3089
                existingTaxa.addIncludedTaxon(uuid, new ArrayList<>(), false);
3090 3090
            }
3091 3091
        }
3092 3092
        return result;
......
3109 3109
		}
3110 3110

  
3111 3111
		Integer numberOfResults = dao.countByIdentifier(clazz, identifier, identifierType, subtreeFilter, matchmode);
3112
        List<Object[]> daoResults = new ArrayList<Object[]>();
3112
        List<Object[]> daoResults = new ArrayList<>();
3113 3113
        if(numberOfResults > 0) { // no point checking again
3114 3114
        	daoResults = dao.findByIdentifier(clazz, identifier, identifierType, subtreeFilter,
3115 3115
    				matchmode, includeEntity, pageSize, pageNumber, propertyPaths);
3116 3116
        }
3117 3117

  
3118
        List<IdentifiedEntityDTO<S>> result = new ArrayList<IdentifiedEntityDTO<S>>();
3118
        List<IdentifiedEntityDTO<S>> result = new ArrayList<>();
3119 3119
        for (Object[] daoObj : daoResults){
3120 3120
        	if (includeEntity){
3121 3121
        		result.add(new IdentifiedEntityDTO<S>((DefinedTerm)daoObj[0], (String)daoObj[1], (S)daoObj[2]));
......
3137 3137
        }
3138 3138

  
3139 3139
        Long numberOfResults = dao.countByMarker(clazz, markerType, markerValue, subtreeFilter);
3140
        List<Object[]> daoResults = new ArrayList<Object[]>();
3140
        List<Object[]> daoResults = new ArrayList<>();
3141 3141
        if(numberOfResults > 0) { // no point checking again
3142 3142
            daoResults = dao.findByMarker(clazz, markerType, markerValue, subtreeFilter,
3143 3143
                    includeEntity, titleType, pageSize, pageNumber, propertyPaths);

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)