use of eu.etaxonomy.cdm.model.occurrence.DerivationEventType in project cdmlib by cybertaxonomy.
the class DerivedUnitFacadeTest method setUp.
// ****************************** SET UP **********************************/
/**
* @throws java.lang.Exception
*/
@Before
public void setUp() throws Exception {
specimen = DerivedUnit.NewPreservedSpecimenInstance();
derivationEvent = DerivationEvent.NewInstance(DerivationEventType.ACCESSIONING());
specimen.setDerivedFrom(derivationEvent);
fieldUnit = FieldUnit.NewInstance();
fieldUnit.addDerivationEvent(derivationEvent);
gatheringEvent = GatheringEvent.NewInstance();
fieldUnit.setGatheringEvent(gatheringEvent);
gatheringEvent.setAbsoluteElevation(absoluteElevation);
gatheringEvent.setAbsoluteElevationMax(absoluteElevationMaximum);
gatheringEvent.setActor(collector);
gatheringEvent.setCollectingMethod(collectingMethod);
gatheringEvent.setDistanceToGround(distanceToGround);
gatheringEvent.setDistanceToWaterSurface(distanceToSurface);
gatheringEvent.setDistanceToWaterSurfaceMax(distanceToSurfaceMax);
gatheringEvent.setExactLocation(exactLocation);
gatheringEvent.setDescription(gatheringEventDescription);
gatheringEvent.setCountry(Country.GERMANY());
gatheringEvent.setTimeperiod(gatheringPeriod);
gatheringEvent.setLocality(locality);
fieldUnit.setFieldNumber(fieldNumber);
fieldUnit.setFieldNotes(fieldNotes);
fieldUnit.setIndividualCount(individualCount);
fieldUnit.setSex(sex);
fieldUnit.setLifeStage(lifeStage);
fieldUnit.setKindOfUnit(kindOfUnit);
specimen.setAccessionNumber(accessionNumber);
specimen.setCatalogNumber(catalogNumber);
specimen.setStoredUnder(taxonName);
specimen.setCollection(collection);
specimen.setPreservation(preservationMethod);
specimen.setOriginalLabelInfo(originalLabelInfo);
specimen.setPreferredStableUri(stableUri);
specimenFacade = DerivedUnitFacade.NewInstance(specimen);
// existing specimen with 2 derivation events in line
collectionSpecimen = DerivedUnit.NewPreservedSpecimenInstance();
DerivedUnit middleSpecimen = DerivedUnit.NewPreservedSpecimenInstance();
firstFieldObject = FieldUnit.NewInstance();
// TODO maybe we should define concrete event types here
DerivationEventType eventType = DerivationEventType.ACCESSIONING();
DerivationEvent lastDerivationEvent = DerivationEvent.NewInstance(eventType);
DerivationEvent middleDerivationEvent = DerivationEvent.NewInstance(eventType);
firstDerivationEvent = DerivationEvent.NewInstance(eventType);
collectionSpecimen.setDerivedFrom(lastDerivationEvent);
lastDerivationEvent.addOriginal(middleSpecimen);
middleSpecimen.setDerivedFrom(firstDerivationEvent);
firstDerivationEvent.addOriginal(firstFieldObject);
existingGatheringEvent = GatheringEvent.NewInstance();
firstFieldObject.setGatheringEvent(existingGatheringEvent);
// empty facade
emptyFacade = DerivedUnitFacade.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
}
use of eu.etaxonomy.cdm.model.occurrence.DerivationEventType in project cdmlib by cybertaxonomy.
the class DerivedUnitFacade method getDerivationEvent.
/**
* Returns the derivation event. If no derivation event exists and <code>createIfNotExists</code>
* is <code>true</code> a new derivation event is created and returned.
* Otherwise <code>null</code> is returned.
* @param createIfNotExists
*/
private DerivationEvent getDerivationEvent(boolean createIfNotExists) {
DerivationEvent result = null;
if (derivedUnit != null) {
result = derivedUnit.getDerivedFrom();
} else {
return null;
}
if (result == null && createIfNotExists) {
DerivationEventType type = null;
if (isAccessioned(derivedUnit)) {
type = DerivationEventType.ACCESSIONING();
}
result = DerivationEvent.NewInstance(type);
derivedUnit.setDerivedFrom(result);
}
return result;
}
Aggregations