Project

General

Profile

Download (6.44 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2008 EDIT
3
 * European Distributed Institute of Taxonomy 
4
 * http://www.e-taxonomy.eu
5
 * 
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.
8
 */
9

    
10
package eu.etaxonomy.cdm.io.jaxb;
11

    
12
import eu.etaxonomy.cdm.common.URI;
13

    
14
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
15

    
16
import eu.etaxonomy.cdm.database.DbSchemaValidation;
17
import eu.etaxonomy.cdm.database.ICdmDataSource;
18
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
19
import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
20
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
21
import eu.etaxonomy.cdm.model.reference.Reference;
22
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23

    
24
/**
25
 * @author a.babadshanjan
26
 * @since 14.11.2008
27
 */
28
public class JaxbImportConfigurator extends ImportConfiguratorBase<JaxbImportState, URI> implements IImportConfigurator {
29

    
30
	private static final Logger logger = LogManager.getLogger(JaxbImportConfigurator.class);
31
		
32
	private int maxRows = 0;
33
	
34
	//TODO
35
	private static IInputTransformer defaultTransformer = null;
36

    
37
	
38
	private boolean doUser = true;
39
	private boolean doAgentData = true;
40
	private boolean doLanguageData = true;
41
	private boolean doFeatureData = true;
42
	private boolean doDescriptions = true;
43
	private boolean doMedia = true;
44
	private boolean doOccurrence = true;
45
	private boolean doReferencedEntities = true;
46
	private boolean doSynonyms = true;
47
	private boolean doTerms = true;
48
	private boolean doTermVocabularies = true;
49
	private boolean doHomotypicalGroups = true;
50

    
51
	private boolean doTypeDesignations = true;
52
	private boolean doClassificationData = true;
53
	private boolean doAuthors = true;
54
	//references
55
	private DO_REFERENCES doReferences = DO_REFERENCES.ALL;
56
	//names
57
	private boolean doTaxonNames = true;
58
	//taxa
59
	private boolean doTaxa = true;
60

    
61
	@Override
62
	public JaxbImportState getNewState() {
63
		return new JaxbImportState(this);
64
	}
65

    
66
	public int getMaxRows() {
67
		return maxRows;
68
	}
69

    
70
	public void setMaxRows(int maxRows) {
71
		this.maxRows = maxRows;
72
	}
73
	
74
	
75
	
76
	public boolean isDoAgentData() {
77
		return doAgentData;
78
	}
79
	
80
	public void setDoAgentData(boolean doAgentData) {
81
		this.doAgentData = doAgentData;
82
	}
83

    
84
	public boolean isDoLanguageData() {
85
		return doLanguageData;
86
	}
87

    
88
	public void setDoLanguageData(boolean doLanguageData) {
89
		this.doLanguageData = doLanguageData;
90
	}
91

    
92
	public boolean isDoFeatureData() {
93
		return doFeatureData;
94
	}
95

    
96
	public void setDoFeatureData(boolean doFeatureData) {
97
		this.doFeatureData = doFeatureData;
98
	}
99

    
100
	public boolean isDoDescriptions() {
101
		return doDescriptions;
102
	}
103

    
104
	public void setDoDescriptions(boolean doDescriptions) {
105
		this.doDescriptions = doDescriptions;
106
	}
107

    
108
	public boolean isDoMedia() {
109
		return doMedia;
110
	}
111

    
112
	public void setDoMedia(boolean doMedia) {
113
		this.doMedia = doMedia;
114
	}
115

    
116

    
117
	public boolean isDoReferencedEntities() {
118
		return doReferencedEntities;
119
	}
120

    
121
	public void setDoReferencedEntities(boolean doReferencedEntities) {
122
		this.doReferencedEntities = doReferencedEntities;
123
	}
124

    
125

    
126
	public boolean isDoSynonyms() {
127
		return doSynonyms;
128
	}
129

    
130
	public void setDoSynonyms(boolean doSynonyms) {
131
		this.doSynonyms = doSynonyms;
132
	}
133

    
134

    
135
	public boolean isDoTerms() {
136
		return doTerms;
137
	}
138

    
139
	public void setDoTerms(boolean doTerms) {
140
		this.doTerms = doTerms;
141
	}
142

    
143
	public boolean isDoTermVocabularies() {
144
		return doTermVocabularies;
145
	}
146

    
147
	public void setDoTermVocabularies(boolean doTermVocabularies) {
148
		this.doTermVocabularies = doTermVocabularies;
149
	}
150

    
151
	public boolean isDoHomotypicalGroups() {
152
		return doHomotypicalGroups;
153
	}
154

    
155
	public void setDoHomotypicalGroups(boolean doHomotypicalGroups) {
156
		this.doHomotypicalGroups = doHomotypicalGroups;
157
	}
158

    
159
//	@SuppressWarnings("unchecked")
160
	protected void makeIoClassList() {
161
		ioClassList = new Class[] {
162
				JaxbImport.class,
163
		};
164
	};
165

    
166
	public static JaxbImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
167
		return new JaxbImportConfigurator(uri, destination);
168
	}
169

    
170

    
171
	/**
172
	 * @param url
173
	 * @param destination
174
	 */
175
	private JaxbImportConfigurator(URI uri, ICdmDataSource destination) {
176
		super(defaultTransformer);
177
		setSource(uri);
178
		setDestination(destination);
179
		setDbSchemaValidation(DbSchemaValidation.CREATE);
180
	}
181

    
182
	@Override
183
	public Reference getSourceReference() {
184
		//TODO
185
		if (this.sourceReference == null){
186
			logger.warn("getSource Reference not yet fully implemented");
187
			sourceReference = ReferenceFactory.newDatabase();
188
			sourceReference.setTitleCache("Jaxb import", true);
189
		}
190
		return sourceReference;
191
	}
192

    
193

    
194
	@Override
195
	public String getSourceNameString() {
196
		if (this.getSource() == null){
197
			return null;
198
		}else{
199
			return this.getSource().toString();
200
		}
201
	}
202
	
203
//******************** GETTER / SETTER ***************************************/	
204
	
205
	public boolean isDoTypeDesignations() {
206
		return doTypeDesignations;
207
	}
208

    
209
	public void setDoTypeDesignations(boolean doTypeDesignations) {
210
		this.doTypeDesignations = doTypeDesignations;
211
	}
212

    
213
	public boolean isDoClassificationData() {
214
		return this.doClassificationData;
215
	}
216
	
217
	
218
	public boolean isDoOccurrence() {
219
		return doOccurrence;
220
	}
221
	public void setDoOccurrence(boolean doOccurrence) {
222
		this.doOccurrence = doOccurrence;
223
	}
224
	
225

    
226
	public boolean isDoUser() {
227
		return doUser;
228
	}
229

    
230
	public void setDoUser(boolean doUser) {
231
		this.doUser = doUser;
232
	}
233
	
234

    
235
	public boolean isDoAuthors() {
236
		return doAuthors;
237
	}
238
	public void setDoAuthors(boolean doAuthors) {
239
		this.doAuthors = doAuthors;
240
	}
241

    
242
	public DO_REFERENCES getDoReferences() {
243
		return doReferences;
244
	}
245
	public void setDoReferences(DO_REFERENCES doReferences) {
246
		this.doReferences = doReferences;
247
	}
248
	
249
	public boolean isDoTaxonNames() {
250
		return doTaxonNames;
251
	}
252
	public void setDoTaxonNames(boolean doTaxonNames) {
253
		this.doTaxonNames = doTaxonNames;
254
	}
255

    
256
	public boolean isDoTaxa() {
257
		return doTaxa;
258
	}
259
	public void setDoTaxa(boolean doTaxa) {
260
		this.doTaxa = doTaxa;
261
	}
262

    
263

    
264
	@Override
265
	public boolean isOmitTermLoading() {
266
		return true;
267
	}
268

    
269
	@Override
270
	public boolean isCreateNew(){
271
		return true;
272
	}
273

    
274
	@Override
275
	public DbSchemaValidation getDbSchemaValidation() {
276
		if (isCreateNew()){
277
			return DbSchemaValidation.CREATE;
278
		}else{
279
			return super.getDbSchemaValidation();
280
		}
281
	}
282

    
283

    
284
}
285

    
286
   
(13-13/17)