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