2 * Copyright (C) 2008 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
7 package eu
.etaxonomy
.cdm
.io
.jaxb
;
9 import org
.apache
.log4j
.Logger
;
11 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
12 import eu
.etaxonomy
.cdm
.io
.common
.ExportConfiguratorBase
;
13 import eu
.etaxonomy
.cdm
.io
.common
.IExportConfigurator
;
14 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
15 import eu
.etaxonomy
.cdm
.io
.common
.ImportConfiguratorBase
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.Database
;
17 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
20 * @author a.babadshanjan
23 public class JaxbExportConfigurator
extends ExportConfiguratorBase
implements IExportConfigurator
{
25 private static final Logger logger
= Logger
.getLogger(JaxbExportConfigurator
.class);
27 private int maxRows
= 0;
29 // private boolean doAgents = true;
30 private boolean doAgentData
= true;
31 private boolean doLanguageData
= true;
32 private boolean doFeatureData
= true;
33 private boolean doDescriptions
= true;
34 private boolean doMedia
= true;
35 // private boolean doOccurrences = true;
36 // private boolean doReferences = true;
37 private boolean doReferencedEntities
= true;
38 // private boolean doRelationships = true;
39 private boolean doSynonyms
= true;
40 // private boolean doTaxonNames = true;
41 // private boolean doTaxa = true;
42 private boolean doTerms
= true;
43 private boolean doTermVocabularies
= true;
44 private boolean doHomotypicalGroups
= true;
46 // private Object source;
47 // private ICdmDataSource cdmDb;
48 // private ICdmDataSource cdmSource;
49 // private ICdmDataSource cdmDestination;
50 // private DbSchemaValidation cdmSourceSchemaValidation = DbSchemaValidation.VALIDATE;
51 // private DbSchemaValidation cdmDestSchemaValidation = DbSchemaValidation.CREATE;
52 // private CdmApplicationController cdmApp = null;
56 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
57 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
58 * been created before a new controller is returned.
61 // public CdmApplicationController getSourceAppController(ICdmDataSource cdmDb, boolean createNew){
62 // if (cdmApp == null || createNew == true){
64 // cdmApp = CdmApplicationController.NewInstance(this.getCdmSource(), this.getCdmSourceSchemaValidation(), true);
65 // } catch (DataSourceNotFoundException e) {
66 // logger.error("Could not connect to source database");
68 // }catch (TermNotFoundException e) {
69 // logger.error("Terms not found in source database. " +
70 // "This error should not happen since preloaded terms are not expected for this application.");
78 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
79 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
80 * been created before a new controller is returned.
83 // public CdmApplicationController getDestinationAppController(ICdmDataSource cdmDb, boolean createNew){
84 // if (cdmApp == null || createNew == true){
86 // cdmApp = CdmApplicationController.NewInstance(this.getCdmDestination(), this.getCdmDestSchemaValidation(), true);
87 // } catch (DataSourceNotFoundException e) {
88 // logger.error("Could not connect to destination database");
90 // }catch (TermNotFoundException e) {
91 // logger.error("Terms not found in destination database. " +
92 // "This error should not happen since preloaded terms are not expected for this application.");
99 public int getMaxRows() {
103 public void setMaxRows(int maxRows
) {
104 this.maxRows
= maxRows
;
107 // public ICdmDataSource getCdmSource() {
111 // public void setCdmSource(ICdmDataSource cdmSource) {
112 // this.cdmSource = cdmSource;
115 // public ICdmDataSource getCdmDestination() {
116 // return cdmDestination;
119 // public void setCdmDestination(ICdmDataSource cdmDestination) {
120 // this.cdmDestination = cdmDestination;
123 // public DbSchemaValidation getCdmSourceSchemaValidation() {
124 // return cdmSourceSchemaValidation;
127 // public void setCdmSourceSchemaValidation(DbSchemaValidation cdmSchemaValidation) {
128 // this.cdmSourceSchemaValidation = cdmSchemaValidation;
131 // public DbSchemaValidation getCdmDestSchemaValidation() {
132 // return cdmDestSchemaValidation;
135 // public void setCdmDestSchemaValidation(DbSchemaValidation cdmSchemaValidation) {
136 // this.cdmDestSchemaValidation = cdmSchemaValidation;
139 // public boolean isDoAgents() {
143 // public void setDoAgents(boolean doAgents) {
144 // this.doAgents = doAgents;
147 public boolean isDoAgentData() {
151 public void setDoAgentData(boolean doAgentData
) {
152 this.doAgentData
= doAgentData
;
155 public boolean isDoLanguageData() {
156 return doLanguageData
;
159 public void setDoLanguageData(boolean doLanguageData
) {
160 this.doLanguageData
= doLanguageData
;
163 public boolean isDoFeatureData() {
164 return doFeatureData
;
167 public void setDoFeatureData(boolean doFeatureData
) {
168 this.doFeatureData
= doFeatureData
;
171 public boolean isDoDescriptions() {
172 return doDescriptions
;
175 public void setDoDescriptions(boolean doDescriptions
) {
176 this.doDescriptions
= doDescriptions
;
179 public boolean isDoMedia() {
183 public void setDoMedia(boolean doMedia
) {
184 this.doMedia
= doMedia
;
187 // public boolean isDoOccurrences() {
188 // return doOccurrences;
191 // public void setDoOccurrences(boolean doOccurrences) {
192 // this.doOccurrences = doOccurrences;
195 // public boolean isDoReferences() {
196 // return doReferences;
199 // public void setDoReferences(boolean doReferences) {
200 // this.doReferences = doReferences;
203 public boolean isDoReferencedEntities() {
204 return doReferencedEntities
;
207 public void setDoReferencedEntities(boolean doReferencedEntities
) {
208 this.doReferencedEntities
= doReferencedEntities
;
211 // public boolean isDoRelationships() {
212 // return doRelationships;
215 // public void setDoRelationships(boolean doRelationships) {
216 // this.doRelationships = doRelationships;
219 public boolean isDoSynonyms() {
223 public void setDoSynonyms(boolean doSynonyms
) {
224 this.doSynonyms
= doSynonyms
;
227 // public boolean isDoTaxonNames() {
228 // return doTaxonNames;
231 // public void setDoTaxonNames(boolean doTaxonNames) {
232 // this.doTaxonNames = doTaxonNames;
235 // public boolean isDoTaxa() {
239 // public void setDoTaxa(boolean doTaxa) {
240 // this.doTaxa = doTaxa;
243 public boolean isDoTerms() {
247 public void setDoTerms(boolean doTerms
) {
248 this.doTerms
= doTerms
;
251 public boolean isDoTermVocabularies() {
252 return doTermVocabularies
;
255 public void setDoTermVocabularies(boolean doTermVocabularies
) {
256 this.doTermVocabularies
= doTermVocabularies
;
259 public boolean isDoHomotypicalGroups() {
260 return doHomotypicalGroups
;
263 public void setDoHomotypicalGroups(boolean doHomotypicalGroups
) {
264 this.doHomotypicalGroups
= doHomotypicalGroups
;
268 // @SuppressWarnings("unchecked")
269 protected void makeIoClassList() {
270 exportClassList
= new Class
[] {
276 public static JaxbExportConfigurator
NewInstance(ICdmDataSource source
, String url
) {
277 return new JaxbExportConfigurator(source
, url
);
285 private JaxbExportConfigurator(ICdmDataSource source
, String url
) {
293 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
295 public String
getDestination() {
296 return (String
)super.getDestination();
303 public void setDestination(String fileName
) {
304 super.setDestination(fileName
);
309 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getDestinationReference()
312 // public ReferenceBase getDestinationReference() {
314 // if (this.destinationReference == null){
315 // logger.warn("getDestinationReference() not yet fully implemented");
316 // destinationReference = Database.NewInstance();
317 // destinationReference.setTitleCache("Jaxb export");
319 // return destinationReference;
324 * @see eu.etaxonomy.cdm.io.common.IExportConfigurator#getDestinationNameString()
326 public String
getDestinationNameString() {
327 if (this.getDestination() == null) {
330 return this.getDestination();