use of eu.etaxonomy.cdm.model.description.TextFormat in project cdmlib by cybertaxonomy.
the class FullCoverageDataGenerator method createDescriptions.
private void createDescriptions(List<CdmBase> cdmBases) {
TermVocabulary<AnnotationType> voc = TermVocabulary.NewInstance(TermType.AnnotationType, AnnotationType.class, "my termVoc desc", "myTerm voc", "mtv", URI.create("http://www.abc.de"));
handleIdentifiableEntity(voc);
cdmBases.add(voc);
Representation rep = voc.getRepresentations().iterator().next();
handleAnnotatableEntity(rep);
// Representation engRep = Language.ENGLISH().getRepresentations().iterator().next();
// handleAnnotatableEntity(engRep);
// cdmBases.add(engRep); //needed?
// Categorical data
State state = State.NewInstance("Test state", "state", "st.");
state.addMedia(Media.NewInstance());
cdmBases.add(state);
CategoricalData categoricalData = CategoricalData.NewInstance(state, Feature.CONSERVATION());
StateData stateData = categoricalData.getStateData().get(0);
stateData.addModifier(DefinedTerm.SEX_FEMALE());
handleAnnotatableEntity(categoricalData);
State nextState = State.NewInstance();
cdmBases.add(nextState);
StateData stateData2 = StateData.NewInstance(nextState);
stateData2.setCount(3);
stateData2.putModifyingText(Language.ENGLISH(), "State2 modifying text");
categoricalData.addStateData(stateData2);
categoricalData.setOrderRelevant(true);
// Quantitative data
Feature leaveLength = Feature.NewInstance("Leave length description", "leave length", "l.l.");
cdmBases.add(leaveLength);
leaveLength.setSupportsQuantitativeData(true);
QuantitativeData quantitativeData = QuantitativeData.NewInstance(leaveLength);
MeasurementUnit measurementUnit = MeasurementUnit.NewInstance("Measurement Unit", "munit", null);
cdmBases.add(measurementUnit);
quantitativeData.setUnit(measurementUnit);
quantitativeData.setUuid(UUID.fromString("920fce5e-4913-4a3f-89bf-1611f5081869"));
StatisticalMeasurementValue statisticalMeasurementValue = quantitativeData.setAverage(new BigDecimal("22.9215"), null);
handleAnnotatableEntity(quantitativeData);
handleIdentifiableEntity(measurementUnit);
DefinedTerm valueModifier = DefinedTerm.NewModifierInstance("about", "about", null);
statisticalMeasurementValue.addModifier(valueModifier);
cdmBases.add(valueModifier);
// Feature
TermVocabulary<DefinedTerm> recommendedModifierEnumeration = TermVocabulary.NewInstance(TermType.Modifier, DefinedTerm.class);
leaveLength.addRecommendedModifierEnumeration(recommendedModifierEnumeration);
cdmBases.add(recommendedModifierEnumeration);
TermVocabulary<State> supportedCategoricalEnumeration = TermVocabulary.NewInstance(TermType.State, State.class);
leaveLength.addSupportedCategoricalEnumeration(supportedCategoricalEnumeration);
cdmBases.add(supportedCategoricalEnumeration);
leaveLength.addRecommendedMeasurementUnit(measurementUnit);
leaveLength.addRecommendedStatisticalMeasure(StatisticalMeasure.AVERAGE());
// CommonTaxonName
CommonTaxonName commonTaxonName = CommonTaxonName.NewInstance("common name", Language.ENGLISH(), Country.UNITEDSTATESOFAMERICA());
handleAnnotatableEntity(commonTaxonName);
// TextData
TextData textData = TextData.NewInstance(Feature.DIAGNOSIS());
Language eng = Language.ENGLISH();
textData.putText(eng, "My text data");
LanguageString languageString = textData.getLanguageText(eng);
Taxon referencedTaxon = getTaxon();
cdmBases.add(referencedTaxon);
languageString.addIntextReference(IntextReference.NewInstance(referencedTaxon, languageString, 2, 5));
textData.putModifyingText(eng, "nice diagnosis");
handleAnnotatableEntity(textData);
handleAnnotatableEntity(languageString);
TextFormat format = TextFormat.NewInstance("format", "format", null);
textData.setFormat(format);
cdmBases.add(format);
handleAnnotatableEntity(format);
// IndividualsAssociation
DerivedUnit specimen = DerivedUnit.NewInstance(SpecimenOrObservationType.PreservedSpecimen);
IndividualsAssociation indAssoc = IndividualsAssociation.NewInstance(specimen);
indAssoc.putDescription(Language.ENGLISH(), "description for individuals association");
handleAnnotatableEntity(indAssoc);
// TaxonInteraction
TaxonInteraction taxonInteraction = TaxonInteraction.NewInstance(Feature.HOSTPLANT());
taxonInteraction.putDescription(Language.ENGLISH(), "interaction description");
handleAnnotatableEntity(taxonInteraction);
// Distribution
NamedArea inCountryArea = NamedArea.NewInstance("My area in a country", "my area", "ma");
inCountryArea.addCountry(Country.TURKEYREPUBLICOF());
cdmBases.add(inCountryArea);
Distribution distribution = Distribution.NewInstance(inCountryArea, PresenceAbsenceTerm.CULTIVATED());
handleAnnotatableEntity(distribution);
// TemporalData
Feature floweringSeason = Feature.FLOWERING_PERIOD();
TemporalData temporalData = TemporalData.NewInstance(ExtendedTimePeriod.NewExtendedMonthInstance(5, 8, 4, 9));
temporalData.setFeature(floweringSeason);
temporalData.getPeriod().setFreeText("My temporal text");
handleAnnotatableEntity(temporalData);
temporalData.setUuid(UUID.fromString("9a1c91c0-fc58-4310-94cb-8c26115985d3"));
Taxon taxon = getTaxon();
TaxonDescription taxonDescription = TaxonDescription.NewInstance(taxon);
taxonDescription.addElements(categoricalData, quantitativeData, textData, commonTaxonName, taxonInteraction, indAssoc, distribution, temporalData);
DerivedUnit describedSpecimenOrObservation = DerivedUnit.NewInstance(SpecimenOrObservationType.DerivedUnit);
taxonDescription.setDescribedSpecimenOrObservation(describedSpecimenOrObservation);
taxonDescription.addScope(DefinedTerm.SEX_FEMALE());
taxonDescription.addGeoScope(Country.GERMANY());
handleIdentifiableEntity(taxonDescription);
taxon.addAggregationSource(taxonDescription);
cdmBases.add(taxon);
// DescriptionElmenetBase + source
textData.addMedia(Media.NewInstance());
textData.addModifier(DefinedTerm.SEX_HERMAPHRODITE());
textData.putModifyingText(Language.ENGLISH(), "no modification");
textData.setTimeperiod(TimePeriodParser.parseString("1970-1980"));
Reference ref = ReferenceFactory.newArticle();
DescriptionElementSource source = textData.addSource(OriginalSourceType.Import, "22", "taxon description table", ref, "detail");
source.setNameUsedInSource(TaxonNameFactory.NewBotanicalInstance(Rank.GENUS()));
ExternalLink link = ExternalLink.NewInstance(ExternalLinkType.WebSite, URI.create("http://wwww.abd.de"), "Somehow useful link", 445);
source.addLink(link);
handleAnnotatableEntity(source);
// as long as it still exists
taxonDescription.addDescriptionSource(ref);
// Specimen description
SpecimenOrObservationBase<?> describedSpecimen = getSpecimen();
SpecimenDescription specDesc = SpecimenDescription.NewInstance(specimen);
cdmBases.add(describedSpecimen);
handleAnnotatableEntity(specDesc);
// Name description
TaxonName name = TaxonNameFactory.NewBotanicalInstance(Rank.GENUS());
TaxonNameDescription nameDesc = TaxonNameDescription.NewInstance(name);
cdmBases.add(name);
handleAnnotatableEntity(nameDesc);
// Feature Tree
TermTree<Feature> featureTree = TermTree.NewFeatureInstance();
// featureTree
TermNode<Feature> descriptionTermNode = featureTree.getRoot().addChild(Feature.DESCRIPTION());
TermNode<Feature> leaveLengthNode = descriptionTermNode.addChild(leaveLength);
handleIdentifiableEntity(featureTree);
State inapplicableState = State.NewInstance("inapplicableState", "inapplicableState", null);
State applicableState = State.NewInstance("only applicable state", "only applicable state", null);
cdmBases.add(applicableState);
cdmBases.add(inapplicableState);
// this is semantically not correct, should be a parent feature
leaveLengthNode.addInapplicableState(leaveLength, inapplicableState);
leaveLengthNode.addApplicableState(leaveLength, applicableState);
cdmBases.add(featureTree);
cdmBases.add(leaveLengthNode);
// DescriptiveDataSet
DescriptiveDataSet descriptiveDataSet = DescriptiveDataSet.NewInstance();
descriptiveDataSet.addDescription(taxonDescription);
descriptiveDataSet.setLabel("My Descriptive Dataset");
descriptiveDataSet.getDescriptiveSystem();
handleAnnotatableEntity(descriptiveDataSet);
descriptiveDataSet.addGeoFilterArea(Country.GERMANY());
Classification classification = Classification.NewInstance("DescriptiveDataSet subtree classification");
Taxon subTreeTaxon = getTaxon();
TaxonNode subtree = classification.addChildTaxon(subTreeTaxon, null, null);
descriptiveDataSet.addTaxonSubtree(subtree);
cdmBases.add(classification);
cdmBases.add(subtree);
// polytomous keys
Taxon coveredTaxon = Taxon.NewInstance(name, null);
PolytomousKey key = PolytomousKey.NewTitledInstance("My Polykey");
handleIdentificationKey(key, taxon, coveredTaxon);
key.setStartNumber(10);
PolytomousKeyNode firstChildNode = PolytomousKeyNode.NewInstance("Green", "What is the leave length?", coveredTaxon, leaveLength);
key.getRoot().addChild(firstChildNode);
PolytomousKeyNode secondChildNode = PolytomousKeyNode.NewInstance("234");
firstChildNode.addChild(secondChildNode);
PolytomousKey subkey = PolytomousKey.NewTitledInstance("Sub-key");
firstChildNode.setSubkey(subkey);
PolytomousKeyNode subKeyNode = PolytomousKeyNode.NewInstance("sub key couplet");
subkey.getRoot().addChild(subKeyNode);
secondChildNode.setOtherNode(subKeyNode);
secondChildNode.putModifyingText(Language.GERMAN(), "manchmal");
cdmBases.add(key);
cdmBases.add(subkey);
MediaKey mediaKey = MediaKey.NewInstance();
mediaKey.addKeyRepresentation(Representation.NewInstance("Media Key Representation", "media key", null, Language.ENGLISH()));
handleIdentificationKey(mediaKey, taxon, coveredTaxon);
MultiAccessKey multiAccessKey = MultiAccessKey.NewInstance();
handleIdentificationKey(multiAccessKey, taxon, coveredTaxon);
cdmBases.add(mediaKey);
cdmBases.add(multiAccessKey);
}
use of eu.etaxonomy.cdm.model.description.TextFormat in project cdmlib by cybertaxonomy.
the class DbImportTextDataCreationMapper method createObject.
// ************************************ METHODS *******************************************/
@Override
protected TextData createObject(ResultSet rs) throws SQLException {
TextData textData = TextData.NewInstance();
String text = null;
if (StringUtils.isNotBlank(dbTextAttribute)) {
text = rs.getString(dbTextAttribute);
}
if (text != null) {
Language language = this.defaultLanguage;
if (language == null) {
language = Language.DEFAULT();
}
textData.putText(language, text);
}
TextFormat format = this.defaultFormat;
textData.setFormat(format);
Feature feature = this.defaultFeature;
textData.setFeature(feature);
return textData;
}
use of eu.etaxonomy.cdm.model.description.TextFormat in project cdmlib by cybertaxonomy.
the class DbImportTextDataCreationMapper method NewInstance.
// ******************************** FACTORY METHOD ***************************************************/
/**
* Creates a TextData and adds it to the description of a taxon.
* @param dbIdAttribute
* @param objectToCreateNamespace
* @param dbTaxonFkAttribute
* @param taxonNamespace
* @return
*/
public static DbImportTextDataCreationMapper<?> NewInstance(String dbIdAttribute, String objectToCreateNamespace, String dbTaxonFkAttribute, String taxonNamespace) {
Feature feature = null;
Language language = null;
TextFormat format = null;
String dbTextAttribute = null;
return new DbImportTextDataCreationMapper<>(dbIdAttribute, objectToCreateNamespace, dbTaxonFkAttribute, taxonNamespace, dbTextAttribute, language, feature, format);
}
Aggregations