Search in sources :

Example 1 with Attribute

use of org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute in project collect by openforis.

the class SpeciesExportTask method extractInfoAttributeNames.

private List<String> extractInfoAttributeNames() {
    List<String> colNames = new ArrayList<String>();
    TaxonomyDefinition taxonReferenceDataSchema = survey.getReferenceDataSchema().getTaxonomyDefinition(taxonomyName);
    List<Attribute> infoAttributes = taxonReferenceDataSchema.getAttributes();
    for (Attribute infoAttribute : infoAttributes) {
        colNames.add(infoAttribute.getName());
    }
    return colNames;
}
Also used : TaxonomyDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition) Attribute(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute) ArrayList(java.util.ArrayList)

Example 2 with Attribute

use of org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute in project collect by openforis.

the class SpeciesImportProcess method createTaxon.

protected Taxon createTaxon(SpeciesLine line, TaxonRank rank, Taxon parent, String normalizedScientificName) throws ParsingException {
    boolean mostSpecificRank = line.getRank() == rank;
    Taxon taxon = taxonTree.findTaxonByScientificName(normalizedScientificName);
    boolean newTaxon = taxon == null;
    if (newTaxon) {
        taxon = new Taxon();
        taxon.setTaxonRank(rank);
        taxon.setScientificName(normalizedScientificName);
        Node node = taxonTree.addNode(parent, taxon);
        node.addMetadata(LINE_NUMBER_TREE_NODE_METADATA, line.getLineNumber());
        node.addMetadata(RAW_SCIENTIFIC_NAME_TREE_NODE_METADATA, line.getRawScientificName());
    } else if (mostSpecificRank) {
        checkDuplicateScientificName(line, parent, normalizedScientificName);
    }
    if (mostSpecificRank) {
        String code = line.getCode();
        Integer taxonId = line.getTaxonId();
        checkDuplicates(line, code, taxonId);
        taxon.setCode(code);
        taxon.setTaxonId(taxonId);
        TaxonomyDefinition taxonDefinition = survey.getReferenceDataSchema().getTaxonomyDefinition(taxonomyName);
        List<Attribute> taxonAttributes = taxonDefinition.getAttributes();
        for (Attribute attribute : taxonAttributes) {
            String value = line.getInfoAttribute(attribute.getName());
            taxon.addInfoAttribute(value);
        }
        taxonTree.updateNodeInfo(taxon);
        processVernacularNames(line, taxon);
    }
    return taxon;
}
Also used : TaxonomyDefinition(org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition) Attribute(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute) Taxon(org.openforis.idm.model.species.Taxon) Node(org.openforis.collect.model.TaxonTree.Node)

Example 3 with Attribute

use of org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute in project collect by openforis.

the class SpeciesBackupImportTask method processLine.

protected void processLine(SpeciesBackupLine line) throws ParsingException {
    Taxon taxon = new Taxon();
    taxon.setSystemId(line.getId());
    taxon.setParentId(line.getParentId());
    taxon.setTaxonRank(line.getRank());
    taxon.setTaxonId(line.getNo());
    taxon.setCode(line.getCode());
    taxon.setScientificName(line.getScientificName());
    List<Attribute> taxonAttributes = survey.getReferenceDataSchema().getTaxonomyDefinition(taxonomyName).getAttributes();
    for (Attribute taxonAttribute : taxonAttributes) {
        taxon.addInfoAttribute(line.getInfoAttribute(taxonAttribute.getName()));
    }
    Taxon parent = findParentTaxon(line);
    taxonTree.addNode(parent, taxon);
    processVernacularNames(line, taxon);
}
Also used : Attribute(org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute) Taxon(org.openforis.idm.model.species.Taxon)

Aggregations

Attribute (org.openforis.idm.metamodel.ReferenceDataSchema.ReferenceDataDefinition.Attribute)3 TaxonomyDefinition (org.openforis.idm.metamodel.ReferenceDataSchema.TaxonomyDefinition)2 Taxon (org.openforis.idm.model.species.Taxon)2 ArrayList (java.util.ArrayList)1 Node (org.openforis.collect.model.TaxonTree.Node)1