Search in sources :

Example 1 with AnnotationType

use of eu.etaxonomy.cdm.model.common.AnnotationType in project cdmlib by cybertaxonomy.

the class MarkupFeatureImport method handleChar.

/**
 * Handle the char or subchar element. As
 * @param state the import state
 * @param reader
 * @param parentEvent
 * @param parentFeature in case of subchars we need to attache the newly created feature to a parent feature, should be <code>null</code>
 * for top level chars.
 * @return List of TextData. Not a single one as the recursive TextData will also be returned
 * @throws XMLStreamException
 */
private List<TextData> handleChar(MarkupImportState state, XMLEventReader reader, XMLEvent parentEvent, Feature parentFeature, CharOrder myCharOrder) throws XMLStreamException {
    List<TextData> result = new ArrayList<>();
    String classValue = getClassOnlyAttribute(parentEvent);
    Feature feature = makeFeature(classValue, state, parentEvent, parentFeature);
    if (parentFeature == null) {
        state.putFeatureToCharSorterList(feature);
    } else {
        FeatureSorterInfo parentInfo = state.getLatestCharFeatureSorterInfo();
        // if (! parentInfo.getUuid().equals(parentFeature.getUuid())){
        // String message = "The parent char feature is not the same as the latest feature. This is the case for char hierarchies with > 2 levels, which is not yet handled by the import";
        // fireWarningEvent(message, parentEvent, 6);
        // }else{
        state.getLatestCharFeatureSorterInfo().addSubFeature(new FeatureSorterInfo(feature));
    // }
    }
    TextData textData = TextData.NewInstance(feature);
    textData.addPrimaryTaxonomicSource(state.getConfig().getSourceReference());
    result.add(textData);
    AnnotationType annType = getAnnotationType(state, MarkupTransformer.uuidOriginalOrder, "Original order", "Order in original treatment", null, AnnotationType.TECHNICAL().getVocabulary());
    textData.addAnnotation(Annotation.NewInstance(myCharOrder.orderString(), annType, Language.ENGLISH()));
    boolean isTextMode = true;
    String text = "";
    while (reader.hasNext()) {
        XMLEvent next = readNoWhitespace(reader);
        if (isMyEndingElement(next, parentEvent)) {
            text = text.trim();
            textData.putText(getDefaultLanguage(state), text);
            return result;
        } else if (isStartingElement(next, FIGURE_REF)) {
            // TODO
            handleNotYetImplementedElement(next);
        } else if (isStartingElement(next, FOOTNOTE_REF)) {
            // TODO
            handleNotYetImplementedElement(next);
        } else if (isStartingElement(next, BR)) {
            text += "<br/>";
            isTextMode = false;
        } else if (isEndingElement(next, BR)) {
            isTextMode = true;
        } else if (isHtml(next)) {
            text += getXmlTag(next);
        } else if (next.isStartElement()) {
            if (isStartingElement(next, ANNOTATION)) {
                // TODO test handleSimpleAnnotation
                handleNotYetImplementedElement(next);
            } else if (isStartingElement(next, ITALICS)) {
                handleNotYetImplementedElement(next);
            } else if (isStartingElement(next, BOLD)) {
                handleNotYetImplementedElement(next);
            } else if (isStartingElement(next, FIGURE)) {
                handleFigure(state, reader, next, specimenImport, nomenclatureImport);
            } else if (isStartingElement(next, SUB_CHAR)) {
                List<TextData> subTextData = handleChar(state, reader, next, feature, myCharOrder.nextChild());
                result.addAll(subTextData);
            } else if (isStartingElement(next, FOOTNOTE)) {
                FootnoteDataHolder footnote = handleFootnote(state, reader, next, specimenImport, nomenclatureImport);
                if (footnote.isRef()) {
                    String message = "Ref footnote not implemented here";
                    fireWarningEvent(message, next, 4);
                } else {
                    registerGivenFootnote(state, footnote);
                }
            } else {
                handleUnexpectedStartElement(next.asStartElement());
            }
        } else if (next.isCharacters()) {
            if (!isTextMode) {
                String message = "String is not in text mode";
                fireWarningEvent(message, next, 6);
            } else {
                text += next.asCharacters().getData();
            }
        } else {
            handleUnexpectedEndElement(next.asEndElement());
        }
    }
    throw new IllegalStateException("RefPart has no closing tag");
}
Also used : TextData(eu.etaxonomy.cdm.model.description.TextData) ArrayList(java.util.ArrayList) XMLEvent(javax.xml.stream.events.XMLEvent) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) Feature(eu.etaxonomy.cdm.model.description.Feature) AnnotationType(eu.etaxonomy.cdm.model.common.AnnotationType)

