Project

General

Profile

« Previous | Next » 

Revision 6930747c

Added by Patrick Plitzner almost 8 years ago

Export features ("Eigenschaften")

View differences:

app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlTaxonNameExport.java
27 27
import eu.etaxonomy.cdm.io.redlist.bfnXml.in.BfnXmlTransformer;
28 28
import eu.etaxonomy.cdm.model.common.IdentifiableSource;
29 29
import eu.etaxonomy.cdm.model.common.OriginalSourceType;
30
import eu.etaxonomy.cdm.model.common.TermVocabulary;
30 31
import eu.etaxonomy.cdm.model.description.CommonTaxonName;
31 32
import eu.etaxonomy.cdm.model.description.DescriptionElementBase;
33
import eu.etaxonomy.cdm.model.description.Feature;
34
import eu.etaxonomy.cdm.model.description.State;
32 35
import eu.etaxonomy.cdm.model.description.TaxonDescription;
33 36
import eu.etaxonomy.cdm.model.name.NonViralName;
34 37
import eu.etaxonomy.cdm.model.name.Rank;
......
58 61

  
59 62
	@Override
60 63
    protected void doInvoke(BfnXmlExportState state){
64
	    startTransaction(true);
65

  
61 66
	    Document document = state.getConfig().getDocument();
62 67

  
63
	    startTransaction(true);
64 68

  
65 69
	    //get all classifications
66 70
	    List<Classification> classifications = getClassificationService().list(Classification.class, null, null, null, null);
......
69 73
            roteListeDaten.setAttribute(new Attribute(BfnXmlConstants.ATT_INHALT, classification.getTitleCache()));
70 74
            document.getRootElement().addContent(roteListeDaten);
71 75

  
76
            //export features
77
            Element eigenschaften = new Element(BfnXmlConstants.EL_EIGENSCHAFTEN);
78
            roteListeDaten.addContent(eigenschaften);
79
            TermVocabulary<Feature> redListFeaturesVoc = getVocabularyService().load(BfnXmlConstants.vocRLFeatures);
80
            Set<Feature> terms = redListFeaturesVoc.getTerms();
81
            for (Feature feature : terms) {
82
                //export red list features
83
                Element eigenschaft = new Element(BfnXmlConstants.EL_EIGENSCHAFT);
84
                eigenschaft.setAttribute(new Attribute(BfnXmlConstants.ATT_STANDARDNAME, feature.getLabel()));
85
                eigenschaften.addContent(eigenschaft);
86
                //export feature states
87
                Element listenwerte = new Element(BfnXmlConstants.EL_LISTENWERTE);
88
                eigenschaften.addContent(listenwerte);
89
                Set<TermVocabulary<State>> supportedCategoricalEnumerations = feature.getSupportedCategoricalEnumerations();
90
                for (TermVocabulary<State> termVocabulary : supportedCategoricalEnumerations) {
91
                    Set<State> featureStates = termVocabulary.getTerms();
92
//                    int reihenfolge = 1;
93
                    for (State featureState : featureStates) {
94
                        Element lwert = new Element(BfnXmlConstants.EL_LWERT);
95
//                        lwert.setAttribute(new Attribute(BfnXmlConstants.ATT_REIHENFOLGE, String.valueOf(reihenfolge)));
96
                        lwert.addContent(featureState.getLabel());
97
                        listenwerte.addContent(lwert);
98

  
99
//                        reihenfolge++;
100
                    }
101
                }
102
            }
103

  
72 104
            //export taxonomy
73 105
            Element taxonyme = new Element(BfnXmlConstants.EL_TAXONYME);
74 106
            roteListeDaten.addContent(taxonyme);
......
102 134
                }
103 135
            });
104 136
            for (TaxonNode taxonNode : childNodes) {
105
                exportTaxon(taxonNode, taxonyme);
137
                exportTaxon(taxonNode.getTaxon(), taxonyme);
106 138
            }
107 139
        }
108 140

  
......
116 148

  
117 149
	}
118 150

  
119
    private void exportTaxon(TaxonNode taxonNode, Element parent) {
151
    private void exportTaxon(Taxon taxon, Element parent) {
120 152
        Element taxonym = new Element(BfnXmlConstants.EL_TAXONYM);
121 153
        parent.addContent(taxonym);
122 154

  
123
        Taxon taxon = taxonNode.getTaxon();
124 155
        NonViralName name = HibernateProxyHelper.deproxy(taxon.getName(), NonViralName.class);
125 156
        Rank rank = name.getRank();
126 157
        //wissName

Also available in: Unified diff