View Javadoc

1   /**
2   * Copyright (C) 2008 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   package eu.etaxonomy.cdm.io.faunaEuropaea;
10  
11  import org.apache.log4j.Logger;
12  
13  import eu.etaxonomy.cdm.database.ICdmDataSource;
14  import eu.etaxonomy.cdm.io.common.IImportConfigurator;
15  import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
16  import eu.etaxonomy.cdm.io.common.Source;
17  import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
18  import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
19  import eu.etaxonomy.cdm.model.reference.ReferenceBase;
20  import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
21  
22  /**
23   * @author a.babadshanjan
24   * @created 08.05.2009
25   * @version 1.0
26   */
27  public class FaunaEuropaeaImportConfigurator extends ImportConfiguratorBase<FaunaEuropaeaImportState> implements IImportConfigurator {
28  	private static final Logger logger = Logger.getLogger(FaunaEuropaeaImportConfigurator.class);
29  
30  	//TODO
31  	private static IInputTransformer defaultTransformer = null;
32  	
33  	private boolean doBasionyms = true;
34  	private boolean doTaxonomicallyIncluded = true;
35  	private boolean doMisappliedNames = true;
36  	private boolean doHeterotypicSynonyms = true;
37  	private boolean doHeterotypicSynonymsForBasionyms;
38  	
39  	/* Max number of taxa to be saved with one service call */
40  	private int limitSave = 900;
41  	private ReferenceBase<?> auctReference;
42  	
43  	@SuppressWarnings("unchecked")
44  	protected void makeIoClassList() {
45  		ioClassList = new Class[] {
46  				FaunaEuropaeaAuthorImport.class,
47  				FaunaEuropaeaTaxonNameImport.class,
48  				FaunaEuropaeaRelTaxonIncludeImport.class,
49  				FaunaEuropaeaRefImport.class,
50  				FaunaEuropaeaUsersImport.class,
51  				FaunaEuropaeaDistributionImport.class,
52  				FaunaEuropaeaHeterotypicSynonymImport.class,
53  				FaunaEuropaeaAdditionalTaxonDataImport.class,
54  		};
55  	};
56  	
57  	public static FaunaEuropaeaImportConfigurator NewInstance(Source source, ICdmDataSource destination){
58  		return new FaunaEuropaeaImportConfigurator(source, destination);
59  }
60  	
61  	private FaunaEuropaeaImportConfigurator(Source source, ICdmDataSource destination) {
62  		super(defaultTransformer);
63  		setSource(source);
64  		setDestination(destination);
65  		setNomenclaturalCode(NomenclaturalCode.ICBN);
66  	}
67  	
68  	public static FaunaEuropaeaImportConfigurator NewInstance(ICdmDataSource source, ICdmDataSource destination){
69  		return new FaunaEuropaeaImportConfigurator(source, destination);
70  }
71  	
72  	private FaunaEuropaeaImportConfigurator(ICdmDataSource source, ICdmDataSource destination) {
73  		super(defaultTransformer);
74  		setSource(source);
75  		setDestination(destination);
76  		setNomenclaturalCode(NomenclaturalCode.ICBN);
77  	}
78  	
79  	/* (non-Javadoc)
80  	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
81  	 */
82  	public Source getSource() {
83  		return (Source)super.getSource();
84  	}
85  	
86  	/**
87  	 * @param dbSource
88  	 */
89  	public void setSource(Source dbSource) {
90  		super.setSource(dbSource);
91  	}
92  
93  	
94  	/* (non-Javadoc)
95  	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
96  	 */
97  	@Override
98  	public ReferenceBase<?> getSourceReference() {
99  		//TODO
100 		if (this.sourceReference == null){
101 			logger.warn("getSource Reference not yet fully implemented");
102 			sourceReference = ReferenceFactory.newDatabase();
103 			
104 			sourceReference.setTitleCache("Fauna Europaea database", true);
105 		}
106 		return sourceReference;
107 	}
108 
109 
110 	/* (non-Javadoc)
111 	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
112 	 */
113 	public ReferenceBase<?> getAuctReference() {
114 		//TODO
115 		if (auctReference == null){
116 			auctReference = ReferenceFactory.newPersonalCommunication();
117 			
118 			auctReference.setTitleCache("auct.", true);
119 		}
120 		return auctReference;
121 	}
122 
123 	/* (non-Javadoc)
124 	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
125 	 */
126 	public String getSourceNameString() {
127 		if (this.getSource() == null) {
128 			return null;
129 		}else{
130 			return this.getSource().toString();
131 		}
132 	}
133 
134 	/* (non-Javadoc)
135 	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
136 	 */
137 	public FaunaEuropaeaImportState getNewState() {
138 		return new FaunaEuropaeaImportState(this);
139 	}
140 
141 	/**
142 	 * @return the doBasionyms
143 	 */
144 	public boolean isDoBasionyms() {
145 		return doBasionyms;
146 	}
147 
148 	/**
149 	 * @param doBasionyms the doBasionyms to set
150 	 */
151 	public void setDoBasionyms(boolean doBasionyms) {
152 		this.doBasionyms = doBasionyms;
153 	}
154 
155 	/**
156 	 * @return the doTaxonomicallyIncluded
157 	 */
158 	public boolean isDoTaxonomicallyIncluded() {
159 		return doTaxonomicallyIncluded;
160 	}
161 
162 	/**
163 	 * @param doTaxonomicallyIncluded the doTaxonomicallyIncluded to set
164 	 */
165 	public void setDoTaxonomicallyIncluded(boolean doTaxonomicallyIncluded) {
166 		this.doTaxonomicallyIncluded = doTaxonomicallyIncluded;
167 	}
168 
169 	/**
170 	 * @return the doMisappliedNames
171 	 */
172 	public boolean isDoMisappliedNames() {
173 		return doMisappliedNames;
174 	}
175 
176 	/**
177 	 * @param doMisappliedNames the doMisappliedNames to set
178 	 */
179 	public void setDoMisappliedNames(boolean doMisappliedNames) {
180 		this.doMisappliedNames = doMisappliedNames;
181 	}
182 
183 	/**
184 	 * @return the doHeterotypicSynonyms
185 	 */
186 	public boolean isDoHeterotypicSynonyms() {
187 		return doHeterotypicSynonyms;
188 	}
189 
190 	/**
191 	 * @param doHeterotypicSynonyms the doHeterotypicSynonyms to set
192 	 */
193 	public void setDoHeterotypicSynonyms(boolean doHeterotypicSynonyms) {
194 		this.doHeterotypicSynonyms = doHeterotypicSynonyms;
195 	}
196 
197 	/**
198 	 * @param auctReference the auctReference to set
199 	 */
200 	public void setAuctReference(ReferenceBase<?> auctReference) {
201 		this.auctReference = auctReference;
202 	}
203 
204 	/**
205 	 * @return the limitSave
206 	 */
207 	public int getLimitSave() {
208 		return limitSave;
209 	}
210 
211 	/**
212 	 * @param limitSave the limitSave to set
213 	 */
214 	public void setLimitSave(int limitSave) {
215 		this.limitSave = limitSave;
216 	}
217 
218 	/**
219 	 * @param doHeterotypicSynonymsForBasionyms the doHeterotypicSynonymsForBasionyms to set
220 	 */
221 	public void setDoHeterotypicSynonymsForBasionyms(
222 			boolean doHeterotypicSynonymsForBasionyms) {
223 		this.doHeterotypicSynonymsForBasionyms = doHeterotypicSynonymsForBasionyms;
224 	}
225 
226 	/**
227 	 * @return the doHeterotypicSynonymsForBasionyms
228 	 */
229 	public boolean isDoHeterotypicSynonymsForBasionyms() {
230 		return doHeterotypicSynonymsForBasionyms;
231 	}
232 
233 }