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
.abcd206
.in
;
13 import java
.io
.InputStream
;
15 import java
.util
.HashMap
;
17 import java
.util
.UUID
;
19 import org
.apache
.log4j
.Logger
;
21 import eu
.etaxonomy
.cdm
.common
.UriUtils
;
22 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
24 import eu
.etaxonomy
.cdm
.io
.common
.IMatchingImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.io
.common
.ImportConfiguratorBase
;
26 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
27 import eu
.etaxonomy
.cdm
.io
.specimen
.SpecimenUserInteraction
;
28 import eu
.etaxonomy
.cdm
.model
.agent
.Person
;
29 import eu
.etaxonomy
.cdm
.model
.agent
.Team
;
30 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
37 public class Abcd206ImportConfigurator
extends ImportConfiguratorBase
<Abcd206ImportState
, InputStream
> implements IImportConfigurator
, IMatchingImportConfigurator
{
38 private static final Logger logger
= Logger
.getLogger(Abcd206ImportConfigurator
.class);
40 private static String sourceReferenceTitle
= null;
42 //FIXME what does this do?
43 private boolean parseNameAutomatically
= false;
44 private boolean reuseExistingMetadata
= true;
45 private String taxonReference
= null;
46 private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations
= true;
47 private boolean reuseExistingDescriptiveGroups
= false;
48 private boolean reuseExistingTaxaWhenPossible
= true;
49 private final Map
<UUID
, UUID
> taxonToDescriptionMap
= new HashMap
<UUID
, UUID
>();
50 private Map
<String
, Team
> titleCacheTeam
;
51 private Map
<String
, Person
> titleCachePerson
;
52 private String defaultAuthor
="";
53 private boolean allowReuseOtherClassifications
=true;
54 private boolean addMediaAsMediaSpecimen
= false;
55 private boolean determinationOnFieldUnitLevel
= false;
56 private boolean deduplicateReferences
= false;
57 private boolean deduplicateClassifications
= false;
58 private boolean ignoreAuthorship
= false;
59 private boolean removeCountryFromLocalityText
= false;
60 private boolean moveNewTaxaToDefaultClassification
= false;
62 private boolean mapUnitIdToCatalogNumber
= true;
63 private boolean mapUnitIdToAccessionNumber
= false;
64 private boolean mapUnitIdToBarcode
= false;
66 private final SpecimenUserInteraction specimenUserInteraction
= new SpecimenUserInteraction();
68 private Map
<String
,UUID
> namedAreaDecisions
= new HashMap
<String
,UUID
>();
71 private static IInputTransformer defaultTransformer
= null;
73 private URI sourceUri
;
74 private URI reportUri
;
78 @SuppressWarnings("unchecked")
79 protected void makeIoClassList(){
80 System
.out
.println("makeIOClassList");
81 ioClassList
= new Class
[]{
86 public static Abcd206ImportConfigurator
NewInstance(URI uri
,ICdmDataSource destination
){
87 return new Abcd206ImportConfigurator(null, uri
, destination
, false);
96 public static Abcd206ImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
, boolean interact
) {
97 return new Abcd206ImportConfigurator(null, uri
, destination
, interact
);
106 public static Abcd206ImportConfigurator
NewInstance(InputStream stream
, ICdmDataSource destination
, boolean interact
) {
107 return new Abcd206ImportConfigurator(stream
, null, destination
, interact
);
113 * @param berlinModelSource
114 * @param sourceReference
117 private Abcd206ImportConfigurator(InputStream stream
, URI uri
, ICdmDataSource destination
, boolean interact
) {
118 super(defaultTransformer
);
122 this.sourceUri
= uri
;
124 setDestination(destination
);
125 setSourceReferenceTitle("ABCD classic");
126 setInteractWithUser(interact
);
134 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
137 public Abcd206ImportState
getNewState() {
138 return new Abcd206ImportState(this);
143 public InputStream
getSource(){
144 if (super.getSource() != null){
145 return super.getSource();
146 }else if (this.sourceUri
!= null){
148 InputStream is
= UriUtils
.getInputStream(sourceUri
);
151 } catch (Exception e
) {
152 throw new RuntimeException(e
);
163 public void setSource(InputStream is
) {
164 this.sourceUri
= null;
168 public URI
getSourceUri(){
169 return this.sourceUri
;
175 public void setSourceUri(URI sourceUri
) {
176 this.sourceUri
= sourceUri
;
177 super.setSource(null);
182 public String
getSourceReferenceTitle(){
183 return this.sourceReferenceTitle
;
187 public void setSourceReferenceTitle(String name
){
188 this.sourceReferenceTitle
=name
;
192 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
195 public Reference
getSourceReference() {
197 return sourceReference
;
200 public void setTaxonReference(String taxonReference
) {
201 this.taxonReference
= taxonReference
;
204 public Reference
getTaxonReference() {
206 if (this.taxonReference
== null){
207 logger
.info("getTaxonReference not yet fully implemented");
209 return sourceReference
;
212 public void setParseNameAutomatically(boolean doParsing
){
213 this.parseNameAutomatically
=doParsing
;
216 public boolean isParseNameAutomatically(){
217 return this.parseNameAutomatically
;
220 public void setReuseExistingMetadata(boolean reuseMetadata
){
221 this.reuseExistingMetadata
= reuseMetadata
;
224 public boolean isReUseExistingMetadata(){
225 return this.reuseExistingMetadata
;
228 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
229 boolean doCreateIndividualsAssociations
) {
230 this.addIndividualsAssociationsSuchAsSpecimenAndObservations
= doCreateIndividualsAssociations
;
234 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
238 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
239 return addIndividualsAssociationsSuchAsSpecimenAndObservations
;
243 * @param doReuseExistingDescription the doReuseExistingDescription to set
246 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription
) {
247 this.reuseExistingDescriptiveGroups
= doReuseExistingDescription
;
251 * @return the doReuseExistingDescription
253 public boolean isReuseExistingDescriptiveGroups() {
254 return reuseExistingDescriptiveGroups
;
258 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
261 public boolean isReuseExistingTaxaWhenPossible() {
262 return reuseExistingTaxaWhenPossible
;
266 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
269 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa
) {
270 this.reuseExistingTaxaWhenPossible
= doMatchTaxa
;
276 public Map
<UUID
, UUID
> getTaxonToDescriptionMap() {
277 // TODO Auto-generated method stub
278 return taxonToDescriptionMap
;
283 public Map
<String
, Team
> getTeams() {
284 return titleCacheTeam
;
287 public void setTeams(Map
<String
, Team
> titleCacheTeam
) {
288 this.titleCacheTeam
= titleCacheTeam
;
291 public Map
<String
, Person
> getPersons() {
292 return titleCachePerson
;
295 public void setPersons(Map
<String
, Person
> titleCachePerson
) {
296 this.titleCachePerson
= titleCachePerson
;
302 public void setDefaultAuthor(String string
) {
303 defaultAuthor
=string
;
307 public String
getDefaultAuthor(){
308 return defaultAuthor
;
311 public Map
<String
,UUID
> getNamedAreaDecisions() {
312 return namedAreaDecisions
;
315 public void setNamedAreaDecisions(Map
<String
,UUID
> namedAreaDecisions
) {
316 this.namedAreaDecisions
= namedAreaDecisions
;
319 public void putNamedAreaDecision(String areaStr
,UUID uuid
){
320 this.namedAreaDecisions
.put(areaStr
,uuid
);
323 public UUID
getNamedAreaDecision(String areaStr
){
324 return namedAreaDecisions
.get(areaStr
);
328 * @return the doAddMediaAsMediaSpecimen
330 public boolean isAddMediaAsMediaSpecimen() {
331 return addMediaAsMediaSpecimen
;
334 public void setAddMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen
) {
335 this.addMediaAsMediaSpecimen
= addMediaAsMediaSpecimen
;
338 public boolean isDeterminationOnFieldUnitLevel() {
339 return determinationOnFieldUnitLevel
;
342 public void setDeterminationOnFieldUnitLevel(boolean determinationOnFieldUnitLevel
) {
343 this.determinationOnFieldUnitLevel
= determinationOnFieldUnitLevel
;
347 public boolean isDeduplicateClassifications() {
348 return deduplicateClassifications
;
351 public void setDeduplicateClassifications(boolean deduplicateClassifications
) {
352 this.deduplicateClassifications
= deduplicateClassifications
;
355 public boolean isDeduplicateReferences() {
356 return deduplicateReferences
;
359 public void setDeduplicateReferences(boolean deduplicateReferences
) {
360 this.deduplicateReferences
= deduplicateReferences
;
363 public boolean isAllowReuseOtherClassifications() {
364 return allowReuseOtherClassifications
;
367 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications
) {
368 this.allowReuseOtherClassifications
= allowReuseOtherClassifications
;
371 public SpecimenUserInteraction
getSpecimenUserInteraction() {
372 return specimenUserInteraction
;
375 public void setReportUri(URI reportUri
) {
376 this.reportUri
= reportUri
;
379 public URI
getReportUri() {
383 public void setIgnoreAuthorship(boolean ignoreAuthorship
) {
384 this.ignoreAuthorship
= ignoreAuthorship
;
387 public boolean isIgnoreAuthorship() {
388 return ignoreAuthorship
;
391 public boolean isMapUnitIdToAccessionNumber() {
392 return mapUnitIdToAccessionNumber
;
395 public boolean isMapUnitIdToBarcode() {
396 return mapUnitIdToBarcode
;
399 public boolean isMapUnitIdToCatalogNumber() {
400 return mapUnitIdToCatalogNumber
;
403 public void setMapUnitIdToAccessionNumber(boolean mapUnitIdToAccessionNumber
) {
404 this.mapUnitIdToAccessionNumber
= mapUnitIdToAccessionNumber
;
407 public void setMapUnitIdToBarcode(boolean mapUnitIdToBarcode
) {
408 this.mapUnitIdToBarcode
= mapUnitIdToBarcode
;
411 public void setMapUnitIdToCatalogNumber(boolean mapUnitIdToCatalogNumber
) {
412 this.mapUnitIdToCatalogNumber
= mapUnitIdToCatalogNumber
;
415 public void setRemoveCountryFromLocalityText(boolean removeCountryFromLocalityText
) {
416 this.removeCountryFromLocalityText
= removeCountryFromLocalityText
;
419 public boolean isRemoveCountryFromLocalityText() {
420 return removeCountryFromLocalityText
;
423 public boolean isMoveNewTaxaToDefaultClassification() {
424 return moveNewTaxaToDefaultClassification
;
427 public void setMoveNewTaxaToDefaultClassification(boolean moveNewTaxaToDefaultClassification
) {
428 this.moveNewTaxaToDefaultClassification
= moveNewTaxaToDefaultClassification
;