Revision 70d09a58
Added by Patrick Plitzner over 8 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/redlist/out/BfnXmlExport.java | ||
---|---|---|
44 | 44 |
document = createDocument(); |
45 | 45 |
BfnXmlExportConfigurator config = BfnXmlExportConfigurator.NewInstance(destination, sourceDb, transformer, document); |
46 | 46 |
|
47 |
CdmDefaultExport<BfnXmlExportConfigurator> export = new CdmDefaultExport<BfnXmlExportConfigurator>(); |
|
47 |
|
|
48 |
CdmDefaultExport<BfnXmlExportConfigurator> export = |
|
49 |
new CdmDefaultExport<BfnXmlExportConfigurator>(); |
|
48 | 50 |
|
49 | 51 |
// invoke export |
50 | 52 |
logger.debug("Invoking BfnXml export"); |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/BfnXmlConstants.java | ||
---|---|---|
27 | 27 |
|
28 | 28 |
public static final String EL_DEB_EXPORT = "DEBExport"; |
29 | 29 |
public static final String EL_ROTELISTEDATEN = "ROTELISTEDATEN"; |
30 |
public static final String ATT_INHALT = "inhalt"; |
|
30 | 31 |
|
31 | 32 |
public static final String EL_EIGENSCHAFTEN = "EIGENSCHAFTEN"; |
32 | 33 |
public static final String EL_EIGENSCHAFT = "EIGENSCHAFT"; |
... | ... | |
68 | 69 |
public static final String EL_KONZEPTBEZIEHUNG = "KONZEPTBEZIEHUNG"; |
69 | 70 |
|
70 | 71 |
|
72 |
public static final String BEREICH_WISSNAME = "wissName"; |
|
73 |
// public static final String BEREICH_WISSNAME = "Eindeutiger Code"; |
|
74 |
// public static final String BEREICH_WISSNAME = "Epitheton 1"; |
|
75 |
// public static final String BEREICH_WISSNAME = "Epitheton 2"; |
|
76 |
// public static final String BEREICH_WISSNAME = "Epitheton 3"; |
|
77 |
// public static final String BEREICH_WISSNAME = "Epitheton 4"; |
|
78 |
// public static final String BEREICH_WISSNAME = "Rang"; |
|
79 |
// public static final String BEREICH_WISSNAME = "Ordnungszahl"; |
|
80 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
81 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
82 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
83 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
84 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
85 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
86 |
// public static final String BEREICH_WISSNAME = "wissName"; |
|
87 |
|
|
71 | 88 |
public static final String RNK_SUPERTRIB = "supertrib"; |
72 | 89 |
public static final String RNK_TRIB = "trib"; |
73 | 90 |
public static final String RNK_SUBTRIB = "subtrib"; |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlExportConfigurator.java | ||
---|---|---|
13 | 13 |
|
14 | 14 |
import org.apache.log4j.Logger; |
15 | 15 |
import org.jdom2.Document; |
16 |
|
|
17 | 16 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
18 | 17 |
import eu.etaxonomy.cdm.io.common.XmlExportConfiguratorBase; |
19 | 18 |
import eu.etaxonomy.cdm.io.common.mapping.out.IExportTransformer; |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/bfnXml/out/BfnXmlTaxonNameExport.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.io.redlist.bfnXml.out; |
10 | 10 |
|
11 |
import java.io.FileWriter; |
|
12 |
import java.io.IOException; |
|
13 |
import java.util.List; |
|
14 |
|
|
11 | 15 |
import org.apache.log4j.Logger; |
16 |
import org.jdom2.Attribute; |
|
17 |
import org.jdom2.Document; |
|
18 |
import org.jdom2.Element; |
|
19 |
import org.jdom2.output.Format; |
|
20 |
import org.jdom2.output.XMLOutputter; |
|
12 | 21 |
import org.springframework.stereotype.Component; |
22 |
import org.springframework.transaction.TransactionStatus; |
|
13 | 23 |
|
24 |
import eu.etaxonomy.cdm.io.redlist.bfnXml.BfnXmlConstants; |
|
14 | 25 |
import eu.etaxonomy.cdm.model.name.TaxonNameBase; |
26 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
27 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
28 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
29 |
|
|
15 | 30 |
|
16 | 31 |
|
17 | 32 |
/** |
... | ... | |
33 | 48 |
|
34 | 49 |
@Override |
35 | 50 |
protected void doInvoke(BfnXmlExportState state){ |
51 |
// Document document = state.getConfig().getDocument(); |
|
52 |
Document document = new Document(); |
|
53 |
Element rootElement = new Element(BfnXmlConstants.EL_DEB_EXPORT); |
|
54 |
document.setRootElement(rootElement); |
|
55 |
TransactionStatus transaction = startTransaction(true); |
|
56 |
|
|
57 |
//get all classifications |
|
58 |
List<Classification> classifications = getClassificationService().list(Classification.class, null, null, null, null); |
|
59 |
for (Classification classification : classifications) { |
|
60 |
Element roteListeDaten = new Element(BfnXmlConstants.EL_ROTELISTEDATEN); |
|
61 |
roteListeDaten.setAttribute(new Attribute(BfnXmlConstants.ATT_INHALT, classification.getTitleCache())); |
|
62 |
rootElement.addContent(roteListeDaten); |
|
63 |
|
|
64 |
//export taxonomy |
|
65 |
Element taxonyme = new Element(BfnXmlConstants.EL_TAXONYME); |
|
66 |
roteListeDaten.addContent(taxonyme); |
|
67 |
List<TaxonNode> childNodes = classification.getChildNodes(); |
|
68 |
for (TaxonNode taxonNode : childNodes) { |
|
69 |
exportTaxon(taxonNode, taxonyme); |
|
70 |
} |
|
71 |
} |
|
72 |
|
|
73 |
XMLOutputter outputter = new XMLOutputter(); |
|
74 |
outputter.setFormat(Format.getPrettyFormat()); |
|
75 |
try { |
|
76 |
outputter.output(document, new FileWriter(state.getConfig().getDestination())); |
|
77 |
} catch (IOException e) { |
|
78 |
// TODO Auto-generated catch block |
|
79 |
e.printStackTrace(); |
|
80 |
} |
|
81 |
|
|
36 | 82 |
} |
37 | 83 |
|
84 |
private void exportTaxon(TaxonNode taxonNode, Element parent) { |
|
85 |
Element taxonym = new Element(BfnXmlConstants.EL_TAXONYM); |
|
86 |
parent.addContent(taxonym); |
|
87 |
|
|
88 |
Taxon taxon = taxonNode.getTaxon(); |
|
89 |
Element nanteil = addNanteil(BfnXmlConstants.BEREICH_WISSNAME, taxon.getTitleCache()); |
|
90 |
taxonym.addContent(nanteil); |
|
91 |
|
|
92 |
} |
|
93 |
|
|
94 |
private Element addNanteil(String bereich, String textContent) { |
|
95 |
Element nanteil = new Element(BfnXmlConstants.EL_NANTEIL); |
|
96 |
nanteil.setAttribute(new Attribute(BfnXmlConstants.ATT_BEREICH, bereich)); |
|
97 |
nanteil.addContent(textContent); |
|
98 |
return nanteil; |
|
99 |
} |
|
100 |
|
|
38 | 101 |
@Override |
39 | 102 |
protected boolean doCheck(BfnXmlExportState state) { |
40 | 103 |
return false; |
Also available in: Unified diff
Import taxa