Search in sources :

Example 1 with TaxonInteraction

use of eu.etaxonomy.cdm.model.description.TaxonInteraction in project cdmlib by cybertaxonomy.

the class ReferencingObjectFormatter method getCache.

// from taxeditor DescriptionHelper
private static String getCache(DescriptionElementBase element, Language defaultLanguage) {
    String mainElementLabel = null;
    DescriptionBase<?> descr = element.getInDescription();
    descr = CdmBase.deproxy(descr);
    if (descr != null) {
        if (descr.isInstanceOf(TaxonDescription.class)) {
            Taxon taxon = CdmBase.deproxy(descr, TaxonDescription.class).getTaxon();
            if (taxon != null) {
                mainElementLabel = taxon.getTitleCache();
            }
        } else if (descr.isInstanceOf(SpecimenDescription.class)) {
            SpecimenOrObservationBase<?> specimen = CdmBase.deproxy(descr, SpecimenDescription.class).getDescribedSpecimenOrObservation();
            if (specimen != null) {
                mainElementLabel = specimen.getTitleCache();
            }
        } else if (descr.isInstanceOf(TaxonNameDescription.class)) {
            TaxonName name = CdmBase.deproxy(descr, TaxonNameDescription.class).getTaxonName();
            if (name != null) {
                mainElementLabel = name.getTitleCache();
            }
        }
    }
    String cache = null;
    if (element instanceof TextData) {
        // cache = ((TextData) element).getText(language);
        cache = "Text Data";
    }
    if (element instanceof CommonTaxonName) {
        cache = ((CommonTaxonName) element).getName();
    }
    if (element instanceof TaxonInteraction) {
        Taxon taxon2 = ((TaxonInteraction) element).getTaxon2();
        if (taxon2 != null && taxon2.getName() != null) {
            cache = taxon2.getName().getTitleCache();
        } else {
            cache = "No taxon chosen";
        }
    }
    if (element instanceof Distribution) {
        Distribution distribution = (Distribution) element;
        NamedArea area = distribution.getArea();
        if (area != null) {
            cache = area.getLabel();
            PresenceAbsenceTerm status = distribution.getStatus();
            if (status == null) {
                cache += ", no status";
            } else {
                cache += ", " + status.getLabel();
            }
        }
    }
    String result = cache == null ? "" : cache;
    if (isNotBlank(mainElementLabel)) {
        result = CdmUtils.concat(" ", result, "(" + mainElementLabel + ")");
    }
    return result;
}
Also used : CommonTaxonName(eu.etaxonomy.cdm.model.description.CommonTaxonName) SpecimenDescription(eu.etaxonomy.cdm.model.description.SpecimenDescription) TaxonNameDescription(eu.etaxonomy.cdm.model.description.TaxonNameDescription) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) TaxonInteraction(eu.etaxonomy.cdm.model.description.TaxonInteraction) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) NamedArea(eu.etaxonomy.cdm.model.location.NamedArea) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) TextData(eu.etaxonomy.cdm.model.description.TextData) Distribution(eu.etaxonomy.cdm.model.description.Distribution) SpecimenOrObservationBase(eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase) PresenceAbsenceTerm(eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm) CommonTaxonName(eu.etaxonomy.cdm.model.description.CommonTaxonName) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName)

Example 2 with TaxonInteraction

use of eu.etaxonomy.cdm.model.description.TaxonInteraction 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 3 with TaxonInteraction

use of eu.etaxonomy.cdm.model.description.TaxonInteraction in project cdmlib by cybertaxonomy.

the class DescriptionElementFormatter method format.

