Project

General

Profile

« Previous | Next » 

Revision ad4999ae

Added by Patrick Plitzner over 5 years ago

ref #7980 Delete existing aggregation when re-aggregating

View differences:

cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/DescriptiveDataSetService.java
252 252
        super.updateTitleCacheImpl(clazz, stepSize, cacheStrategy, monitor);
253 253
    }
254 254

  
255
    @Override
256
    public TaxonDescription findTaxonDescriptionByMarkerType(UUID dataSetUuid, UUID taxonNodeUuid, MarkerType markerType){
257
        DescriptiveDataSet dataSet = load(dataSetUuid);
258
        TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
255
    private TaxonDescription findTaxonDescriptionByMarkerType(DescriptiveDataSet dataSet, Taxon taxon, MarkerType markerType){
259 256
        Set<DescriptionBase> dataSetDescriptions = dataSet.getDescriptions();
260 257
        //filter by DEFAULT descriptions
261
        Optional<TaxonDescription> first = taxonNode.getTaxon().getDescriptions().stream()
258
        Optional<TaxonDescription> first = taxon.getDescriptions().stream()
262 259
                .filter(desc -> desc.getMarkers().stream().anyMatch(marker -> marker.getMarkerType().equals(markerType)))
263 260
                .filter(defaultDescription->dataSetDescriptions.contains(defaultDescription))
264 261
                .findFirst();
......
270 267
    }
271 268

  
272 269
    @Override
270
    public TaxonDescription findTaxonDescriptionByMarkerType(UUID dataSetUuid, UUID taxonNodeUuid, MarkerType markerType){
271
        DescriptiveDataSet dataSet = load(dataSetUuid);
272
        TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid);
273
        return findTaxonDescriptionByMarkerType(dataSet, taxonNode.getTaxon(), markerType);
274
    }
275

  
276
    @Override
273 277
    @Transactional(readOnly=false)
274 278
    public UpdateResult aggregateTaxonDescription(UUID taxonNodeUuid, UUID descriptiveDataSetUuid,
275 279
            IRemotingProgressMonitor monitor){
......
352 356
            });
353 357
        });
354 358

  
359
        // delete existing aggregation description, if present
360
        TaxonDescription aggregation = findTaxonDescriptionByMarkerType(dataSet, taxon, MarkerType.COMPUTED());
361
        removeDescription(aggregation.getUuid(), descriptiveDataSetUuid);
362

  
363
        // create new aggregation
355 364
        TaxonDescription description = TaxonDescription.NewInstance(taxon);
356 365
        description.setTitleCache("[Aggregation] "+descriptionTitle, true);
357 366
        description.addMarker(Marker.NewInstance(MarkerType.COMPUTED(), true));

Also available in: Unified diff