1
|
/**
|
2
|
* Copyright (C) 2008 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*/
|
6
|
|
7
|
package eu.etaxonomy.cdm.app.pilotOutputHtml;
|
8
|
|
9
|
import java.io.File;
|
10
|
|
11
|
import org.apache.log4j.Logger;
|
12
|
|
13
|
import eu.etaxonomy.cdm.app.sdd.ViolaExportActivator;
|
14
|
import eu.etaxonomy.cdm.database.CdmDataSource;
|
15
|
import eu.etaxonomy.cdm.database.DbSchemaValidation;
|
16
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
17
|
import eu.etaxonomy.cdm.io.common.CdmDefaultExport;
|
18
|
import eu.etaxonomy.cdm.io.common.IExportConfigurator.DO_REFERENCES;
|
19
|
import eu.etaxonomy.cdm.io.pilotOutputHtml.PilotOutputExportConfigurator;
|
20
|
|
21
|
/**
|
22
|
* @author h.fradin (from a.babadshanjan eu.etaxonomy.cdm.app.jaxb.CdmExportImportActivator)
|
23
|
* @created 09.12.2008
|
24
|
*/
|
25
|
public class SimpleDescriptionOutput {
|
26
|
|
27
|
/* SerializeFrom DB **/
|
28
|
private static final String sourceDbName = "cdm";
|
29
|
private static final String destinationFileName = "ViolaFromCDMhtml.xml";
|
30
|
private static final String destinationFolder = "C:/Documents and Settings/lis/Mes documents/EDIT/CDM/exports SDD";
|
31
|
//private static final String destinationFolder = "C:/tmp/viola/exports_SDD";
|
32
|
|
33
|
/** NUMBER_ROWS_TO_RETRIEVE = 0 is the default case to retrieve all rows.
|
34
|
* For testing purposes: If NUMBER_ROWS_TO_RETRIEVE >0 then retrieve
|
35
|
* as many rows as specified for agents, references, etc.
|
36
|
* Only root taxa and no synonyms and relationships are retrieved. */
|
37
|
private static final int NUMBER_ROWS_TO_RETRIEVE = 0;
|
38
|
|
39
|
private static final String server = "134.157.190.207";
|
40
|
private static final String username = "sa";
|
41
|
|
42
|
public static ICdmDataSource CDM_DB(String dbname) {
|
43
|
|
44
|
logger.info("Setting DB " + dbname);
|
45
|
ICdmDataSource datasource = CdmDataSource.NewH2EmbeddedInstance(dbname, username, "");
|
46
|
return datasource;
|
47
|
}
|
48
|
|
49
|
private static final Logger logger = Logger.getLogger(ViolaExportActivator.class);
|
50
|
|
51
|
private static boolean doAgents = true;
|
52
|
private static boolean doAgentData = true;
|
53
|
private static boolean doLanguageData = true;
|
54
|
private static boolean doFeatureData = true;
|
55
|
private static boolean doDescriptions = true;
|
56
|
private static boolean doMedia = true;
|
57
|
private static boolean doOccurrences = true;
|
58
|
//private static boolean doReferences = true;
|
59
|
private static final DO_REFERENCES doReferences = DO_REFERENCES.ALL;
|
60
|
private static boolean doReferencedEntities = true;
|
61
|
private static boolean doRelationships = true;
|
62
|
private static boolean doSynonyms = true;
|
63
|
private static boolean doTaxonNames = true;
|
64
|
private static boolean doTaxa = true;
|
65
|
private static boolean doTerms = true;
|
66
|
private static boolean doTermVocabularies = true;
|
67
|
private static boolean doHomotypicalGroups = true;
|
68
|
|
69
|
// 3 arguments: name of the CDM database, name of the destination file, path for the destination file
|
70
|
private void invokeExport(String[] args) {
|
71
|
|
72
|
// PilotOutputExportConfigurator htmlExportConfigurator =
|
73
|
// PilotOutputExportConfigurator.NewInstance(sourceDb, destinationFileName, destinationFolder);
|
74
|
ICdmDataSource sourceDb = ViolaExportActivator.CDM_DB(args[0]);
|
75
|
PilotOutputExportConfigurator htmlExportConfigurator =
|
76
|
PilotOutputExportConfigurator.NewInstance(sourceDb, args[1], args[2]);
|
77
|
|
78
|
CdmDefaultExport<PilotOutputExportConfigurator> htmlExport =
|
79
|
new CdmDefaultExport<PilotOutputExportConfigurator>();
|
80
|
|
81
|
htmlExportConfigurator.setSource(sourceDb);
|
82
|
File destinationFile = new File(args[2] + File.separator + args[1]);
|
83
|
htmlExportConfigurator.setDestination(destinationFile);
|
84
|
htmlExportConfigurator.setDbSchemaValidation(DbSchemaValidation.VALIDATE);
|
85
|
|
86
|
htmlExportConfigurator.setMaxRows(NUMBER_ROWS_TO_RETRIEVE);
|
87
|
|
88
|
htmlExportConfigurator.setDoAuthors(doAgents);
|
89
|
htmlExportConfigurator.setDoAgentData(doAgentData);
|
90
|
htmlExportConfigurator.setDoLanguageData(doLanguageData);
|
91
|
htmlExportConfigurator.setDoFeatureData(doFeatureData);
|
92
|
htmlExportConfigurator.setDoDescriptions(doDescriptions);
|
93
|
htmlExportConfigurator.setDoMedia(doMedia);
|
94
|
htmlExportConfigurator.setDoOccurrence(doOccurrences);
|
95
|
htmlExportConfigurator.setDoReferences(doReferences);
|
96
|
htmlExportConfigurator.setDoReferencedEntities(doReferencedEntities);
|
97
|
htmlExportConfigurator.setDoRelTaxa(doRelationships);
|
98
|
htmlExportConfigurator.setDoSynonyms(doSynonyms);
|
99
|
htmlExportConfigurator.setDoTaxonNames(doTaxonNames);
|
100
|
htmlExportConfigurator.setDoTaxa(doTaxa);
|
101
|
htmlExportConfigurator.setDoTerms(doTerms);
|
102
|
htmlExportConfigurator.setDoTermVocabularies(doTermVocabularies);
|
103
|
htmlExportConfigurator.setDoHomotypicalGroups(doHomotypicalGroups);
|
104
|
|
105
|
// invoke export
|
106
|
logger.debug("Invoking SimpleDescriptionOutput export");
|
107
|
htmlExport.invoke(htmlExportConfigurator);
|
108
|
|
109
|
}
|
110
|
|
111
|
/**
|
112
|
* @param args
|
113
|
*/
|
114
|
public static void main(String[] args) {
|
115
|
|
116
|
SimpleDescriptionOutput sdo = new SimpleDescriptionOutput();
|
117
|
|
118
|
// CdmApplicationController appCtr = null;
|
119
|
// appCtr = sc.initDb(sourceDb);
|
120
|
// sc.loadTestData(appCtr);
|
121
|
|
122
|
sdo.invokeExport(args);
|
123
|
|
124
|
}
|
125
|
|
126
|
}
|