1 |
83863ca3
|
a.babadshanjan
|
/**
|
2 |
|
|
* Copyright (C) 2008 EDIT
|
3 |
|
|
* European Distributed Institute of Taxonomy
|
4 |
|
|
* http://www.e-taxonomy.eu
|
5 |
|
|
*/
|
6 |
|
|
|
7 |
|
|
package eu.etaxonomy.cdm.io.common;
|
8 |
|
|
|
9 |
|
|
import org.apache.log4j.Logger;
|
10 |
|
|
|
11 |
|
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
12 |
|
|
import eu.etaxonomy.cdm.io.common.IExportConfigurator.CHECK;
|
13 |
f53af173
|
Katja Luther
|
import eu.etaxonomy.cdm.model.reference.IDatabase;
|
14 |
|
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
15 |
83863ca3
|
a.babadshanjan
|
|
16 |
|
|
/**
|
17 |
|
|
* @author a.babadshanjan
|
18 |
|
|
* @created 16.11.2008
|
19 |
|
|
*/
|
20 |
3e04d6ad
|
Andreas Müller
|
public abstract class ExportConfiguratorBase<DESTINATION extends Object> extends IoConfiguratorBase {
|
21 |
83863ca3
|
a.babadshanjan
|
|
22 |
|
|
private static final Logger logger = Logger.getLogger(ExportConfiguratorBase.class);
|
23 |
|
|
|
24 |
a4ac7c4b
|
a.babadshanjan
|
private CHECK check = CHECK.EXPORT_WITHOUT_CHECK;
|
25 |
7c121c3a
|
Andreas Müller
|
|
26 |
83863ca3
|
a.babadshanjan
|
private ICdmDataSource source;
|
27 |
3e04d6ad
|
Andreas Müller
|
private DESTINATION destination;
|
28 |
f53af173
|
Katja Luther
|
protected IDatabase sourceReference;
|
29 |
68a6503a
|
a.babadshanjan
|
protected Class<ICdmIO>[] ioClassList;
|
30 |
83863ca3
|
a.babadshanjan
|
|
31 |
|
|
|
32 |
|
|
public ExportConfiguratorBase(){
|
33 |
|
|
super();
|
34 |
3e04d6ad
|
Andreas Müller
|
//setDbSchemaValidation(DbSchemaValidation.UPDATE);
|
35 |
83863ca3
|
a.babadshanjan
|
makeIoClassList();
|
36 |
|
|
}
|
37 |
|
|
|
38 |
|
|
abstract protected void makeIoClassList();
|
39 |
|
|
|
40 |
|
|
public ICdmDataSource getSource() {
|
41 |
|
|
return source;
|
42 |
|
|
}
|
43 |
|
|
|
44 |
|
|
public void setSource(ICdmDataSource source) {
|
45 |
|
|
this.source = source;
|
46 |
|
|
}
|
47 |
|
|
|
48 |
|
|
/**
|
49 |
|
|
* @param source the source to get
|
50 |
|
|
*/
|
51 |
3e04d6ad
|
Andreas Müller
|
public DESTINATION getDestination() {
|
52 |
83863ca3
|
a.babadshanjan
|
return destination;
|
53 |
|
|
}
|
54 |
|
|
|
55 |
|
|
/**
|
56 |
|
|
* @param source the source to set
|
57 |
|
|
*/
|
58 |
3e04d6ad
|
Andreas Müller
|
public void setDestination(DESTINATION destination) {
|
59 |
83863ca3
|
a.babadshanjan
|
this.destination = destination;
|
60 |
|
|
}
|
61 |
|
|
|
62 |
7c121c3a
|
Andreas Müller
|
|
63 |
|
|
|
64 |
83863ca3
|
a.babadshanjan
|
/* (non-Javadoc)
|
65 |
|
|
* @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
|
66 |
|
|
*/
|
67 |
|
|
// @Override
|
68 |
f53af173
|
Katja Luther
|
public IDatabase getSourceReference() {
|
69 |
612e57d5
|
Andreas Müller
|
//TODO //needed
|
70 |
f53af173
|
Katja Luther
|
ReferenceFactory refFactory = ReferenceFactory.newInstance();
|
71 |
83863ca3
|
a.babadshanjan
|
if (this.sourceReference == null){
|
72 |
f53af173
|
Katja Luther
|
sourceReference = refFactory.newDatabase();
|
73 |
612e57d5
|
Andreas Müller
|
if (getSource() != null){
|
74 |
892efc69
|
Andreas Kohlbecker
|
sourceReference.setTitleCache(getSource().getDatabase(), true);
|
75 |
612e57d5
|
Andreas Müller
|
}
|
76 |
83863ca3
|
a.babadshanjan
|
}
|
77 |
|
|
return sourceReference;
|
78 |
|
|
}
|
79 |
|
|
|
80 |
68a6503a
|
a.babadshanjan
|
public Class<ICdmIO>[] getIoClassList(){
|
81 |
|
|
return ioClassList;
|
82 |
83863ca3
|
a.babadshanjan
|
}
|
83 |
|
|
|
84 |
|
|
/* (non-Javadoc)
|
85 |
01be5674
|
Andreas Müller
|
* @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getCheck()
|
86 |
83863ca3
|
a.babadshanjan
|
*/
|
87 |
|
|
public CHECK getCheck() {
|
88 |
|
|
return this.check;
|
89 |
|
|
}
|
90 |
|
|
|
91 |
|
|
/* (non-Javadoc)
|
92 |
01be5674
|
Andreas Müller
|
* @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#setCheck(eu.etaxonomy.cdm.io.tcsrdf.TcsRdfImportConfigurator.CHECK)
|
93 |
83863ca3
|
a.babadshanjan
|
*/
|
94 |
|
|
public void setCheck(CHECK check) {
|
95 |
|
|
this.check = check;
|
96 |
|
|
}
|
97 |
|
|
|
98 |
|
|
/* (non-Javadoc)
|
99 |
01be5674
|
Andreas Müller
|
* @see eu.etaxonomy.cdm.io.tcsrdf.IExportConfigurator#getDbSchemaValidation()
|
100 |
83863ca3
|
a.babadshanjan
|
*/
|
101 |
c0e7ef2f
|
a.babadshanjan
|
// public DbSchemaValidation getDbSchemaValidation() {
|
102 |
|
|
// return dbSchemaValidation;
|
103 |
|
|
// }
|
104 |
83863ca3
|
a.babadshanjan
|
|
105 |
6b2cc8fd
|
Andreas Müller
|
// /**
|
106 |
|
|
// * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
|
107 |
|
|
// * If a controller was already created before the last created controller is returned.
|
108 |
|
|
// * @return
|
109 |
|
|
// */
|
110 |
|
|
// public CdmApplicationController getCdmAppController(){
|
111 |
|
|
// return getCdmAppController(false);
|
112 |
|
|
// }
|
113 |
|
|
//
|
114 |
|
|
// /**
|
115 |
|
|
// * Returns a new instance of <code>CdmApplicationController</code> created by the values of this configuration.
|
116 |
|
|
// * @return
|
117 |
|
|
// */
|
118 |
|
|
// public CdmApplicationController getNewCdmAppController(){
|
119 |
|
|
// return getCdmAppController(true, false);
|
120 |
|
|
// }
|
121 |
|
|
//
|
122 |
|
|
// /**
|
123 |
|
|
// * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
|
124 |
|
|
// * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
|
125 |
|
|
// * been created before a new controller is returned.
|
126 |
|
|
// * @return
|
127 |
|
|
// */
|
128 |
|
|
// public CdmApplicationController getCdmAppController(boolean createNew){
|
129 |
|
|
// return getCdmAppController(createNew, false);
|
130 |
|
|
// }
|
131 |
|
|
//
|
132 |
|
|
//
|
133 |
|
|
// /**
|
134 |
|
|
// * Returns a <code>CdmApplicationController</code> created by the values of this configuration.
|
135 |
|
|
// * If create new is true always a new controller is returned, else the last created controller is returned. If no controller has
|
136 |
|
|
// * been created before a new controller is returned.
|
137 |
|
|
// * @return
|
138 |
|
|
// */
|
139 |
|
|
// public CdmApplicationController getCdmAppController(boolean createNew, boolean omitTermLoading){
|
140 |
|
|
// if (cdmApp == null || createNew == true){
|
141 |
|
|
// try {
|
142 |
|
|
// cdmApp = CdmApplicationController.NewInstance(this.getSource(), this.getDbSchemaValidation(), omitTermLoading);
|
143 |
|
|
// } catch (DataSourceNotFoundException e) {
|
144 |
|
|
// logger.error("could not connect to destination database");
|
145 |
|
|
// return null;
|
146 |
|
|
// }catch (TermNotFoundException e) {
|
147 |
|
|
// logger.error("could not find needed term in destination datasource");
|
148 |
|
|
// return null;
|
149 |
|
|
// }
|
150 |
|
|
// }
|
151 |
|
|
// return cdmApp;
|
152 |
|
|
// }
|
153 |
9d190d4a
|
a.babadshanjan
|
|
154 |
a1320b67
|
Andreas Müller
|
|
155 |
7c121c3a
|
Andreas Müller
|
/**
|
156 |
|
|
* @return
|
157 |
83863ca3
|
a.babadshanjan
|
*/
|
158 |
|
|
public boolean isValid(){
|
159 |
|
|
boolean result = true;
|
160 |
b5a48894
|
n.hoffmann
|
// if (source == null && this.getCdmAppController() == null ){
|
161 |
|
|
// logger.warn("Connection to CDM could not be established");
|
162 |
|
|
// result = false;
|
163 |
|
|
// }
|
164 |
83863ca3
|
a.babadshanjan
|
if (destination == null){
|
165 |
|
|
logger.warn("Invalid export destination");
|
166 |
|
|
result = false;
|
167 |
|
|
}
|
168 |
|
|
|
169 |
|
|
return result;
|
170 |
|
|
}
|
171 |
|
|
|
172 |
ad5965e7
|
Andreas Müller
|
public String getSourceNameString() {
|
173 |
|
|
if (this.getSource() == null) {
|
174 |
|
|
return null;
|
175 |
|
|
} else {
|
176 |
|
|
return (String)this.getSource().getName();
|
177 |
|
|
}
|
178 |
|
|
}
|
179 |
|
|
|
180 |
83863ca3
|
a.babadshanjan
|
}
|