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;
41 private boolean parseNameAutomatically
= false;
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 determinationOnFieldUnitLevel
= false;
56 private final SpecimenUserInteraction specimenUserInteraction
= new SpecimenUserInteraction();
58 private Map
<String
,UUID
> namedAreaDecisions
= new HashMap
<String
,UUID
>();
61 private static IInputTransformer defaultTransformer
= null;
63 private URI sourceUri
;
67 @SuppressWarnings("unchecked")
68 protected void makeIoClassList(){
69 System
.out
.println("makeIOClassList");
70 ioClassList
= new Class
[]{
75 public static Abcd206ImportConfigurator
NewInstance(URI uri
,ICdmDataSource destination
){
76 return new Abcd206ImportConfigurator(null, uri
, destination
, false);
85 public static Abcd206ImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
, boolean interact
) {
86 return new Abcd206ImportConfigurator(null, uri
, destination
, interact
);
95 public static Abcd206ImportConfigurator
NewInstance(InputStream stream
, ICdmDataSource destination
, boolean interact
) {
96 return new Abcd206ImportConfigurator(stream
, null, destination
, interact
);
102 * @param berlinModelSource
103 * @param sourceReference
106 private Abcd206ImportConfigurator(InputStream stream
, URI uri
, ICdmDataSource destination
, boolean interact
) {
107 super(defaultTransformer
);
111 this.sourceUri
= uri
;
113 setDestination(destination
);
114 setSourceReferenceTitle("ABCD classic");
115 setInteractWithUser(interact
);
123 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
126 public Abcd206ImportState
getNewState() {
127 return new Abcd206ImportState(this);
132 public InputStream
getSource(){
133 if (super.getSource() != null){
134 return super.getSource();
135 }else if (this.sourceUri
!= null){
137 InputStream is
= UriUtils
.getInputStream(sourceUri
);
140 } catch (Exception e
) {
141 throw new RuntimeException(e
);
152 public void setSource(InputStream is
) {
153 this.sourceUri
= null;
157 public URI
getSourceUri(){
158 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 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
184 public Reference
getSourceReference() {
186 return sourceReference
;
189 public void setTaxonReference(String taxonReference
) {
190 this.taxonReference
= taxonReference
;
193 public Reference
getTaxonReference() {
195 if (this.taxonReference
== null){
196 logger
.info("getTaxonReference not yet fully implemented");
198 return sourceReference
;
201 public void setParseNameAutomatically(boolean doParsing
){
202 this.parseNameAutomatically
=doParsing
;
205 public boolean isParseNameAutomatically(){
206 return this.parseNameAutomatically
;
209 public void setReuseExistingMetadata(boolean reuseMetadata
){
210 this.reuseExistingMetadata
= reuseMetadata
;
213 public boolean isReUseExistingMetadata(){
214 return this.reuseExistingMetadata
;
217 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
218 boolean doCreateIndividualsAssociations
) {
219 this.addIndividualsAssociationsSuchAsSpecimenAndObservations
= doCreateIndividualsAssociations
;
223 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
227 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
228 return addIndividualsAssociationsSuchAsSpecimenAndObservations
;
232 * @param doReuseExistingDescription the doReuseExistingDescription to set
235 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription
) {
236 this.reuseExistingDescriptiveGroups
= doReuseExistingDescription
;
240 * @return the doReuseExistingDescription
242 public boolean isReuseExistingDescriptiveGroups() {
243 return reuseExistingDescriptiveGroups
;
247 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
250 public boolean isReuseExistingTaxaWhenPossible() {
251 return reuseExistingTaxaWhenPossible
;
255 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
258 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa
) {
259 this.reuseExistingTaxaWhenPossible
= doMatchTaxa
;
265 public Map
<UUID
, UUID
> getTaxonToDescriptionMap() {
266 // TODO Auto-generated method stub
267 return taxonToDescriptionMap
;
272 public Map
<String
, Team
> getTeams() {
273 return titleCacheTeam
;
276 public void setTeams(Map
<String
, Team
> titleCacheTeam
) {
277 this.titleCacheTeam
= titleCacheTeam
;
280 public Map
<String
, Person
> getPersons() {
281 return titleCachePerson
;
284 public void setPersons(Map
<String
, Person
> titleCachePerson
) {
285 this.titleCachePerson
= titleCachePerson
;
291 public void setDefaultAuthor(String string
) {
292 defaultAuthor
=string
;
296 public String
getDefaultAuthor(){
297 return defaultAuthor
;
300 public Map
<String
,UUID
> getNamedAreaDecisions() {
301 return namedAreaDecisions
;
304 public void setNamedAreaDecisions(Map
<String
,UUID
> namedAreaDecisions
) {
305 this.namedAreaDecisions
= namedAreaDecisions
;
308 public void putNamedAreaDecision(String areaStr
,UUID uuid
){
309 this.namedAreaDecisions
.put(areaStr
,uuid
);
312 public UUID
getNamedAreaDecision(String areaStr
){
313 return namedAreaDecisions
.get(areaStr
);
317 * @return the doAddMediaAsMediaSpecimen
319 public boolean isAddMediaAsMediaSpecimen() {
320 return addMediaAsMediaSpecimen
;
323 public void setAddMediaAsMediaSpecimen(boolean addMediaAsMediaSpecimen
) {
324 this.addMediaAsMediaSpecimen
= addMediaAsMediaSpecimen
;
327 public boolean isDeterminationOnFieldUnitLevel() {
328 return determinationOnFieldUnitLevel
;
331 public void setDeterminationOnFieldUnitLevel(boolean determinationOnFieldUnitLevel
) {
332 this.determinationOnFieldUnitLevel
= determinationOnFieldUnitLevel
;
336 * @return the allowReuseOtherClassifications
338 public boolean isAllowReuseOtherClassifications() {
339 return allowReuseOtherClassifications
;
343 * @param allowReuseOtherClassifications the allowReuseOtherClassifications to set
345 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications
) {
346 this.allowReuseOtherClassifications
= allowReuseOtherClassifications
;
350 * @return the specimenUserInteraction
352 public SpecimenUserInteraction
getSpecimenUserInteraction() {
353 return specimenUserInteraction
;