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
.database
.ICdmDataSource
;
13 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.out
.IExportTransformer
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.IDatabase
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceFactory
;
18 * @author a.babadshanjan
21 public abstract class ExportConfiguratorBase
<DESTINATION
extends Object
, STATE
extends ExportStateBase
, TRANSFORM
extends IExportTransformer
> extends IoConfiguratorBase
implements IExportConfigurator
<STATE
, TRANSFORM
>{
23 private static final Logger logger
= Logger
.getLogger(ExportConfiguratorBase
.class);
25 private CHECK check
= CHECK
.EXPORT_WITHOUT_CHECK
;
27 private ICdmDataSource source
;
28 private DESTINATION destination
;
29 protected IDatabase sourceReference
;
30 protected Class
<ICdmIO
>[] ioClassList
;
33 * The transformer class to be used for Input
35 private TRANSFORM transformer
;
37 public ExportConfiguratorBase(TRANSFORM transformer
){
39 //setDbSchemaValidation(DbSchemaValidation.UPDATE);
41 this.setTransformer(transformer
);
44 abstract protected void makeIoClassList();
47 public TRANSFORM
getTransformer() {
51 public void setTransformer(TRANSFORM transformer
) {
52 this.transformer
= transformer
;
56 public ICdmDataSource
getSource() {
60 public void setSource(ICdmDataSource source
) {
65 * @param source the source to get
67 public DESTINATION
getDestination() {
72 * @param source the source to set
74 public void setDestination(DESTINATION destination
) {
75 this.destination
= destination
;
81 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
84 public IDatabase
getSourceReference() {
86 ReferenceFactory refFactory
= ReferenceFactory
.newInstance();
87 if (this.sourceReference
== null){
88 sourceReference
= refFactory
.newDatabase();
89 if (getSource() != null){
90 sourceReference
.setTitleCache(getSource().getDatabase(), true);
93 return sourceReference
;
96 public Class
<ICdmIO
>[] getIoClassList(){
101 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCheck()
103 public CHECK
getCheck() {
108 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setCheck(eu.etaxonomy.cdm.io.tcsrdf.TcsRdfImportConfigurator.CHECK)
110 public void setCheck(CHECK check
) {
115 * @see eu.etaxonomy.cdm.io.tcsrdf.IExportConfigurator#getDbSchemaValidation()
117 // public DbSchemaValidation getDbSchemaValidation() {
118 // return dbSchemaValidation;
122 // * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
123 // * If a controller was already created before the last created controller is returned.
126 // public CdmApplicationController getCdmAppController(){
127 // return getCdmAppController(false);
131 * Returns a new instance of <code>CdmApplicationController</code> created by the values of this configuration.
134 public CdmApplicationController
getNewCdmAppController(){
135 return getCdmAppController(true, false);
139 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
140 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
141 * been created before a new controller is returned.
144 public CdmApplicationController
getCdmAppController(boolean createNew
){
145 return getCdmAppController(createNew
, false);
150 * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
151 * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
152 * been created before a new controller is returned.
155 public CdmApplicationController
getCdmAppController(boolean createNew
, boolean omitTermLoading
){
156 if (cdmApp
== null || createNew
== true){
157 cdmApp
= CdmApplicationController
.NewInstance(this.getSource(), this.getDbSchemaValidation(), omitTermLoading
);
166 public boolean isValid(){
167 boolean result
= true;
168 // if (source == null && this.getCdmAppController() == null ){
169 // logger.warn("Connection to CDM could not be established");
172 if (destination
== null){
173 logger
.warn("Invalid export destination");
180 public String
getSourceNameString() {
181 if (this.getSource() == null) {
184 return (String
)this.getSource().getName();