Example 2 with AnnotationType

use of eu.etaxonomy.cdm.model.common.AnnotationType in project cdmlib by cybertaxonomy.

the class CdmImportBase method getAnnotationType.

protected AnnotationType getAnnotationType(STATE state, UUID uuid, String label, String text, String labelAbbrev, TermVocabulary<AnnotationType> voc) {
    if (uuid == null) {
        uuid = UUID.randomUUID();
    }
    AnnotationType annotationType = state.getAnnotationType(uuid);
    if (annotationType == null) {
        annotationType = (AnnotationType) getTermService().find(uuid);
        if (annotationType == null) {
            annotationType = AnnotationType.NewInstance(label, text, labelAbbrev);
            annotationType.setUuid(uuid);
            if (voc == null) {
                boolean isOrdered = false;
                voc = getVocabulary(state, TermType.AnnotationType, uuidUserDefinedAnnotationTypeVocabulary, "User defined vocabulary for annotation types", "User Defined Annotation Types", null, null, isOrdered, annotationType);
            }
            voc.addTerm(annotationType);
            getTermService().save(annotationType);
        }
        state.putAnnotationType(annotationType);
    }
    return annotationType;
}
Also used : AnnotationType(eu.etaxonomy.cdm.model.common.AnnotationType)

Example 3 with AnnotationType

use of eu.etaxonomy.cdm.model.common.AnnotationType 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 4 with AnnotationType

use of eu.etaxonomy.cdm.model.common.AnnotationType in project cdmlib by cybertaxonomy.

the class SDDDocumentBuilder method buildScope.

/**
 * Builds Scope associated with a CodedDescription
 */
public void buildScope(ElementImpl element, TaxonDescription taxonDescription) throws ParseException {
    // <Scope>
    // <TaxonName ref="t1"/>
    // <Citation ref="p1" location="p. 30"/>
    // </Scope>
    ElementImpl scope = new ElementImpl(document, SCOPE);
    Taxon taxon = taxonDescription.getTaxon();
    if (taxon != null) {
        TaxonName taxonName = taxon.getName();
        if (taxonName != null) {
            String ref = taxonNames.get(taxonName);
            if (!ref.equals("")) {
                ElementImpl taxonNameEl = new ElementImpl(document, TAXON_NAME);
                taxonNameEl.setAttribute(REF, ref);
                scope.appendChild(taxonNameEl);
            }
        }
    }
    Set<Reference> descriptionSources = new HashSet<Reference>();
    for (IdentifiableSource source : taxonDescription.getSources()) {
        descriptionSources.add(source.getCitation());
    }
    for (Iterator<Reference> rb = descriptionSources.iterator(); rb.hasNext(); ) {
        Reference descriptionSource = rb.next();
        if (descriptionSource.getType().equals(ReferenceType.Article)) {
            ElementImpl citation = new ElementImpl(document, CITATION);
            articlesCount = buildReference(descriptionSource, articles, REF, citation, "p", articlesCount);
            Set<Annotation> annotations = descriptionSource.getAnnotations();
            for (Iterator<Annotation> a = annotations.iterator(); a.hasNext(); ) {
                Annotation annotation = a.next();
                AnnotationType annotationType = annotation.getAnnotationType();
                if (annotationType != null) {
                    String type = annotationType.getLabel();
                    if (type.equals("location")) {
                        citation.setAttribute("location", annotation.getText());
                    }
                }
            }
            scope.appendChild(citation);
        }
    }
    element.appendChild(scope);
}
Also used : Reference(eu.etaxonomy.cdm.model.reference.Reference) Taxon(eu.etaxonomy.cdm.model.taxon.Taxon) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) Annotation(eu.etaxonomy.cdm.model.common.Annotation) AnnotationType(eu.etaxonomy.cdm.model.common.AnnotationType) ElementImpl(org.apache.xerces.dom.ElementImpl) TaxonName(eu.etaxonomy.cdm.model.name.TaxonName) IdentifiableSource(eu.etaxonomy.cdm.model.common.IdentifiableSource) HashSet(java.util.HashSet)

