reverting: r16792 (merging of debugged ABCD import into the trunk)
[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.model.reference.Reference;
26 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
27
28 /**
29 * @author p.kelbert
30 * @created 20.10.2008
31 * @version 1.0
32 */
33 public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState, URI> implements IImportConfigurator, IMatchingImportConfigurator {
34 private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);
35 private boolean doParsing = false;
36 private boolean reuseMetadata = false;
37 private boolean reuseTaxon = true;
38 private String taxonReference = null;
39 private boolean doCreateIndividualsAssociations = true;
40 private boolean doReuseExistingDescription = false;
41 private boolean doMatchTaxa = true;
42 private Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
43
44
45 //TODO
46 private static IInputTransformer defaultTransformer = null;
47
48 @SuppressWarnings("unchecked")
49 protected void makeIoClassList(){
50 System.out.println("makeIOClassList");
51 ioClassList = new Class[]{
52 Abcd206Import.class,
53 };
54 };
55
56 public static Abcd206ImportConfigurator NewInstance(URI uri,
57 ICdmDataSource destination){
58 return new Abcd206ImportConfigurator(uri, destination);
59 }
60
61
62 /**
63 * @param berlinModelSource
64 * @param sourceReference
65 * @param destination
66 */
67 private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination) {
68 super(defaultTransformer);
69 setSource(uri);
70 setDestination(destination);
71 }
72
73
74
75
76 // /* (non-Javadoc)
77 // * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
78 // */
79 // public String getSource() {
80 // return (String)super.getSource();
81 // }
82
83 /* (non-Javadoc)
84 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
85 */
86 @Override
87 public Abcd206ImportState getNewState() {
88 return new Abcd206ImportState(this);
89 }
90
91
92 public URI getSource(){
93 return super.getSource();
94 }
95
96 /**
97 * @param file
98 */
99 public void setSource(URI uri) {
100 super.setSource(uri);
101 }
102
103
104
105 /* (non-Javadoc)
106 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
107 */
108 @Override
109 public Reference getSourceReference() {
110 //TODO
111 if (this.sourceReference == null){
112 logger.warn("getSource Reference not yet fully implemented");
113 ReferenceFactory refFactory = ReferenceFactory.newInstance();
114 sourceReference = refFactory.newDatabase();
115 sourceReference.setTitleCache("ABCD specimen import", true);
116 }
117 return sourceReference;
118 }
119
120 public void setTaxonReference(String taxonReference) {
121 this.taxonReference = taxonReference;
122 }
123
124 public Reference getTaxonReference() {
125 //TODO
126 if (this.taxonReference == null){
127 logger.info("getTaxonReference not yet fully implemented");
128 }
129 return sourceReference;
130 }
131
132 public void setDoAutomaticParsing(boolean doParsing){
133 this.doParsing=doParsing;
134 }
135
136 public boolean isDoAutomaticParsing(){
137 return this.doParsing;
138 }
139
140 public void setReUseExistingMetadata(boolean reuseMetadata){
141 this.reuseMetadata = reuseMetadata;
142 }
143
144 public boolean isReUseExistingMetadata(){
145 return this.reuseMetadata;
146 }
147
148 public void setReUseTaxon(boolean reuseTaxon){
149 this.reuseTaxon = reuseTaxon;
150 }
151
152 /**
153 * if {@link #doMatchTaxa} is set false or no matching taxon is found new
154 * taxa will be created. If this flag is set <code>true</code> the newly created taxa
155 * will be reused if possible. Setting this flag to <code>false</code> may lead to
156 * multiple identical taxa.
157 *
158 * @return
159 */
160 public boolean isDoReUseTaxon(){
161 return this.reuseTaxon;
162 }
163
164 public void setDoCreateIndividualsAssociations(
165 boolean doCreateIndividualsAssociations) {
166 this.doCreateIndividualsAssociations = doCreateIndividualsAssociations;
167 }
168
169 /**
170 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
171 *
172 * @return
173 */
174 public boolean isDoCreateIndividualsAssociations() {
175 return doCreateIndividualsAssociations;
176 }
177
178 /**
179 * @param doReuseExistingDescription the doReuseExistingDescription to set
180 */
181 public void setDoReuseExistingDescription(boolean doReuseExistingDescription) {
182 this.doReuseExistingDescription = doReuseExistingDescription;
183 }
184
185 /**
186 * @return the doReuseExistingDescription
187 */
188 public boolean isDoMatchToExistingDescription() {
189 return doReuseExistingDescription;
190 }
191
192 /* (non-Javadoc)
193 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
194 */
195 @Override
196 public boolean isDoMatchTaxa() {
197 return doMatchTaxa;
198 }
199
200 /* (non-Javadoc)
201 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
202 */
203 @Override
204 public void setDoMatchTaxa(boolean doMatchTaxa) {
205 this.doMatchTaxa = doMatchTaxa;
206 }
207
208 /**
209 * @return
210 */
211 public Map<UUID, UUID> getTaxonToDescriptionMap() {
212 // TODO Auto-generated method stub
213 return taxonToDescriptionMap ;
214 }
215
216
217 }