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>/{datasource-name}/geo/map/distribution/{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;
}
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>/{datasource-name}/geo/map/distribution/{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;
}
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>/{datasource-name}/geo/map/distribution/{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;
}
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;
}
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;
}
Aggregations