Example 5 with AnnotationType

use of eu.etaxonomy.cdm.model.common.AnnotationType in project cdmlib by cybertaxonomy.

the class SDDImport method importDataset.

// imports the complete dataset information
protected void importDataset(Element elDataset, Namespace sddNamespace, SDDImportState state) {
    // <Dataset xml:lang="en-us">
    descriptiveDataSet = DescriptiveDataSet.NewInstance();
    importDatasetLanguage(elDataset, state);
    importDatasetRepresentation(elDataset, sddNamespace);
    importRevisionData(elDataset, sddNamespace);
    importIPRStatements(elDataset, sddNamespace, state);
    importTaxonNames(elDataset, sddNamespace, state);
    importDescriptiveConcepts(elDataset, sddNamespace, state);
    importCharacters(elDataset, sddNamespace, state);
    importCharacterTrees(elDataset, sddNamespace, state);
    MarkerType editorMarkerType = getMarkerType(state, SDDTransformer.uuidMarkerEditor, "editor", "Editor", "edt");
    MarkerType geographicAreaMarkerType = getMarkerType(state, SDDTransformer.uuidMarkerSDDGeographicArea, "SDDGeographicArea", "SDDGeographicArea", "ga");
    MarkerType descriptiveConceptMarkerType = getMarkerType(state, SDDTransformer.uuidMarkerDescriptiveConcept, "DescriptiveConcept", "Descriptive Concept", "DC");
    markerTypes.add(editorMarkerType);
    markerTypes.add(geographicAreaMarkerType);
    markerTypes.add(descriptiveConceptMarkerType);
    // saving of all imported data into the CDM db
    saveVocabularies();
    saveFeatures();
    saveModifiers();
    saveStates();
    saveMarkerType();
    saveAreas(geographicAreaMarkerType);
    saveUnits();
    saveStatisticalMeasure();
    saveAnnotationType();
    importCodedDescriptions(elDataset, sddNamespace, state);
    importAgents(elDataset, sddNamespace, state);
    importPublications(elDataset, sddNamespace, state);
    importMediaObjects(elDataset, sddNamespace, state);
    importTaxonHierarchies(elDataset, sddNamespace, state);
    importGeographicAreas(elDataset, sddNamespace, state);
    importSpecimens(elDataset, sddNamespace, state);
    if ((authors != null) || (editors != null)) {
        Team team = Team.NewInstance();
        if (authors != null) {
            for (Person author : authors.values()) {
                team.addTeamMember(author);
            }
        }
        if (editors != null) {
            Marker marker = Marker.NewInstance();
            marker.setMarkerType(editorMarkerType);
            for (Person editor : editors.values()) {
                Person edit = editor;
                edit.addMarker(marker);
                team.addTeamMember(edit);
            }
        }
        sec.setAuthorship(team);
        sourceReference.setAuthorship(team);
    }
    if (copyright != null) {
        sourceReference.addRights(copyright);
        sec.addRights(copyright);
    }
    // Returns a CdmApplicationController created by the values of this configuration.
    IDescriptionService descriptionService = getDescriptionService();
    for (TaxonDescription taxonDescription : taxonDescriptions.values()) {
        // Persists a Description
        descriptionService.save(taxonDescription);
    }
    for (String ref : taxonDescriptions.keySet()) {
        TaxonDescription td = taxonDescriptions.get(ref);
        if (citations.containsKey(ref)) {
            Reference publication = publications.get(citations.get(ref));
            if (locations.containsKey(ref)) {
                Annotation location = Annotation.NewInstance(locations.get(ref), datasetLanguage);
                // TODO move to a generic place (implemented in hurry therefore dirty)
                AnnotationType annotationType = getAnnotationType(state, uuidAnnotationTypeLocation, "location", "location", "location", null);
                // annotationTypes.add(annotationType);  TODO necessary??
                location.setAnnotationType(annotationType);
                (publication).addAnnotation(location);
            }
            // TODO type
            td.addSource(OriginalSourceType.Unknown, null, null, publication, null);
        }
    }
    logger.info("end makeTaxonDescriptions ...");
    if (descriptiveConcepts != null) {
        for (Feature feature : descriptiveConcepts) {
            Marker marker = Marker.NewInstance();
            marker.setMarkerType(descriptiveConceptMarkerType);
            feature.addMarker(marker);
        }
    }
    saveFeatures();
    for (Reference publication : publications.values()) {
        getReferenceService().save(publication);
    }
    for (Reference source : sources) {
        getReferenceService().save(source);
    }
    for (TermTree<Feature> featureTree : featureTrees) {
        getTermTreeService().save(featureTree);
    }
    getDescriptiveDataSetService().save(descriptiveDataSet);
    for (Classification classification : classifications) {
        getClassificationService().save(classification);
    }
    for (DerivedUnit specimen : specimens.values()) {
        getOccurrenceService().save(specimen);
    }
    logger.info("end of persistence ...");
    return;
}
Also used : Reference(eu.etaxonomy.cdm.model.reference.Reference) TaxonDescription(eu.etaxonomy.cdm.model.description.TaxonDescription) Marker(eu.etaxonomy.cdm.model.common.Marker) LanguageString(eu.etaxonomy.cdm.model.common.LanguageString) Feature(eu.etaxonomy.cdm.model.description.Feature) Annotation(eu.etaxonomy.cdm.model.common.Annotation) AnnotationType(eu.etaxonomy.cdm.model.common.AnnotationType) DerivedUnit(eu.etaxonomy.cdm.model.occurrence.DerivedUnit) Classification(eu.etaxonomy.cdm.model.taxon.Classification) MarkerType(eu.etaxonomy.cdm.model.common.MarkerType) Team(eu.etaxonomy.cdm.model.agent.Team) Person(eu.etaxonomy.cdm.model.agent.Person) IDescriptionService(eu.etaxonomy.cdm.api.service.IDescriptionService)

