Search in sources :

Example 1 with TextFormat

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);
}
Also used : TaxonNode(eu.etaxonomy.cdm.model.taxon.TaxonNode) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) QuantitativeData(eu.etaxonomy.cdm.model.description.QuantitativeData) Feature(eu.etaxonomy.cdm.model.description.Feature) AnnotationType(eu.etaxonomy.cdm.model.common.AnnotationType) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) MediaKey(eu.etaxonomy.cdm.model.description.MediaKey) Language(eu.etaxonomy.cdm.model.common.Language) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) TextData(eu.etaxonomy.cdm.model.description.TextData) Classification(eu.etaxonomy.cdm.model.taxon.Classification) TextFormat(eu.etaxonomy.cdm.model.description.TextFormat) CommonTaxonName(eu.etaxonomy.cdm.model.description.CommonTaxonName) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) StatisticalMeasurementValue(eu.etaxonomy.cdm.model.description.StatisticalMeasurementValue) PolytomousKey(eu.etaxonomy.cdm.model.description.PolytomousKey) MeasurementUnit(eu.etaxonomy.cdm.model.description.MeasurementUnit) CommonTaxonName(eu.etaxonomy.cdm.model.description.CommonTaxonName) SpecimenDescription(eu.etaxonomy.cdm.model.description.SpecimenDescription) TaxonNameDescription(eu.etaxonomy.cdm.model.description.TaxonNameDescription) Reference(eu.etaxonomy.cdm.model.reference.Reference) IntextReference(eu.etaxonomy.cdm.model.common.IntextReference) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) TaxonInteraction(eu.etaxonomy.cdm.model.description.TaxonInteraction) MultiAccessKey(eu.etaxonomy.cdm.model.description.MultiAccessKey) Representation(eu.etaxonomy.cdm.model.term.Representation) MediaRepresentation(eu.etaxonomy.cdm.model.media.MediaRepresentation) NamedArea(eu.etaxonomy.cdm.model.location.NamedArea) StateData(eu.etaxonomy.cdm.model.description.StateData) BigDecimal(java.math.BigDecimal) ExternalLink(eu.etaxonomy.cdm.model.media.ExternalLink) DescriptiveDataSet(eu.etaxonomy.cdm.model.description.DescriptiveDataSet) State(eu.etaxonomy.cdm.model.description.State) IndividualsAssociation(eu.etaxonomy.cdm.model.description.IndividualsAssociation) CategoricalData(eu.etaxonomy.cdm.model.description.CategoricalData) Distribution(eu.etaxonomy.cdm.model.description.Distribution) TemporalData(eu.etaxonomy.cdm.model.description.TemporalData) DescriptionElementSource(eu.etaxonomy.cdm.model.description.DescriptionElementSource) PolytomousKeyNode(eu.etaxonomy.cdm.model.description.PolytomousKeyNode) DefinedTerm(eu.etaxonomy.cdm.model.term.DefinedTerm)

Example 2 with TextFormat

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;
}
Also used : Language(eu.etaxonomy.cdm.model.common.Language) TextData(eu.etaxonomy.cdm.model.description.TextData) TextFormat(eu.etaxonomy.cdm.model.description.TextFormat) Feature(eu.etaxonomy.cdm.model.description.Feature)

Example 3 with TextFormat

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);
}
Also used : Language(eu.etaxonomy.cdm.model.common.Language) TextFormat(eu.etaxonomy.cdm.model.description.TextFormat) Feature(eu.etaxonomy.cdm.model.description.Feature)

Aggregations

Language (eu.etaxonomy.cdm.model.common.Language)3 Feature (eu.etaxonomy.cdm.model.description.Feature)3 TextFormat (eu.etaxonomy.cdm.model.description.TextFormat)3 TextData (eu.etaxonomy.cdm.model.description.TextData)2 AnnotationType (eu.etaxonomy.cdm.model.common.AnnotationType)1 IntextReference (eu.etaxonomy.cdm.model.common.IntextReference)1 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)1 CategoricalData (eu.etaxonomy.cdm.model.description.CategoricalData)1 CommonTaxonName (eu.etaxonomy.cdm.model.description.CommonTaxonName)1 DescriptionElementSource (eu.etaxonomy.cdm.model.description.DescriptionElementSource)1 DescriptiveDataSet (eu.etaxonomy.cdm.model.description.DescriptiveDataSet)1 Distribution (eu.etaxonomy.cdm.model.description.Distribution)1 IndividualsAssociation (eu.etaxonomy.cdm.model.description.IndividualsAssociation)1 MeasurementUnit (eu.etaxonomy.cdm.model.description.MeasurementUnit)1 MediaKey (eu.etaxonomy.cdm.model.description.MediaKey)1 MultiAccessKey (eu.etaxonomy.cdm.model.description.MultiAccessKey)1 PolytomousKey (eu.etaxonomy.cdm.model.description.PolytomousKey)1 PolytomousKeyNode (eu.etaxonomy.cdm.model.description.PolytomousKeyNode)1 QuantitativeData (eu.etaxonomy.cdm.model.description.QuantitativeData)1 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)1