Project

General

Profile

Revision 26cfae1e

ID26cfae1e69f4c034ad5fe70deaa75a27838f234b
Parent 775d38e1
Child ff7c0745

Added by Katja Luther over 1 year ago

ref #8677: use uuid list instead of namedArea list in DistributionAggregationConfig

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/DistributionAggregation.java
128 128

  
129 129
    private void makeSuperAreas() {
130 130
        TransactionStatus tx = startTransaction(true);
131
        List<NamedArea> superAreas = getConfig().getSuperAreas();
132

  
133
        Set<UUID> superAreaUuids = new HashSet<>(superAreas.size());
134
        for (NamedArea superArea : superAreas){
135
            superAreaUuids.add(superArea.getUuid());
136
        }
137
        superAreaList = getTermService().find(NamedArea.class, superAreaUuids);
138
        for (NamedArea superArea : superAreaList){
139
            Set<NamedArea> subAreas = getSubAreasFor(superArea);
140
            for(NamedArea subArea : subAreas){
141
                if (logger.isTraceEnabled()) {
142
                    logger.trace("Initialize " + subArea.getTitleCache());
131
        Set<UUID> superAreaUuids = new HashSet(getConfig().getSuperAreas());
132
        if (superAreaUuids != null){
133
            superAreaList = getTermService().find(NamedArea.class, superAreaUuids);
134
            for (NamedArea superArea : superAreaList){
135
                Set<NamedArea> subAreas = getSubAreasFor(superArea);
136
                for(NamedArea subArea : subAreas){
137
                    if (logger.isTraceEnabled()) {
138
                        logger.trace("Initialize " + subArea.getTitleCache());
139
                    }
143 140
                }
144 141
            }
145 142
        }
......
584 581
            stOrder = defaultStatusOrder();
585 582
        }
586 583
        if (stOrder.isInstanceOf(TermTree.class)){
587
            statusOrder = CdmBase.deproxy(stOrder, TermTree.class).asTermList();
584
            statusOrder = getRepository().getTermTreeService().load(stOrder.getUuid()).asTermList();
588 585
        }else if (stOrder.isInstanceOf(OrderedTermVocabulary.class)){
589 586
            statusOrder = new ArrayList<>(CdmBase.deproxy(stOrder, OrderedTermVocabulary.class).getOrderedTerms());
590 587
        }else{
cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/DistributionAggregationConfiguration.java
16 16
import eu.etaxonomy.cdm.filter.LogicFilter;
17 17
import eu.etaxonomy.cdm.filter.TaxonNodeFilter;
18 18
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm;
19
import eu.etaxonomy.cdm.model.location.NamedArea;
20 19
import eu.etaxonomy.cdm.model.name.Rank;
21 20
import eu.etaxonomy.cdm.model.term.TermCollection;
22 21
import eu.etaxonomy.cdm.model.term.TermNode;
......
31 30

  
32 31
    private static final long serialVersionUID = 2542246141660930545L;
33 32

  
34
    private List<NamedArea> superAreas;
33
    private List<UUID> superAreasUuids;
35 34

  
36 35
    private TermCollection<PresenceAbsenceTerm, TermNode> statusOrder;
37 36

  
......
50 49

  
51 50
// **************************************** FACTORY ************************************/
52 51

  
53
    public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<NamedArea> superAreas,
52
    public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<UUID> superAreas,
54 53
            TaxonNodeFilter filter, IProgressMonitor monitor){
54

  
55

  
55 56
        return new DistributionAggregationConfiguration(aggregationModes, superAreas, filter, monitor);
56 57
    }
57 58

  
58
    public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<NamedArea> superAreas,
59
    public static DistributionAggregationConfiguration NewInstance(List<AggregationMode> aggregationModes, List<UUID> superAreas,
59 60
            TaxonNodeFilter filter, TermTree<PresenceAbsenceTerm> statusOrder,  IProgressMonitor monitor){
61

  
60 62
        DistributionAggregationConfiguration result = new DistributionAggregationConfiguration(aggregationModes, superAreas, filter, monitor);
61 63
        result.setStatusOrder(statusOrder);
62 64
        return result;
63 65
    }
64 66

  
65 67

  
68

  
66 69
// ************************ CONSTRUCTOR *****************************/
67 70

  
68
    private DistributionAggregationConfiguration(List<AggregationMode> aggregationModes, List<NamedArea> superAreas,
71
    private DistributionAggregationConfiguration(List<AggregationMode> aggregationModes, List<UUID> superAreas,
69 72
            TaxonNodeFilter filter, IProgressMonitor monitor) {
70 73
        super(filter, monitor, aggregationModes);
71
        this.superAreas = superAreas;
74
        this.superAreasUuids = superAreas;
72 75
    }
73 76

  
74 77
// ******************** METHOD **************************************/
......
80 83

  
81 84
// ******************* GETTER / SETTER ****************************/
82 85

  
83
    public List<NamedArea> getSuperAreas() {
84
        return superAreas;
86
    public List<UUID> getSuperAreas() {
87
        return superAreasUuids;
85 88
    }
86
    public void setSuperAreas(List<NamedArea> superAreas) {
87
        this.superAreas = superAreas;
89
    public void setSuperAreas(List<UUID> superAreas) {
90
        this.superAreasUuids = superAreas;
88 91
    }
89 92

  
90 93
    public UUID getLowerRank() {
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/DistributionAggregationTest.java
127 127
    private NamedArea yug_ma = null;
128 128
    private NamedArea yug_mn = null;
129 129

  
130
    List<NamedArea> superAreas = null;
130
    List<UUID> superAreas = null;
131 131
    Rank upperRank = null;
132 132
    Rank lowerRank = null;
133 133

  
......
142 142
    @Before
143 143
    public void setUp() {
144 144

  
145
        superAreas = Arrays.asList(new NamedArea[]{
146
        		termService.getAreaByTdwgAbbreviation("YUG")
145
        superAreas = Arrays.asList(new UUID[]{
146
        		termService.getAreaByTdwgAbbreviation("YUG").getUuid()
147 147
        });
148 148
        lowerRank = Rank.SUBSPECIES();
149 149
        upperRank = Rank.GENUS();
cdmlib-services/src/test/java/eu/etaxonomy/cdm/test/function/TestAggregations.java
9 9

  
10 10
package eu.etaxonomy.cdm.test.function;
11 11

  
12
import java.util.ArrayList;
12 13
import java.util.List;
13 14
import java.util.UUID;
14 15

  
......
112 113
		UUID uuidCichorium = UUID.fromString("6a7ac1ad-2fd9-4218-8132-12dd463d04b9");
113 114
		UUID uuidArnoseris = UUID.fromString("0f71555c-676b-4d66-8a0c-281787ac72f6");
114 115
		TaxonNodeFilter filter = TaxonNodeFilter.NewSubtreeInstance(uuidArnoseris);
115

  
116
		List<UUID> areaUuids = new ArrayList();
117
        areaPager.getRecords().forEach(p ->areaUuids.add(p.getUuid()));
116 118
		DistributionAggregationConfiguration config = DistributionAggregationConfiguration
117
		        .NewInstance(AggregationMode.byAreasAndRanks(), areaPager.getRecords(), filter, monitor);
119
		        .NewInstance(AggregationMode.byAreasAndRanks(), areaUuids, filter, monitor);
118 120
		config.setToParentSourceMode(SourceMode.DESCRIPTION);
119 121
        config.setWithinTaxonSourceMode(SourceMode.ALL_SAMEVALUE);
120 122
		try {

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)