Project

General

Profile

« Previous | Next » 

Revision 4a31998d

Added by Patrick Plitzner over 6 years ago

Export taxNr

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlConstants.java
170 170
    //redList feature vocabulary
171 171
    public static final UUID vocRLFeatures =  UUID.fromString("74091f30-faa0-487b-bd7e-c82eed05d3c9");
172 172
   
173
    public static final UUID TAX_NR_IDENTIFIER =  UUID.fromString("7d12de50-0db7-47b3-bb8e-703ad1d54fbc");
173
    public static final UUID UUID_TAX_NR_IDENTIFIER_TYPE =  UUID.fromString("7d12de50-0db7-47b3-bb8e-703ad1d54fbc");
174 174

  
175 175
    //redList state Vocabularies
176 176
    public static final UUID vocStateRLKat =  UUID.fromString("66bbb391-af8a-423b-9506-a235b61af922");
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/in/BfnXmlImportTaxonName.java
420 420
					String microRefStr = microRef == null ? null : microRef.getTitle();
421 421
					taxon.addImportSource(uniqueID, namespace, state.getCompleteSourceRef(), microRefStr);
422 422

  
423
					taxon.addIdentifier(taxonId, getIdentiferType(state, BfnXmlConstants.TAX_NR_IDENTIFIER, "taxNr", "TaxNr attribute of Bfn Xml file", "taxNr", null));
423
					taxon.addIdentifier(taxonId, getIdentiferType(state, BfnXmlConstants.UUID_TAX_NR_IDENTIFIER_TYPE, "taxNr", "TaxNr attribute of Bfn Xml file", "taxNr", null));
424 424
				} catch (UnknownCdmTypeException e) {
425 425
					success.setValue(false);
426 426
				}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlExportState.java
10 10

  
11 11
package eu.etaxonomy.cdm.io.redlist.bfnXml.out;
12 12

  
13
import java.util.HashMap;
14
import java.util.Map;
15
import java.util.UUID;
16

  
13 17
import org.apache.log4j.Logger;
14 18

  
15 19
import eu.etaxonomy.cdm.io.common.XmlExportState;
......
25 29
	@SuppressWarnings("unused")
26 30
	private static final Logger logger = Logger.getLogger(BfnXmlExportState.class);
27 31

  
32
	private Map<String, UUID> taxNrMap = new HashMap<String, UUID>();
33

  
28 34
	public BfnXmlExportState(BfnXmlExportConfigurator config) {
29 35
		super(config);
30 36
	}
31 37

  
38
    public Map<String, UUID> getTaxNrMap() {
39
        return taxNrMap;
40
    }
41

  
32 42
}
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlTaxonNameExport.java
21 21
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
22 22
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlConstants;
23 23
import eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlTransformer;
24
import eu.etaxonomy.cdm.model.common.DefinedTerm;
24 25
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
25 26
import eu.etaxonomy.cdm.model.common.Language;
26 27
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
......
76 77

  
77 78
            exportFeatures(roteListeDaten);
78 79

  
79
            exportTaxonomy(classification, roteListeDaten);
80
            exportTaxonomy(classification, roteListeDaten, state);
80 81

  
81 82
        }
82 83

  
83 84
	}
84 85

  
85
    private void exportTaxonomy(Classification classification, Element roteListeDaten) {
86
    private void exportTaxonomy(Classification classification, Element roteListeDaten, BfnXmlExportState state) {
86 87
        Element taxonyme = new Element(BfnXmlConstants.EL_TAXONYME);
87 88
        roteListeDaten.addContent(taxonyme);
88 89
        List<TaxonNode> childNodes = classification.getChildNodes();
89 90
        java.util.Collections.sort(childNodes, new OriginalSourceComparator());
90 91
        for (TaxonNode taxonNode : childNodes) {
91
            exportTaxon(taxonNode.getTaxon(), taxonyme);
92
            exportTaxon(taxonNode.getTaxon(), taxonyme, state);
92 93
        }
93 94
    }
94 95

  
......
163 164
        }
164 165
    }
165 166

  
166
    private void exportTaxon(Taxon taxon, Element parent) {
167
    private void exportTaxon(Taxon taxon, Element parent, BfnXmlExportState state) {
167 168
        Element taxonym = new Element(BfnXmlConstants.EL_TAXONYM);
168 169
        parent.addContent(taxonym);
169 170

  
171
        DefinedTerm taxNrIdentifierType = HibernateProxyHelper.deproxy(getTermService().load(BfnXmlConstants.UUID_TAX_NR_IDENTIFIER_TYPE), DefinedTerm.class);
172
        Set<String> identifiers = taxon.getIdentifiers(taxNrIdentifierType);
173
        if(identifiers.size()==1){
174
            String taxNr = identifiers.iterator().next();
175
            taxonym.setAttribute(BfnXmlConstants.ATT_TAXNR, taxNr);
176
            state.getTaxNrMap().put(taxNr, taxon.getUuid());
177
        }
178
        else{
179
            logger.error("Taxon "+taxon.getTitleCache()+" has none or multiple identifiers of type 'taxNr'");
180
        }
181

  
170 182
        exportWissName(taxon, taxonym);
171 183

  
172 184
        //synonyms

Also available in: Unified diff