public static String format(DescriptionElementBase element, Language defaultLanguage) {
    // String mainElementLabel= null;
    // DescriptionBase<?> descr = element.getInDescription();
    // descr = CdmBase.deproxy(descr);
    // 
    // if (descr != null){
    // IDescribable<?> target = CdmBase.deproxy(descr.describedEntity());
    // if (target != null){
    // mainElementLabel = target.getTitleCache();
    // }else{
    // return descr.getTitleCache();
    // }
    // }
    String cache = null;
    if (element instanceof TextData) {
        // cache = ((TextData) element).getText(language);
        cache = "Text Data";
    }
    if (element instanceof CommonTaxonName) {
        cache = ((CommonTaxonName) element).getName();
    }
    if (element instanceof TaxonInteraction) {
        Taxon taxon2 = ((TaxonInteraction) element).getTaxon2();
        if (taxon2 != null && taxon2.getName() != null) {
            cache = taxon2.getName().getTitleCache();
        } else {
            cache = "No taxon chosen";
        }
    }
    if (element instanceof Distribution) {
        Distribution distribution = (Distribution) element;
        NamedArea area = distribution.getArea();
        if (area != null) {
            cache = area.getLabel();
            PresenceAbsenceTerm status = distribution.getStatus();
            if (status == null) {
                cache += ", no status";
            } else {
                cache += ", " + status.getLabel();
            }
        }
    }
    String result = cache == null ? "" : cache;
    // }
    return result;
}
Also used : CommonTaxonName(eu.etaxonomy.cdm.model.description.CommonTaxonName) TextData(eu.etaxonomy.cdm.model.description.TextData) TaxonInteraction(eu.etaxonomy.cdm.model.description.TaxonInteraction) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) Distribution(eu.etaxonomy.cdm.model.description.Distribution) PresenceAbsenceTerm(eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm) NamedArea(eu.etaxonomy.cdm.model.location.NamedArea)

Example 4 with TaxonInteraction

use of eu.etaxonomy.cdm.model.description.TaxonInteraction in project cdmlib by cybertaxonomy.

the class CdmLightClassificationExport method handleTaxonInteractionsFacts.

private void handleTaxonInteractionsFacts(CdmLightExportState state, CdmBase cdmBase, List<DescriptionElementBase> taxonInteractionsFacts) {
    CdmLightExportTable table = CdmLightExportTable.TAXON_INTERACTION_FACT;
    String titleCache = null;
    if (cdmBase instanceof TaxonBase) {
        titleCache = ((TaxonBase) cdmBase).getTitleCache();
    }
    for (DescriptionElementBase element : taxonInteractionsFacts) {
        try {
            String[] csvLine = new String[table.getSize()];
            csvLine[table.getIndex(CdmLightExportTable.FACT_ID)] = getId(state, element);
            handleSource(state, element, table);
            csvLine[table.getIndex(CdmLightExportTable.TAXON_FK)] = getId(state, cdmBase);
            csvLine[table.getIndex(CdmLightExportTable.TAXON2_FK)] = getId(state, ((TaxonInteraction) element).getTaxon2());
            csvLine[table.getIndex(CdmLightExportTable.DESCRIPTION)] = createMultilanguageString(((TaxonInteraction) element).getDescription());
            state.getProcessor().put(table, element, csvLine);
        } catch (Exception e) {
            state.getResult().addException(e, "An unexpected error occurred when handling taxon interaction" + cdmBaseStr(element) + (titleCache != null ? (" " + titleCache) : "") + ": " + e.getMessage());
        }
    }
}
Also used : TaxonBase(eu.etaxonomy.cdm.model.taxon.TaxonBase) TaxonInteraction(eu.etaxonomy.cdm.model.description.TaxonInteraction) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) UnknownCdmTypeException(eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException) DescriptionElementBase(eu.etaxonomy.cdm.model.description.DescriptionElementBase)

Example 5 with TaxonInteraction

use of eu.etaxonomy.cdm.model.description.TaxonInteraction in project cdmlib by cybertaxonomy.

the class DwcaResourceRelationExport method handleTaxonNode.

