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.excel.in;
|
11
|
|
12
|
|
13
|
import eu.etaxonomy.cdm.common.URI;
|
14
|
|
15
|
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
16
|
|
17
|
import eu.etaxonomy.cdm.database.ICdmDataSource;
|
18
|
import eu.etaxonomy.cdm.io.common.CdmImportBase.TermMatchMode;
|
19
|
import eu.etaxonomy.cdm.io.common.IImportConfigurator;
|
20
|
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
|
21
|
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase;
|
22
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
23
|
import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @since 05.05.2011
|
28
|
*/
|
29
|
public class SpecimenCdmExcelImportConfigurator extends ExcelImportConfiguratorBase implements IImportConfigurator {
|
30
|
private static final long serialVersionUID = -114046010543496409L;
|
31
|
private static final Logger logger = LogManager.getLogger(SpecimenCdmExcelImportConfigurator.class);
|
32
|
private static IInputTransformer defaultTransformer = new SpecimenCdmExcelTransformer();
|
33
|
|
34
|
//old
|
35
|
private boolean doParsing = false;
|
36
|
private boolean reuseMetadata = false;
|
37
|
private boolean reuseTaxon = false;
|
38
|
private String taxonReference = null;
|
39
|
|
40
|
//new
|
41
|
private boolean doSpecimen = true; //reads the specimen worksheet
|
42
|
private boolean doAreaLevels = true; //reads the areaLevels worksheet
|
43
|
private boolean doExtensionTypes = true; //reads the extensionType worksheet
|
44
|
|
45
|
|
46
|
private boolean useCountry; //if isocountry and country is available, use country instead of isocountry
|
47
|
//tries to match areas by the abbreviated label
|
48
|
//TODO still needs to be refined as this may hold only for certain vocabularies, levels, ...
|
49
|
//there also maybe more strategies like first label, then abbreviated label, ....
|
50
|
private TermMatchMode areaMatchMode = TermMatchMode.UUID_ONLY;
|
51
|
private final PersonParserFormatEnum personParserFormat = PersonParserFormatEnum.POSTFIX; //
|
52
|
|
53
|
//if true, determinations are imported also as individualAssociations
|
54
|
private boolean makeIndividualAssociations = true;
|
55
|
private boolean useMaterialsExaminedForIndividualsAssociations = true;
|
56
|
private boolean firstDeterminationIsStoredUnder = false;
|
57
|
private boolean determinationsAreDeterminationEvent = true;
|
58
|
|
59
|
private boolean preferNameCache = true;
|
60
|
private boolean createTaxonIfNotExists = false;
|
61
|
// private boolean includeSynonymsForTaxonMatching = false;
|
62
|
|
63
|
|
64
|
|
65
|
|
66
|
@Override
|
67
|
@SuppressWarnings("unchecked")
|
68
|
protected void makeIoClassList(){
|
69
|
ioClassList = new Class[]{
|
70
|
NamedAreaLevelExcelImport.class,
|
71
|
ExtensionTypeExcelImport.class,
|
72
|
SpecimenCdmExcelImport.class
|
73
|
};
|
74
|
}
|
75
|
|
76
|
public static SpecimenCdmExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination){
|
77
|
return new SpecimenCdmExcelImportConfigurator(uri, destination);
|
78
|
}
|
79
|
|
80
|
|
81
|
/**
|
82
|
* @param uri
|
83
|
* @param object
|
84
|
* @param b
|
85
|
* @return
|
86
|
*/
|
87
|
public static SpecimenCdmExcelImportConfigurator NewInstance(URI uri, ICdmDataSource destination, boolean interact) {
|
88
|
return new SpecimenCdmExcelImportConfigurator(uri, destination, interact);
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
* @param berlinModelSource
|
93
|
* @param sourceReference
|
94
|
* @param destination
|
95
|
*/
|
96
|
private SpecimenCdmExcelImportConfigurator(URI uri, ICdmDataSource destination) {
|
97
|
super(uri, destination, defaultTransformer);
|
98
|
}
|
99
|
|
100
|
/**
|
101
|
* @param berlinModelSource
|
102
|
* @param sourceReference
|
103
|
* @param destination
|
104
|
*/
|
105
|
private SpecimenCdmExcelImportConfigurator(URI uri, ICdmDataSource destination, boolean interact) {
|
106
|
super(uri, destination, defaultTransformer);
|
107
|
setInteractWithUser(interact);
|
108
|
}
|
109
|
|
110
|
@Override
|
111
|
public SpecimenCdmExcelImportState getNewState() {
|
112
|
return new SpecimenCdmExcelImportState(this);
|
113
|
}
|
114
|
|
115
|
@Override
|
116
|
public Reference getSourceReference() {
|
117
|
//TODO
|
118
|
if (this.sourceReference == null){
|
119
|
logger.warn("getSource Reference not yet fully implemented");
|
120
|
sourceReference = ReferenceFactory.newDatabase();
|
121
|
sourceReference.setTitleCache("Specimen import", true);
|
122
|
}
|
123
|
return sourceReference;
|
124
|
}
|
125
|
|
126
|
@Override
|
127
|
public String getSourceNameString() {
|
128
|
if (this.getSource() == null){
|
129
|
return null;
|
130
|
}else{
|
131
|
return this.getSource().toString();
|
132
|
}
|
133
|
}
|
134
|
|
135
|
// **************************** OLD ******************************************
|
136
|
|
137
|
public void setTaxonReference(String taxonReference) {
|
138
|
this.taxonReference = taxonReference;
|
139
|
}
|
140
|
|
141
|
public Reference getTaxonReference() {
|
142
|
//TODO
|
143
|
if (this.taxonReference == null){
|
144
|
logger.info("getTaxonReference not yet fully implemented");
|
145
|
}
|
146
|
return sourceReference;
|
147
|
}
|
148
|
|
149
|
public void setDoAutomaticParsing(boolean doParsing){
|
150
|
this.doParsing=doParsing;
|
151
|
}
|
152
|
|
153
|
public boolean getDoAutomaticParsing(){
|
154
|
return this.doParsing;
|
155
|
}
|
156
|
|
157
|
public void setReUseExistingMetadata(boolean reuseMetadata){
|
158
|
this.reuseMetadata = reuseMetadata;
|
159
|
}
|
160
|
|
161
|
public boolean getReUseExistingMetadata(){
|
162
|
return this.reuseMetadata;
|
163
|
}
|
164
|
|
165
|
public void setReUseTaxon(boolean reuseTaxon){
|
166
|
this.reuseTaxon = reuseTaxon;
|
167
|
}
|
168
|
|
169
|
public boolean getDoReUseTaxon(){
|
170
|
return this.reuseTaxon;
|
171
|
}
|
172
|
|
173
|
public void setDoSpecimen(boolean doSpecimen) {
|
174
|
this.doSpecimen = doSpecimen;
|
175
|
}
|
176
|
|
177
|
public boolean isDoSpecimen() {
|
178
|
return doSpecimen;
|
179
|
}
|
180
|
|
181
|
public void setDoAreaLevels(boolean doAreaLevels) {
|
182
|
this.doAreaLevels = doAreaLevels;
|
183
|
}
|
184
|
|
185
|
public boolean isDoAreaLevels() {
|
186
|
return doAreaLevels;
|
187
|
}
|
188
|
|
189
|
public void setMakeIndividualAssociations(boolean makeIndividualAssociations) {
|
190
|
this.makeIndividualAssociations = makeIndividualAssociations;
|
191
|
}
|
192
|
|
193
|
public boolean isMakeIndividualAssociations() {
|
194
|
return makeIndividualAssociations;
|
195
|
}
|
196
|
|
197
|
public boolean isFirstDeterminationIsStoredUnder() {
|
198
|
return firstDeterminationIsStoredUnder ;
|
199
|
}
|
200
|
|
201
|
/**
|
202
|
* @param firstDeterminationIsStoredUnder the firstDeterminationIsStoredUnder to set
|
203
|
*/
|
204
|
public void setFirstDeterminationIsStoredUnder(boolean firstDeterminationIsStoredUnder) {
|
205
|
this.firstDeterminationIsStoredUnder = firstDeterminationIsStoredUnder;
|
206
|
}
|
207
|
|
208
|
public boolean isDeterminationsAreDeterminationEvent() {
|
209
|
return determinationsAreDeterminationEvent ;
|
210
|
}
|
211
|
|
212
|
/**
|
213
|
* @param determinationsAreDeterminationEvent the determinationsAreDeterminationEvent to set
|
214
|
*/
|
215
|
public void setDeterminationsAreDeterminationEvent( boolean determinationsAreDeterminationEvent) {
|
216
|
this.determinationsAreDeterminationEvent = determinationsAreDeterminationEvent;
|
217
|
}
|
218
|
|
219
|
public void setPreferNameCache(boolean preferNameCache) {
|
220
|
this.preferNameCache = preferNameCache;
|
221
|
}
|
222
|
|
223
|
public boolean isPreferNameCache() {
|
224
|
return preferNameCache;
|
225
|
}
|
226
|
|
227
|
public void setDoExtensionTypes(boolean doExtensionTypes) {
|
228
|
this.doExtensionTypes = doExtensionTypes;
|
229
|
}
|
230
|
|
231
|
public boolean isDoExtensionTypes() {
|
232
|
return doExtensionTypes;
|
233
|
}
|
234
|
|
235
|
public void setCreateTaxonIfNotExists(boolean createTaxonIfNotExists) {
|
236
|
this.createTaxonIfNotExists = createTaxonIfNotExists;
|
237
|
}
|
238
|
|
239
|
public boolean isCreateTaxonIfNotExists() {
|
240
|
return createTaxonIfNotExists;
|
241
|
}
|
242
|
|
243
|
public void setUseMaterialsExaminedForIndividualsAssociations(
|
244
|
boolean useMaterialsExaminedForIndividualsAssociations) {
|
245
|
this.useMaterialsExaminedForIndividualsAssociations = useMaterialsExaminedForIndividualsAssociations;
|
246
|
}
|
247
|
|
248
|
public boolean isUseMaterialsExaminedForIndividualsAssociations() {
|
249
|
return useMaterialsExaminedForIndividualsAssociations;
|
250
|
}
|
251
|
|
252
|
public void setAreaMatchMode(TermMatchMode areaMatchMode) {
|
253
|
this.areaMatchMode = areaMatchMode;
|
254
|
}
|
255
|
|
256
|
public TermMatchMode getAreaMatchMode() {
|
257
|
return areaMatchMode;
|
258
|
}
|
259
|
|
260
|
|
261
|
|
262
|
|
263
|
|
264
|
|
265
|
}
|