2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.app
.dwca
;
14 import java
.util
.Arrays
;
15 import java
.util
.List
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
19 import org
.joda
.time
.DateTime
;
21 import eu
.etaxonomy
.cdm
.app
.common
.CdmDestinations
;
22 import eu
.etaxonomy
.cdm
.common
.monitor
.DefaultProgressMonitor
;
23 import eu
.etaxonomy
.cdm
.common
.monitor
.IProgressMonitor
;
24 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
25 import eu
.etaxonomy
.cdm
.io
.common
.CdmDefaultExport
;
26 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
.CHECK
;
27 import eu
.etaxonomy
.cdm
.io
.dwca
.out
.DwcaEmlRecord
;
28 import eu
.etaxonomy
.cdm
.io
.dwca
.out
.DwcaTaxExportConfigurator
;
29 import eu
.etaxonomy
.cdm
.model
.agent
.Institution
;
30 import eu
.etaxonomy
.cdm
.model
.agent
.InstitutionalMembership
;
31 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
39 public class DwcaExportActivator
{
40 @SuppressWarnings("unused")
41 private static final Logger logger
= Logger
.getLogger(DwcaExportActivator
.class);
43 //database validation status (create, update, validate ...)
44 private static final String fileDestination
= "C:\\tmp\\dwcaTmp\\cyprus\\";
45 // private static final ICdmDataSource cdmSource = CdmDestinations.cdm_local_cichorieae();
46 // private static final ICdmDataSource cdmSource = CdmDestinations.cdm_test_local_mysql();
47 // private static final ICdmDataSource cdmSource = CdmDestinations.cdm_production_cichorieae();
48 // private static final ICdmDataSource cdmSource = CdmDestinations.cdm_flora_central_africa_production();
49 private static final ICdmDataSource cdmSource
= CdmDestinations
.cdm_cyprus_production();
51 private IProgressMonitor monitor
= DefaultProgressMonitor
.NewInstance();
53 private static DateTime dateTime
= new DateTime();
54 private static String date
= dateTime
.getYear() + "-" + dateTime
.getMonthOfYear() + "-" + dateTime
.getDayOfMonth();
56 private static final String defaultBibliographicCitation
= "ICN (Hand, R., Kilian, N. & Raab-Straube, E. von; general editors) 2009+ (continuously updated): International Cichorieae Network: Cichorieae Portal. Published on the Internet at http://wp6-cichorieae.e-taxonomy.eu/portal/; " +
57 "accessed ["+date
+"].";
59 private static final String taxonSourceDefault
= "http://wp6-cichorieae.e-taxonomy.eu/portal/?q=cdm_dataportal/taxon/{id}";
62 private static final CHECK check
= CHECK
.EXPORT_WITHOUT_CHECK
;
64 private static List
<UUID
> featureExclusions
= Arrays
.asList(new UUID
[]{
65 UUID
.fromString("5deff505-1a32-4817-9a74-50e6936fd630"), //occurrences
66 UUID
.fromString("8075074c-ace8-496b-ac82-47c14553f7fd"), //Editor_Parenthesis
67 UUID
.fromString("c0cc5ebe-1f0c-4c31-af53-d486858ea415"), //Image Sources
68 UUID
.fromString("9f6c551d-0f19-45ea-a855-4946f6fc1093"), //Credits
69 UUID
.fromString("cbf12c6c-94e6-4724-9c48-0f6f10d83e1c"), //Editor Brackets
70 UUID
.fromString("0508114d-4158-48b5-9100-369fa75120d3") //inedited
74 // ****************** ALL *****************************************
76 // private boolean doTaxa = true;
77 // private boolean doResourceRelation = true;
78 // private boolean doTypesAndSpecimen = true;
79 // private boolean doVernacularNames = true;
80 // private boolean doReferences = true;
81 // private boolean doDescription = true;
82 // private boolean doDistributions = true;
83 // private boolean doImages = false;
84 // private boolean doMetaData = true;
85 // private boolean doEml = true;
87 // ************************ NONE **************************************** //
89 private boolean doTaxa
= true;
90 private boolean doResourceRelation
= false;
91 private boolean doTypesAndSpecimen
= false;
92 private boolean doVernacularNames
= false;
93 private boolean doReferences
= false;
94 private boolean doDescription
= false;
95 private boolean doDistributions
= false;
96 private boolean doImages
= false;
97 private boolean doMetaData
= true;
98 private boolean doEml
= false;
100 public boolean doExport(ICdmDataSource source
){
101 System
.out
.println("Start export to DWC-A ("+ fileDestination
+ ") ...");
103 // CdmUpdater su = CdmUpdater.NewInstance();
104 // IProgressMonitor monitor = DefaultProgressMonitor.NewInstance();
107 // su.updateToCurrentVersion(source, monitor);
108 // } catch (Exception e) {
109 // e.printStackTrace();
115 //make file destination
116 String destination
= fileDestination
;
117 DwcaEmlRecord emlRecord
= getEmlRecord();
119 DwcaTaxExportConfigurator config
= DwcaTaxExportConfigurator
.NewInstance(source
, new File(destination
), emlRecord
);
121 config
.setDoTaxa(doTaxa
);
122 config
.setDoResourceRelation(doResourceRelation
);
123 config
.setDoTypesAndSpecimen(doTypesAndSpecimen
);
124 config
.setDoVernacularNames(doVernacularNames
);
125 config
.setDoReferences(doReferences
);
126 config
.setDoDescription(doDescription
);
127 config
.setDoDistributions(doDistributions
);
128 config
.setDoImages(doImages
);
129 config
.setDoMetaData(doMetaData
);
130 config
.setDoEml(doEml
);
131 config
.setCheck(check
);
132 config
.setProgressMonitor(monitor
);
133 config
.setDefaultBibliographicCitation(defaultBibliographicCitation
);
134 config
.setDefaultTaxonSource(taxonSourceDefault
);
135 monitor
.beginTask("DwcA-Export", 10);
137 config
.setFeatureExclusions(featureExclusions
);
139 CdmDefaultExport
<DwcaTaxExportConfigurator
> bmExport
= new CdmDefaultExport
<DwcaTaxExportConfigurator
>();
140 boolean result
= bmExport
.invoke(config
);
142 System
.out
.println("End export to DWC-A ("+ fileDestination
+ ")..." + (result?
"(successful)":"(with errors)"));
147 private DwcaEmlRecord
getEmlRecord() {
148 DwcaEmlRecord emlRecord
= new DwcaEmlRecord();
149 emlRecord
.setIdentifier("My Identifier");
150 emlRecord
.setTitle("Flora of cyprus");
151 emlRecord
.setPublicationDate(new DateTime());
152 emlRecord
.setExpectedCitation("Expected Citation");
153 emlRecord
.setAbstractInfo("The abstract");
154 emlRecord
.setAdditionalInformation("Add info");
155 emlRecord
.setResourceLanguage(null);
156 emlRecord
.setResourceUrl(URI
.create("http://www.flora-of-cyprus.eu//portal/"));
157 emlRecord
.setMetaDataLanguage(null);
158 emlRecord
.setResourceLogoUri(null);
159 emlRecord
.setCreativeCommonsLicensing(null);
160 emlRecord
.setProjectTitle("Projekt tit");
161 emlRecord
.setProjectLead("Proj Lead");
162 emlRecord
.setProjectDescription("Proj Desc");
164 Person person
= Person
.NewInstance();
165 Institution institution
= Institution
.NewInstance();
167 InstitutionalMembership m
= person
.addInstitutionalMembership(institution
, null, null, null);
168 emlRecord
.setResourceCreator(m
);
177 public static void main(String
[] args
) {
178 DwcaExportActivator ex
= new DwcaExportActivator();
179 ICdmDataSource source
= CdmDestinations
.chooseDestination(args
) != null ? CdmDestinations
.chooseDestination(args
) : cdmSource
;