@Override
@Transactional(readOnly = false)
- public DeleteResult deleteDescription(DescriptionBase description) {
+ public DeleteResult deleteDescription(DescriptionBase<?> description) {
DeleteResult deleteResult = new DeleteResult();
if (description == null){
return deleteResult;
}
- description = load(description.getId(), Arrays.asList("descriptiveDataSets"));
//avoid lazy init exception
+ description = load(description.getId(), Arrays.asList("descriptiveDataSets"));
deleteResult = isDeletable(description.getUuid());
if (deleteResult.getRelatedObjects() != null && deleteResult.getRelatedObjects().size() == 1){
deleteResult.addUpdatedObject(specimen);
}
- Set<DescriptiveDataSet> descriptiveDataSets = description.getDescriptiveDataSets();
- for (Iterator<DescriptiveDataSet> iterator = descriptiveDataSets.iterator(); iterator.hasNext();) {
- iterator.next().removeDescription(description);
+ for (DescriptiveDataSet dataset : description.getDescriptiveDataSets()) {
+ dataset.removeDescription(description);
}
dao.delete(description);
return result;
}
for (CdmBase ref: references){
- String message = null;
- if (description instanceof TaxonDescription && ref instanceof Taxon && ((TaxonDescription)description).getTaxon().equals(ref)){
+ if (description instanceof TaxonDescription && ref instanceof Taxon && ref.equals(((TaxonDescription)description).getTaxon())){
continue;
- } else if (description instanceof TaxonNameDescription && ref instanceof TaxonName && ((TaxonNameDescription)description).getTaxonName().equals(ref)){
+ } else if (description instanceof TaxonNameDescription && ref instanceof TaxonName && ref.equals(((TaxonNameDescription)description).getTaxonName())){
continue;
- } else if (description instanceof SpecimenDescription && ref instanceof SpecimenOrObservationBase && ((SpecimenDescription)description).getDescribedSpecimenOrObservation().equals(ref)){
+ } else if (description instanceof SpecimenDescription && ref instanceof SpecimenOrObservationBase && ref.equals(((SpecimenDescription)description).getDescribedSpecimenOrObservation())){
continue;
} else if (ref instanceof DescriptionElementBase){
continue;
}else {
- message = "The description can't be completely deleted because it is referenced by " + ref.getUserFriendlyTypeName() ;
+ String message = "The description can't be completely deleted because it is referenced by " + ref.getUserFriendlyTypeName() ;
result.setAbort();
- }
- if (message != null){
result.addException(new ReferencedObjectUndeletableException(message));
result.addRelatedObject(ref);
}
* The contents of this file are subject to the Mozilla Public License Version 1.1
* See LICENSE.TXT at the top of this package for the full license terms.
*/
-
package eu.etaxonomy.cdm.api.service;
import java.util.Collection;
public Pager<TermDto> pageNamedAreasInUse(boolean includeAllParents, Integer pageSize,
Integer pageNumber);
- public DeleteResult deleteDescription(DescriptionBase description);
+ /**
+ * Deletes the description and prior removes it from taxon, specimen or descriptive dataset.
+ */
+ public DeleteResult deleteDescription(DescriptionBase<?> description);
public DeleteResult deleteDescription(UUID descriptionUuid);
- /**
- * @param sourceTaxon
- * @param targetTaxon
- * @return
- */
public UpdateResult moveTaxonDescriptions(Taxon sourceTaxon, Taxon targetTaxon, boolean setNameInSource);
- /**
- * @param sourceTaxonUuid
- * @param targetTaxonUuid
- * @return
- */
public UpdateResult moveTaxonDescriptions(UUID sourceTaxonUuid, UUID targetTaxonUuid, boolean setNameInSource);
-
- /**
- * @param descriptionElementUUIDs
- * @param targetDescriptionUuid
- * @param isCopy
- * @return
- */
public UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs, UUID targetDescriptionUuid,
boolean isCopy, boolean setNameInSource);
- /**
- * @param descriptionElementUUIDs
- * @param targetTaxonUuid
- * @param moveMessage
- * @param isCopy
- * @return
- */
public UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs, UUID targetTaxonUuid,
String moveMessage, boolean isCopy, boolean setNameInSource);
- /**
- * @param descriptionUUID
- * @param targetTaxonUuid
- * @return
- */
public UpdateResult moveTaxonDescription(UUID descriptionUuid, UUID targetTaxonUuid, boolean setNameInSource);
- /**
- * @param descriptionElements
- * @param returnTransientEntity
- * @return
- */
public List<MergeResult<DescriptionBase>> mergeDescriptionElements(Collection<TaxonDistributionDTO> descriptionElements,
boolean returnTransientEntity);
- /**
- * @param descriptions
- * @param returnTransientEntity
- * @return
- */
public UpdateResult mergeDescriptions(Collection<DescriptionBaseDto> descriptions, UUID descriptiveDataSetUuid);
-
- /**
- * @param descriptionElementUUIDs
- * @param targetDescription
- * @param isCopy
- * @return
- */
- UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs,
+ public UpdateResult moveDescriptionElementsToDescription(Set<UUID> descriptionElementUUIDs,
DescriptionBase targetDescription, boolean isCopy, boolean setNameInSource);
public DeleteResult isDeletable(UUID descriptionUuid);
public DescriptionBaseDto loadDto(UUID descriptionUuid);
- /**
- * @param taxonUuid
- * @return
- */
- List<DescriptionBaseDto> loadDtosForTaxon(UUID taxonUuid);
-
-
-
-}
+ public List<DescriptionBaseDto> loadDtosForTaxon(UUID taxonUuid);
+}
\ No newline at end of file
UUID yugDistributionUuid = null;
UUID yug_mn_DistributionUuid = null;
for (DescriptionElementBase element : lapsanaAggregatedDescription.getElements()){
- Distribution labsanaDistribution = (Distribution)element;
- if(labsanaDistribution.getArea().equals(yug)){
+ Distribution lapsanaDistribution = (Distribution)element;
+ if(lapsanaDistribution.getArea().equals(yug)){
numExpectedFound++;
- assertEquals("Aggregated status of area YUG is wrong", PresenceAbsenceTerm.NATIVE(), labsanaDistribution.getStatus());
- assertEquals(2, labsanaDistribution.getSources().size());
+ assertEquals("Aggregated status of area YUG is wrong", PresenceAbsenceTerm.NATIVE(), lapsanaDistribution.getStatus());
+ assertEquals(2, lapsanaDistribution.getSources().size());
// should contain source_LCA_yug_ma and source_LCA_yug_ko, testing the microreference which is unique in the tests
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "2"));
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "4"));
- yugDistributionUuid = labsanaDistribution.getUuid(); //for later
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "2"));
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "4"));
+ yugDistributionUuid = lapsanaDistribution.getUuid(); //for later
}
- if(labsanaDistribution.getArea().equals(yug_mn)){
+ if(lapsanaDistribution.getArea().equals(yug_mn)){
numExpectedFound++;
- assertEquals("Aggregated status of area YUG-MN is wrong", PresenceAbsenceTerm.CULTIVATED(), labsanaDistribution.getStatus());
- assertEquals(2, labsanaDistribution.getSources().size());
+ assertEquals("Aggregated status of area YUG-MN is wrong", PresenceAbsenceTerm.CULTIVATED(), lapsanaDistribution.getStatus());
+ assertEquals(2, lapsanaDistribution.getSources().size());
// should contain source_LCA_yug_ma and source_LCA_yug_ko, testing the microreference which is unique in the tests
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "1"));
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "3"));
- yug_mn_DistributionUuid = labsanaDistribution.getUuid(); //for reaggregation test
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "1"));
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "3"));
+ yug_mn_DistributionUuid = lapsanaDistribution.getUuid(); //for reaggregation test
}
- if(labsanaDistribution.getArea().equals(yug_ko)){
+ if(lapsanaDistribution.getArea().equals(yug_ko)){
numExpectedFound++;
- assertEquals("aggregated status of area YUG-KO wrong", PresenceAbsenceTerm.NATIVE(), labsanaDistribution.getStatus());
- assertEquals(2, labsanaDistribution.getSources().size());
+ assertEquals("aggregated status of area YUG-KO wrong", PresenceAbsenceTerm.NATIVE(), lapsanaDistribution.getStatus());
+ assertEquals(2, lapsanaDistribution.getSources().size());
// should contain source_LCA_yug_ma and source_LCA_yug_ko, testing the microreference which is unique in the tests
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "2"));
- assertTrue(sourceExists(labsanaDistribution.getSources(), book_a, "4"));
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "2"));
+ assertTrue(sourceExists(lapsanaDistribution.getSources(), book_a, "4"));
}
}
assertEquals("All three expected areas should have been found before", numExpectedFound, 3);