Search in sources :

Example 16 with GatheringEvent

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));
}
Also used : GatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) FieldUnit(eu.etaxonomy.cdm.model.occurrence.FieldUnit) DerivationEvent(eu.etaxonomy.cdm.model.occurrence.DerivationEvent) DnaSample(eu.etaxonomy.cdm.model.molecular.DnaSample) SpecimenDeleteConfigurator(eu.etaxonomy.cdm.api.service.config.SpecimenDeleteConfigurator) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) Test(org.junit.Test) DataSet(org.unitils.dbunit.annotation.DataSet)

Example 17 with GatheringEvent

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());
}
Also used : GatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent) Ignore(org.junit.Ignore) CdmTransactionalIntegrationTest(eu.etaxonomy.cdm.test.integration.CdmTransactionalIntegrationTest) Test(org.junit.Test)

Example 18 with GatheringEvent

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);
    }
}
Also used : GatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) Transient(javax.persistence.Transient)

Example 19 with GatheringEvent

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);
        }
    }
}
Also used : GatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) Transient(javax.persistence.Transient)

Example 20 with GatheringEvent

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();
}
Also used : GatheringEvent(eu.etaxonomy.cdm.model.occurrence.GatheringEvent)

Aggregations

GatheringEvent (eu.etaxonomy.cdm.model.occurrence.GatheringEvent)21 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)9 FieldUnit (eu.etaxonomy.cdm.model.occurrence.FieldUnit)9 DerivedUnit (eu.etaxonomy.cdm.model.occurrence.DerivedUnit)8 DerivationEvent (eu.etaxonomy.cdm.model.occurrence.DerivationEvent)6 Institution (eu.etaxonomy.cdm.model.agent.Institution)5 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)5 Collection (eu.etaxonomy.cdm.model.occurrence.Collection)5 UnitsGatheringEvent (eu.etaxonomy.cdm.io.specimen.UnitsGatheringEvent)4 Person (eu.etaxonomy.cdm.model.agent.Person)4 DeterminationEvent (eu.etaxonomy.cdm.model.occurrence.DeterminationEvent)4 DerivedUnitFacade (eu.etaxonomy.cdm.api.facade.DerivedUnitFacade)3 UnitsGatheringArea (eu.etaxonomy.cdm.io.specimen.UnitsGatheringArea)3 IdentifiableSource (eu.etaxonomy.cdm.model.common.IdentifiableSource)3 TimePeriod (eu.etaxonomy.cdm.model.common.TimePeriod)3 NamedArea (eu.etaxonomy.cdm.model.location.NamedArea)3 Media (eu.etaxonomy.cdm.model.media.Media)3 MediaSpecimen (eu.etaxonomy.cdm.model.occurrence.MediaSpecimen)3 SpecimenOrObservationBase (eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase)3 URI (eu.etaxonomy.cdm.common.URI)2