Project

General

Profile

« Previous | Next » 

Revision 843fbe64

Added by Andreas Müller over 2 years ago

cleanup

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/description/DistributionAggregation.java
124 124
    @Override
125 125
    protected void verifyConfiguration(IProgressMonitor monitor){
126 126
        if (!AggregationSourceMode.list(AggregationMode.ToParent, AggregationType.Distribution)
127
            .contains(getConfig().getToParentSourceMode())){
127
                .contains(getConfig().getToParentSourceMode())){
128 128
            throw new AggregationException("Unsupported source mode for to-parent aggregation: " + getConfig().getToParentSourceMode());
129 129
        }
130 130
        if (!AggregationSourceMode.list(AggregationMode.WithinTaxon, AggregationType.Distribution)
131 131
                .contains(getConfig().getWithinTaxonSourceMode())){
132
                throw new AggregationException("Unsupported source mode for within-taxon aggregation: " + getConfig().getToParentSourceMode());
132
            throw new AggregationException("Unsupported source mode for within-taxon aggregation: " + getConfig().getToParentSourceMode());
133 133
        }
134 134
    }
135 135

  
cdmlib-services/src/test/java/eu/etaxonomy/cdm/api/service/description/StructuredDescriptionAggregationTest.java
105 105
    private static final UUID uuidFeatureLeafPA = UUID.fromString("c4dfd16f-f2ed-45e0-8f4d-7fe1ae880510");
106 106
    private static UUID uuidFeatureLeafLength = UUID.fromString("3c19b50b-4a8e-467e-b7d4-89ebc05a33e1");
107 107
    private static UUID uuidFeatureLeafColor = UUID.fromString("1e8f503c-5aeb-4788-b4f9-84128f7141c7");
108
    private static UUID uuidFeatureLeafAdd = UUID.fromString("774b52a5-c16c-43e5-94e7-3946b506554d");
108 109

  
109 110
    private static UUID uuidLeafColorBlue = UUID.fromString("9b4df19d-f89d-4788-9d71-d1f6f7cae910");
110 111
    private static UUID uuidLeafColorYellow = UUID.fromString("4cf0881b-0e7b-489a-9fdb-adbe6ae4e0ae");
......
179 180
        commitAndStartNewTransaction();
180 181
        verifyAggregatedDescription(new TestConfig().setWithAddedData());
181 182

  
182
        // 2nd aggregation
183
        // 2nd aggregation => should be same as originally as data was only added to aggregation to see if it is correctly deleted
183 184
        result = engine.invoke(config, repository);
184 185
        verifyStatusOk(result);
185 186
        commitAndStartNewTransaction();
186 187
        verifyAggregatedDescription(new TestConfig());
188

  
189
        // reaggregate with an element having a feature not yet in the existing descriptions
190
        addNewFeature();
191
        commitAndStartNewTransaction();
192
        result = engine.invoke(config, repository);
193
        verifyStatusOk(result);
194
        commitAndStartNewTransaction();
195
        verifyAggregatedDescription(new TestConfig().setWithFeature());
196

  
187 197
    }
188 198

  
189 199
    private void addSomeDataToFirstAggregation() {
......
196 206
        addCategoricalData(taxonDescription, uuidFeatureLeafPA, State.uuidPresent);
197 207
    }
198 208

  
209
    private void addNewFeature() {
210
        SpecimenOrObservationBase<?> spec1 = occurrenceService.find(T_LAPSANA_COMMUNIS_ADENOPHORA_SPEC1_UUID);
211
        SpecimenDescription specimenDescription = (SpecimenDescription)spec1.getDescriptions().stream()
212
                .filter(desc->!desc.getTypes().contains(DescriptionType.AGGREGATED_STRUC_DESC))
213
                .filter(desc->!desc.getTypes().contains(DescriptionType.CLONE_FOR_SOURCE))
214
                .findFirst().get();
215

  
216
        addQuantitativeData(specimenDescription, uuidFeatureLeafAdd, new BigDecimal("2.5"), new BigDecimal("3.6"));
217
    }
218

  
199 219
    @Test
