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 doAddMediaAsMediaSpecimen
= false;
55 private final SpecimenUserInteraction specimenUserInteraction
= new SpecimenUserInteraction();
57 private Map
<String
,UUID
> namedAreaDecisions
= new HashMap
<String
,UUID
>();
60 private static IInputTransformer defaultTransformer
= null;
62 private URI sourceUri
;
66 @SuppressWarnings("unchecked")
67 protected void makeIoClassList(){
68 System
.out
.println("makeIOClassList");
69 ioClassList
= new Class
[]{
74 public static Abcd206ImportConfigurator
NewInstance(URI uri
,ICdmDataSource destination
){
75 return new Abcd206ImportConfigurator(null, uri
, destination
, false);
84 public static Abcd206ImportConfigurator
NewInstance(URI uri
, ICdmDataSource destination
, boolean interact
) {
85 return new Abcd206ImportConfigurator(null, uri
, destination
, interact
);
94 public static Abcd206ImportConfigurator
NewInstance(InputStream stream
, ICdmDataSource destination
, boolean interact
) {
95 return new Abcd206ImportConfigurator(stream
, null, destination
, interact
);
101 * @param berlinModelSource
102 * @param sourceReference
105 private Abcd206ImportConfigurator(InputStream stream
, URI uri
, ICdmDataSource destination
, boolean interact
) {
106 super(defaultTransformer
);
110 this.sourceUri
= uri
;
112 setDestination(destination
);
113 setSourceReferenceTitle("ABCD classic");
114 setInteractWithUser(interact
);
122 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
125 public Abcd206ImportState
getNewState() {
126 return new Abcd206ImportState(this);
131 public InputStream
getSource(){
132 if (super.getSource() != null){
133 return super.getSource();
134 }else if (this.sourceUri
!= null){
136 InputStream is
= UriUtils
.getInputStream(sourceUri
);
139 } catch (Exception e
) {
140 throw new RuntimeException(e
);
151 public void setSource(InputStream is
) {
152 this.sourceUri
= null;
156 public URI
getSourceUri(){
157 return this.sourceUri
;
163 public void setSourceUri(URI sourceUri
) {
164 this.sourceUri
= sourceUri
;
165 super.setSource(null);
170 public String
getSourceReferenceTitle(){
171 return this.sourceReferenceTitle
;
175 public void setSourceReferenceTitle(String name
){
176 this.sourceReferenceTitle
=name
;
180 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
183 public Reference
getSourceReference() {
185 return sourceReference
;
188 public void setTaxonReference(String taxonReference
) {
189 this.taxonReference
= taxonReference
;
192 public Reference
getTaxonReference() {
194 if (this.taxonReference
== null){
195 logger
.info("getTaxonReference not yet fully implemented");
197 return sourceReference
;
200 public void setParseNameAutomatically(boolean doParsing
){
201 this.parseNameAutomatically
=doParsing
;
204 public boolean isParseNameAutomatically(){
205 return this.parseNameAutomatically
;
208 public void setReuseExistingMetadata(boolean reuseMetadata
){
209 this.reuseExistingMetadata
= reuseMetadata
;
212 public boolean isReUseExistingMetadata(){
213 return this.reuseExistingMetadata
;
216 public void setAddIndividualsAssociationsSuchAsSpecimenAndObservations(
217 boolean doCreateIndividualsAssociations
) {
218 this.addIndividualsAssociationsSuchAsSpecimenAndObservations
= doCreateIndividualsAssociations
;
221 public void setAddMediaAsMediaSpecimen(boolean doAddMediaAsMediaSpecimen
) {
222 this.doAddMediaAsMediaSpecimen
= doAddMediaAsMediaSpecimen
;
226 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
230 public boolean isAddIndividualsAssociationsSuchAsSpecimenAndObservations() {
231 return addIndividualsAssociationsSuchAsSpecimenAndObservations
;
235 * @param doReuseExistingDescription the doReuseExistingDescription to set
238 public void reuseExistingDescriptiveGroups(boolean doReuseExistingDescription
) {
239 this.reuseExistingDescriptiveGroups
= doReuseExistingDescription
;
243 * @return the doReuseExistingDescription
245 public boolean isReuseExistingDescriptiveGroups() {
246 return reuseExistingDescriptiveGroups
;
250 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
253 public boolean isReuseExistingTaxaWhenPossible() {
254 return reuseExistingTaxaWhenPossible
;
258 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
261 public void setReuseExistingTaxaWhenPossible(boolean doMatchTaxa
) {
262 this.reuseExistingTaxaWhenPossible
= doMatchTaxa
;
268 public Map
<UUID
, UUID
> getTaxonToDescriptionMap() {
269 // TODO Auto-generated method stub
270 return taxonToDescriptionMap
;
275 public Map
<String
, Team
> getTeams() {
276 return titleCacheTeam
;
279 public void setTeams(Map
<String
, Team
> titleCacheTeam
) {
280 this.titleCacheTeam
= titleCacheTeam
;
283 public Map
<String
, Person
> getPersons() {
284 return titleCachePerson
;
287 public void setPersons(Map
<String
, Person
> titleCachePerson
) {
288 this.titleCachePerson
= titleCachePerson
;
294 public void setDefaultAuthor(String string
) {
295 defaultAuthor
=string
;
299 public String
getDefaultAuthor(){
300 return defaultAuthor
;
303 public Map
<String
,UUID
> getNamedAreaDecisions() {
304 return namedAreaDecisions
;
307 public void setNamedAreaDecisions(Map
<String
,UUID
> namedAreaDecisions
) {
308 this.namedAreaDecisions
= namedAreaDecisions
;
311 public void putNamedAreaDecision(String areaStr
,UUID uuid
){
312 this.namedAreaDecisions
.put(areaStr
,uuid
);
315 public UUID
getNamedAreaDecision(String areaStr
){
316 return namedAreaDecisions
.get(areaStr
);
320 * @return the doAddMediaAsMediaSpecimen
322 public boolean isDoAddMediaAsMediaSpecimen() {
323 return doAddMediaAsMediaSpecimen
;
327 * @param doAddMediaAsMediaSpecimen the doAddMediaAsMediaSpecimen to set
329 public void setDoAddMediaAsMediaSpecimen(boolean doAddMediaAsMediaSpecimen
) {
330 this.doAddMediaAsMediaSpecimen
= doAddMediaAsMediaSpecimen
;
334 * @return the allowReuseOtherClassifications
336 public boolean isAllowReuseOtherClassifications() {
337 return allowReuseOtherClassifications
;
341 * @param allowReuseOtherClassifications the allowReuseOtherClassifications to set
343 public void setAllowReuseOtherClassifications(boolean allowReuseOtherClassifications
) {
344 this.allowReuseOtherClassifications
= allowReuseOtherClassifications
;
348 * @return the specimenUserInteraction
350 public SpecimenUserInteraction
getSpecimenUserInteraction() {
351 return specimenUserInteraction
;