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   
10  package eu.etaxonomy.cdm.io.jaxb;
11  
12  import org.apache.log4j.Logger;
13  
14  import eu.etaxonomy.cdm.database.DbSchemaValidation;
15  import eu.etaxonomy.cdm.database.ICdmDataSource;
16  import eu.etaxonomy.cdm.io.common.IImportConfigurator;
17  import eu.etaxonomy.cdm.io.common.ImportConfiguratorBase;
18  import eu.etaxonomy.cdm.io.common.IImportConfigurator.DO_REFERENCES;
19  import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer;
20  import eu.etaxonomy.cdm.model.reference.IDatabase;
21  import eu.etaxonomy.cdm.model.reference.ReferenceBase;
22  import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
23  
24  /**
25   * @author a.babadshanjan
26   * @created 14.11.2008
27   */
28  public class JaxbImportConfigurator extends ImportConfiguratorBase implements IImportConfigurator {
29  
30  	private static final Logger logger = Logger.getLogger(JaxbImportConfigurator.class);
31  		
32  	private int maxRows = 0;
33  	
34  	//TODO
35  	private static IInputTransformer defaultTransformer = null;
36  
37  	
38  	private boolean doUsers = true;
39  	private boolean doAgentData = true;
40  	private boolean doLanguageData = true;
41  	private boolean doFeatureData = true;
42  	private boolean doDescriptions = true;
43  	private boolean doMedia = true;
44  //	private boolean doOccurrences = true;
45  //	private boolean doReferences = true;
46  	private boolean doReferencedEntities = true;
47  //	private boolean doRelationships = true;
48  	private boolean doSynonyms = true;
49  //	private boolean doTaxonNames = true;
50  //	private boolean doTaxa = true;
51  	private boolean doTerms = true;
52  	private boolean doTermVocabularies = true;
53  	private boolean doHomotypicalGroups = true;
54  
55  	private boolean doTypeDesignations = true;
56  	private boolean doTaxonomicTreeData = true;
57  
58  	
59  	
60  	
61  	
62  	/* (non-Javadoc)
63  	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState()
64  	 */
65  	public JaxbImportState getNewState() {
66  		return new JaxbImportState(this);
67  	}
68  
69  	public int getMaxRows() {
70  		return maxRows;
71  	}
72  
73  	public void setMaxRows(int maxRows) {
74  		this.maxRows = maxRows;
75  	}
76  	
77  	
78  	
79  	public boolean isDoAgentData() {
80  		return doAgentData;
81  	}
82  	
83  	public void setDoAgentData(boolean doAgentData) {
84  		this.doAgentData = doAgentData;
85  	}
86  
87  	public boolean isDoLanguageData() {
88  		return doLanguageData;
89  	}
90  
91  	public void setDoLanguageData(boolean doLanguageData) {
92  		this.doLanguageData = doLanguageData;
93  	}
94  
95  	public boolean isDoFeatureData() {
96  		return doFeatureData;
97  	}
98  
99  	public void setDoFeatureData(boolean doFeatureData) {
100 		this.doFeatureData = doFeatureData;
101 	}
102 
103 	public boolean isDoDescriptions() {
104 		return doDescriptions;
105 	}
106 
107 	public void setDoDescriptions(boolean doDescriptions) {
108 		this.doDescriptions = doDescriptions;
109 	}
110 
111 	public boolean isDoMedia() {
112 		return doMedia;
113 	}
114 
115 	public void setDoMedia(boolean doMedia) {
116 		this.doMedia = doMedia;
117 	}
118 
119 
120 	public boolean isDoReferencedEntities() {
121 		return doReferencedEntities;
122 	}
123 
124 	public void setDoReferencedEntities(boolean doReferencedEntities) {
125 		this.doReferencedEntities = doReferencedEntities;
126 	}
127 
128 
129 	public boolean isDoSynonyms() {
130 		return doSynonyms;
131 	}
132 
133 	public void setDoSynonyms(boolean doSynonyms) {
134 		this.doSynonyms = doSynonyms;
135 	}
136 
137 
138 	public boolean isDoTerms() {
139 		return doTerms;
140 	}
141 
142 	public void setDoTerms(boolean doTerms) {
143 		this.doTerms = doTerms;
144 	}
145 
146 	public boolean isDoTermVocabularies() {
147 		return doTermVocabularies;
148 	}
149 
150 	public void setDoTermVocabularies(boolean doTermVocabularies) {
151 		this.doTermVocabularies = doTermVocabularies;
152 	}
153 
154 	public boolean isDoHomotypicalGroups() {
155 		return doHomotypicalGroups;
156 	}
157 
158 	public void setDoHomotypicalGroups(boolean doHomotypicalGroups) {
159 		this.doHomotypicalGroups = doHomotypicalGroups;
160 	}
161 
162 //	@SuppressWarnings("unchecked")
163 	protected void makeIoClassList() {
164 		ioClassList = new Class[] {
165 				JaxbImport.class,
166 		};
167 	};
168 
169 	public static JaxbImportConfigurator NewInstance(String url,
170 			ICdmDataSource destination){
171 		return new JaxbImportConfigurator(url, destination);
172 	}
173 
174 
175 	/**
176 	 * @param url
177 	 * @param destination
178 	 */
179 	private JaxbImportConfigurator(String url, ICdmDataSource destination) {
180 		super(defaultTransformer);
181 		setSource(url);
182 		setDestination(destination);
183 		setDbSchemaValidation(DbSchemaValidation.CREATE);
184 	}
185 
186 
187 	/* (non-Javadoc)
188 	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSource()
189 	 */
190 	public Object getSource() {
191 //	public String getSource() {
192 		return (String)super.getSource();
193 	}
194 
195 
196 	/**
197 	 * @param file
198 	 */
199 	public void setSource(String fileName) {
200 		super.setSource(fileName);
201 	}
202 
203 
204 	/* (non-Javadoc)
205 	 * @see eu.etaxonomy.cdm.io.common.ImportConfiguratorBase#getSourceReference()
206 	 */
207 	@Override
208 	public ReferenceBase getSourceReference() {
209 		//TODO
210 		if (this.sourceReference == null){
211 			ReferenceFactory refFactory = ReferenceFactory.newInstance();
212 			logger.warn("getSource Reference not yet fully implemented");
213 			sourceReference = refFactory.newDatabase();
214 			sourceReference.setTitleCache("Jaxb import", true);
215 		}
216 		return sourceReference;
217 	}
218 
219 
220 	/* (non-Javadoc)
221 	 * @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString()
222 	 */
223 	public String getSourceNameString() {
224 		if (this.getSource() == null){
225 			return null;
226 		}else{
227 			return (String)this.getSource();
228 		}
229 	}
230 	
231 	public boolean isDoTypeDesignations() {
232 		return doTypeDesignations;
233 	}
234 
235 	public void setDoTypeDesignations(boolean doTypeDesignations) {
236 		this.doTypeDesignations = doTypeDesignations;
237 	}
238 
239 	public boolean isDoTaxonomicTreeData() {
240 		return this.doTaxonomicTreeData;
241 	}
242 }
243 
244