@Override
protected void handleTaxonNode(DwcaTaxExportState state, TaxonNode node) throws FileNotFoundException, UnsupportedEncodingException, IOException {
    try {
        DwcaTaxExportConfigurator config = state.getConfig();
        Taxon taxon = CdmBase.deproxy(node.getTaxon());
        // taxon interactions
        Set<TaxonDescription> descriptions = taxon.getDescriptions();
        for (TaxonDescription description : descriptions) {
            for (DescriptionElementBase el : description.getElements()) {
                if (el.isInstanceOf(TaxonInteraction.class)) {
                    DwcaResourceRelationRecord record = new DwcaResourceRelationRecord(metaRecord, config);
                    TaxonInteraction taxonInteraction = CdmBase.deproxy(el, TaxonInteraction.class);
                    if (!state.recordExistsUuid(taxonInteraction)) {
                        handleInteraction(state, record, taxon, taxonInteraction);
                        PrintWriter writer = createPrintWriter(state, file);
                        record.write(state, writer);
                        state.addExistingRecordUuid(taxonInteraction);
                    }
                }
            }
        }
        // concept relationships
        for (TaxonRelationship rel : taxon.getTaxonRelations()) {
            DwcaResourceRelationRecord record = new DwcaResourceRelationRecord(metaRecord, config);
            IdentifiableEntity<?> subject = rel.getFromTaxon();
            IdentifiableEntity<?> object = rel.getToTaxon();
            if (rel.getType().isAnyMisappliedName()) {
                // misapplied names are handled in core (tax)
                continue;
            }
            if (!state.recordExistsUuid(rel)) {
                handleRelationship(record, subject, object, rel, false);
                PrintWriter writer = createPrintWriter(state, file);
                record.write(state, writer);
                state.addExistingRecordUuid(rel);
            }
        }
        // Name relationship
        // TODO
        INonViralName name = taxon.getName();
        if (name == null) {
            String message = "There is a taxon node without name: " + node.getId();
            state.getResult().addError(message, "DwcaResourceRelationExport.makeSingleTaxonNode");
            return;
        }
        Set<NameRelationship> rels = name.getNameRelations();
        for (NameRelationship rel : rels) {
            DwcaResourceRelationRecord record = new DwcaResourceRelationRecord(metaRecord, config);
            IdentifiableEntity<?> subject = CdmBase.deproxy(rel.getFromName());
            IdentifiableEntity<?> object = CdmBase.deproxy(rel.getToName());
            name = CdmBase.deproxy(name);
            boolean isInverse = false;
            if (subject == name) {
                subject = taxon;
            } else if (object == name) {
                object = subject;
                subject = taxon;
                isInverse = true;
            } else {
                String message = "Both, subject and object, are not part of the relationship for " + name.getTitleCache();
                state.getResult().addWarning(message);
            }
            if (!state.recordExistsUuid(rel)) {
                // ????
                handleRelationship(record, subject, object, rel, isInverse);
                PrintWriter writer = createPrintWriter(state, file);
                record.write(state, writer);
                state.addExistingRecordUuid(rel);
            }
        }
    } catch (Exception e) {
        String message = "Unexpected exception: " + e.getMessage();
        state.getResult().addException(e, message);
    } finally {
        flushWriter(state, file);
    }
    return;
}
Also used : TaxonRelationship(eu.etaxonomy.cdm.model.taxon.TaxonRelationship) INonViralName(eu.etaxonomy.cdm.model.name.INonViralName) NameRelationship(eu.etaxonomy.cdm.model.name.NameRelationship) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) TaxonInteraction(eu.etaxonomy.cdm.model.description.TaxonInteraction) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) DescriptionElementBase(eu.etaxonomy.cdm.model.description.DescriptionElementBase) PrintWriter(java.io.PrintWriter)

Aggregations

TaxonInteraction (eu.etaxonomy.cdm.model.description.TaxonInteraction)5 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)4 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)4 CommonTaxonName (eu.etaxonomy.cdm.model.description.CommonTaxonName)3 Distribution (eu.etaxonomy.cdm.model.description.Distribution)3 TaxonDescription (eu.etaxonomy.cdm.model.description.TaxonDescription)3 TextData (eu.etaxonomy.cdm.model.description.TextData)3 NamedArea (eu.etaxonomy.cdm.model.location.NamedArea)3 DescriptionElementBase (eu.etaxonomy.cdm.model.description.DescriptionElementBase)2 PresenceAbsenceTerm (eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm)2 SpecimenDescription (eu.etaxonomy.cdm.model.description.SpecimenDescription)2 TaxonNameDescription (eu.etaxonomy.cdm.model.description.TaxonNameDescription)2 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)2 AnnotationType (eu.etaxonomy.cdm.model.common.AnnotationType)1 IntextReference (eu.etaxonomy.cdm.model.common.IntextReference)1 Language (eu.etaxonomy.cdm.model.common.Language)1 CategoricalData (eu.etaxonomy.cdm.model.description.CategoricalData)1 DescriptionElementSource (eu.etaxonomy.cdm.model.description.DescriptionElementSource)1 DescriptiveDataSet (eu.etaxonomy.cdm.model.description.DescriptiveDataSet)1 Feature (eu.etaxonomy.cdm.model.description.Feature)1