Search in sources :

Example 16 with DescriptiveDataSet

use of eu.etaxonomy.cdm.model.description.DescriptiveDataSet in project cdmlib by cybertaxonomy.

the class DescriptiveDataSetService method removeDescription.

@Override
@Transactional(readOnly = false)
public DeleteResult removeDescription(UUID descriptionUuid, UUID descriptiveDataSetUuid, RemoveDescriptionsFromDescriptiveDataSetConfigurator config) {
    DeleteResult result = new DeleteResult();
    DescriptiveDataSet dataSet = load(descriptiveDataSetUuid);
    DescriptionBase<?> descriptionBase = descriptionService.load(descriptionUuid);
    if (dataSet == null || descriptionBase == null) {
        result.setError();
    } else {
        removeDescriptionFromDataSet(result, dataSet, descriptionBase, config);
    }
    return result;
}
Also used : DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with DescriptiveDataSet

use of eu.etaxonomy.cdm.model.description.DescriptiveDataSet in project cdmlib by cybertaxonomy.

the class DescriptiveDataSetService method createTaxonDescription.

@Override
@Transactional(readOnly = false)
public TaxonRowWrapperDTO createTaxonDescription(UUID dataSetUuid, UUID taxonNodeUuid, DescriptionType descriptionType) {
    DescriptiveDataSet dataSet = load(dataSetUuid);
    TaxonNode taxonNode = taxonNodeService.load(taxonNodeUuid, Arrays.asList("taxon"));
    TaxonDescription newTaxonDescription = TaxonDescription.NewInstance(taxonNode.getTaxon());
    // $NON-NLS-2$
    newTaxonDescription.setTitleCache(dataSet.getLabel() + ": " + newTaxonDescription.generateTitle(), true);
    newTaxonDescription.getTypes().add(descriptionType);
    dataSet.addDescription(newTaxonDescription);
    saveOrUpdate(dataSet);
    return createTaxonRowWrapper(newTaxonDescription.getUuid(), dataSet.getUuid());
}
Also used : DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) Transactional(org.springframework.transaction.annotation.Transactional)

Example 18 with DescriptiveDataSet

use of eu.etaxonomy.cdm.model.description.DescriptiveDataSet in project cdmlib by cybertaxonomy.

the class DescriptiveDataSetService method createTaxonRowWrapper.

