2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.io
.specimen
.excel
.in
;
15 import org
.apache
.log4j
.Logger
;
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
;
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();
34 private boolean doParsing
= false;
35 private boolean reuseMetadata
= false;
36 private boolean reuseTaxon
= false;
37 private String taxonReference
= null;
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
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
; //
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;
58 private boolean preferNameCache
= true;
59 private boolean createTaxonIfNotExists
= false;
60 // private boolean includeSynonymsForTaxonMatching = false;
65 @SuppressWarnings("unchecked")
66 protected void makeIoClassList(){
67 ioClassList
= new Class
[]{
68 NamedAreaLevelExcelImport
.class,
69 ExtensionTypeExcelImport
.class,
70 SpecimenCdmExcelImport
.class
74 public static SpecimenCdmExcelImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
){
75 return new SpecimenCdmExcelImportConfigurator(uri
, destination
);
80 * @param berlinModelSource
81 * @param sourceReference
84 private SpecimenCdmExcelImportConfigurator(URI uri
, ICdmDataSource destination
) {
85 super(uri
, destination
, defaultTransformer
);
91 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
93 public SpecimenCdmExcelImportState
getNewState() {
94 return new SpecimenCdmExcelImportState(this);
99 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
102 public Reference
getSourceReference() {
104 if (this.sourceReference
== null){
105 logger
.warn("getSource Reference not yet fully implemented");
106 sourceReference
= ReferenceFactory
.newDatabase();
107 sourceReference
.setTitleCache("Specimen import", true);
109 return sourceReference
;
116 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
118 public String
getSourceNameString() {
119 if (this.getSource() == null){
122 return this.getSource().toString();
126 // **************************** OLD ******************************************
128 public void setTaxonReference(String taxonReference
) {
129 this.taxonReference
= taxonReference
;
132 public Reference
getTaxonReference() {
134 if (this.taxonReference
== null){
135 logger
.info("getTaxonReference not yet fully implemented");
137 return sourceReference
;
140 public void setDoAutomaticParsing(boolean doParsing
){
141 this.doParsing
=doParsing
;
144 public boolean getDoAutomaticParsing(){
145 return this.doParsing
;
148 public void setReUseExistingMetadata(boolean reuseMetadata
){
149 this.reuseMetadata
= reuseMetadata
;
152 public boolean getReUseExistingMetadata(){
153 return this.reuseMetadata
;
156 public void setReUseTaxon(boolean reuseTaxon
){
157 this.reuseTaxon
= reuseTaxon
;
160 public boolean getDoReUseTaxon(){
161 return this.reuseTaxon
;
164 public void setDoSpecimen(boolean doSpecimen
) {
165 this.doSpecimen
= doSpecimen
;
168 public boolean isDoSpecimen() {
172 public void setDoAreaLevels(boolean doAreaLevels
) {
173 this.doAreaLevels
= doAreaLevels
;
176 public boolean isDoAreaLevels() {
180 public void setMakeIndividualAssociations(boolean makeIndividualAssociations
) {
181 this.makeIndividualAssociations
= makeIndividualAssociations
;
184 public boolean isMakeIndividualAssociations() {
185 return makeIndividualAssociations
;
188 public boolean isFirstDeterminationIsStoredUnder() {
189 return firstDeterminationIsStoredUnder
;
193 * @param firstDeterminationIsStoredUnder the firstDeterminationIsStoredUnder to set
195 public void setFirstDeterminationIsStoredUnder(boolean firstDeterminationIsStoredUnder
) {
196 this.firstDeterminationIsStoredUnder
= firstDeterminationIsStoredUnder
;
199 public boolean isDeterminationsAreDeterminationEvent() {
200 return determinationsAreDeterminationEvent
;
204 * @param determinationsAreDeterminationEvent the determinationsAreDeterminationEvent to set
206 public void setDeterminationsAreDeterminationEvent( boolean determinationsAreDeterminationEvent
) {
207 this.determinationsAreDeterminationEvent
= determinationsAreDeterminationEvent
;
210 public void setPreferNameCache(boolean preferNameCache
) {
211 this.preferNameCache
= preferNameCache
;
214 public boolean isPreferNameCache() {
215 return preferNameCache
;
218 public void setDoExtensionTypes(boolean doExtensionTypes
) {
219 this.doExtensionTypes
= doExtensionTypes
;
222 public boolean isDoExtensionTypes() {
223 return doExtensionTypes
;
226 public void setCreateTaxonIfNotExists(boolean createTaxonIfNotExists
) {
227 this.createTaxonIfNotExists
= createTaxonIfNotExists
;
230 public boolean isCreateTaxonIfNotExists() {
231 return createTaxonIfNotExists
;
234 public void setUseMaterialsExaminedForIndividualsAssociations(
235 boolean useMaterialsExaminedForIndividualsAssociations
) {
236 this.useMaterialsExaminedForIndividualsAssociations
= useMaterialsExaminedForIndividualsAssociations
;
239 public boolean isUseMaterialsExaminedForIndividualsAssociations() {
240 return useMaterialsExaminedForIndividualsAssociations
;
243 public void setAreaMatchMode(TermMatchMode areaMatchMode
) {
244 this.areaMatchMode
= areaMatchMode
;
247 public TermMatchMode
getAreaMatchMode() {
248 return areaMatchMode
;