Aggregations

AnnotationType (eu.etaxonomy.cdm.model.common.AnnotationType)12 Annotation (eu.etaxonomy.cdm.model.common.Annotation)7 LanguageString (eu.etaxonomy.cdm.model.common.LanguageString)4 Reference (eu.etaxonomy.cdm.model.reference.Reference)4 Language (eu.etaxonomy.cdm.model.common.Language)3 Feature (eu.etaxonomy.cdm.model.description.Feature)3 TaxonDescription (eu.etaxonomy.cdm.model.description.TaxonDescription)2 TextData (eu.etaxonomy.cdm.model.description.TextData)2 TaxonName (eu.etaxonomy.cdm.model.name.TaxonName)2 DerivedUnit (eu.etaxonomy.cdm.model.occurrence.DerivedUnit)2 Classification (eu.etaxonomy.cdm.model.taxon.Classification)2 Taxon (eu.etaxonomy.cdm.model.taxon.Taxon)2 UUID (java.util.UUID)2 IDescriptionService (eu.etaxonomy.cdm.api.service.IDescriptionService)1 ITermService (eu.etaxonomy.cdm.api.service.ITermService)1 IVocabularyService (eu.etaxonomy.cdm.api.service.IVocabularyService)1 Person (eu.etaxonomy.cdm.model.agent.Person)1 Team (eu.etaxonomy.cdm.model.agent.Team)1 AnnotatableEntity (eu.etaxonomy.cdm.model.common.AnnotatableEntity)1 Extension (eu.etaxonomy.cdm.model.common.Extension)1