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;
54 private final SpecimenUserInteraction specimenUserInteraction
= new SpecimenUserInteraction();
56 private Map
<String
,UUID
> namedAreaDecisions
= new HashMap
<String
,UUID
>();
59 private static IInputTransformer defaultTransformer
= null;
61 private URI sourceUri
;
64 @SuppressWarnings("unchecked")
65 protected void makeIoClassList(){
66 System
.out
.println("makeIOClassList");
67 ioClassList
= new Class
[]{
72 public static Abcd206ImportConfigurator
NewInstance(URI uri
,ICdmDataSource destination
){
73 return new Abcd206ImportConfigurator(null, uri
, destination
, false);
82 public static Abcd206ImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
, boolean interact
) {
83 return new Abcd206ImportConfigurator(null, uri
, destination
, interact
);
92 public static Abcd206ImportConfigurator
NewInstance(InputStream stream
, ICdmDataSource destination
, boolean interact
) {
93 return new Abcd206ImportConfigurator(stream
, null, destination
, interact
);
99 * @param berlinModelSource
100 * @param sourceReference
103 private Abcd206ImportConfigurator(InputStream stream
, URI uri
, ICdmDataSource destination
, boolean interact
) {
104 super(defaultTransformer
);
108 this.sourceUri
= uri
;
110 setDestination(destination
);
111 setSourceReferenceTitle("ABCD classic");
112 setInteractWithUser(interact
);
120 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
123 public Abcd206ImportState
getNewState() {
124 return new Abcd206ImportState(this);
129 public InputStream
getSource(){
130 if (super.getSource() != null){
131 return super.getSource();
132 }else if (this.sourceUri
!= null){
134 InputStream is
= UriUtils
.getInputStream(sourceUri
);
137 } catch (Exception e
) {
138 throw new RuntimeException(e
);
149 public void setSource(InputStream is
) {
150 this.sourceUri
= null;
154 public URI
getSourceUri(){
155 return this.sourceUri
;
161 public void setSourceUri(URI sourceUri
) {
162 this.sourceUri
= sourceUri
;
163 super.setSource(null);
168 public String
getSourceReferenceTitle(){
169 return this.sourceReferenceTitle
;
173 public void setSourceReferenceTitle(String name
){
174 this.sourceReferenceTitle
=name
;
178 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
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 setParseNameAutomatically(boolean doParsing
){
199 this.parseNameAutomatically
=doParsing
;
202 public boolean isParseNameAutomatically(){
203 return this.parseNameAutomatically
;
206 public void setReuseExistingMetadata(boolean reuseMetadata
){
207 this.reuseExistingMetadata
= reuseMetadata
;
210 public boolean isReUseExistingMetadata(){
211 return this.reuseExistingMetadata
;
214 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
215 boolean doCreateIndividualsAssociations
) {
216 this.addIndividualsAssociationsSuchAsSpecimenAndObservations
= doCreateIndividualsAssociations
;
220 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
224 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
225 return addIndividualsAssociationsSuchAsSpecimenAndObservations
;
229 * @param doReuseExistingDescription the doReuseExistingDescription to set
232 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription
) {
233 this.reuseExistingDescriptiveGroups
= doReuseExistingDescription
;
237 * @return the doReuseExistingDescription
239 public boolean isReuseExistingDescriptiveGroups() {
240 return reuseExistingDescriptiveGroups
;
244 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
247 public boolean isReuseExistingTaxaWhenPossible() {
248 return reuseExistingTaxaWhenPossible
;
252 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
255 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa
) {
256 this.reuseExistingTaxaWhenPossible
= doMatchTaxa
;
262 public Map
<UUID
, UUID
> getTaxonToDescriptionMap() {
263 // TODO Auto-generated method stub
264 return taxonToDescriptionMap
;
269 public Map
<String
, Team
> getTeams() {
270 return titleCacheTeam
;
273 public void setTeams(Map
<String
, Team
> titleCacheTeam
) {
274 this.titleCacheTeam
= titleCacheTeam
;
277 public Map
<String
, Person
> getPersons() {
278 return titleCachePerson
;
281 public void setPersons(Map
<String
, Person
> titleCachePerson
) {
282 this.titleCachePerson
= titleCachePerson
;
288 public void setDefaultAuthor(String string
) {
289 defaultAuthor
=string
;
293 public String
getDefaultAuthor(){
294 return defaultAuthor
;
297 public Map
<String
,UUID
> getNamedAreaDecisions() {
298 return namedAreaDecisions
;
301 public void setNamedAreaDecisions(Map
<String
,UUID
> namedAreaDecisions
) {
302 this.namedAreaDecisions
= namedAreaDecisions
;
305 public void putNamedAreaDecision(String areaStr
,UUID uuid
){
306 this.namedAreaDecisions
.put(areaStr
,uuid
);
309 public UUID
getNamedAreaDecision(String areaStr
){
310 return namedAreaDecisions
.get(areaStr
);
315 * @return the allowReuseOtherClassifications
317 public boolean isAllowReuseOtherClassifications() {
318 return allowReuseOtherClassifications
;
322 * @param allowReuseOtherClassifications the allowReuseOtherClassifications to set
324 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications
) {
325 this.allowReuseOtherClassifications
= allowReuseOtherClassifications
;
329 * @return the specimenUserInteraction
331 public SpecimenUserInteraction
getSpecimenUserInteraction() {
332 return specimenUserInteraction
;