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