Update of Maxime's work since Hélène's last update for SDD import functions.
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / jaxb / JaxbImportConfigurator.java
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 org.apache.log4j.Logger;
13
14 import eu.etaxonomy.cdm.database.DbSchemaValidation;
15 import eu.etaxonomy.cdm.database.ICdmDataSource;
16 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
17 import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
18 import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
19 import eu.etaxonomy.cdm.model.reference.IDatabase;
20 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
21 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
22
23 /**
24 * @author a.babadshanjan
25 * @created 14.11.2008
26 */
27 public class JaxbImportConfigurator extends ImportConfiguratorBase implements IImportConfigurator {
28
29 private static final Logger logger = Logger.getLogger(JaxbImportConfigurator.class);
30
31 private int maxRows = 0;
32
33
34 private boolean doUsers = true;
35 private boolean doAgentData = true;
36 private boolean doLanguageData = true;
37 private boolean doFeatureData = true;
38 private boolean doDescriptions = true;
39 private boolean doMedia = true;
40 // private boolean doOccurrences = true;
41 // private boolean doReferences = true;
42 private boolean doReferencedEntities = true;
43 // private boolean doRelationships = true;
44 private boolean doSynonyms = true;
45 // private boolean doTaxonNames = true;
46 // private boolean doTaxa = 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 doTaxonomicTreeData = true;
53
54
55
56
57
58 /* (non-Javadoc)
59 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
60 */
61 public JaxbImportState getNewState() {
62 return new JaxbImportState(this);
63 }
64
65 public int getMaxRows() {
66 return maxRows;
67 }
68
69 public void setMaxRows(int maxRows) {
70 this.maxRows = maxRows;
71 }
72
73
74
75 public boolean isDoAgentData() {
76 return doAgentData;
77 }
78
79 public void setDoAgentData(boolean doAgentData) {
80 this.doAgentData = doAgentData;
81 }
82
83 public boolean isDoLanguageData() {
84 return doLanguageData;
85 }
86
87 public void setDoLanguageData(boolean doLanguageData) {
88 this.doLanguageData = doLanguageData;
89 }
90
91 public boolean isDoFeatureData() {
92 return doFeatureData;
93 }
94
95 public void setDoFeatureData(boolean doFeatureData) {
96 this.doFeatureData = doFeatureData;
97 }
98
99 public boolean isDoDescriptions() {
100 return doDescriptions;
101 }
102
103 public void setDoDescriptions(boolean doDescriptions) {
104 this.doDescriptions = doDescriptions;
105 }
106
107 public boolean isDoMedia() {
108 return doMedia;
109 }
110
111 public void setDoMedia(boolean doMedia) {
112 this.doMedia = doMedia;
113 }
114
115
116 public boolean isDoReferencedEntities() {
117 return doReferencedEntities;
118 }
119
120 public void setDoReferencedEntities(boolean doReferencedEntities) {
121 this.doReferencedEntities = doReferencedEntities;
122 }
123
124
125 public boolean isDoSynonyms() {
126 return doSynonyms;
127 }
128
129 public void setDoSynonyms(boolean doSynonyms) {
130 this.doSynonyms = doSynonyms;
131 }
132
133
134 public boolean isDoTerms() {
135 return doTerms;
136 }
137
138 public void setDoTerms(boolean doTerms) {
139 this.doTerms = doTerms;
140 }
141
142 public boolean isDoTermVocabularies() {
143 return doTermVocabularies;
144 }
145
146 public void setDoTermVocabularies(boolean doTermVocabularies) {
147 this.doTermVocabularies = doTermVocabularies;
148 }
149
150 public boolean isDoHomotypicalGroups() {
151 return doHomotypicalGroups;
152 }
153
154 public void setDoHomotypicalGroups(boolean doHomotypicalGroups) {
155 this.doHomotypicalGroups = doHomotypicalGroups;
156 }
157
158 // @SuppressWarnings("unchecked")
159 protected void makeIoClassList() {
160 ioClassList = new Class[] {
161 JaxbImport.class,
162 };
163 };
164
165 public static JaxbImportConfigurator NewInstance(String url,
166 ICdmDataSource destination){
167 return new JaxbImportConfigurator(url, destination);
168 }
169
170
171 /**
172 * @param url
173 * @param destination
174 */
175 private JaxbImportConfigurator(String url, ICdmDataSource destination) {
176 super();
177 setSource(url);
178 setDestination(destination);
179 setDbSchemaValidation(DbSchemaValidation.CREATE);
180 }
181
182
183 /* (non-Javadoc)
184 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
185 */
186 public Object getSource() {
187 // public String getSource() {
188 return (String)super.getSource();
189 }
190
191
192 /**
193 * @param file
194 */
195 public void setSource(String fileName) {
196 super.setSource(fileName);
197 }
198
199
200 /* (non-Javadoc)
201 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
202 */
203 @Override
204 public ReferenceBase getSourceReference() {
205 //TODO
206 if (this.sourceReference == null){
207 ReferenceFactory refFactory = ReferenceFactory.newInstance();
208 logger.warn("getSource Reference not yet fully implemented");
209 sourceReference = refFactory.newDatabase();
210 sourceReference.setTitleCache("Jaxb import");
211 }
212 return sourceReference;
213 }
214
215
216 /* (non-Javadoc)
217 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
218 */
219 public String getSourceNameString() {
220 if (this.getSource() == null){
221 return null;
222 }else{
223 return (String)this.getSource();
224 }
225 }
226
227 public boolean isDoTypeDesignations() {
228 return doTypeDesignations;
229 }
230
231 public void setDoTypeDesignations(boolean doTypeDesignations) {
232 this.doTypeDesignations = doTypeDesignations;
233 }
234
235 public boolean isDoTaxonomicTreeData() {
236 return this.doTaxonomicTreeData;
237 }
238 }
239
240