Revision ff9af820
Added by Patrick Plitzner over 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlTaxonNameExport.java | ||
---|---|---|
10 | 10 |
|
11 | 11 |
import java.io.FileWriter; |
12 | 12 |
import java.io.IOException; |
13 |
import java.util.Comparator; |
|
13 | 14 |
import java.util.List; |
14 | 15 |
import java.util.Set; |
15 | 16 |
|
... | ... | |
72 | 73 |
Element taxonyme = new Element(BfnXmlConstants.EL_TAXONYME); |
73 | 74 |
roteListeDaten.addContent(taxonyme); |
74 | 75 |
List<TaxonNode> childNodes = classification.getChildNodes(); |
76 |
java.util.Collections.sort(childNodes, new Comparator<TaxonNode>() { |
|
77 |
|
|
78 |
@Override |
|
79 |
public int compare(TaxonNode o1, TaxonNode o2) { |
|
80 |
Taxon taxon1 = o1.getTaxon(); |
|
81 |
Taxon taxon2 = o2.getTaxon(); |
|
82 |
int id1 = 0; |
|
83 |
int id2 = 0; |
|
84 |
|
|
85 |
Set<IdentifiableSource> sources1 = taxon1.getSources(); |
|
86 |
for (IdentifiableSource identifiableSource : sources1) { |
|
87 |
if(identifiableSource.getType().equals(OriginalSourceType.Import) |
|
88 |
&& identifiableSource.getIdNamespace().equals(BfnXmlConstants.EL_TAXONYM+":" |
|
89 |
+BfnXmlConstants.EL_WISSNAME+":"+BfnXmlConstants.EL_NANTEIL+":"+BfnXmlConstants.BEREICH_EINDEUTIGER_CODE)){ |
|
90 |
id1 = Integer.parseInt(identifiableSource.getIdInSource()); |
|
91 |
} |
|
92 |
} |
|
93 |
Set<IdentifiableSource> sources2 = taxon2.getSources(); |
|
94 |
for (IdentifiableSource identifiableSource : sources2) { |
|
95 |
if(identifiableSource.getType().equals(OriginalSourceType.Import) |
|
96 |
&& identifiableSource.getIdNamespace().equals(BfnXmlConstants.EL_TAXONYM+":" |
|
97 |
+BfnXmlConstants.EL_WISSNAME+":"+BfnXmlConstants.EL_NANTEIL+":"+BfnXmlConstants.BEREICH_EINDEUTIGER_CODE)){ |
|
98 |
id2 = Integer.parseInt(identifiableSource.getIdInSource()); |
|
99 |
} |
|
100 |
} |
|
101 |
return id1-id2; |
|
102 |
} |
|
103 |
}); |
|
75 | 104 |
for (TaxonNode taxonNode : childNodes) { |
76 | 105 |
exportTaxon(taxonNode, taxonyme); |
77 | 106 |
} |
Also available in: Unified diff
Sort exported taxon list