refactor Abcd import so that save can be handled separately, not yet complete
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / specimen / abcd206 / in / Abcd206ImportConfigurator.java
1 /**
2 * Copyright (C) 2007 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.specimen.abcd206.in;
11
12
13 import java.net.URI;
14 import java.util.HashMap;
15 import java.util.Map;
16 import java.util.UUID;
17
18 import org.apache.log4j.Logger;
19
20 import eu.etaxonomy.cdm.database.ICdmDataSource;
21 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
22 import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;
23 import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
24 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
25 import eu.etaxonomy.cdm.io.specimen.SpecimenUserInteraction;
26 import eu.etaxonomy.cdm.model.agent.Person;
27 import eu.etaxonomy.cdm.model.agent.Team;
28 import eu.etaxonomy.cdm.model.reference.Reference;
29
30 /**
31 * @author p.kelbert
32 * @created 20.10.2008
33 * @version 1.0
34 */
35 public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState, URI> implements IImportConfigurator, IMatchingImportConfigurator {
36 private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);
37
38 private static String sourceReferenceTitle = null;
39 private boolean parseNameAutomatically = false;
40 private boolean reuseExistingMetadata = true;
41 private String taxonReference = null;
42 private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations = true;
43 private boolean reuseExistingDescriptiveGroups = false;
44 private boolean reuseExistingTaxaWhenPossible = true;
45 private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
46 private Map<String, Team> titleCacheTeam;
47 private Map<String, Person> titleCachePerson;
48 private String defaultAuthor="";
49 private boolean allowReuseOtherClassifications =true;
50
51
52 private final SpecimenUserInteraction specimenUserInteraction = new SpecimenUserInteraction();
53
54 private Map<String,UUID> namedAreaDecisions = new HashMap<String,UUID>();
55
56 //TODO
57 private static IInputTransformer defaultTransformer = null;
58
59 @Override
60 @SuppressWarnings("unchecked")
61 protected void makeIoClassList(){
62 System.out.println("makeIOClassList");
63 ioClassList = new Class[]{
64 Abcd206Import.class,
65 };
66 };
67
68 public static Abcd206ImportConfigurator NewInstance(URI uri,
69 ICdmDataSource destination){
70 return new Abcd206ImportConfigurator(uri, destination);
71 }
72
73 /**
74 * @param uri
75 * @param object
76 * @param b
77 * @return
78 */
79 public static Abcd206ImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {
80 return new Abcd206ImportConfigurator(uri, destination,interact);
81 }
82
83
84 /**
85 * @param berlinModelSource
86 * @param sourceReference
87 * @param destination
88 */
89 private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination) {
90 super(defaultTransformer);
91 setSource(uri);
92 setDestination(destination);
93 setSourceReferenceTitle("ABCD classic");
94 }
95
96 /**
97 * @param berlinModelSource
98 * @param sourceReference
99 * @param destination
100 */
101 private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination, boolean interact) {
102 super(defaultTransformer);
103 setSource(uri);
104 setDestination(destination);
105 setSourceReferenceTitle("ABCD classic");
106 setInteractWithUser(interact);
107 }
108
109
110
111
112
113 /* (non-Javadoc)
114 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
115 */
116 @Override
117 public Abcd206ImportState getNewState() {
118 return new Abcd206ImportState(this);
119 }
120
121
122 @Override
123 public URI getSource(){
124 return super.getSource();
125 }
126
127 /**
128 * @param file
129 */
130 @Override
131 public void setSource(URI uri) {
132 super.setSource(uri);
133 }
134
135
136 @Override
137 public String getSourceReferenceTitle(){
138 return this.sourceReferenceTitle;
139 }
140
141 @Override
142 public void setSourceReferenceTitle(String name){
143 this.sourceReferenceTitle=name;
144 }
145
146 /* (non-Javadoc)
147 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
148 */
149 @Override
150 public Reference getSourceReference() {
151 //TODO
152 return sourceReference;
153 }
154
155 public void setTaxonReference(String taxonReference) {
156 this.taxonReference = taxonReference;
157 }
158
159 public Reference getTaxonReference() {
160 //TODO
161 if (this.taxonReference == null){
162 logger.info("getTaxonReference not yet fully implemented");
163 }
164 return sourceReference;
165 }
166
167 public void setParseNameAutomatically(boolean doParsing){
168 this.parseNameAutomatically=doParsing;
169 }
170
171 public boolean isParseNameAutomatically(){
172 return this.parseNameAutomatically;
173 }
174
175 public void setReuseExistingMetadata(boolean reuseMetadata){
176 this.reuseExistingMetadata = reuseMetadata;
177 }
178
179 public boolean isReUseExistingMetadata(){
180 return this.reuseExistingMetadata;
181 }
182
183 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
184 boolean doCreateIndividualsAssociations) {
185 this.addIndividualsAssociationsSuchAsSpecimenAndObservations = doCreateIndividualsAssociations;
186 }
187
188 /**
189 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
190 *
191 * @return
192 */
193 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
194 return addIndividualsAssociationsSuchAsSpecimenAndObservations;
195 }
196
197 /**
198 * @param doReuseExistingDescription the doReuseExistingDescription to set
199 * NOT USED YET
200 */
201 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription) {
202 this.reuseExistingDescriptiveGroups = doReuseExistingDescription;
203 }
204
205 /**
206 * @return the doReuseExistingDescription
207 */
208 public boolean isReuseExistingDescriptiveGroups() {
209 return reuseExistingDescriptiveGroups;
210 }
211
212 /* (non-Javadoc)
213 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
214 */
215 @Override
216 public boolean isReuseExistingTaxaWhenPossible() {
217 return reuseExistingTaxaWhenPossible;
218 }
219
220 /* (non-Javadoc)
221 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
222 */
223 @Override
224 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa) {
225 this.reuseExistingTaxaWhenPossible = doMatchTaxa;
226 }
227
228 /**
229 * @return
230 */
231 public Map<UUID, UUID> getTaxonToDescriptionMap() {
232 // TODO Auto-generated method stub
233 return taxonToDescriptionMap ;
234 }
235
236
237
238 public Map<String, Team> getTeams() {
239 return titleCacheTeam;
240 }
241
242 public void setTeams(Map<String, Team> titleCacheTeam) {
243 this.titleCacheTeam = titleCacheTeam;
244 }
245
246 public Map<String, Person> getPersons() {
247 return titleCachePerson;
248 }
249
250 public void setPersons(Map<String, Person> titleCachePerson) {
251 this.titleCachePerson = titleCachePerson;
252 }
253
254 /**
255 * @param string
256 */
257 public void setDefaultAuthor(String string) {
258 defaultAuthor=string;
259
260 }
261
262 public String getDefaultAuthor(){
263 return defaultAuthor;
264 }
265
266 public Map<String,UUID> getNamedAreaDecisions() {
267 return namedAreaDecisions;
268 }
269
270 public void setNamedAreaDecisions(Map<String,UUID> namedAreaDecisions) {
271 this.namedAreaDecisions = namedAreaDecisions;
272 }
273
274 public void putNamedAreaDecision(String areaStr,UUID uuid){
275 this.namedAreaDecisions.put(areaStr,uuid);
276 }
277
278 public UUID getNamedAreaDecision(String areaStr){
279 return namedAreaDecisions.get(areaStr);
280 }
281
282
283 /**
284 * @return the allowReuseOtherClassifications
285 */
286 public boolean isAllowReuseOtherClassifications() {
287 return allowReuseOtherClassifications;
288 }
289
290 /**
291 * @param allowReuseOtherClassifications the allowReuseOtherClassifications to set
292 */
293 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications) {
294 this.allowReuseOtherClassifications = allowReuseOtherClassifications;
295 }
296
297 /**
298 * @return the specimenUserInteraction
299 */
300 public SpecimenUserInteraction getSpecimenUserInteraction() {
301 return specimenUserInteraction;
302 }
303
304
305
306
307 }