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.erms;
11  
12  import java.lang.reflect.Method;
13  
14  import org.apache.log4j.Logger;
15  
16  import eu.etaxonomy.cdm.database.ICdmDataSource;
17  import eu.etaxonomy.cdm.io.common.IImportConfigurator;
18  import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
19  import eu.etaxonomy.cdm.io.common.ImportStateBase;
20  import eu.etaxonomy.cdm.io.common.Source;
21  import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
22  import eu.etaxonomy.cdm.io.erms.validation.ErmsGeneralImportValidator;
23  import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
24  import eu.etaxonomy.cdm.model.reference.ReferenceBase;
25  import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
26  
27  
28  /**
29   * @author a.mueller
30   * @created 20.03.2008
31   * @version 1.0
32   */
33  public class ErmsImportConfigurator extends ImportConfiguratorBase<ErmsImportState> implements IImportConfigurator{
34  	@SuppressWarnings("unused")
35  	private static Logger logger = Logger.getLogger(ErmsImportConfigurator.class);
36  
37  	public static ErmsImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){
38  			return new ErmsImportConfigurator(ermsSource, destination);
39  	}
40  
41  	/* Max number of records to be saved with one service call */
42  	private int recordsPerTransaction = 1000;  //defaultValue
43  
44  	//TODO needed ??
45  	private Method userTransformationMethod;
46  	
47  	private boolean doVernaculars = true;
48  	private boolean doLinks = true;
49  	private boolean doNotes = true;
50  	private boolean doImages = true;
51  	
52  	private static IInputTransformer defaultTransformer = new ErmsTransformer();
53  	
54  	protected void makeIoClassList(){
55  		ioClassList = new Class[]{
56  				ErmsGeneralImportValidator.class
57  				, ErmsImportRankMap.class
58  				, ErmsReferenceImport.class
59  				, ErmsTaxonImport.class
60  				, ErmsTaxonRelationImport.class
61  				, ErmsVernacularImport.class
62  				, ErmsNotesImport.class
63  				, ErmsVernacularSourcesImport.class
64  				, ErmsNotesSourcesImport.class
65  				
66  				, ErmsAreaImport.class
67  				, ErmsDrImport.class
68  				, ErmsSourceUsesImport.class
69  				, ErmsLinkImport.class  //kann weiter hoch
70  				, ErmsImageImport.class
71  		};	
72  	}
73  	
74  
75  	/* (non-Javadoc)
76  	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
77  	 */
78  	public ImportStateBase getNewState() {
79  		return new ErmsImportState(this);
80  	}
81  
82  
83  
84  	/**
85  	 * @param berlinModelSource
86  	 * @param sourceReference
87  	 * @param destination
88  	 */
89  	private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) {
90  	   super(defaultTransformer);
91  	   setNomenclaturalCode(NomenclaturalCode.ICZN); //default for ERMS
92  	   setSource(ermsSource);
93  	   setDestination(destination);
94  	}
95  	
96  	
97  	public Source getSource() {
98  		return (Source)super.getSource();
99  	}
100 	public void setSource(Source berlinModelSource) {
101 		super.setSource(berlinModelSource);
102 	}
103 
104 	/* (non-Javadoc)
105 	 * @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference()
106 	 */
107 	public ReferenceBase getSourceReference() {
108 		ReferenceFactory refFactory = ReferenceFactory.newInstance();
109 		if (sourceReference == null){
110 			sourceReference =  refFactory.newDatabase();
111 			if (getSource() != null){
112 				sourceReference.setTitleCache(getSource().getDatabase(), true);
113 			}
114 		}
115 		return sourceReference;
116 	}
117 
118 
119 	/* (non-Javadoc)
120 	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
121 	 */
122 	public String getSourceNameString() {
123 		if (this.getSource() == null){
124 			return null;
125 		}else{
126 			return this.getSource().getDatabase();
127 		}
128 	}
129 
130 	/**
131 	 * @return the userTransformationMethod
132 	 */
133 	public Method getUserTransformationMethod() {
134 		return userTransformationMethod;
135 	}
136 
137 	/**
138 	 * @param userTransformationMethod the userTransformationMethod to set
139 	 */
140 	public void setUserTransformationMethod(Method userTransformationMethod) {
141 		this.userTransformationMethod = userTransformationMethod;
142 	}
143 
144 	
145 	/**
146 	 * @return the limitSave
147 	 */
148 	public int getRecordsPerTransaction() {
149 		return recordsPerTransaction;
150 	}
151 
152 	/**
153 	 * @param limitSave the limitSave to set
154 	 */
155 	public void setRecordsPerTransaction(int recordsPerTransaction) {
156 		this.recordsPerTransaction = recordsPerTransaction;
157 	}
158 
159 	/**
160 	 * @param doVernaculars the doVernaculars to set
161 	 */
162 	public void setDoVernaculars(boolean doVernaculars) {
163 		this.doVernaculars = doVernaculars;
164 	}
165 
166 	/**
167 	 * @return the doVernaculars
168 	 */
169 	public boolean isDoVernaculars() {
170 		return doVernaculars;
171 	}
172 
173 
174 
175 	/**
176 	 * @param doLinks the doLinks to set
177 	 */
178 	public void setDoLinks(boolean doLinks) {
179 		this.doLinks = doLinks;
180 	}
181 
182 
183 
184 	/**
185 	 * @return the doLinks
186 	 */
187 	public boolean isDoLinks() {
188 		return doLinks;
189 	}
190 
191 
192 
193 	/**
194 	 * @param doNotes the doNotes to set
195 	 */
196 	public void setDoNotes(boolean doNotes) {
197 		this.doNotes = doNotes;
198 	}
199 
200 
201 
202 	/**
203 	 * @return the doNotes
204 	 */
205 	public boolean isDoNotes() {
206 		return doNotes;
207 	}
208 
209 
210 
211 	/**
212 	 * @param doImages the doImages to set
213 	 */
214 	public void setDoImages(boolean doImages) {
215 		this.doImages = doImages;
216 	}
217 
218 
219 
220 	/**
221 	 * @return the doImages
222 	 */
223 	public boolean isDoImages() {
224 		return doImages;
225 	}
226 	
227 	
228 
229 }