View Javadoc

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.util.HashMap;
14  import java.util.Map;
15  import java.util.UUID;
16  
17  import org.apache.log4j.Logger;
18  
19  import eu.etaxonomy.cdm.api.service.IDescriptionService;
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.ImportStateBase;
25  import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
26  import eu.etaxonomy.cdm.model.description.TaxonDescription;
27  import eu.etaxonomy.cdm.model.reference.ReferenceBase;
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> 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 = false;
42  	private boolean doReuseExistingDescription = false;
43  	private boolean doMatchTaxa = false;
44  	private Map<UUID, UUID> taxonToDescriptionMap = new HashMap<UUID, UUID>();
45  
46  	
47  	//TODO
48  	private static IInputTransformer defaultTransformer = null;
49  		
50  	@SuppressWarnings("unchecked")
51  	protected void makeIoClassList(){
52  		System.out.println("makeIOClassList");
53  		ioClassList = new Class[]{
54  			Abcd206Import.class,
55  		};
56  	};
57  	
58  	public static Abcd206ImportConfigurator NewInstance(String url,
59  			ICdmDataSource destination){
60  		return new Abcd206ImportConfigurator(url, destination);
61  	}
62  	
63  	
64  	/**
65  	 * @param berlinModelSource
66  	 * @param sourceReference
67  	 * @param destination
68  	 */
69  	private Abcd206ImportConfigurator(String url, ICdmDataSource destination) {
70  		super(defaultTransformer);
71  		setSource(url);
72  		setDestination(destination);
73  	}
74  	
75  
76  	
77  	
78  //	/* (non-Javadoc)
79  //	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
80  //	 */
81  //	public String getSource() {
82  //		return (String)super.getSource();
83  //	}
84  	
85  	/* (non-Javadoc)
86  	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
87  	 */
88  	@Override
89  	public Abcd206ImportState getNewState() {
90  		return new Abcd206ImportState(this);
91  	}
92  	
93  
94  	public String getSource(){
95  		return (String)super.getSource();
96  	}
97  	
98  	/**
99  	 * @param file
100 	 */
101 	public void setSource(String file) {
102 		super.setSource(file);
103 	}
104 	
105 
106 
107 	/* (non-Javadoc)
108 	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
109 	 */
110 	@Override
111 	public ReferenceBase getSourceReference() {
112 		//TODO
113 		if (this.sourceReference == null){
114 			logger.warn("getSource Reference not yet fully implemented");
115 			ReferenceFactory refFactory = ReferenceFactory.newInstance();
116 			sourceReference = refFactory.newDatabase();
117 			sourceReference.setTitleCache("ABCD specimen import", true);
118 		}
119 		return sourceReference;
120 	}
121 	
122 	public void setTaxonReference(String taxonReference) {
123 		this.taxonReference = taxonReference;
124 	}
125 	
126 	public ReferenceBase getTaxonReference() {
127 		//TODO
128 		if (this.taxonReference == null){
129 			logger.info("getTaxonReference not yet fully implemented");
130 		}
131 		return sourceReference;
132 	}
133 
134 
135 	/* (non-Javadoc)
136 	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
137 	 */
138 	public String getSourceNameString() {
139 		if (this.getSource() == null){
140 			return null;
141 		}else{
142 			return (String)this.getSource();
143 		}
144 	}
145 	
146 	public void setDoAutomaticParsing(boolean doParsing){
147 		this.doParsing=doParsing;
148 	}
149 	
150 	public boolean isDoAutomaticParsing(){
151 		return this.doParsing;
152 	}
153 	
154 	public void setReUseExistingMetadata(boolean reuseMetadata){
155 		this.reuseMetadata = reuseMetadata;
156 	}
157 	
158 	public boolean isReUseExistingMetadata(){
159 		return this.reuseMetadata;
160 	}
161 	
162 	public void setReUseTaxon(boolean reuseTaxon){
163 		this.reuseTaxon = reuseTaxon;
164 	}
165 	
166 	/**
167 	 * if {@link #doMatchTaxa} is set false or no matching taxon is found new
168 	 * taxa will be created. If this flag is set <code>true</code> the newly created taxa
169 	 * will be reused if possible. Setting this flag to <code>false</code> may lead to
170 	 * multiple identical taxa.
171 	 * 
172 	 * @return
173 	 */
174 	public boolean isDoReUseTaxon(){
175 		return this.reuseTaxon;
176 	}
177 
178 	public void setDoCreateIndividualsAssociations(
179 			boolean doCreateIndividualsAssociations) {
180 		this.doCreateIndividualsAssociations = doCreateIndividualsAssociations;
181 	}
182 
183 	/**
184 	 * Create an IndividualsAssociations for each determination element in the ABCD data. ABCD has no such concept as IndividualsAssociations so the only way to 
185 	 * 
186 	 * @return
187 	 */
188 	public boolean isDoCreateIndividualsAssociations() {
189 		return doCreateIndividualsAssociations;
190 	}
191 
192 	/**
193 	 * @param doReuseExistingDescription the doReuseExistingDescription to set
194 	 */
195 	public void setDoReuseExistingDescription(boolean doReuseExistingDescription) {
196 		this.doReuseExistingDescription = doReuseExistingDescription;
197 	}
198 
199 	/**
200 	 * @return the doReuseExistingDescription
201 	 */
202 	public boolean isDoMatchToExistingDescription() {
203 		return doReuseExistingDescription;
204 	}
205 
206 	/* (non-Javadoc)
207 	 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#isDoMatchTaxa()
208 	 */
209 	@Override
210 	public boolean isDoMatchTaxa() {
211 		return doMatchTaxa;
212 	}
213 
214 	/* (non-Javadoc)
215 	 * @see eu.etaxonomy.cdm.io.common.IMatchingImportConfigurator#setDoMatchTaxa(boolean)
216 	 */
217 	@Override
218 	public void setDoMatchTaxa(boolean doMatchTaxa) {
219 		this.doMatchTaxa = doMatchTaxa;
220 	}
221 
222 	/**
223 	 * @return
224 	 */
225 	public Map<UUID, UUID> getTaxonToDescriptionMap() {
226 		// TODO Auto-generated method stub
227 		return taxonToDescriptionMap ;
228 	}
229 	
230 	
231 }