Search in sources :

Example 6 with SpecimenOrObservationType

use of eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType in project cdmlib by cybertaxonomy.

the class ExternalGeoController method doGetOccurrenceXMapUriParams.

/**
 * Assembles and returns URI parameter Strings for the EDIT Map Service. The distribution areas for the
 * {@link Taxon} instance identified by the <code>{taxon-uuid}</code> are found and are translated into
 * an valid URI parameter String. Higher level distribution areas are expanded in order to include all
 * nested sub-areas.
 * <p>
 * URI: <b>&#x002F;{datasource-name}&#x002F;geo&#x002F;map&#x002F;distribution&#x002F;{taxon-uuid}</b>
 *
 * @param request
 * @param response
 * @return URI parameter Strings for the EDIT Map Service
 * @throws IOException TODO write controller method documentation
 */
@RequestMapping(value = { "taxonOccurrencesForX" }, method = RequestMethod.GET)
public ModelAndView doGetOccurrenceXMapUriParams(@RequestParam(value = "fieldUnitUuidList", required = false) UuidList fieldUnitUuids, HttpServletRequest request, HttpServletResponse response) throws IOException {
    Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors = null;
    logger.info("doGetOccurrenceMapUriParams() " + requestPathAndQuery(request));
    ModelAndView mv = new ModelAndView();
    List<Point> fieldUnitPoints = occurrenceService.findPointsForFieldUnitList(fieldUnitUuids);
    OccurrenceServiceRequestParameterDto dto = EditGeoServiceUtilities.getOccurrenceServiceRequestParameterString(fieldUnitPoints, null, specimenOrObservationTypeColors);
    mv.addObject(dto);
    return mv;
}
Also used : Color(java.awt.Color) ModelAndView(org.springframework.web.servlet.ModelAndView) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) Point(eu.etaxonomy.cdm.model.location.Point) OccurrenceServiceRequestParameterDto(eu.etaxonomy.cdm.ext.geo.OccurrenceServiceRequestParameterDto) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with SpecimenOrObservationType

use of eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType in project cdmlib by cybertaxonomy.

the class KmlController method doGetTypeDesignationsKml.

/**
 * Assembles and returns URI parameter Strings for the EDIT Map Service. The distribution areas for the
 * {@link Taxon} instance identified by the <code>{taxon-uuid}</code> are found and are translated into
 * an valid URI parameter String. Higher level distribution areas are expanded in order to include all
 * nested sub-areas.
 * <p>
 * URI: <b>&#x002F;{datasource-name}&#x002F;geo&#x002F;map&#x002F;distribution&#x002F;{taxon-uuid}</b>
 *
 * @param request
 * @param response
 * @return URI parameter Strings for the EDIT Map Service
 * @throws IOException TODO write controller method documentation
 */
