merge trunk and bugfix linkbackuri jaxb
[cdmlib.git] / cdmlib-io / src / main / java / eu / etaxonomy / cdm / io / specimen / abcd206 / in / Abcd206ImportConfigurator.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.io.specimen.abcd206.in;
11
12
13 import java.net.URI;
14 import java.util.HashMap;
15 import java.util.Map;
16 import java.util.UUID;
17
18 import org.apache.log4j.Logger;
19
20 import eu.etaxonomy.cdm.database.ICdmDataSource;
21 import eu.etaxonomy.cdm.io.common.IImportConfigurator;
22 import eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator;
23 import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
24 import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
25 import eu.etaxonomy.cdm.model.agent.Person;
26 import eu.etaxonomy.cdm.model.agent.Team;
27 import eu.etaxonomy.cdm.model.reference.Reference;
28 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
29
30 /**
31 * @author p.kelbert
32 * @created 20.10.2008
33 * @version 1.0
34 */
35 public class Abcd206ImportConfigurator extends ImportConfiguratorBase<Abcd206ImportState, URI> implements IImportConfigurator, IMatchingImportConfigurator {
36 private static final Logger logger = Logger.getLogger(Abcd206ImportConfigurator.class);
37 private boolean doParsing = false;
38 private boolean reuseMetadata = false;
39 private boolean reuseTaxon = true;
40 private String taxonReference = null;
41 private boolean doCreateIndividualsAssociations = true;
42 private boolean doReuseExistingDescription = false;
43 private boolean doMatchTaxa = true;
44 private final Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
45 private Map<String, Team> titleCacheTeam;
46 private Map<String, Person> titleCachePerson;
47 private String defaultAuthor="";
48
49 //TODO
50 private static IInputTransformer defaultTransformer = null;
51
52 @Override
53 @SuppressWarnings("unchecked")
54 protected void makeIoClassList(){
55 System.out.println("makeIOClassList");
56 ioClassList = new Class[]{
57 Abcd206Import.class,
58 };
59 };
60
61 public static Abcd206ImportConfigurator NewInstance(URI uri,
62 ICdmDataSource destination){
63 return new Abcd206ImportConfigurator(uri, destination);
64 }
65
66
67 /**
68 * @param berlinModelSource
69 * @param sourceReference
70 * @param destination
71 */
72 private Abcd206ImportConfigurator(URI uri, ICdmDataSource destination) {
73 super(defaultTransformer);
74 setSource(uri);
75 setDestination(destination);
76 }
77
78
79
80
81 // /* (non-Javadoc)
82 // * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
83 // */
84 // public String getSource() {
85 // return (String)super.getSource();
86 // }
87
88 /* (non-Javadoc)
89 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
90 */
91 @Override
92 public Abcd206ImportState getNewState() {
93 return new Abcd206ImportState(this);
94 }
95
96
97 @Override
98 public URI getSource(){
99 return super.getSource();
100 }
101
102 /**
103 * @param file
104 */
105 @Override
106 public void setSource(URI uri) {
107 super.setSource(uri);
108 }
109
110
111
112 /* (non-Javadoc)
113 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
114 */
115 @Override
116 public Reference getSourceReference() {
117 //TODO
118 if (this.sourceReference == null){
119 logger.warn("getSource Reference not yet fully implemented");
120 ReferenceFactory refFactory = ReferenceFactory.newInstance();
121 sourceReference = refFactory.newDatabase();
122 sourceReference.setTitleCache("ABCD specimen import", true);
123 }
124 return sourceReference;
125 }
126
127 public void setTaxonReference(String taxonReference) {
128 this.taxonReference = taxonReference;
129 }
130
131 public Reference getTaxonReference() {
132 //TODO
133 if (this.taxonReference == null){
134 logger.info("getTaxonReference not yet fully implemented");
135 }
136 return sourceReference;
137 }
138
139 public void setDoAutomaticParsing(boolean doParsing){
140 this.doParsing=doParsing;
141 }
142
143 public boolean isDoAutomaticParsing(){
144 return this.doParsing;
145 }
146
147 public void setReUseExistingMetadata(boolean reuseMetadata){
148 this.reuseMetadata = reuseMetadata;
149 }
150
151 public boolean isReUseExistingMetadata(){
152 return this.reuseMetadata;
153 }
154
155 public void setReUseTaxon(boolean reuseTaxon){
156 this.reuseTaxon = reuseTaxon;
157 }
158
159 /**
160 * if {@link #doMatchTaxa} is set false or no matching taxon is found new
161 * taxa will be created. If this flag is set <code>true</code> the newly created taxa
162 * will be reused if possible. Setting this flag to <code>false</code> may lead to
163 * multiple identical taxa.
164 *
165 * @return
166 */
167 public boolean isDoReUseTaxon(){
168 return this.reuseTaxon;
169 }
170
171 public void setDoCreateIndividualsAssociations(
172 boolean doCreateIndividualsAssociations) {
173 this.doCreateIndividualsAssociations = doCreateIndividualsAssociations;
174 }
175
176 /**
177 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to
178 *
179 * @return
180 */
181 public boolean isDoCreateIndividualsAssociations() {
182 return doCreateIndividualsAssociations;
183 }
184
185 /**
186 * @param doReuseExistingDescription the doReuseExistingDescription to set
187 */
188 public void setDoReuseExistingDescription(boolean doReuseExistingDescription) {
189 this.doReuseExistingDescription = doReuseExistingDescription;
190 }
191
192 /**
193 * @return the doReuseExistingDescription
194 */
195 public boolean isDoMatchToExistingDescription() {
196 return doReuseExistingDescription;
197 }
198
199 /* (non-Javadoc)
200 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
201 */
202 @Override
203 public boolean isDoMatchTaxa() {
204 return doMatchTaxa;
205 }
206
207 /* (non-Javadoc)
208 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
209 */
210 @Override
211 public void setDoMatchTaxa(boolean doMatchTaxa) {
212 this.doMatchTaxa = doMatchTaxa;
213 }
214
215 /**
216 * @return
217 */
218 public Map<UUID, UUID> getTaxonToDescriptionMap() {
219 // TODO Auto-generated method stub
220 return taxonToDescriptionMap ;
221 }
222
223
224
225 public Map<String, Team> getTeams() {
226 return titleCacheTeam;
227 }
228
229 public void setTeams(Map<String, Team> titleCacheTeam) {
230 this.titleCacheTeam = titleCacheTeam;
231 }
232
233 public Map<String, Person> getPersons() {
234 return titleCachePerson;
235 }
236
237 public void setPersons(Map<String, Person> titleCachePerson) {
238 this.titleCachePerson = titleCachePerson;
239 }
240
241 /**
242 * @param string
243 */
244 public void setDefaultAuthor(String string) {
245 defaultAuthor=string;
246
247 }
248
249 public String getDefaultAuthor(){
250 return defaultAuthor;
251 }
252
253
254
255 }