Revision 8bec79dd
Added by Andreas Kohlbecker almost 8 years ago
app-import/.gitignore | ||
---|---|---|
1 | 1 |
.idea/ |
2 | 2 |
imports.iml |
3 |
src/main/java/eu/etaxonomy/cdm/app/iapt/ |
|
4 |
src/main/java/eu/etaxonomy/cdm/io/iapt/ |
|
5 | 3 |
src/main/main.iml |
6 | 4 |
src/test/test.iml |
app-import/src/main/java/eu/etaxonomy/cdm/app/iapt/IAPTActivator.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.app.iapt; |
|
11 |
|
|
12 |
import java.io.File; |
|
13 |
import java.net.URI; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.log4j.Logger; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.app.common.CdmDestinations; |
|
19 |
import eu.etaxonomy.cdm.database.DbSchemaValidation; |
|
20 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
21 |
import eu.etaxonomy.cdm.io.common.CdmDefaultImport; |
|
22 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.CHECK; |
|
23 |
import eu.etaxonomy.cdm.io.iapt.IAPTImportConfigurator; |
|
24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
25 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
26 |
|
|
27 |
|
|
28 |
/** |
|
29 |
* @author a.kohlbecker |
|
30 |
* @date Jul 26, 2016 |
|
31 |
* |
|
32 |
*/ |
|
33 |
public class IAPTActivator { |
|
34 |
private static final Logger logger = Logger.getLogger(IAPTActivator.class); |
|
35 |
|
|
36 |
//database validation status (create, update, validate ...) |
|
37 |
static DbSchemaValidation hbm2dll = DbSchemaValidation.VALIDATE; |
|
38 |
|
|
39 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2(); |
|
40 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_test_local_mysql_test(); |
|
41 |
// static final ICdmDataSource cdmDestination = CdmDestinations.cdm_cuba_production(); |
|
42 |
|
|
43 |
static boolean invers = true; |
|
44 |
|
|
45 |
static boolean include = !invers; |
|
46 |
|
|
47 |
//classification |
|
48 |
static final UUID classificationUuid = UUID.fromString("8c51efb4-3d67-4bea-8f87-4bc1cba1310d"); |
|
49 |
private static final String classificationName = "IAPT"; |
|
50 |
static final String sourceReferenceTitle = "IAPT Import"; |
|
51 |
|
|
52 |
//check - import |
|
53 |
static final CHECK check = CHECK.IMPORT_WITHOUT_CHECK; |
|
54 |
|
|
55 |
static final boolean doTaxa = false; |
|
56 |
|
|
57 |
|
|
58 |
private void doImport(ICdmDataSource cdmDestination){ |
|
59 |
|
|
60 |
URI source = iapt(); //just any |
|
61 |
|
|
62 |
Reference secRef = ReferenceFactory.newDatabase(); |
|
63 |
secRef.setTitle("IAPT"); |
|
64 |
|
|
65 |
//make Source |
|
66 |
IAPTImportConfigurator config= IAPTImportConfigurator.NewInstance(source, cdmDestination); |
|
67 |
config.setClassificationUuid(classificationUuid); |
|
68 |
config.setClassificationName(classificationName); |
|
69 |
config.setCheck(check); |
|
70 |
config.setDbSchemaValidation(hbm2dll); |
|
71 |
config.setSourceReferenceTitle(sourceReferenceTitle); |
|
72 |
config.setSecReference(secRef); |
|
73 |
|
|
74 |
CdmDefaultImport<IAPTImportConfigurator> myImport = new CdmDefaultImport<>(); |
|
75 |
|
|
76 |
doSingleSource(iapt(), config, myImport); |
|
77 |
|
|
78 |
System.exit(0); |
|
79 |
|
|
80 |
} |
|
81 |
|
|
82 |
/** |
|
83 |
* @param source |
|
84 |
* @param config |
|
85 |
* @param myImport |
|
86 |
*/ |
|
87 |
private void doSingleSource(URI source, IAPTImportConfigurator config, CdmDefaultImport<IAPTImportConfigurator> myImport) { |
|
88 |
config.setSource(source); |
|
89 |
String fileName = source.toString(); |
|
90 |
fileName = fileName.substring(fileName.lastIndexOf("/") + 1 ); |
|
91 |
|
|
92 |
String message = "Start import from ("+ fileName + ") ..."; |
|
93 |
System.out.println(message); |
|
94 |
logger.warn(message); |
|
95 |
config.setSourceReference(getSourceReference(fileName)); |
|
96 |
myImport.invoke(config); |
|
97 |
|
|
98 |
System.out.println("End import from ("+ source.toString() + ")..."); |
|
99 |
} |
|
100 |
|
|
101 |
private final Reference inRef = ReferenceFactory.newGeneric(); |
|
102 |
private Reference getSourceReference(String string) { |
|
103 |
Reference result = ReferenceFactory.newGeneric(); |
|
104 |
result.setTitleCache(string, true); |
|
105 |
result.setInReference(inRef); |
|
106 |
inRef.setTitleCache(sourceReferenceTitle, true); |
|
107 |
return result; |
|
108 |
} |
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
public static URI iapt() { |
|
113 |
File f = new File("~/data/Projekte/Algea Name Registry/registry/sources/IAPT/Registration_DB_from_BGBM17-cleaned.xls"); |
|
114 |
return f.toURI(); |
|
115 |
} |
|
116 |
|
|
117 |
/** |
|
118 |
* @param args |
|
119 |
*/ |
|
120 |
public static void main(String[] args) { |
|
121 |
IAPTActivator me = new IAPTActivator(); |
|
122 |
me.doImport(cdmDestination); |
|
123 |
} |
|
124 |
|
|
125 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/iapt/IAPTExcelImport.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.iapt; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
13 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImport; |
|
14 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
|
15 |
import eu.etaxonomy.cdm.model.common.*; |
|
16 |
import eu.etaxonomy.cdm.model.name.*; |
|
17 |
import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; |
|
18 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
19 |
import eu.etaxonomy.cdm.model.taxon.*; |
|
20 |
import eu.etaxonomy.cdm.strategy.exceptions.StringNotParsableException; |
|
21 |
import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser; |
|
22 |
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl; |
|
23 |
import org.apache.commons.lang.StringUtils; |
|
24 |
import org.apache.log4j.Logger; |
|
25 |
import org.springframework.stereotype.Component; |
|
26 |
|
|
27 |
import java.util.*; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.mueller |
|
31 |
* @created 05.01.2016 |
|
32 |
*/ |
|
33 |
|
|
34 |
@Component |
|
35 |
public class IAPTExcelImport<CONFIG extends IAPTImportConfigurator> extends SimpleExcelTaxonImport<CONFIG> { |
|
36 |
private static final long serialVersionUID = -747486709409732371L; |
|
37 |
private static final Logger logger = Logger.getLogger(IAPTExcelImport.class); |
|
38 |
|
|
39 |
|
|
40 |
private static UUID ROOT_UUID = UUID.fromString("4137fd2a-20f6-4e70-80b9-f296daf51d82"); |
|
41 |
|
|
42 |
private static INonViralNameParser<?> nameParser = NonViralNameParserImpl.NewInstance(); |
|
43 |
|
|
44 |
private final static String REGISTRATIONNO_PK= "RegistrationNo_Pk"; |
|
45 |
private final static String HIGHERTAXON= "HigherTaxon"; |
|
46 |
private final static String FULLNAME= "FullName"; |
|
47 |
private final static String AUTHORSSPELLING= "AuthorsSpelling"; |
|
48 |
private final static String LITSTRING= "LitString"; |
|
49 |
private final static String REGISTRATION= "Registration"; |
|
50 |
private final static String TYPE= "Type"; |
|
51 |
private final static String CAVEATS= "Caveats"; |
|
52 |
private final static String FULLBASIONYM= "FullBasionym"; |
|
53 |
private final static String FULLSYNSUBST= "FullSynSubst"; |
|
54 |
private final static String NOTESTXT= "NotesTxt"; |
|
55 |
private final static String REGDATE= "RegDate"; |
|
56 |
private final static String NAMESTRING= "NameString"; |
|
57 |
private final static String BASIONYMSTRING= "BasionymString"; |
|
58 |
private final static String SYNSUBSTSTR= "SynSubstStr"; |
|
59 |
private final static String AUTHORSTRING= "AuthorString"; |
|
60 |
|
|
61 |
private static List<String> expectedKeys= Arrays.asList(new String[]{ |
|
62 |
REGISTRATIONNO_PK, HIGHERTAXON, FULLNAME, AUTHORSSPELLING, LITSTRING, REGISTRATION, TYPE, CAVEATS, FULLBASIONYM, FULLSYNSUBST, NOTESTXT, REGDATE, NAMESTRING, BASIONYMSTRING, SYNSUBSTSTR, AUTHORSTRING}); |
|
63 |
|
|
64 |
|
|
65 |
private Taxon makeTaxon(HashMap<String, String> record, SimpleExcelTaxonImportState<CONFIG> state, |
|
66 |
TaxonNode higherTaxonNode, boolean isSynonym) { |
|
67 |
|
|
68 |
String line = state.getCurrentLine() + ": "; |
|
69 |
|
|
70 |
String fullNameStr = getValue(record, FULLNAME); |
|
71 |
String nameStr = getValue(record, NAMESTRING); |
|
72 |
String authorStr = getValue(record, AUTHORSTRING); |
|
73 |
|
|
74 |
String sourceReference = getValue(record, LITSTRING); |
|
75 |
|
|
76 |
BotanicalName taxonName = (BotanicalName) nameParser.parseFullName(fullNameStr, NomenclaturalCode.ICNAFP, null); |
|
77 |
if (taxonName.isProtectedTitleCache()) { |
|
78 |
logger.warn(line + "Name could not be parsed: " + fullNameStr); |
|
79 |
} else { |
|
80 |
// Check Name |
|
81 |
if (!taxonName.getNameCache().equals(nameStr)) { |
|
82 |
logger.warn(line + "parsed nameCache differs from " + NAMESTRING + " : " + taxonName.getNameCache() + " <> " + nameStr); |
|
83 |
} |
|
84 |
// Check Author |
|
85 |
INomenclaturalReference nomRef = taxonName.getNomenclaturalReference(); |
|
86 |
if (!nomRef.getAuthorship().getTitleCache().equals(authorStr)) { |
|
87 |
logger.warn(line + "parsed nomRef.authorship differs from " + AUTHORSTRING + " : " + nomRef.getAuthorship().getTitleCache() + " <> " + authorStr); |
|
88 |
// preserve current titleCache |
|
89 |
taxonName.setProtectedTitleCache(true); |
|
90 |
try { |
|
91 |
nameParser.parseAuthors(taxonName, authorStr); |
|
92 |
} catch (StringNotParsableException e) { |
|
93 |
logger.error(" " + authorStr + " can not be parsed"); |
|
94 |
} |
|
95 |
} |
|
96 |
|
|
97 |
// deduplicate |
|
98 |
replaceAuthorNamesAndNomRef(state, taxonName); |
|
99 |
} |
|
100 |
|
|
101 |
Reference sec = state.getConfig().getSecReference(); |
|
102 |
Taxon taxon = Taxon.NewInstance(taxonName, sec); |
|
103 |
getTaxonService().save(taxon); |
|
104 |
if(higherTaxonNode != null){ |
|
105 |
higherTaxonNode.addChildTaxon(taxon, null, null); |
|
106 |
getTaxonNodeService().save(higherTaxonNode); |
|
107 |
} |
|
108 |
|
|
109 |
return taxon; |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @param state |
|
115 |
* @return |
|
116 |
*/ |
|
117 |
private TaxonNode getClassification(IAPTImportState state) { |
|
118 |
|
|
119 |
Classification classification = state.getClassification(); |
|
120 |
if (classification == null){ |
|
121 |
IAPTImportConfigurator config = state.getConfig(); |
|
122 |
classification = Classification.NewInstance(state.getConfig().getClassificationName()); |
|
123 |
classification.setUuid(config.getClassificationUuid()); |
|
124 |
classification.setReference(config.getSecReference()); |
|
125 |
classification = getClassificationService().find(state.getConfig().getClassificationUuid()); |
|
126 |
} |
|
127 |
TaxonNode rootNode = state.getRootNode(); |
|
128 |
if (rootNode == null){ |
|
129 |
rootNode = getTaxonNodeService().find(ROOT_UUID); |
|
130 |
} |
|
131 |
if (rootNode == null){ |
|
132 |
Reference sec = state.getSecReference(); |
|
133 |
if (classification == null){ |
|
134 |
String classificationName = state.getConfig().getClassificationName(); |
|
135 |
//TODO |
|
136 |
Language language = Language.DEFAULT(); |
|
137 |
classification = Classification.NewInstance(classificationName, sec, language); |
|
138 |
state.setClassification(classification); |
|
139 |
classification.setUuid(state.getConfig().getClassificationUuid()); |
|
140 |
classification.getRootNode().setUuid(ROOT_UUID); |
|
141 |
} |
|
142 |
|
|
143 |
getClassificationService().save(classification); |
|
144 |
rootNode = classification.getRootNode(); |
|
145 |
} |
|
146 |
return rootNode; |
|
147 |
} |
|
148 |
|
|
149 |
|
|
150 |
/** |
|
151 |
* @param record |
|
152 |
* @param originalKey |
|
153 |
* @return |
|
154 |
*/ |
|
155 |
private String getValue(HashMap<String, String> record, String originalKey) { |
|
156 |
String value = record.get(originalKey); |
|
157 |
if (! StringUtils.isBlank(value)) { |
|
158 |
if (logger.isDebugEnabled()) { logger.debug(originalKey + ": " + value); } |
|
159 |
value = CdmUtils.removeDuplicateWhitespace(value.trim()).toString(); |
|
160 |
return value; |
|
161 |
}else{ |
|
162 |
return null; |
|
163 |
} |
|
164 |
} |
|
165 |
|
|
166 |
|
|
167 |
|
|
168 |
/** |
|
169 |
* Stores taxa records in DB |
|
170 |
*/ |
|
171 |
@Override |
|
172 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) { |
|
173 |
|
|
174 |
boolean isSynonymOnly = false; |
|
175 |
|
|
176 |
String line = state.getCurrentLine() + ": "; |
|
177 |
HashMap<String, String> record = state.getOriginalRecord(); |
|
178 |
|
|
179 |
Set<String> keys = record.keySet(); |
|
180 |
for (String key: keys) { |
|
181 |
if (! expectedKeys.contains(key)){ |
|
182 |
logger.warn(line + "Unexpected Key: " + key); |
|
183 |
} |
|
184 |
} |
|
185 |
|
|
186 |
//higherTaxon |
|
187 |
TaxonNode higherTaxon = getHigherTaxon(record, (IAPTImportState)state); |
|
188 |
|
|
189 |
//Taxon |
|
190 |
Taxon taxon = makeTaxon(record, state, higherTaxon, isSynonymOnly); |
|
191 |
if (taxon == null && ! isSynonymOnly){ |
|
192 |
logger.warn(line + "taxon could not be created and is null"); |
|
193 |
return; |
|
194 |
} |
|
195 |
((IAPTImportState)state).setCurrentTaxon(taxon); |
|
196 |
|
|
197 |
//(Notas) |
|
198 |
//makeNotes(record, state); |
|
199 |
|
|
200 |
//Syn. |
|
201 |
//makeSynonyms(record, state, !isSynonymOnly); |
|
202 |
|
|
203 |
|
|
204 |
return; |
|
205 |
} |
|
206 |
|
|
207 |
private TaxonNode getHigherTaxon(HashMap<String, String> record, IAPTImportState state) { |
|
208 |
String higherTaxaString = record.get(HIGHERTAXON); |
|
209 |
// higherTaxaString is like |
|
210 |
// - DICOTYLEDONES: LEGUMINOSAE: MIMOSOIDEAE |
|
211 |
// - FOSSIL DICOTYLEDONES: PROTEACEAE |
|
212 |
// - [fungi] |
|
213 |
// - [no group assigned] |
|
214 |
if(higherTaxaString.equals("[no group assigned]")){ |
|
215 |
return null; |
|
216 |
} |
|
217 |
String[] higherTaxaNames = higherTaxaString.toLowerCase().replaceAll("[\\[\\]]", "").split(":"); |
|
218 |
TaxonNode higherTaxonNode = null; |
|
219 |
|
|
220 |
ITaxonTreeNode rootNode = getClassification(state); |
|
221 |
for (String htn : higherTaxaNames) { |
|
222 |
htn = htn.trim(); |
|
223 |
Taxon higherTaxon = state.getHigherTaxon(htn); |
|
224 |
if (higherTaxon != null){ |
|
225 |
higherTaxonNode = higherTaxon.getTaxonNodes().iterator().next(); |
|
226 |
}else{ |
|
227 |
BotanicalName name = makeHigherTaxonName(state, htn); |
|
228 |
Reference sec = state.getSecReference(); |
|
229 |
higherTaxon = Taxon.NewInstance(name, sec); |
|
230 |
higherTaxonNode = rootNode.addChildTaxon(higherTaxon, sec, null); |
|
231 |
state.putHigherTaxon(htn, higherTaxon); |
|
232 |
rootNode = higherTaxonNode; |
|
233 |
} |
|
234 |
} |
|
235 |
return higherTaxonNode; |
|
236 |
} |
|
237 |
|
|
238 |
private BotanicalName makeHigherTaxonName(IAPTImportState state, String name) { |
|
239 |
// Abteilung: -phyta (bei Pflanzen), -mycota (bei Pilzen) |
|
240 |
// Unterabteilung: -phytina (bei Pflanzen), -mycotina (bei Pilzen) |
|
241 |
// Klasse: -opsida (bei Pflanzen), -phyceae (bei Algen), -mycetes (bei Pilzen) |
|
242 |
// Unterklasse: -idae (bei Pflanzen), -phycidae (bei Algen), -mycetidae (bei Pilzen) |
|
243 |
// Ordnung: -ales |
|
244 |
// Unterordnung: -ineae |
|
245 |
// Familie: -aceae |
|
246 |
// Unterfamilie: -oideae |
|
247 |
// Tribus: -eae |
|
248 |
// Subtribus: -inae |
|
249 |
Rank rank = Rank.UNKNOWN_RANK(); |
|
250 |
if(name.matches("phyta$|mycota$")){ |
|
251 |
rank = Rank.SECTION_BOTANY(); |
|
252 |
} else if(name.matches("phytina$|mycotina$")){ |
|
253 |
rank = Rank.SUBSECTION_BOTANY(); |
|
254 |
} else if(name.matches("opsida$|phyceae$|mycetes$")){ |
|
255 |
rank = Rank.CLASS(); |
|
256 |
} else if(name.matches("idae$|phycidae$|mycetidae$")){ |
|
257 |
rank = Rank.SUBCLASS(); |
|
258 |
} else if(name.matches("ales$")){ |
|
259 |
rank = Rank.ORDER(); |
|
260 |
} else if(name.matches("ineae$")){ |
|
261 |
rank = Rank.SUBORDER(); |
|
262 |
} else if(name.matches("aceae$")){ |
|
263 |
rank = Rank.FAMILY(); |
|
264 |
} else if(name.matches("oideae$")){ |
|
265 |
rank = Rank.SUBFAMILY(); |
|
266 |
} else if(name.matches("eae$")){ |
|
267 |
rank = Rank.TRIBE(); |
|
268 |
} else if(name.matches("inae$")){ |
|
269 |
rank = Rank.SUBTRIBE(); |
|
270 |
} |
|
271 |
|
|
272 |
BotanicalName taxonName = BotanicalName.NewInstance(rank); |
|
273 |
taxonName.addSource(makeOriginalSource(state)); |
|
274 |
taxonName.setGenusOrUninomial(StringUtils.capitalize(name)); |
|
275 |
return taxonName; |
|
276 |
} |
|
277 |
|
|
278 |
|
|
279 |
/** |
|
280 |
* @param state |
|
281 |
* @return |
|
282 |
*/ |
|
283 |
private IdentifiableSource makeOriginalSource(IAPTImportState state) { |
|
284 |
return IdentifiableSource.NewDataImportInstance("line: " + state.getCurrentLine(), null, state.getConfig().getSourceReference()); |
|
285 |
} |
|
286 |
|
|
287 |
|
|
288 |
private Reference makeReference(IAPTImportState state, UUID uuidRef) { |
|
289 |
Reference ref = state.getReference(uuidRef); |
|
290 |
if (ref == null){ |
|
291 |
ref = getReferenceService().find(uuidRef); |
|
292 |
state.putReference(uuidRef, ref); |
|
293 |
} |
|
294 |
return ref; |
|
295 |
} |
|
296 |
|
|
297 |
|
|
298 |
|
|
299 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/iapt/IAPTImportConfigurator.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2016 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
package eu.etaxonomy.cdm.io.iapt; |
|
11 |
|
|
12 |
import eu.etaxonomy.cdm.database.ICdmDataSource; |
|
13 |
import eu.etaxonomy.cdm.io.common.ImportStateBase; |
|
14 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer; |
|
15 |
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase; |
|
16 |
import eu.etaxonomy.cdm.io.mexico.MexicoBorhidiExcelImport; |
|
17 |
import eu.etaxonomy.cdm.io.mexico.MexicoConabioTransformer; |
|
18 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
|
19 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
20 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
21 |
|
|
22 |
import java.net.URI; |
|
23 |
|
|
24 |
/** |
|
25 |
* @author a.mueller |
|
26 |
* @date 16.06.2016 |
|
27 |
* |
|
28 |
*/ |
|
29 |
public class IAPTImportConfigurator extends ExcelImportConfiguratorBase{ |
|
30 |
|
|
31 |
private static final long serialVersionUID = -4793138681632122831L; |
|
32 |
|
|
33 |
private static IInputTransformer defaultTransformer = new IAPTTransformer(); |
|
34 |
|
|
35 |
private Reference secReference; |
|
36 |
|
|
37 |
|
|
38 |
public static IAPTImportConfigurator NewInstance(URI source, ICdmDataSource destination) { |
|
39 |
return new IAPTImportConfigurator(source, destination); |
|
40 |
} |
|
41 |
|
|
42 |
|
|
43 |
private IAPTImportConfigurator(URI source, ICdmDataSource destination) { |
|
44 |
super(source, destination, defaultTransformer); |
|
45 |
setNomenclaturalCode(NomenclaturalCode.ICNAFP); |
|
46 |
setSource(source); |
|
47 |
setDestination(destination); |
|
48 |
} |
|
49 |
|
|
50 |
@Override |
|
51 |
public ImportStateBase getNewState() { |
|
52 |
return new SimpleExcelTaxonImportState<>(this); |
|
53 |
} |
|
54 |
|
|
55 |
@Override |
|
56 |
protected void makeIoClassList() { |
|
57 |
ioClassList = new Class[]{ |
|
58 |
IAPTExcelImport.class |
|
59 |
}; |
|
60 |
} |
|
61 |
|
|
62 |
|
|
63 |
/** |
|
64 |
* @return the secReference |
|
65 |
*/ |
|
66 |
public Reference getSecReference() { |
|
67 |
return secReference; |
|
68 |
} |
|
69 |
|
|
70 |
|
|
71 |
/** |
|
72 |
* @param secReference |
|
73 |
*/ |
|
74 |
public void setSecReference(Reference secReference) { |
|
75 |
this.secReference = secReference; |
|
76 |
} |
|
77 |
|
|
78 |
} |
|
79 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/iapt/IAPTImportState.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.io.iapt; |
|
12 |
|
|
13 |
import java.util.HashMap; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.io.mexico.SimpleExcelTaxonImportState; |
|
18 |
import org.apache.log4j.Logger; |
|
19 |
|
|
20 |
import eu.etaxonomy.cdm.io.excel.common.ExcelImportState; |
|
21 |
import eu.etaxonomy.cdm.io.excel.common.ExcelRowBase; |
|
22 |
import eu.etaxonomy.cdm.model.description.PresenceAbsenceTerm; |
|
23 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
|
24 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
25 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
26 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
|
27 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.mueller |
|
31 |
* @created 11.05.2009 |
|
32 |
*/ |
|
33 |
public class IAPTImportState extends SimpleExcelTaxonImportState<IAPTImportConfigurator> { |
|
34 |
@SuppressWarnings("unused") |
|
35 |
private static final Logger logger = Logger.getLogger(IAPTImportState.class); |
|
36 |
|
|
37 |
private final Map<String, Taxon> higherTaxonTaxonMap = new HashMap<String, Taxon>(); |
|
38 |
|
|
39 |
private final Map<String, UUID> higherTaxonUuidMap = new HashMap<String, UUID>(); |
|
40 |
|
|
41 |
private final Map<String, BotanicalName> familyNameMap = new HashMap<String, BotanicalName>(); |
|
42 |
|
|
43 |
//classification |
|
44 |
private Classification classification; |
|
45 |
public Classification getClassification() {return classification;} |
|
46 |
public void setClassification(Classification classification) {this.classification = classification;} |
|
47 |
|
|
48 |
//current taxon |
|
49 |
private Taxon currentTaxon; |
|
50 |
public Taxon getCurrentTaxon() {return currentTaxon;} |
|
51 |
public void setCurrentTaxon(Taxon currentTaxon) {this.currentTaxon = currentTaxon;} |
|
52 |
|
|
53 |
//rootNode |
|
54 |
private TaxonNode rootNode; |
|
55 |
public void setRootNode(TaxonNode rootNode) {this.rootNode = rootNode;} |
|
56 |
public TaxonNode getRootNode() { return rootNode;} |
|
57 |
|
|
58 |
private Reference secReference; |
|
59 |
public Reference getSecReference() {return secReference;} |
|
60 |
public void setSecReference(Reference secReference) {this.secReference = secReference;} |
|
61 |
|
|
62 |
private PresenceAbsenceTerm highestStatusForTaxon; |
|
63 |
public PresenceAbsenceTerm getHighestStatusForTaxon(){return highestStatusForTaxon;} |
|
64 |
public void setHighestStatusForTaxon(PresenceAbsenceTerm highestStatusForTaxon){this.highestStatusForTaxon = highestStatusForTaxon;} |
|
65 |
|
|
66 |
//Constructor |
|
67 |
public IAPTImportState(IAPTImportConfigurator config) { |
|
68 |
super(config); |
|
69 |
} |
|
70 |
|
|
71 |
//higher taxon |
|
72 |
public Taxon getHigherTaxon(String higherName) { |
|
73 |
return higherTaxonTaxonMap.get(higherName); |
|
74 |
} |
|
75 |
public Taxon putHigherTaxon(String higherName, Taxon taxon) { |
|
76 |
return higherTaxonTaxonMap.put(higherName, taxon); |
|
77 |
} |
|
78 |
public Taxon removeHigherTaxon(String higherName) { |
|
79 |
return higherTaxonTaxonMap.remove(higherName); |
|
80 |
} |
|
81 |
public boolean containsHigherTaxon(String higherName) { |
|
82 |
return higherTaxonTaxonMap.containsKey(higherName); |
|
83 |
} |
|
84 |
|
|
85 |
//higher taxon uuid |
|
86 |
public UUID getHigherTaxonUuid(String higherName) { |
|
87 |
return higherTaxonUuidMap.get(higherName); |
|
88 |
} |
|
89 |
public UUID putHigherTaxon(String higherName, UUID uuid) { |
|
90 |
return higherTaxonUuidMap.put(higherName, uuid); |
|
91 |
} |
|
92 |
public UUID removeHigherTaxonUuid(String higherName) { |
|
93 |
return higherTaxonUuidMap.remove(higherName); |
|
94 |
} |
|
95 |
public boolean containsHigherTaxonUuid(String higherName) { |
|
96 |
return higherTaxonUuidMap.containsKey(higherName); |
|
97 |
} |
|
98 |
|
|
99 |
//family names |
|
100 |
public BotanicalName getFamilyName(String familyStr) { |
|
101 |
return familyNameMap.get(familyStr); |
|
102 |
} |
|
103 |
public void putFamilyName(String familyStr, BotanicalName name) { |
|
104 |
familyNameMap.put(familyStr, name); |
|
105 |
} |
|
106 |
|
|
107 |
|
|
108 |
Map<UUID, Reference> refMap = new HashMap<UUID, Reference>(); |
|
109 |
//reference |
|
110 |
public Reference getReference(UUID uuidRef) { |
|
111 |
return refMap.get(uuidRef); |
|
112 |
} |
|
113 |
public void putReference(UUID uuidRef, Reference ref) { |
|
114 |
refMap.put(uuidRef, ref); |
|
115 |
} |
|
116 |
|
|
117 |
|
|
118 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/iapt/IAPTTransformer.java | ||
---|---|---|
1 |
// $Id$ |
|
2 |
/** |
|
3 |
* Copyright (C) 2007 EDIT |
|
4 |
* European Distributed Institute of Taxonomy |
|
5 |
* http://www.e-taxonomy.eu |
|
6 |
* |
|
7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
|
8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
|
9 |
*/ |
|
10 |
|
|
11 |
package eu.etaxonomy.cdm.io.iapt; |
|
12 |
|
|
13 |
import java.util.UUID; |
|
14 |
|
|
15 |
import org.apache.log4j.Logger; |
|
16 |
|
|
17 |
import eu.etaxonomy.cdm.io.common.mapping.InputTransformerBase; |
|
18 |
|
|
19 |
/** |
|
20 |
* @author a.mueller |
|
21 |
* @created 01.03.2010 |
|
22 |
*/ |
|
23 |
public final class IAPTTransformer extends InputTransformerBase { |
|
24 |
private static final long serialVersionUID = 1070018208741186271L; |
|
25 |
|
|
26 |
@SuppressWarnings("unused") |
|
27 |
private static final Logger logger = Logger.getLogger(IAPTTransformer.class); |
|
28 |
|
|
29 |
//references |
|
30 |
public static final UUID uuidRefFRC = UUID.fromString("c1caf6a2-5083-4f44-8f97-9abe23a84cd8"); |
|
31 |
public static final UUID uuidRefAS = UUID.fromString("1f15291a-b4c5-4e15-960f-d0145a250539"); |
|
32 |
public static final UUID uuidRefFC = UUID.fromString("c5a0bfb8-85b2-422d-babe-423aa2e24c35"); |
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/mexico/SimpleExcelTaxonImportState.java | ||
---|---|---|
12 | 12 |
import java.util.HashMap; |
13 | 13 |
import java.util.Map; |
14 | 14 |
|
15 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
|
15 | 16 |
import org.apache.log4j.Logger; |
16 | 17 |
|
17 | 18 |
import eu.etaxonomy.cdm.io.excel.common.ExcelImportConfiguratorBase; |
Also available in: Unified diff
Initial set of classes for the IAPT import