@Override
public TaxonRowWrapperDTO createTaxonRowWrapper(DescriptionBaseDto description, UUID descriptiveDataSetUuid) {
    Classification classification = null;
    DescriptiveDataSet descriptiveDataSet = dao.load(descriptiveDataSetUuid, null);
    Optional<TaxonNode> first = descriptiveDataSet.getTaxonSubtreeFilter().stream().filter(node -> node.getClassification() != null).findFirst();
    Optional<Classification> classificationOptional = first.map(node -> node.getClassification());
    Set<DescriptionBaseDto> descriptions = new HashSet<>();
    TaxonNodeDto nodeDto = null;
    if (classificationOptional.isPresent()) {
        classification = classificationOptional.get();
        nodeDto = taxonNodeService.dto(description.getTaxonDto().getUuid(), classification.getUuid());
    }
    return new TaxonRowWrapperDTO(description, nodeDto, descriptions);
}
Also used : Arrays(java.util.Arrays) TermDto(eu.etaxonomy.cdm.persistence.dto.TermDto) IProgressMonitor(eu.etaxonomy.cdm.common.monitor.IProgressMonitor) StatisticalMeasurementValueDto(eu.etaxonomy.cdm.api.service.dto.StatisticalMeasurementValueDto) Autowired(org.springframework.beans.factory.annotation.Autowired) IdentifiableServiceConfiguratorImpl(eu.etaxonomy.cdm.api.service.config.IdentifiableServiceConfiguratorImpl) CategoricalData(eu.etaxonomy.cdm.model.description.CategoricalData) DescriptiveSystemRole(eu.etaxonomy.cdm.model.description.DescriptiveSystemRole) TaxonNodeDto(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto) BigDecimal(java.math.BigDecimal) Logger(org.apache.log4j.Logger) DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) Classification(eu.etaxonomy.cdm.model.taxon.Classification) QuantitativeDataDto(eu.etaxonomy.cdm.api.service.dto.QuantitativeDataDto) TaxonBase(eu.etaxonomy.cdm.model.taxon.TaxonBase) DescriptionBaseDto(eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto) Map(java.util.Map) Query(org.hibernate.Query) TaxonNodeFilter(eu.etaxonomy.cdm.filter.TaxonNodeFilter) DescriptionElementBase(eu.etaxonomy.cdm.model.description.DescriptionElementBase) Collection(java.util.Collection) Set(java.util.Set) StateDataDto(eu.etaxonomy.cdm.api.service.dto.StateDataDto) CdmLinkSource(eu.etaxonomy.cdm.model.reference.CdmLinkSource) UUID(java.util.UUID) DescriptiveDataSetBaseDto(eu.etaxonomy.cdm.persistence.dto.DescriptiveDataSetBaseDto) QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Collectors(java.util.stream.Collectors) PolytomousKeyGeneratorConfigurator(eu.etaxonomy.cdm.strategy.generate.PolytomousKeyGeneratorConfigurator) SpecimenOrObservationDTOFactory(eu.etaxonomy.cdm.api.service.dto.SpecimenOrObservationDTOFactory) PolytomousKeyGenerator(eu.etaxonomy.cdm.strategy.generate.PolytomousKeyGenerator) List(java.util.List) DeleteDescriptiveDataSetConfigurator(eu.etaxonomy.cdm.api.service.config.DeleteDescriptiveDataSetConfigurator) DescriptionType(eu.etaxonomy.cdm.model.description.DescriptionType) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) Optional(java.util.Optional) DescriptionBase(eu.etaxonomy.cdm.model.description.DescriptionBase) SpecimenDescription(eu.etaxonomy.cdm.model.description.SpecimenDescription) IDefinedTermDao(eu.etaxonomy.cdm.persistence.dao.term.IDefinedTermDao) MergeResult(eu.etaxonomy.cdm.persistence.dto.MergeResult) IIdentifiableEntityCacheStrategy(eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy) TextData(eu.etaxonomy.cdm.model.description.TextData) Session(org.hibernate.Session) StatisticalMeasure(eu.etaxonomy.cdm.model.description.StatisticalMeasure) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) HashMap(java.util.HashMap) Status(eu.etaxonomy.cdm.api.service.UpdateResult.Status) IndividualsAssociation(eu.etaxonomy.cdm.model.description.IndividualsAssociation) RowWrapperDTO(eu.etaxonomy.cdm.api.service.dto.RowWrapperDTO) UuidAndTitleCache(eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache) ArrayList(java.util.ArrayList) IdentifiableSource(eu.etaxonomy.cdm.model.common.IdentifiableSource) HashSet(java.util.HashSet) NamedArea(eu.etaxonomy.cdm.model.location.NamedArea) SpecimenNodeWrapper(eu.etaxonomy.cdm.persistence.dto.SpecimenNodeWrapper) TermTreeDto(eu.etaxonomy.cdm.persistence.dto.TermTreeDto) PolytomousKey(eu.etaxonomy.cdm.model.description.PolytomousKey) Service(org.springframework.stereotype.Service) RemoveDescriptionsFromDescriptiveDataSetConfigurator(eu.etaxonomy.cdm.api.service.config.RemoveDescriptionsFromDescriptiveDataSetConfigurator) State(eu.etaxonomy.cdm.model.description.State) StatisticalMeasurementValue(eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue) IDescriptiveDataSetDao(eu.etaxonomy.cdm.persistence.dao.description.IDescriptiveDataSetDao) DefaultQuantitativeDescriptionBuilder(eu.etaxonomy.cdm.format.description.DefaultQuantitativeDescriptionBuilder) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) CdmBase(eu.etaxonomy.cdm.model.common.CdmBase) TaxonRowWrapperDTO(eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO) DescriptionElementDto(eu.etaxonomy.cdm.api.service.dto.DescriptionElementDto) HibernateProxyHelper(eu.etaxonomy.cdm.hibernate.HibernateProxyHelper) MeasurementUnit(eu.etaxonomy.cdm.model.description.MeasurementUnit) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) CategoricalDataDto(eu.etaxonomy.cdm.api.service.dto.CategoricalDataDto) FieldUnit(eu.etaxonomy.cdm.model.occurrence.FieldUnit) Language(eu.etaxonomy.cdm.model.common.Language) DefaultCategoricalDescriptionBuilder(eu.etaxonomy.cdm.format.description.DefaultCategoricalDescriptionBuilder) SpecimenRowWrapperDTO(eu.etaxonomy.cdm.api.service.dto.SpecimenRowWrapperDTO) Feature(eu.etaxonomy.cdm.model.description.Feature) DefinedTermBase(eu.etaxonomy.cdm.model.term.DefinedTermBase) Collections(java.util.Collections) Transactional(org.springframework.transaction.annotation.Transactional) DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) DescriptionBaseDto(eu.etaxonomy.cdm.api.service.dto.DescriptionBaseDto) Classification(eu.etaxonomy.cdm.model.taxon.Classification) TaxonRowWrapperDTO(eu.etaxonomy.cdm.api.service.dto.TaxonRowWrapperDTO) HashSet(java.util.HashSet) TaxonNodeDto(eu.etaxonomy.cdm.persistence.dto.TaxonNodeDto)

