1
2
3
4
5
6
7
8
9
10 package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11
12
13 import java.util.HashMap;
14 import java.util.Map;
15 import java.util.UUID;
16
17 import org.apache.log4j.Logger;
18
19 import eu.etaxonomy.cdm.api.service.IDescriptionService;
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.ImportStateBase;
25 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
26 import eu.etaxonomy.cdm.model.description.TaxonDescription;
27 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
28 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
29
30
31
32
33
34
35 public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState> implements IImportConfigurator, IMatchingImportConfigurator {
36 private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);
37 private boolean doParsing = false;
38 private boolean reuseMetadata = false;
39 private boolean reuseTaxon = true;
40 private String taxonReference = null;
41 private boolean doCreateIndividualsAssociations = false;
42 private boolean doReuseExistingDescription = false;
43 private boolean doMatchTaxa = false;
44 private Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
45
46
47
48 private static IInputTransformer defaultTransformer = null;
49
50 @SuppressWarnings("unchecked")
51 protected void makeIoClassList(){
52 System.out.println("makeIOClassList");
53 ioClassList = new Class[]{
54 Abcd206Import.class,
55 };
56 };
57
58 public static Abcd206ImportConfigurator NewInstance(String url,
59 ICdmDataSource destination){
60 return new Abcd206ImportConfigurator(url, destination);
61 }
62
63
64
65
66
67
68
69 private Abcd206ImportConfigurator(String url, ICdmDataSource destination) {
70 super(defaultTransformer);
71 setSource(url);
72 setDestination(destination);
73 }
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88 @Override
89 public Abcd206ImportState getNewState() {
90 return new Abcd206ImportState(this);
91 }
92
93
94 public String getSource(){
95 return (String)super.getSource();
96 }
97
98
99
100
101 public void setSource(String file) {
102 super.setSource(file);
103 }
104
105
106
107
108
109
110 @Override
111 public ReferenceBase getSourceReference() {
112
113 if (this.sourceReference == null){
114 logger.warn("getSource Reference not yet fully implemented");
115 ReferenceFactory refFactory = ReferenceFactory.newInstance();
116 sourceReference = refFactory.newDatabase();
117 sourceReference.setTitleCache("ABCD specimen import", true);
118 }
119 return sourceReference;
120 }
121
122 public void setTaxonReference(String taxonReference) {
123 this.taxonReference = taxonReference;
124 }
125
126 public ReferenceBase getTaxonReference() {
127
128 if (this.taxonReference == null){
129 logger.info("getTaxonReference not yet fully implemented");
130 }
131 return sourceReference;
132 }
133
134
135
136
137
138 public String getSourceNameString() {
139 if (this.getSource() == null){
140 return null;
141 }else{
142 return (String)this.getSource();
143 }
144 }
145
146 public void setDoAutomaticParsing(boolean doParsing){
147 this.doParsing=doParsing;
148 }
149
150 public boolean isDoAutomaticParsing(){
151 return this.doParsing;
152 }
153
154 public void setReUseExistingMetadata(boolean reuseMetadata){
155 this.reuseMetadata = reuseMetadata;
156 }
157
158 public boolean isReUseExistingMetadata(){
159 return this.reuseMetadata;
160 }
161
162 public void setReUseTaxon(boolean reuseTaxon){
163 this.reuseTaxon = reuseTaxon;
164 }
165
166
167
168
169
170
171
172
173
174 public boolean isDoReUseTaxon(){
175 return this.reuseTaxon;
176 }
177
178 public void setDoCreateIndividualsAssociations(
179 boolean doCreateIndividualsAssociations) {
180 this.doCreateIndividualsAssociations = doCreateIndividualsAssociations;
181 }
182
183
184
185
186
187
188 public boolean isDoCreateIndividualsAssociations() {
189 return doCreateIndividualsAssociations;
190 }
191
192
193
194
195 public void setDoReuseExistingDescription(boolean doReuseExistingDescription) {
196 this.doReuseExistingDescription = doReuseExistingDescription;
197 }
198
199
200
201
202 public boolean isDoMatchToExistingDescription() {
203 return doReuseExistingDescription;
204 }
205
206
207
208
209 @Override
210 public boolean isDoMatchTaxa() {
211 return doMatchTaxa;
212 }
213
214
215
216
217 @Override
218 public void setDoMatchTaxa(boolean doMatchTaxa) {
219 this.doMatchTaxa = doMatchTaxa;
220 }
221
222
223
224
225 public Map<UUID, UUID> getTaxonToDescriptionMap() {
226
227 return taxonToDescriptionMap ;
228 }
229
230
231 }