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
.log4j
.Logger
;
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
;
22 * @author h.fradin (from a.babadshanjan eu.etaxonomy.cdm.app.jaxb.CdmExportImportActivator)
25 public class SimpleDescriptionOutput
{
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";
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;
39 private static final String server
= "134.157.190.207";
40 private static final String username
= "sa";
42 public static ICdmDataSource
CDM_DB(String dbname
) {
44 logger
.info("Setting DB " + dbname
);
45 ICdmDataSource datasource
= CdmDataSource
.NewH2EmbeddedInstance(dbname
, username
, "");
49 private static final Logger logger
= Logger
.getLogger(ViolaExportActivator
.class);
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;
69 // 3 arguments: name of the CDM database, name of the destination file, path for the destination file
70 private void invokeExport(String
[] args
) {
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]);
78 CdmDefaultExport
<PilotOutputExportConfigurator
> htmlExport
=
79 new CdmDefaultExport
<PilotOutputExportConfigurator
>();
81 htmlExportConfigurator
.setSource(sourceDb
);
82 File destinationFile
= new File(args
[2] + File
.separator
+ args
[1]);
83 htmlExportConfigurator
.setDestination(destinationFile
);
84 htmlExportConfigurator
.setDbSchemaValidation(DbSchemaValidation
.VALIDATE
);
86 htmlExportConfigurator
.setMaxRows(NUMBER_ROWS_TO_RETRIEVE
);
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
);
106 logger
.debug("Invoking SimpleDescriptionOutput export");
107 htmlExport
.invoke(htmlExportConfigurator
);
114 public static void main(String
[] args
) {
116 SimpleDescriptionOutput sdo
= new SimpleDescriptionOutput();
118 // CdmApplicationController appCtr = null;
119 // appCtr = sc.initDb(sourceDb);
120 // sc.loadTestData(appCtr);
122 sdo
.invokeExport(args
);