2 * Copyright (C) 2008 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
7 package eu
.etaxonomy
.cdm
.io
.common
;
9 import org
.apache
.log4j
.Logger
;
11 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationController
;
12 import eu
.etaxonomy
.cdm
.api
.application
.ICdmApplicationConfiguration
;
13 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
14 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.out
.IExportTransformer
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.IDatabase
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
19 * @author a.babadshanjan
22 public abstract class ExportConfiguratorBase
<DESTINATION
extends Object
, STATE
extends ExportStateBase
, TRANSFORM
extends IExportTransformer
> extends IoConfiguratorBase
implements IExportConfigurator
<STATE
, TRANSFORM
>{
24 private static final Logger logger
= Logger
.getLogger(ExportConfiguratorBase
.class);
26 private CHECK check
= CHECK
.EXPORT_WITHOUT_CHECK
;
28 private ICdmDataSource source
;
29 private DESTINATION destination
;
30 protected IDatabase sourceReference
;
31 protected Class
<ICdmIO
>[] ioClassList
;
34 * The transformer class to be used for Input
36 private TRANSFORM transformer
;
38 public ExportConfiguratorBase(TRANSFORM transformer
){
40 //setDbSchemaValidation(DbSchemaValidation.UPDATE);
42 this.setTransformer(transformer
);
45 abstract protected void makeIoClassList();
49 public TRANSFORM
getTransformer() {
54 public void setTransformer(TRANSFORM transformer
) {
55 this.transformer
= transformer
;
60 public ICdmDataSource
getSource() {
65 public void setSource(ICdmDataSource source
) {
70 * @param source the source to get
72 public DESTINATION
getDestination() {
77 * @param source the source to set
79 public void setDestination(DESTINATION destination
) {
80 this.destination
= destination
;
86 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
89 public IDatabase
getSourceReference() {
91 if (this.sourceReference
== null){
92 sourceReference
= ReferenceFactory
.newDatabase();
93 if (getSource() != null){
94 sourceReference
.setTitleCache(getSource().getDatabase(), true);
97 return sourceReference
;
101 public Class
<ICdmIO
>[] getIoClassList(){
106 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCheck()
109 public CHECK
getCheck() {
114 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setCheck(eu.etaxonomy.cdm.io.tcsrdf.TcsRdfImportConfigurator.CHECK)
116 public void setCheck(CHECK check
) {
121 * @see eu.etaxonomy.cdm.io.tcsrdf.IExportConfigurator#getDbSchemaValidation()
123 // public DbSchemaValidation getDbSchemaValidation() {
124 // return dbSchemaValidation;
128 // * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
129 // * If a controller was already created before the last created controller is returned.
132 // public CdmApplicationController getCdmAppController(){
133 // return getCdmAppController(false);
137 * Returns a new instance of <code>CdmApplicationController</code> created by the values of this configuration.
140 public ICdmApplicationConfiguration
getNewCdmAppController(){
141 return getCdmAppController(true, false);
145 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
146 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
147 * been created before a new controller is returned.
150 public ICdmApplicationConfiguration
getCdmAppController(boolean createNew
){
151 return getCdmAppController(createNew
, false);
156 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
157 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
158 * been created before a new controller is returned.
161 public ICdmApplicationConfiguration
getCdmAppController(boolean createNew
, boolean omitTermLoading
){
162 if (cdmApp
== null || createNew
== true){
163 cdmApp
= CdmApplicationController
.NewInstance(this.getSource(), this.getDbSchemaValidation(), omitTermLoading
);
173 public boolean isValid(){
174 boolean result
= true;
175 // if (source == null && this.getCdmAppController() == null ){
176 // logger.warn("Connection to CDM could not be established");
179 if (destination
== null){
180 logger
.warn("Invalid export destination");
188 public String
getSourceNameString() {
189 if (this.getSource() == null) {
192 return this.getSource().getName();