Example 19 with DescriptiveDataSet

use of eu.etaxonomy.cdm.model.description.DescriptiveDataSet in project cdmlib by cybertaxonomy.

the class DescriptionServiceImpl method deleteDescription.

@Override
@Transactional(readOnly = false)
public DeleteResult deleteDescription(DescriptionBase<?> description) {
    DeleteResult deleteResult = new DeleteResult();
    if (description == null) {
        return deleteResult;
    }
    // avoid lazy init exception
    description = load(description.getId(), Arrays.asList("descriptiveDataSets"));
    deleteResult = isDeletable(description.getUuid());
    if (deleteResult.getRelatedObjects() != null && deleteResult.getRelatedObjects().size() == 1) {
        Iterator<CdmBase> relObjects = deleteResult.getRelatedObjects().iterator();
        CdmBase next = relObjects.next();
        if (next instanceof CdmLinkSource) {
            CdmLinkSource source = (CdmLinkSource) next;
            ICdmTarget target = source.getTarget();
        }
    }
    if (deleteResult.isOk()) {
        CdmBase.deproxy(description);
        if (description instanceof TaxonDescription) {
            TaxonDescription taxDescription = (TaxonDescription) description;
            Taxon tax = taxDescription.getTaxon();
            if (tax != null) {
                tax.removeDescription(taxDescription, true);
                deleteResult.addUpdatedObject(tax);
            }
        } else if (description instanceof SpecimenDescription) {
            SpecimenDescription specimenDescription = (SpecimenDescription) description;
            SpecimenOrObservationBase<?> specimen = specimenDescription.getDescribedSpecimenOrObservation();
            if (specimen != null) {
                specimen.removeDescription(specimenDescription);
                deleteResult.addUpdatedObject(specimen);
            }
        }
        for (DescriptiveDataSet dataset : description.getDescriptiveDataSets()) {
            dataset.removeDescription(description);
        }
        dao.delete(description);
        deleteResult.addDeletedObject(description);
        deleteResult.setCdmEntity(description);
    } else {
        logger.info(deleteResult.getExceptions().toString());
    }
    return deleteResult;
}
Also used : DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) SpecimenDescription(eu.etaxonomy.cdm.model.description.SpecimenDescription) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) CdmBase(eu.etaxonomy.cdm.model.common.CdmBase) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) CdmLinkSource(eu.etaxonomy.cdm.model.reference.CdmLinkSource) ICdmTarget(eu.etaxonomy.cdm.model.reference.ICdmTarget) Transactional(org.springframework.transaction.annotation.Transactional)

Example 20 with DescriptiveDataSet

use of eu.etaxonomy.cdm.model.description.DescriptiveDataSet in project cdmlib by cybertaxonomy.

the class PolytomousKeyGeneratorTest method createDataSet.

private DescriptiveDataSet createDataSet() {
    DescriptiveDataSet dataset = DescriptiveDataSet.NewInstance();
    dataset.setDescriptiveSystem(createFeatureTree());
    for (TaxonDescription desc : taxa) {
        dataset.addDescription(desc);
    }
    return dataset;
}
Also used : DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription)

Aggregations

DescriptiveDataSet (eu.etaxonomy.cdm.model.description.DescriptiveDataSet)29 TaxonDescription (eu.etaxonomy.cdm.model.description.TaxonDescription)15 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)14 Feature (eu.etaxonomy.cdm.model.description.Feature)13 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)13 TaxonNode (eu.etaxonomy.cdm.model.taxon.TaxonNode)13 HashSet (java.util.HashSet)12 BigDecimal (java.math.BigDecimal)11 Transactional (org.springframework.transaction.annotation.Transactional)11 DescriptionBase (eu.etaxonomy.cdm.model.description.DescriptionBase)10 QuantitativeData (eu.etaxonomy.cdm.model.description.QuantitativeData)10 ArrayList (java.util.ArrayList)10 Set (java.util.Set)10 UUID (java.util.UUID)10 IProgressMonitor (eu.etaxonomy.cdm.common.monitor.IProgressMonitor)8 CdmBase (eu.etaxonomy.cdm.model.common.CdmBase)8 CategoricalData (eu.etaxonomy.cdm.model.description.CategoricalData)8 State (eu.etaxonomy.cdm.model.description.State)8 StatisticalMeasurementValue (eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue)8 HashMap (java.util.HashMap)8