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
;
14 import java
.util
.HashMap
;
16 import java
.util
.UUID
;
18 import org
.apache
.log4j
.Logger
;
20 import eu
.etaxonomy
.cdm
.common
.UriUtils
;
21 import eu
.etaxonomy
.cdm
.database
.ICdmDataSource
;
22 import eu
.etaxonomy
.cdm
.ext
.occurrence
.OccurenceQuery
;
23 import eu
.etaxonomy
.cdm
.io
.common
.IImportConfigurator
;
24 import eu
.etaxonomy
.cdm
.io
.common
.IMatchingImportConfigurator
;
25 import eu
.etaxonomy
.cdm
.io
.common
.mapping
.IInputTransformer
;
26 import eu
.etaxonomy
.cdm
.io
.specimen
.SpecimenImportConfiguratorBase
;
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
;
38 public class Abcd206ImportConfigurator
<AbcdImportState
, InputStream
> extends SpecimenImportConfiguratorBase
implements IImportConfigurator
, IMatchingImportConfigurator
{
39 private static final Logger logger
= Logger
.getLogger(Abcd206ImportConfigurator
.class);
41 private static String sourceReferenceTitle
= null;
42 private boolean reuseExistingMetadata
= true;
43 private String taxonReference
= null;
44 private boolean addIndividualsAssociationsSuchAsSpecimenAndObservations
= true;
45 private boolean reuseExistingDescriptiveGroups
= false;
46 private boolean reuseExistingTaxaWhenPossible
= true;
47 private final Map
<UUID
, UUID
> taxonToDescriptionMap
= new HashMap
<UUID
, UUID
>();
48 private Map
<String
, Team
> titleCacheTeam
;
49 private Map
<String
, Person
> titleCachePerson
;
50 private String defaultAuthor
="";
51 private boolean allowReuseOtherClassifications
=true;
52 private boolean addMediaAsMediaSpecimen
= false;
53 private boolean deduplicateReferences
= false;
54 private boolean deduplicateClassifications
= false;
55 private boolean ignoreAuthorship
= false;
56 private boolean removeCountryFromLocalityText
= false;
57 private boolean moveNewTaxaToDefaultClassification
= true;
59 private boolean mapUnitIdToCatalogNumber
= true;
60 private boolean mapUnitIdToAccessionNumber
= false;
61 private boolean mapUnitIdToBarcode
= false;
63 private boolean overwriteExistingSpecimens
= false;
64 private boolean ignoreImportOfExistingSpecimens
= true;
66 private final SpecimenUserInteraction specimenUserInteraction
= new SpecimenUserInteraction();
68 private Map
<String
,UUID
> namedAreaDecisions
= new HashMap
<String
,UUID
>();
70 private OccurenceQuery query
;
73 private static IInputTransformer defaultTransformer
= null;
75 private URI sourceUri
;
76 private URI reportUri
;
80 @SuppressWarnings("unchecked")
81 protected void makeIoClassList(){
82 System
.out
.println("makeIOClassList");
83 ioClassList
= new Class
[]{
88 public static Abcd206ImportConfigurator
NewInstance(URI uri
,ICdmDataSource destination
){
89 return new Abcd206ImportConfigurator(null, uri
, destination
, false);
98 public static Abcd206ImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
, boolean interact
) {
99 return new Abcd206ImportConfigurator(null, uri
, destination
, interact
);
108 public static Abcd206ImportConfigurator NewInstance(InputStream stream, ICdmDataSource destination, boolean interact) {
109 return new Abcd206ImportConfigurator(stream, null, destination, interact);
115 * @param berlinModelSource
116 * @param sourceReference
119 private Abcd206ImportConfigurator(InputStream stream
, URI uri
, ICdmDataSource destination
, boolean interact
) {
120 super(defaultTransformer
);
124 this.sourceUri
= uri
;
126 setDestination(destination
);
127 setSourceReferenceTitle("ABCD classic");
128 setInteractWithUser(interact
);
136 public Abcd206ImportState
getNewState() {
137 return new Abcd206ImportState(this);
142 public InputStream
getSource(){
143 if (super.getSource() != null){
144 return (InputStream
)super.getSource();
145 }else if (this.sourceUri
!= null){
147 InputStream is
= (InputStream
) UriUtils
.getInputStream(sourceUri
);
150 } catch (Exception e
) {
151 throw new RuntimeException(e
);
160 public URI
getSourceUri(){
161 return this.sourceUri
;
164 public void setSourceUri(URI sourceUri
) {
165 this.sourceUri
= sourceUri
;
166 super.setSource(null);
171 public String
getSourceReferenceTitle(){
172 return this.sourceReferenceTitle
;
176 public void setSourceReferenceTitle(String name
){
177 this.sourceReferenceTitle
=name
;
181 public Reference
getSourceReference() {
183 return sourceReference
;
186 public void setTaxonReference(String taxonReference
) {
187 this.taxonReference
= taxonReference
;
190 public Reference
getTaxonReference() {
192 if (this.taxonReference
== null){
193 logger
.info("getTaxonReference not yet fully implemented");
195 return sourceReference
;
198 public void setReuseExistingMetadata(boolean reuseMetadata
){
199 this.reuseExistingMetadata
= reuseMetadata
;
202 public boolean isReUseExistingMetadata(){
203 return this.reuseExistingMetadata
;
206 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
207 boolean doCreateIndividualsAssociations
) {
208 this.addIndividualsAssociationsSuchAsSpecimenAndObservations
= doCreateIndividualsAssociations
;
212 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
216 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
217 return addIndividualsAssociationsSuchAsSpecimenAndObservations
;
221 * @param doReuseExistingDescription the doReuseExistingDescription to set
224 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription
) {
225 this.reuseExistingDescriptiveGroups
= doReuseExistingDescription
;
229 * @return the doReuseExistingDescription
231 public boolean isReuseExistingDescriptiveGroups() {
232 return reuseExistingDescriptiveGroups
;
236 public boolean isReuseExistingTaxaWhenPossible() {
237 return reuseExistingTaxaWhenPossible
;
241 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa
) {
242 this.reuseExistingTaxaWhenPossible
= doMatchTaxa
;
245 public Map
<UUID
, UUID
> getTaxonToDescriptionMap() {
246 // TODO Auto-generated method stub
247 return taxonToDescriptionMap
;
250 public Map
<String
, Team
> getTeams() {
251 return titleCacheTeam
;
256 public Map
<String
, Person
> getPersons() {
257 return titleCachePerson
;
262 public void setDefaultAuthor(String string
) {
263 defaultAuthor
=string
;
266 public String
getDefaultAuthor(){
267 return defaultAuthor
;
270 public Map
<String
,UUID
> getNamedAreaDecisions() {
271 return namedAreaDecisions
;
274 public void setNamedAreaDecisions(Map
<String
,UUID
> namedAreaDecisions
) {
275 this.namedAreaDecisions
= namedAreaDecisions
;
278 public void putNamedAreaDecision(String areaStr
,UUID uuid
){
279 this.namedAreaDecisions
.put(areaStr
,uuid
);
282 public UUID
getNamedAreaDecision(String areaStr
){
283 return namedAreaDecisions
.get(areaStr
);
286 public boolean isAddMediaAsMediaSpecimen() {
287 return addMediaAsMediaSpecimen
;
290 public void setAddMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen
) {
291 this.addMediaAsMediaSpecimen
= addMediaAsMediaSpecimen
;
294 public boolean isDeduplicateClassifications() {
295 return deduplicateClassifications
;
298 public void setDeduplicateClassifications(boolean deduplicateClassifications
) {
299 this.deduplicateClassifications
= deduplicateClassifications
;
302 public boolean isDeduplicateReferences() {
303 return deduplicateReferences
;
306 public void setDeduplicateReferences(boolean deduplicateReferences
) {
307 this.deduplicateReferences
= deduplicateReferences
;
310 public boolean isAllowReuseOtherClassifications() {
311 return allowReuseOtherClassifications
;
314 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications
) {
315 this.allowReuseOtherClassifications
= allowReuseOtherClassifications
;
318 public SpecimenUserInteraction
getSpecimenUserInteraction() {
319 return specimenUserInteraction
;
322 public void setReportUri(URI reportUri
) {
323 this.reportUri
= reportUri
;
326 public URI
getReportUri() {
330 public void setIgnoreAuthorship(boolean ignoreAuthorship
) {
331 this.ignoreAuthorship
= ignoreAuthorship
;
335 public boolean isIgnoreAuthorship() {
336 return ignoreAuthorship
;
339 public boolean isMapUnitIdToAccessionNumber() {
340 return mapUnitIdToAccessionNumber
;
343 public boolean isMapUnitIdToBarcode() {
344 return mapUnitIdToBarcode
;
347 public boolean isMapUnitIdToCatalogNumber() {
348 return mapUnitIdToCatalogNumber
;
351 public void setMapUnitIdToAccessionNumber(boolean mapUnitIdToAccessionNumber
) {
352 this.mapUnitIdToAccessionNumber
= mapUnitIdToAccessionNumber
;
355 public void setMapUnitIdToBarcode(boolean mapUnitIdToBarcode
) {
356 this.mapUnitIdToBarcode
= mapUnitIdToBarcode
;
359 public void setMapUnitIdToCatalogNumber(boolean mapUnitIdToCatalogNumber
) {
360 this.mapUnitIdToCatalogNumber
= mapUnitIdToCatalogNumber
;
363 public void setRemoveCountryFromLocalityText(boolean removeCountryFromLocalityText
) {
364 this.removeCountryFromLocalityText
= removeCountryFromLocalityText
;
368 public boolean isRemoveCountryFromLocalityText() {
369 return removeCountryFromLocalityText
;
372 public boolean isMoveNewTaxaToDefaultClassification() {
373 return moveNewTaxaToDefaultClassification
;
376 public void setMoveNewTaxaToDefaultClassification(boolean moveNewTaxaToDefaultClassification
) {
377 this.moveNewTaxaToDefaultClassification
= moveNewTaxaToDefaultClassification
;
380 public boolean isOverwriteExistingSpecimens() {
381 return overwriteExistingSpecimens
;
384 public void setOverwriteExistingSpecimens(boolean overwriteExistingSpecimens
) {
385 this.overwriteExistingSpecimens
= overwriteExistingSpecimens
;
389 public boolean isIgnoreImportOfExistingSpecimens() {
390 return ignoreImportOfExistingSpecimens
;
393 public void setIgnoreImportOfExistingSpecimens(boolean ignoreImportOfExistingSpecimens
) {
394 this.ignoreImportOfExistingSpecimens
= ignoreImportOfExistingSpecimens
;
398 public OccurenceQuery
getOccurenceQuery(){
403 public void setOccurenceQuery(OccurenceQuery query
){