@RequestMapping(value = { "typeDesignations/{uuid-list}" }, method = RequestMethod.GET)
public Kml doGetTypeDesignationsKml(@PathVariable("uuid-list") UuidList uuidList, HttpServletRequest request, HttpServletResponse response) throws IOException {
    logger.info("doGetTypeDesignationsKml() " + requestPathAndQuery(request));
    Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors = null;
    List<TypeDesignationBase<?>> typeDesignations = nameService.loadTypeDesignations(uuidList, Arrays.asList("typeSpecimen"));
    List<SpecimenOrObservationBase> specimensOrObersvations = typeDesignations.stream().filter(td -> td != null && td instanceof SpecimenTypeDesignation).map(SpecimenTypeDesignation.class::cast).map(SpecimenTypeDesignation::getTypeSpecimen).filter(s -> s != null).collect(Collectors.toList());
    Kml kml = geoservice.occurrencesToKML(specimensOrObersvations, specimenOrObservationTypeColors);
    return kml;
}
Also used : Color(java.awt.Color) PathVariable(org.springframework.web.bind.annotation.PathVariable) Arrays(java.util.Arrays) RequestParam(org.springframework.web.bind.annotation.RequestParam) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) Controller(org.springframework.stereotype.Controller) SpecimenTypeDesignation(eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation) CrossOrigin(org.springframework.web.bind.annotation.CrossOrigin) IOccurrenceService(eu.etaxonomy.cdm.api.service.IOccurrenceService) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) HttpServletRequest(javax.servlet.http.HttpServletRequest) TaxonBase(eu.etaxonomy.cdm.model.taxon.TaxonBase) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) Map(java.util.Map) BaseController(eu.etaxonomy.cdm.remote.controller.BaseController) Api(io.swagger.annotations.Api) INameService(eu.etaxonomy.cdm.api.service.INameService) MarkerType(eu.etaxonomy.cdm.model.common.MarkerType) HttpServletResponse(javax.servlet.http.HttpServletResponse) OptionsController(eu.etaxonomy.cdm.remote.controller.OptionsController) Set(java.util.Set) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) IOException(java.io.IOException) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) TypeDesignationBase(eu.etaxonomy.cdm.model.name.TypeDesignationBase) IEditGeoService(eu.etaxonomy.cdm.ext.geo.IEditGeoService) SortOrder(eu.etaxonomy.cdm.persistence.query.OrderHint.SortOrder) HttpStatus(org.springframework.http.HttpStatus) List(java.util.List) ITaxonService(eu.etaxonomy.cdm.api.service.ITaxonService) TaxonRelationshipEdge(eu.etaxonomy.cdm.api.util.TaxonRelationshipEdge) UuidList(eu.etaxonomy.cdm.remote.editor.UuidList) ControllerUtils(eu.etaxonomy.cdm.remote.controller.util.ControllerUtils) DefinedTermBaseList(eu.etaxonomy.cdm.remote.editor.DefinedTermBaseList) UpdatableRoutingDataSource(eu.etaxonomy.cdm.database.UpdatableRoutingDataSource) TermBaseListPropertyEditor(eu.etaxonomy.cdm.remote.editor.TermBaseListPropertyEditor) WebDataBinder(org.springframework.web.bind.WebDataBinder) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) ResponseEntity(org.springframework.http.ResponseEntity) OrderHint(eu.etaxonomy.cdm.persistence.query.OrderHint) InitBinder(org.springframework.web.bind.annotation.InitBinder) ITermService(eu.etaxonomy.cdm.api.service.ITermService) UUIDListPropertyEditor(eu.etaxonomy.cdm.remote.editor.UUIDListPropertyEditor) Color(java.awt.Color) TypeDesignationBase(eu.etaxonomy.cdm.model.name.TypeDesignationBase) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) SpecimenTypeDesignation(eu.etaxonomy.cdm.model.name.SpecimenTypeDesignation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 8 with SpecimenOrObservationType

use of eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType in project cdmlib by cybertaxonomy.

the class KmlController method doGetTaxonOccurrenceKml.

/**
 * Assembles and returns URI parameter Strings for the EDIT Map Service. The distribution areas for the
 * {@link Taxon} instance identified by the <code>{taxon-uuid}</code> are found and are translated into
 * an valid URI parameter String. Higher level distribution areas are expanded in order to include all
 * nested sub-areas.
 * <p>
 * URI: <b>&#x002F;{datasource-name}&#x002F;geo&#x002F;map&#x002F;distribution&#x002F;{taxon-uuid}</b>
 *
 * @param request
 * @param response
 * @return URI parameter Strings for the EDIT Map Service
 * @throws IOException TODO write controller method documentation
 */
@RequestMapping(value = { "taxonOccurrencesFor/{uuid}" }, method = RequestMethod.GET)
public Kml doGetTaxonOccurrenceKml(@PathVariable("uuid") UUID uuid, @RequestParam(value = "relationships", required = false) UuidList relationshipUuids, @RequestParam(value = "relationshipsInvers", required = false) UuidList relationshipInversUuids, @RequestParam(value = "maxDepth", required = false) Integer maxDepth, HttpServletRequest request, HttpServletResponse response) throws IOException {
    logger.info("doGetTaxonOccurrenceKml() " + requestPathAndQuery(request));
    Map<SpecimenOrObservationType, Color> specimenOrObservationTypeColors = null;
    List<SpecimenOrObservationBase> specimensOrObersvations = occurencesForTaxon(uuid, relationshipUuids, relationshipInversUuids, maxDepth, response);
    Kml kml = geoservice.occurrencesToKML(specimensOrObersvations, specimenOrObservationTypeColors);
    return kml;
}
Also used : Color(java.awt.Color) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) Kml(de.micromata.opengis.kml.v_2_2_0.Kml) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 9 with SpecimenOrObservationType

use of eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType in project cdmlib by cybertaxonomy.

the class OccurrenceServiceImpl method assembleFieldUnitDTO.

@Override
public FieldUnitDTO assembleFieldUnitDTO(FieldUnit fieldUnit) {
    if (!getSession().contains(fieldUnit)) {
        fieldUnit = (FieldUnit) load(fieldUnit.getUuid());
    }
    // FIXME the filter for SpecimenOrObservationType.PreservedSpecimen has been preserved from the former implementation (see commit 07e3f63c7d  and older)
    // it is questionable if this filter makes sense for all use cases or if it is only a sensible default for the
    // compressed specimen table in the cdm-dataportal (see #6816, #6870)
    EnumSet<SpecimenOrObservationType> typeIncludeFilter = EnumSet.of(SpecimenOrObservationType.PreservedSpecimen);
    FieldUnitDTO fieldUnitDTO = FieldUnitDTO.fromEntity(fieldUnit, null, typeIncludeFilter);
    return fieldUnitDTO;
}
Also used : FieldUnitDTO(eu.etaxonomy.cdm.api.service.dto.FieldUnitDTO) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType)

