Project

General

Profile

Revision da7cc762

IDda7cc7628870e5872858ba65ae12e28b463eb79d
Parent 1b5e778c
Child c4606d40

Added by Patrick Plitzner over 2 years ago

ref #7509 Adapt aggregation method parameter list

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptionServiceImpl.java
11 11

  
12 12
import java.util.ArrayList;
13 13
import java.util.Collection;
14
import java.util.HashMap;
14 15
import java.util.HashSet;
15 16
import java.util.List;
16 17
import java.util.Map;
......
39 40
import eu.etaxonomy.cdm.model.common.TermVocabulary;
40 41
import eu.etaxonomy.cdm.model.description.DescriptionBase;
41 42
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
43
import eu.etaxonomy.cdm.model.description.DescriptiveDataSet;
42 44
import eu.etaxonomy.cdm.model.description.Distribution;
43 45
import eu.etaxonomy.cdm.model.description.Feature;
44 46
import eu.etaxonomy.cdm.model.description.FeatureTree;
......
51 53
import eu.etaxonomy.cdm.model.media.Media;
52 54
import eu.etaxonomy.cdm.model.name.TaxonName;
53 55
import eu.etaxonomy.cdm.model.taxon.Taxon;
56
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
54 57
import eu.etaxonomy.cdm.persistence.dao.common.IDefinedTermDao;
55 58
import eu.etaxonomy.cdm.persistence.dao.common.ITermVocabularyDao;
56 59
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionDao;
57 60
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptionElementDao;
61
import eu.etaxonomy.cdm.persistence.dao.description.IDescriptiveDataSetDao;
58 62
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureDao;
59 63
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureNodeDao;
60 64
import eu.etaxonomy.cdm.persistence.dao.description.IFeatureTreeDao;
......
90 94
    protected IDefinedTermDao definedTermDao;
91 95
    protected IStatisticalMeasurementValueDao statisticalMeasurementValueDao;
92 96
    protected ITaxonDao taxonDao;
97
    protected IDescriptiveDataSetDao dataSetDao;
93 98

  
94 99
    //TODO change to Interface
95 100
    private NaturalLanguageGenerator naturalLanguageGenerator;
......
139 144
        this.taxonDao = taxonDao;
140 145
    }
141 146

  
147
    @Autowired
148
    protected void setDataSetDao(IDescriptiveDataSetDao dataSetDao) {
149
        this.dataSetDao = dataSetDao;
150
    }
151

  
142 152
    /**
143 153
     *
144 154
     */
......
807 817

  
808 818
    }
809 819

  
820
    @Override
821
    public UpdateResult aggregateDescription(UUID taxonUuid, Collection<UUID> descriptionUuids, UUID descriptiveDataSet) {
822
        UpdateResult result = new UpdateResult();
823
        Map<Feature, List<DescriptionElementBase>> featureToElementMap = new HashMap<>();
824

  
825
        DescriptiveDataSet dataSet = dataSetDao.load(descriptiveDataSet);
826
        TaxonBase taxonBase = taxonDao.load(taxonUuid);
827
        if(!(taxonBase instanceof Taxon)){
828
            result.addException(new ClassCastException("The given taxonUUID does not belong to a taxon"));
829
            result.setError();
830
            return result;
831
        }
832
        Taxon taxon = (Taxon)taxonBase;
833

  
834
        Set<DescriptionBase> descriptions = dataSet.getDescriptions();
835
        for (DescriptionBase descriptionBase : descriptions) {
836
            List<DescriptionElementBase> descriptionElements = listDescriptionElements(descriptionBase, null, dataSet.getDescriptiveSystem().getDistinctFeatures(), null, null, null, null);
837
            for (DescriptionElementBase descriptionElement : descriptionElements) {
838
                List<DescriptionElementBase> list = featureToElementMap.get(descriptionElement.getFeature());
839
                if(list==null){
840
                    list = new ArrayList<>();
841
                }
842
                list.add(descriptionElement);
843
                featureToElementMap.put(descriptionElement.getFeature(), list);
844
            }
845
        }
846
        TaxonDescription description = TaxonDescription.NewInstance(taxon);
847
        description.setTitleCache("[Aggregation] "+dataSet.getTitleCache(), true);
848
        return result;
849
    }
850

  
810 851
}
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/IDescriptionService.java
607 607
     * @return
608 608
     */
609 609
    public UpdateResult moveTaxonDescription(UUID descriptionUuid, UUID targetTaxonUuid);
610

  
611
    /**
612
     * Aggregates the character data of the given descriptions that match
613
     * the given descriptive system and creates a new description
614
     * for the given taxon with the aggregated data.
615
     * @param taxonUuid the UUID of the taxon where the new description with the
616
     * aggregated data will be stored
617
     * @param descriptionUuids the uuid of the descriptions that are aggregated
618
     * @param descriptiveDataSet the data set defining the characters that should be aggregated
619
     * @return the result of the operation
620
     */
621
    public UpdateResult aggregateDescription(UUID taxonUuid, Collection<UUID> descriptionUuids, UUID descriptiveDataSet);
610 622
}

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)