200 220
    @DataSets({
201 221
        @DataSet(loadStrategy=CleanSweepInsertLoadStrategy.class, value="/eu/etaxonomy/cdm/database/ClearDB_with_Terms_DataSet.xml"),
......
454 474
        boolean withAddedData;
455 475
        boolean withLiterature;
456 476
        boolean withRemovedData;
477
        boolean withFeature;
457 478
        AggregationSourceMode withinTaxonSourceMode = AggregationSourceMode.DESCRIPTION;
458 479
        AggregationSourceMode toParentSourceMode = AggregationSourceMode.DESCRIPTION;
459 480

  
460 481
        private TestConfig setWithAddedData() {withAddedData = true; return this;}
461 482
        private TestConfig setWithLiterature() {withLiterature = true; return this;}
462 483
        private TestConfig setWithRemoved() {withRemovedData = true; return this;}
484
        private TestConfig setWithFeature() {withFeature = true; return this;}
463 485

  
464 486
        public TestConfig setAggConfig(StructuredDescriptionAggregationConfiguration config) {
465 487
            withinTaxonSourceMode = config.getWithinTaxonSourceMode();
......
474 496
        boolean withLiterature = config.withLiterature;
475 497
        boolean withAddedData = config.withAddedData;
476 498
        boolean isWithinNone = config.withinTaxonSourceMode.isNone();
499
        boolean withFeature = config.withFeature;
477 500
        boolean isToParentNone = config.toParentSourceMode.isNone();
478 501
        boolean isToParentTaxon = config.toParentSourceMode.isTaxon();
479 502
        int intDel = withRemovedData? -1 : 0;
......
510 533

  
511 534
        //L. communis adenophora
512 535
        Taxon taxLapsanaCommunisAdenophora = (Taxon)taxonService.find(T_LAPSANA_COMMUNIS_ADENOPHORA_UUID);
513
        TaxonDescription aggrDescLapsanaCommunisAdenophora = verifyTaxonDescriptions(taxLapsanaCommunisAdenophora, 3);
536
        int nEl = withFeature ? 4 : 3;
537
        TaxonDescription aggrDescLapsanaCommunisAdenophora = verifyTaxonDescriptions(taxLapsanaCommunisAdenophora, nEl);
514 538
        verifyState(verifyCategoricalData(uuidFeatureLeafPA, 1, aggrDescLapsanaCommunisAdenophora, false), State.uuidPresent, 1);
515 539
        List<StateData> sdAdenophoraLeafColor = verifyCategoricalData(uuidFeatureLeafColor, 1, aggrDescLapsanaCommunisAdenophora, false);
516 540
        verifyState(sdAdenophoraLeafColor, uuidLeafColorBlue, 0);
......
520 544

  
521 545
        //L. communis
522 546
        Taxon taxLapsanaCommunis = (Taxon)taxonService.find(T_LAPSANA_COMMUNIS_UUID);
523
        TaxonDescription aggrDescLapsanaCommunis = verifyTaxonDescriptions(taxLapsanaCommunis, 3);
547
        TaxonDescription aggrDescLapsanaCommunis = verifyTaxonDescriptions(taxLapsanaCommunis, nEl);
524 548
        verifyState(verifyCategoricalData(uuidFeatureLeafPA, 1, aggrDescLapsanaCommunis, false), State.uuidPresent, 4+intDel);
525 549
        List<StateData> sdCommunisLeafColor = verifyCategoricalData(uuidFeatureLeafColor, 2, aggrDescLapsanaCommunis, false);
526 550
        verifyState(sdCommunisLeafColor, uuidLeafColorBlue, 2 + intLit);
......
548 572

  
549 573
        //Lapsana
550 574
        Taxon taxLapsana = (Taxon)taxonService.find(T_LAPSANA_UUID);
551
        TaxonDescription aggrDescLapsana = verifyTaxonDescriptions(taxLapsana, 3);
575
        TaxonDescription aggrDescLapsana = verifyTaxonDescriptions(taxLapsana, nEl);
552 576
        verifyState(verifyCategoricalData(uuidFeatureLeafPA, 1, aggrDescLapsana, false), State.uuidPresent, 4+intDel);
553 577
        List<StateData> sdLapsanLeafColor = verifyCategoricalData(uuidFeatureLeafColor, 2, aggrDescLapsana, false);
554 578
        verifyState(sdLapsanLeafColor, uuidLeafColorBlue, 2 + intLit);
......
806 830
        //leaf p/a
807 831
        //  leaf length
808 832
        //  leaf color
833

  
834
        //tree
809 835
        TermTree<Feature> featureTree = TermTree.NewFeatureInstance();
810 836
        featureTree.setUuid(uuidFeatureTree);
837

  
838
        //leaf p/a
811 839
        Feature featureLeafPA = createFeature(uuidFeatureLeafPA, "LeafPA", false);
812 840
        TermNode<Feature> leafPANode = featureTree.getRoot().addChild(featureLeafPA);
841

  
842
        //leaf length
813 843
        Feature featureLeafLength = createFeature(uuidFeatureLeafLength, "LeafLength", true);
814 844
        leafPANode.addChild(featureLeafLength);
845

  
846
        //leaf color
815 847
        Feature featureLeafColor = createFeature(uuidFeatureLeafColor, "LeafColor", false);
816 848
        leafPANode.addChild(featureLeafColor);
849
        TermVocabulary<State> stateVoc = TermVocabulary.NewInstance(TermType.State, State.class, "", "Colors", null, null);
817 850
        State yellow = createState("Yellow", uuidLeafColorYellow);
818 851
        State blue = createState("Blue", uuidLeafColorBlue);
819
        TermVocabulary<State> stateVoc = TermVocabulary.NewInstance(TermType.State, State.class, "", "Colors", null, null);
820 852
        stateVoc.addTerm(yellow);
821 853
        stateVoc.addTerm(blue);
822 854
        featureLeafColor.addSupportedCategoricalEnumeration(stateVoc);
855

  
856
        //additional feature
857
        Feature featureLeafAdd = createFeature(uuidFeatureLeafAdd, "Add", true);
858
        leafPANode.addChild(featureLeafAdd);
859

  
823 860
        vocabularyService.save(stateVoc);
824 861
    }
825 862

  

Also available in: Unified diff