Example 10 with SpecimenOrObservationType

use of eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType in project cdmlib by cybertaxonomy.

the class OccurrenceServiceImpl method moveDerivate.

@Override
@Transactional(readOnly = false)
public UpdateResult moveDerivate(UUID specimenFromUuid, UUID specimenToUuid, UUID derivateUuid) {
    // reload specimens to avoid session conflicts
    SpecimenOrObservationBase<?> from = null;
    if (specimenFromUuid != null) {
        from = load(specimenFromUuid);
    }
    SpecimenOrObservationBase<?> to = load(specimenToUuid);
    DerivedUnit derivate = (DerivedUnit) load(derivateUuid);
    if ((specimenFromUuid != null && from == null) || to == null || derivate == null) {
        throw new TransientObjectException("One of the CDM entities has not been saved to the data base yet. Moving only works for persisted/saved CDM entities.\n" + "Operation was move " + derivate + " from " + from + " to " + to);
    }
    UpdateResult result = new UpdateResult();
    SpecimenOrObservationType derivateType = derivate.getRecordBasis();
    SpecimenOrObservationType toType = to.getRecordBasis();
    // check if type is a sub derivate type
    if (// moving to FieldUnit always works
    toType == SpecimenOrObservationType.FieldUnit || // moving media always works
    derivateType == SpecimenOrObservationType.Media || (derivateType.isKindOf(toType) && toType != derivateType)) {
        // moving only to parent derivate type
        if (from != null) {
            // remove derivation event from parent specimen of dragged object
            DerivationEvent eventToRemove = null;
            for (DerivationEvent event : from.getDerivationEvents()) {
                if (event.getDerivatives().contains(derivate)) {
                    eventToRemove = event;
                    break;
                }
            }
            from.removeDerivationEvent(eventToRemove);
            if (eventToRemove != null) {
                // add new derivation event to target and copy the event parameters of the old one
                DerivationEvent derivedFromNewOriginalEvent = DerivationEvent.NewSimpleInstance(to, derivate, null);
                derivedFromNewOriginalEvent.setActor(eventToRemove.getActor());
                derivedFromNewOriginalEvent.setDescription(eventToRemove.getDescription());
                derivedFromNewOriginalEvent.setInstitution(eventToRemove.getInstitution());
                derivedFromNewOriginalEvent.setTimeperiod(eventToRemove.getTimeperiod());
                derivedFromNewOriginalEvent.setType(eventToRemove.getType());
                to.addDerivationEvent(derivedFromNewOriginalEvent);
                derivate.setDerivedFrom(derivedFromNewOriginalEvent);
            }
        } else {
            // derivative had no parent before so we use empty derivation event
            DerivationEvent derivedFromNewOriginalEvent = DerivationEvent.NewSimpleInstance(to, derivate, null);
            to.addDerivationEvent(derivedFromNewOriginalEvent);
            derivate.setDerivedFrom(derivedFromNewOriginalEvent);
        }
        if (from != null) {
            saveOrUpdate(from);
        }
        saveOrUpdate(to);
        result.setStatus(Status.OK);
        result.addUpdatedObject(from);
        result.addUpdatedObject(to);
    } else {
        result.setStatus(Status.ERROR);
    }
    return result;
}
Also used : TransientObjectException(org.hibernate.TransientObjectException) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) DerivationEvent(eu.etaxonomy.cdm.model.occurrence.DerivationEvent) SpecimenOrObservationType(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

SpecimenOrObservationType (eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType)21 DerivedUnitFacade (eu.etaxonomy.cdm.api.facade.DerivedUnitFacade)7 SpecimenOrObservationBase (eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase)6 Color (java.awt.Color)5 ArrayList (java.util.ArrayList)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 Kml (de.micromata.opengis.kml.v_2_2_0.Kml)3 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)3 DerivedUnit (eu.etaxonomy.cdm.model.occurrence.DerivedUnit)3 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)3 List (java.util.List)3 OccurrenceServiceRequestParameterDto (eu.etaxonomy.cdm.ext.geo.OccurrenceServiceRequestParameterDto)2 IdentifiableSource (eu.etaxonomy.cdm.model.common.IdentifiableSource)2 Point (eu.etaxonomy.cdm.model.location.Point)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 UUID (java.util.UUID)2 AltitudeMode (de.micromata.opengis.kml.v_2_2_0.AltitudeMode)1 ExtendedData (de.micromata.opengis.kml.v_2_2_0.ExtendedData)1 INameService (eu.etaxonomy.cdm.api.service.INameService)1