use of eu.etaxonomy.cdm.model.occurrence.GatheringEvent in project cdmlib by cybertaxonomy.
the class OccurrenceServiceDeepDeleteTest method testDeepDelete_FieldUnit.
@Test
@DataSet(loadStrategy = CleanSweepInsertLoadStrategy.class, value = "OccurrenceServiceTest.testDeleteDerivateHierarchyStepByStep.xml")
public void testDeepDelete_FieldUnit() {
String assertMessage = "Incorrect number of specimens after deletion.";
DeleteResult deleteResult = null;
SpecimenDeleteConfigurator config = new SpecimenDeleteConfigurator();
config.setDeleteMolecularData(true);
config.setDeleteChildren(true);
FieldUnit fieldUnit = (FieldUnit) occurrenceService.load(FIELD_UNIT_UUID);
GatheringEvent gatheringEvent = GatheringEvent.NewInstance();
fieldUnit.setGatheringEvent(gatheringEvent);
FieldUnit fieldUnit2 = (FieldUnit) occurrenceService.load(FIELD_UNIT2_UUID);
fieldUnit2.setGatheringEvent(gatheringEvent);
DnaSample dnaSample = (DnaSample) occurrenceService.load(DNA_SAMPLE_UUID);
// check initial state
assertEquals(assertMessage, 6, occurrenceService.count(SpecimenOrObservationBase.class));
assertEquals(assertMessage, 4, eventService.count(DerivationEvent.class));
assertEquals(assertMessage, 2, occurrenceService.count(FieldUnit.class));
assertEquals(assertMessage, 4, occurrenceService.count(DerivedUnit.class));
assertEquals(assertMessage, 2, occurrenceService.count(DnaSample.class));
assertEquals("incorrect number of amplification results", 1, dnaSample.getAmplificationResults().size());
assertEquals("number of sequences incorrect", 1, dnaSample.getSequences().size());
assertEquals("incorrect number of single reads", 1, dnaSample.getAmplificationResults().iterator().next().getSingleReads().size());
assertEquals("incorrect number of gathering events", 1, eventService.count(GatheringEvent.class));
// delete field unit
deleteResult = occurrenceService.delete(fieldUnit, config);
assertTrue(deleteResult.toString(), deleteResult.isOk());
assertEquals(assertMessage, 2, eventService.count(DerivationEvent.class));
assertEquals(assertMessage, 3, occurrenceService.count(SpecimenOrObservationBase.class));
assertEquals(assertMessage, 1, occurrenceService.count(FieldUnit.class));
assertEquals(assertMessage, 2, occurrenceService.count(DerivedUnit.class));
assertEquals(assertMessage, 1, occurrenceService.count(DnaSample.class));
assertEquals("incorrect number of gathering events", 1, eventService.count(GatheringEvent.class));
deleteResult = occurrenceService.delete(fieldUnit2, config);
assertEquals(assertMessage, 0, eventService.count(GatheringEvent.class));
}
use of eu.etaxonomy.cdm.model.occurrence.GatheringEvent in project cdmlib by cybertaxonomy.
the class DerivedUnitFacadeTest method testSetGatheringEvent.
/**
* Test method for
* {@link eu.etaxonomy.cdm.api.facade.DerivedUnitFacade#setGatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent)}
* .
*/
@Test
// #######DerivationEvent ---------------------------------------- 1
@Ignore
public void testSetGatheringEvent() {
GatheringEvent newGatheringEvent = GatheringEvent.NewInstance();
newGatheringEvent.setDistanceToGround(43.0);
assertFalse("The initial distance to ground should not be 43", specimenFacade.getDistanceToGround() == 43.0);
specimenFacade.setGatheringEvent(newGatheringEvent);
assertTrue("The final distance to ground should be 43", specimenFacade.getDistanceToGround() == 43.0);
assertSame("The new gathering event should be 'newGatheringEvent'", newGatheringEvent, specimenFacade.innerGatheringEvent());
}
use of eu.etaxonomy.cdm.model.occurrence.GatheringEvent in project cdmlib by cybertaxonomy.
the class DerivedUnitFacade method distanceToWaterSurfaceToString.
/**
* Returns the correctly formatted <code>distance to water surface</code> information.
* If distanceToWaterSurfaceText is not blank, it will be returned,
* otherwise distanceToWaterSurface will be returned, followed by distanceToWatersurfaceMax
* if existing, separated by " - "
* @return
*/
@Transient
public String distanceToWaterSurfaceToString() {
if (!hasGatheringEvent()) {
return null;
} else {
GatheringEvent ev = getGatheringEvent(true);
String text = ev.getDistanceToWaterSurfaceText();
Double min = getDistanceToWaterSurface();
Double max = getDistanceToWaterSurfaceMax();
return DistanceStringFormatter.distanceString(min, max, text, METER);
}
}
use of eu.etaxonomy.cdm.model.occurrence.GatheringEvent in project cdmlib by cybertaxonomy.
the class DerivedUnitFacade method absoluteElevationToString.
/**
* Returns the correctly formatted <code>absolute elevation</code> information.
* If absoluteElevationText is set, this will be returned,
* otherwise we absoluteElevation will be returned, followed by absoluteElevationMax
* if existing, separated by " - "
* @return
*/
@Transient
public String absoluteElevationToString() {
if (!hasGatheringEvent()) {
return null;
} else {
GatheringEvent ev = getGatheringEvent(true);
if (StringUtils.isNotBlank(ev.getAbsoluteElevationText())) {
return ev.getAbsoluteElevationText();
} else {
String text = ev.getAbsoluteElevationText();
Integer min = getAbsoluteElevation();
Integer max = getAbsoluteElevationMaximum();
return DistanceStringFormatter.distanceString(min, max, text, METER);
}
}
}
use of eu.etaxonomy.cdm.model.occurrence.GatheringEvent in project cdmlib by cybertaxonomy.
the class DerivedUnitFacade method getGatheringEvent.
public GatheringEvent getGatheringEvent(boolean createIfNotExists) {
if (!hasFieldUnit() && !createIfNotExists) {
return null;
}
if (createIfNotExists && getFieldUnit(true).getGatheringEvent() == null) {
GatheringEvent gatheringEvent = GatheringEvent.NewInstance();
getFieldUnit(true).setGatheringEvent(gatheringEvent);
}
return getFieldUnit(true).getGatheringEvent();
}
Aggregations