Revision 4cec86c7
Added by Andreas Müller over 12 years ago
.gitattributes | ||
---|---|---|
1235 | 1235 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/floraMalesiana/FloraMalesianaImportState.java -text |
1236 | 1236 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/floraMalesiana/FloraMalesianaTaxonImport.java -text |
1237 | 1237 |
cdm-eflora/src/main/java/eu/etaxonomy/cdm/io/eflora/floraMalesiana/FloraMalesianaTransformer.java -text |
1238 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsAreaImport.java -text |
|
1239 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDrImport.java -text |
|
1240 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImageImport.java -text |
|
1241 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportBase.java -text |
|
1242 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportConfigurator.java -text |
|
1243 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportRankMap.java -text |
|
1244 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportState.java -text |
|
1245 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsLinkImport.java -text |
|
1246 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsNotesImport.java -text |
|
1247 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsNotesSourcesImport.java -text |
|
1248 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsReferenceImport.java -text |
|
1249 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsSourceUsesImport.java -text |
|
1250 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java -text |
|
1251 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java -text |
|
1252 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTransformer.java -text |
|
1253 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java -text |
|
1254 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularSourcesImport.java -text |
|
1255 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsAreaImportValidator.java -text |
|
1256 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsGeneralImportValidator.java -text |
|
1257 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsImageImportValidator.java -text |
|
1258 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsLinkImportValidator.java -text |
|
1259 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsNoteImportValidator.java -text |
|
1260 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsRankImportValidator.java -text |
|
1261 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsReferenceImportValidator.java -text |
|
1262 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java -text |
|
1263 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java -text |
|
1264 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsVernacularSourceImportValidator.java -text |
|
1265 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAdditionalTaxonDataImport.java -text |
|
1266 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAuthorImport.java -text |
|
1267 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistribution.java -text |
|
1268 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionImport.java -text |
|
1269 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionTaxon.java -text |
|
1270 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaHeterotypicSynonymImport.java -text |
|
1271 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportBase.java -text |
|
1272 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportConfigurator.java -text |
|
1273 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportState.java -text |
|
1274 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRefImport.java -text |
|
1275 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaReference.java -text |
|
1276 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaReferenceTaxon.java -text |
|
1277 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRelTaxonIncludeImport.java -text |
|
1278 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTaxon.java -text |
|
1279 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTaxonNameImport.java -text |
|
1280 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTransformer.java -text |
|
1281 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaUsersImport.java -text |
|
1282 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/merging/FaunaEuErmsMerging.java -text |
|
1283 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiAdditionalTaxonSourceExport.java -text |
|
1284 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiCollectionExportMapping.java -text |
|
1285 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java -text |
|
1286 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportConfigurator.java -text |
|
1287 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportMapping.java -text |
|
1288 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportState.java -text |
|
1289 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiImageExport.java -text |
|
1290 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiNoteExport.java -text |
|
1291 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiNoteSourceExport.java -text |
|
1292 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiOccurrenceExport.java -text |
|
1293 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiOccurrenceSourceExport.java -text |
|
1294 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiRelTaxonExport.java -text |
|
1295 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiSourceExport.java -text |
|
1296 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java -text |
|
1297 |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java -text |
|
1298 |
cdm-pesi/src/test/java/eu/etaxonomy/cdm/io/erms/ermsErrors.txt -text |
|
1238 | 1299 |
cdmlib-pesi/LICENSE.TXT -text |
1239 | 1300 |
cdmlib-pesi/README.TXT -text |
1240 | 1301 |
cdmlib-pesi/pom.xml -text |
1241 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsAreaImport.java -text |
|
1242 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDrImport.java -text |
|
1243 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImageImport.java -text |
|
1244 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportBase.java -text |
|
1245 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportConfigurator.java -text |
|
1246 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportRankMap.java -text |
|
1247 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportState.java -text |
|
1248 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsLinkImport.java -text |
|
1249 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsNotesImport.java -text |
|
1250 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsNotesSourcesImport.java -text |
|
1251 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsReferenceImport.java -text |
|
1252 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsSourceUsesImport.java -text |
|
1253 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonImport.java -text |
|
1254 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTaxonRelationImport.java -text |
|
1255 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsTransformer.java -text |
|
1256 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularImport.java -text |
|
1257 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsVernacularSourcesImport.java -text |
|
1258 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsAreaImportValidator.java -text |
|
1259 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsGeneralImportValidator.java -text |
|
1260 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsImageImportValidator.java -text |
|
1261 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsLinkImportValidator.java -text |
|
1262 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsNoteImportValidator.java -text |
|
1263 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsRankImportValidator.java -text |
|
1264 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsReferenceImportValidator.java -text |
|
1265 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsSourceUsesImportValidator.java -text |
|
1266 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsTaxonImportValidator.java -text |
|
1267 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/validation/ErmsVernacularSourceImportValidator.java -text |
|
1268 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAdditionalTaxonDataImport.java -text |
|
1269 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaAuthorImport.java -text |
|
1270 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistribution.java -text |
|
1271 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionImport.java -text |
|
1272 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaDistributionTaxon.java -text |
|
1273 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaHeterotypicSynonymImport.java -text |
|
1274 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportBase.java -text |
|
1275 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportConfigurator.java -text |
|
1276 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaImportState.java -text |
|
1277 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRefImport.java -text |
|
1278 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaReference.java -text |
|
1279 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaReferenceTaxon.java -text |
|
1280 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaRelTaxonIncludeImport.java -text |
|
1281 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTaxon.java -text |
|
1282 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTaxonNameImport.java -text |
|
1283 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaTransformer.java -text |
|
1284 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/faunaEuropaea/FaunaEuropaeaUsersImport.java -text |
|
1285 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/merging/FaunaEuErmsMerging.java -text |
|
1286 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiAdditionalTaxonSourceExport.java -text |
|
1287 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiCollectionExportMapping.java -text |
|
1288 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportBase.java -text |
|
1289 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportConfigurator.java -text |
|
1290 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportMapping.java -text |
|
1291 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiExportState.java -text |
|
1292 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiImageExport.java -text |
|
1293 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiNoteExport.java -text |
|
1294 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiNoteSourceExport.java -text |
|
1295 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiOccurrenceExport.java -text |
|
1296 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiOccurrenceSourceExport.java -text |
|
1297 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiRelTaxonExport.java -text |
|
1298 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiSourceExport.java -text |
|
1299 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTaxonExport.java -text |
|
1300 |
cdmlib-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/out/PesiTransformer.java -text |
|
1301 |
cdmlib-pesi/src/test/java/eu/etaxonomy/cdm/io/erms/ermsErrors.txt -text |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsAreaImport.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.pesi.erms; |
|
11 |
|
|
12 |
import java.sql.ResultSet; |
|
13 |
import java.sql.SQLException; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.Map; |
|
16 |
import java.util.UUID; |
|
17 |
|
|
18 |
import org.apache.log4j.Logger; |
|
19 |
import org.springframework.stereotype.Component; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
|
22 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportAnnotationMapper; |
|
23 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportExtensionMapper; |
|
24 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
25 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportObjectCreationMapper; |
|
26 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportStringMapper; |
|
27 |
import eu.etaxonomy.cdm.io.common.mapping.IMappingImport; |
|
28 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsAreaImportValidator; |
|
29 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
|
30 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
31 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
32 |
import eu.etaxonomy.cdm.model.location.NamedAreaLevel; |
|
33 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
|
34 |
|
|
35 |
|
|
36 |
/** |
|
37 |
* @author a.mueller |
|
38 |
* @created 20.02.2010 |
|
39 |
* @version 1.0 |
|
40 |
*/ |
|
41 |
@Component |
|
42 |
public class ErmsAreaImport extends ErmsImportBase<NamedArea> implements IMappingImport<NamedArea, ErmsImportState>{ |
|
43 |
private static final Logger logger = Logger.getLogger(ErmsAreaImport.class); |
|
44 |
|
|
45 |
private DbImportMapping mapping; |
|
46 |
|
|
47 |
|
|
48 |
private int modCount = 10000; |
|
49 |
private static final String pluralString = "areas"; |
|
50 |
private static final String dbTableName = "gu"; |
|
51 |
private static final Class cdmTargetClass = NamedArea.class; |
|
52 |
|
|
53 |
public ErmsAreaImport(){ |
|
54 |
super(pluralString, dbTableName, cdmTargetClass); |
|
55 |
} |
|
56 |
|
|
57 |
|
|
58 |
/* (non-Javadoc) |
|
59 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
60 |
*/ |
|
61 |
@Override |
|
62 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
|
63 |
String strRecordQuery = |
|
64 |
" SELECT * " + |
|
65 |
" FROM gu " + |
|
66 |
" WHERE ( gu.id IN (" + ID_LIST_TOKEN + ") )"; |
|
67 |
return strRecordQuery; |
|
68 |
} |
|
69 |
|
|
70 |
/* (non-Javadoc) |
|
71 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping() |
|
72 |
*/ |
|
73 |
protected DbImportMapping getMapping() { |
|
74 |
if (mapping == null){ |
|
75 |
mapping = new DbImportMapping(); |
|
76 |
|
|
77 |
mapping.addMapper(DbImportObjectCreationMapper.NewInstance(this, "id", AREA_NAMESPACE)); //id |
|
78 |
mapping.addMapper(DbImportStringMapper.NewInstance("gu_name", "titleCache")); |
|
79 |
mapping.addMapper(DbImportExtensionMapper.NewInstance("gazetteer_id", ErmsTransformer.GAZETTEER_UUID, "Gazetteer ID", "Gazetteer ID", "G-ID")); |
|
80 |
mapping.addMapper(DbImportAnnotationMapper.NewInstance("note", AnnotationType.EDITORIAL())); |
|
81 |
|
|
82 |
} |
|
83 |
return mapping; |
|
84 |
} |
|
85 |
|
|
86 |
|
|
87 |
/* (non-Javadoc) |
|
88 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
|
89 |
*/ |
|
90 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) { |
|
91 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
|
92 |
return result; //not needed |
|
93 |
} |
|
94 |
|
|
95 |
|
|
96 |
/* (non-Javadoc) |
|
97 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet) |
|
98 |
*/ |
|
99 |
public NamedArea createObject(ResultSet rs, ErmsImportState state) throws SQLException { |
|
100 |
int id = rs.getInt("id"); |
|
101 |
String strGuName = rs.getString("gu_name"); |
|
102 |
UUID uuid = ErmsTransformer.uuidFromGuName(strGuName); |
|
103 |
String label = strGuName; |
|
104 |
String text = strGuName; |
|
105 |
//TODO |
|
106 |
String labelAbbrev = String.valueOf(id); |
|
107 |
NamedAreaType areaType = null; |
|
108 |
NamedAreaLevel level = null; |
|
109 |
NamedArea area = getNamedArea(state, uuid, label, text, labelAbbrev, areaType, level); |
|
110 |
return area; |
|
111 |
} |
|
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
115 |
*/ |
|
116 |
@Override |
|
117 |
protected boolean doCheck(ErmsImportState state){ |
|
118 |
IOValidator<ErmsImportState> validator = new ErmsAreaImportValidator(); |
|
119 |
return validator.validate(state); |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
/* (non-Javadoc) |
|
124 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
125 |
*/ |
|
126 |
protected boolean isIgnore(ErmsImportState state){ |
|
127 |
//TODO |
|
128 |
// return ! state.getConfig().isDoAreas(); |
|
129 |
return false; |
|
130 |
} |
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsDrImport.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.pesi.erms; |
|
11 |
|
|
12 |
import java.sql.ResultSet; |
|
13 |
import java.sql.SQLException; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.HashSet; |
|
16 |
import java.util.Map; |
|
17 |
import java.util.Set; |
|
18 |
|
|
19 |
import org.apache.log4j.Logger; |
|
20 |
import org.springframework.stereotype.Component; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
|
23 |
import eu.etaxonomy.cdm.io.common.mapping.DbIgnoreMapper; |
|
24 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportAnnotationMapper; |
|
25 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportDescriptionElementSourceCreationMapper; |
|
26 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportDistributionCreationMapper; |
|
27 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
28 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportObjectMapper; |
|
29 |
import eu.etaxonomy.cdm.io.common.mapping.DbNotYetImplementedMapper; |
|
30 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsReferenceImportValidator; |
|
31 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
|
32 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
33 |
import eu.etaxonomy.cdm.model.description.Distribution; |
|
34 |
import eu.etaxonomy.cdm.model.description.PresenceTerm; |
|
35 |
import eu.etaxonomy.cdm.model.location.NamedArea; |
|
36 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
37 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
38 |
|
|
39 |
|
|
40 |
/** |
|
41 |
* @author a.mueller |
|
42 |
* @created 20.02.2010 |
|
43 |
* @version 1.0 |
|
44 |
*/ |
|
45 |
@Component |
|
46 |
public class ErmsDrImport extends ErmsImportBase<Distribution> { |
|
47 |
@SuppressWarnings("unused") |
|
48 |
private static final Logger logger = Logger.getLogger(ErmsDrImport.class); |
|
49 |
|
|
50 |
private DbImportMapping mapping; |
|
51 |
|
|
52 |
private int modCount = 10000; |
|
53 |
private static final String pluralString = "distributions"; |
|
54 |
private static final String dbTableName = "dr"; |
|
55 |
private static final Class cdmTargetClass = Distribution.class; |
|
56 |
|
|
57 |
public ErmsDrImport(){ |
|
58 |
super(pluralString, dbTableName, cdmTargetClass); |
|
59 |
} |
|
60 |
|
|
61 |
|
|
62 |
/* (non-Javadoc) |
|
63 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
64 |
*/ |
|
65 |
@Override |
|
66 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
|
67 |
String strRecordQuery = |
|
68 |
" SELECT dr.*, tu.tu_acctaxon, tu.id " + |
|
69 |
" FROM dr INNER JOIN tu ON dr.tu_id = tu.id " + |
|
70 |
" WHERE ( dr.id IN (" + ID_LIST_TOKEN + ") )"; |
|
71 |
return strRecordQuery; |
|
72 |
} |
|
73 |
|
|
74 |
/* (non-Javadoc) |
|
75 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping() |
|
76 |
*/ |
|
77 |
protected DbImportMapping getMapping() { |
|
78 |
if (mapping == null){ |
|
79 |
mapping = new DbImportMapping(); |
|
80 |
|
|
81 |
PresenceTerm status = PresenceTerm.PRESENT(); |
|
82 |
DbImportDistributionCreationMapper<?> distributionMapper = DbImportDistributionCreationMapper.NewFixedStatusInstance("id", DR_NAMESPACE, "tu_acctaxon", ErmsTaxonImport.TAXON_NAMESPACE, status); |
|
83 |
distributionMapper.setSource("source_id", REFERENCE_NAMESPACE, null); |
|
84 |
mapping.addMapper(distributionMapper); |
|
85 |
|
|
86 |
mapping.addMapper(DbImportObjectMapper.NewInstance("gu_id", "area", ErmsAreaImport.AREA_NAMESPACE)); |
|
87 |
mapping.addMapper(DbImportAnnotationMapper.NewInstance("note", AnnotationType.EDITORIAL())); |
|
88 |
|
|
89 |
mapping.addMapper(DbIgnoreMapper.NewInstance("unacceptsource_id")); |
|
90 |
mapping.addMapper(DbIgnoreMapper.NewInstance("unacceptreason")); |
|
91 |
mapping.addMapper(DbIgnoreMapper.NewInstance("valid_flag")); |
|
92 |
mapping.addMapper(DbIgnoreMapper.NewInstance("certain_flag")); |
|
93 |
mapping.addMapper(DbIgnoreMapper.NewInstance("map_flag")); |
|
94 |
mapping.addMapper(DbIgnoreMapper.NewInstance("endemic_flag")); |
|
95 |
mapping.addMapper(DbIgnoreMapper.NewInstance("exotic_flag")); |
|
96 |
mapping.addMapper(DbIgnoreMapper.NewInstance("typelocality_flag")); |
|
97 |
mapping.addMapper(DbIgnoreMapper.NewInstance("specimenflag")); |
|
98 |
mapping.addMapper(DbIgnoreMapper.NewInstance("lat")); |
|
99 |
mapping.addMapper(DbIgnoreMapper.NewInstance("long")); |
|
100 |
mapping.addMapper(DbIgnoreMapper.NewInstance("depthshallow")); |
|
101 |
mapping.addMapper(DbIgnoreMapper.NewInstance("depthdeep")); |
|
102 |
mapping.addMapper(DbIgnoreMapper.NewInstance("beginyear")); |
|
103 |
mapping.addMapper(DbIgnoreMapper.NewInstance("beginmonth")); |
|
104 |
mapping.addMapper(DbIgnoreMapper.NewInstance("beginday")); |
|
105 |
mapping.addMapper(DbIgnoreMapper.NewInstance("endyear")); |
|
106 |
mapping.addMapper(DbIgnoreMapper.NewInstance("endmonth")); |
|
107 |
mapping.addMapper(DbIgnoreMapper.NewInstance("endday")); |
|
108 |
mapping.addMapper(DbIgnoreMapper.NewInstance("min_abundance")); |
|
109 |
mapping.addMapper(DbIgnoreMapper.NewInstance("max_abundance")); |
|
110 |
|
|
111 |
|
|
112 |
} |
|
113 |
return mapping; |
|
114 |
} |
|
115 |
|
|
116 |
/* (non-Javadoc) |
|
117 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
|
118 |
*/ |
|
119 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) { |
|
120 |
String nameSpace; |
|
121 |
Class cdmClass; |
|
122 |
Set<String> idSet; |
|
123 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
|
124 |
|
|
125 |
try{ |
|
126 |
Set<String> taxonIdSet = new HashSet<String>(); |
|
127 |
Set<String> areaIdSet = new HashSet<String>(); |
|
128 |
Set<String> sourceIdSet = new HashSet<String>(); |
|
129 |
while (rs.next()){ |
|
130 |
handleForeignKey(rs, taxonIdSet,"tu_acctaxon" ); |
|
131 |
handleForeignKey(rs, areaIdSet, "gu_id"); |
|
132 |
handleForeignKey(rs, sourceIdSet, "source_id"); |
|
133 |
} |
|
134 |
|
|
135 |
//taxon map |
|
136 |
nameSpace = ErmsTaxonImport.TAXON_NAMESPACE; |
|
137 |
cdmClass = TaxonBase.class; |
|
138 |
idSet = taxonIdSet; |
|
139 |
Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
140 |
result.put(nameSpace, taxonMap); |
|
141 |
|
|
142 |
//areas |
|
143 |
nameSpace = ErmsAreaImport.AREA_NAMESPACE; |
|
144 |
cdmClass = NamedArea.class; |
|
145 |
idSet = areaIdSet; |
|
146 |
Map<String, NamedArea> areaMap = (Map<String, NamedArea>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
147 |
result.put(nameSpace, areaMap); |
|
148 |
|
|
149 |
//reference map |
|
150 |
nameSpace = ErmsReferenceImport.REFERENCE_NAMESPACE; |
|
151 |
cdmClass = Reference.class; |
|
152 |
idSet = sourceIdSet; |
|
153 |
Map<String, Reference> referenceMap = (Map<String, Reference>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
154 |
result.put(nameSpace, referenceMap); |
|
155 |
|
|
156 |
|
|
157 |
} catch (SQLException e) { |
|
158 |
throw new RuntimeException(e); |
|
159 |
} |
|
160 |
return result; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* @param distribution |
|
165 |
* @param source_id |
|
166 |
* @param state |
|
167 |
*/ |
|
168 |
private void addSource(Distribution distribution, Integer source_id, ErmsImportState state) { |
|
169 |
Reference ref = (Reference)state.getRelatedObject(ErmsReferenceImport.REFERENCE_NAMESPACE, String.valueOf(source_id)); |
|
170 |
distribution.addSource(null, null, ref, null); |
|
171 |
} |
|
172 |
|
|
173 |
/* (non-Javadoc) |
|
174 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase) |
|
175 |
*/ |
|
176 |
public Distribution createObject(ResultSet rs, ErmsImportState state) |
|
177 |
throws SQLException { |
|
178 |
return null; //not needed |
|
179 |
} |
|
180 |
|
|
181 |
|
|
182 |
/* (non-Javadoc) |
|
183 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
184 |
*/ |
|
185 |
@Override |
|
186 |
protected boolean doCheck(ErmsImportState state){ |
|
187 |
IOValidator<ErmsImportState> validator = new ErmsReferenceImportValidator(); |
|
188 |
return validator.validate(state); |
|
189 |
} |
|
190 |
|
|
191 |
/* (non-Javadoc) |
|
192 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
193 |
*/ |
|
194 |
protected boolean isIgnore(ErmsImportState state){ |
|
195 |
return ! state.getConfig().isDoOccurrence(); |
|
196 |
} |
|
197 |
|
|
198 |
|
|
199 |
|
|
200 |
|
|
201 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImageImport.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.pesi.erms; |
|
11 |
|
|
12 |
import java.sql.ResultSet; |
|
13 |
import java.sql.SQLException; |
|
14 |
import java.util.HashMap; |
|
15 |
import java.util.HashSet; |
|
16 |
import java.util.Map; |
|
17 |
import java.util.Set; |
|
18 |
|
|
19 |
import org.apache.log4j.Logger; |
|
20 |
import org.springframework.stereotype.Component; |
|
21 |
|
|
22 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
|
23 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportImageCreationMapper; |
|
24 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
25 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMediaMapper; |
|
26 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsImageImportValidator; |
|
27 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
28 |
import eu.etaxonomy.cdm.model.description.TextData; |
|
29 |
import eu.etaxonomy.cdm.model.media.Media; |
|
30 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
|
31 |
|
|
32 |
|
|
33 |
/** |
|
34 |
* @author a.mueller |
|
35 |
* @created 20.02.2010 |
|
36 |
* @version 1.0 |
|
37 |
*/ |
|
38 |
@Component |
|
39 |
public class ErmsImageImport extends ErmsImportBase<TextData> { |
|
40 |
@SuppressWarnings("unused") |
|
41 |
private static final Logger logger = Logger.getLogger(ErmsImageImport.class); |
|
42 |
|
|
43 |
private DbImportMapping mapping; |
|
44 |
|
|
45 |
|
|
46 |
private int modCount = 10000; |
|
47 |
private static final String pluralString = "images"; |
|
48 |
private static final String dbTableName = "images"; |
|
49 |
private static final Class cdmTargetClass = Media.class; |
|
50 |
|
|
51 |
public ErmsImageImport(){ |
|
52 |
super(pluralString, dbTableName, cdmTargetClass); |
|
53 |
} |
|
54 |
|
|
55 |
|
|
56 |
/* (non-Javadoc) |
|
57 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getIdQuery() |
|
58 |
*/ |
|
59 |
@Override |
|
60 |
protected String getIdQuery() { |
|
61 |
String strIdQuery = |
|
62 |
" SELECT tu_id, img_thumb " + //tu_id is not a key |
|
63 |
" FROM images " + |
|
64 |
" ORDER BY tu_id, img_thumb, img_url "; |
|
65 |
return strIdQuery; |
|
66 |
} |
|
67 |
|
|
68 |
|
|
69 |
/* (non-Javadoc) |
|
70 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportBase#getRecordQuery(eu.etaxonomy.cdm.io.berlinModel.in.BerlinModelImportConfigurator) |
|
71 |
*/ |
|
72 |
@Override |
|
73 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
|
74 |
String strRecordQuery = |
|
75 |
" SELECT * " + |
|
76 |
" FROM images " + |
|
77 |
" WHERE ( images.tu_id IN (" + ID_LIST_TOKEN + ") AND " + |
|
78 |
" images.img_thumb IN (" + ID_LIST_TOKEN + ") )"; |
|
79 |
return strRecordQuery; |
|
80 |
} |
|
81 |
|
|
82 |
/* (non-Javadoc) |
|
83 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping() |
|
84 |
*/ |
|
85 |
protected DbImportMapping getMapping() { |
|
86 |
if (mapping == null){ |
|
87 |
mapping = new DbImportMapping(); |
|
88 |
//TODO do we need to add to TaxonNameBase too? |
|
89 |
String idAttribute = null; |
|
90 |
boolean isOneTextData = true; |
|
91 |
mapping.addMapper(DbImportImageCreationMapper.NewInstance(idAttribute, IMAGE_NAMESPACE, "tu_id", ErmsTaxonImport.TAXON_NAMESPACE, isOneTextData)); |
|
92 |
mapping.addMapper(DbImportMediaMapper.NewInstance("img_url", "img_thumb")); |
|
93 |
} |
|
94 |
return mapping; |
|
95 |
} |
|
96 |
|
|
97 |
/* (non-Javadoc) |
|
98 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
|
99 |
*/ |
|
100 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) { |
|
101 |
String nameSpace; |
|
102 |
Class cdmClass; |
|
103 |
Set<String> idSet; |
|
104 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String, ? extends CdmBase>>(); |
|
105 |
|
|
106 |
try{ |
|
107 |
Set<String> taxonIdSet = new HashSet<String>(); |
|
108 |
Set<String> languageIdSet = new HashSet<String>(); |
|
109 |
while (rs.next()){ |
|
110 |
handleForeignKey(rs, taxonIdSet, "tu_id"); |
|
111 |
} |
|
112 |
|
|
113 |
//taxon map |
|
114 |
nameSpace = ErmsTaxonImport.TAXON_NAMESPACE; |
|
115 |
cdmClass = TaxonBase.class; |
|
116 |
idSet = taxonIdSet; |
|
117 |
Map<String, TaxonBase> taxonMap = (Map<String, TaxonBase>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace); |
|
118 |
result.put(nameSpace, taxonMap); |
|
119 |
|
|
120 |
} catch (SQLException e) { |
|
121 |
throw new RuntimeException(e); |
|
122 |
} |
|
123 |
return result; |
|
124 |
} |
|
125 |
|
|
126 |
/* (non-Javadoc) |
|
127 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
128 |
*/ |
|
129 |
@Override |
|
130 |
protected boolean doCheck(ErmsImportState state){ |
|
131 |
IOValidator<ErmsImportState> validator = new ErmsImageImportValidator(); |
|
132 |
return validator.validate(state); |
|
133 |
} |
|
134 |
|
|
135 |
|
|
136 |
/* (non-Javadoc) |
|
137 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
|
138 |
*/ |
|
139 |
protected boolean isIgnore(ErmsImportState state){ |
|
140 |
return ! state.getConfig().isDoImages(); |
|
141 |
} |
|
142 |
|
|
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportBase.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.pesi.erms; |
|
11 |
|
|
12 |
import java.lang.reflect.Method; |
|
13 |
import java.sql.ResultSet; |
|
14 |
import java.sql.ResultSetMetaData; |
|
15 |
import java.sql.SQLException; |
|
16 |
import java.sql.Timestamp; |
|
17 |
import java.util.HashMap; |
|
18 |
import java.util.HashSet; |
|
19 |
import java.util.Map; |
|
20 |
import java.util.Set; |
|
21 |
import java.util.UUID; |
|
22 |
|
|
23 |
import org.apache.log4j.Logger; |
|
24 |
import org.joda.time.DateTime; |
|
25 |
|
|
26 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
27 |
import eu.etaxonomy.cdm.io.common.CdmImportBase; |
|
28 |
import eu.etaxonomy.cdm.io.common.ICdmIO; |
|
29 |
import eu.etaxonomy.cdm.io.common.IPartitionedIO; |
|
30 |
import eu.etaxonomy.cdm.io.common.ImportHelper; |
|
31 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner; |
|
32 |
import eu.etaxonomy.cdm.io.common.Source; |
|
33 |
import eu.etaxonomy.cdm.io.common.IImportConfigurator.EDITOR; |
|
34 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
35 |
import eu.etaxonomy.cdm.model.common.AnnotatableEntity; |
|
36 |
import eu.etaxonomy.cdm.model.common.Annotation; |
|
37 |
import eu.etaxonomy.cdm.model.common.AnnotationType; |
|
38 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
39 |
import eu.etaxonomy.cdm.model.common.ExtensionType; |
|
40 |
import eu.etaxonomy.cdm.model.common.IdentifiableEntity; |
|
41 |
import eu.etaxonomy.cdm.model.common.Language; |
|
42 |
import eu.etaxonomy.cdm.model.common.MarkerType; |
|
43 |
import eu.etaxonomy.cdm.model.common.User; |
|
44 |
|
|
45 |
/** |
|
46 |
* @author a.mueller |
|
47 |
* @created 20.03.2008 |
|
48 |
* @version 1.0 |
|
49 |
*/ |
|
50 |
public abstract class ErmsImportBase<CDM_BASE extends CdmBase> extends CdmImportBase<ErmsImportConfigurator, ErmsImportState> implements ICdmIO<ErmsImportState>, IPartitionedIO<ErmsImportState> { |
|
51 |
private static final Logger logger = Logger.getLogger(ErmsImportBase.class); |
|
52 |
|
|
53 |
public static final UUID ID_IN_SOURCE_EXT_UUID = UUID.fromString("23dac094-e793-40a4-bad9-649fc4fcfd44"); |
|
54 |
|
|
55 |
//NAMESPACES |
|
56 |
|
|
57 |
protected static final String AREA_NAMESPACE = "gu"; |
|
58 |
protected static final String DR_NAMESPACE = "dr"; |
|
59 |
protected static final String IMAGE_NAMESPACE = "Images"; |
|
60 |
protected static final String LINKS_NAMESPACE = "Links"; |
|
61 |
protected static final String NOTES_NAMESPACE = "Notes"; |
|
62 |
protected static final String LANGUAGE_NAMESPACE = "Language"; |
|
63 |
protected static final String REFERENCE_NAMESPACE = "Source"; |
|
64 |
protected static final String SOURCEUSE_NAMESPACE = "tu_sources"; |
|
65 |
protected static final String TAXON_NAMESPACE = "Taxon"; |
|
66 |
protected static final String NAME_NAMESPACE = "TaxonName"; |
|
67 |
protected static final String VERNACULAR_NAMESPACE = "Vernaculars"; |
|
68 |
protected static final String FEATURE_NAMESPACE = "note.type"; |
|
69 |
protected static final String EXTENSION_TYPE_NAMESPACE = "ExtensionType"; |
|
70 |
|
|
71 |
|
|
72 |
|
|
73 |
private String pluralString; |
|
74 |
private String dbTableName; |
|
75 |
//TODO needed? |
|
76 |
private Class cdmTargetClass; |
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
/** |
|
81 |
* @param dbTableName |
|
82 |
* @param dbTableName2 |
|
83 |
*/ |
|
84 |
public ErmsImportBase(String pluralString, String dbTableName, Class cdmTargetClass) { |
|
85 |
this.pluralString = pluralString; |
|
86 |
this.dbTableName = dbTableName; |
|
87 |
this.cdmTargetClass = cdmTargetClass; |
|
88 |
} |
|
89 |
|
|
90 |
protected void doInvoke(ErmsImportState state){ |
|
91 |
logger.info("start make " + getPluralString() + " ..."); |
|
92 |
ErmsImportConfigurator config = state.getConfig(); |
|
93 |
Source source = config.getSource(); |
|
94 |
|
|
95 |
String strIdQuery = getIdQuery(); |
|
96 |
String strRecordQuery = getRecordQuery(config); |
|
97 |
|
|
98 |
int recordsPerTransaction = config.getRecordsPerTransaction(); |
|
99 |
try{ |
|
100 |
ResultSetPartitioner partitioner = ResultSetPartitioner.NewInstance(source, strIdQuery, strRecordQuery, recordsPerTransaction); |
|
101 |
while (partitioner.nextPartition()){ |
|
102 |
partitioner.doPartition(this, state); |
|
103 |
} |
|
104 |
} catch (SQLException e) { |
|
105 |
logger.error("SQLException:" + e); |
|
106 |
state.setUnsuccessfull(); |
|
107 |
return; |
|
108 |
} |
|
109 |
|
|
110 |
logger.info("end make " + getPluralString() + " ... " + getSuccessString(true)); |
|
111 |
return; |
|
112 |
} |
|
113 |
|
|
114 |
public boolean doPartition(ResultSetPartitioner partitioner, ErmsImportState state) { |
|
115 |
boolean success = true ; |
|
116 |
Set objectsToSave = new HashSet(); |
|
117 |
|
|
118 |
DbImportMapping<?, ?> mapping = getMapping(); |
|
119 |
mapping.initialize(state, cdmTargetClass); |
|
120 |
|
|
121 |
ResultSet rs = partitioner.getResultSet(); |
|
122 |
try{ |
|
123 |
while (rs.next()){ |
|
124 |
success &= mapping.invoke(rs,objectsToSave); |
|
125 |
} |
|
126 |
} catch (SQLException e) { |
|
127 |
logger.error("SQLException:" + e); |
|
128 |
return false; |
|
129 |
} |
|
130 |
|
|
131 |
partitioner.startDoSave(); |
|
132 |
getCommonService().save(objectsToSave); |
|
133 |
return success; |
|
134 |
} |
|
135 |
|
|
136 |
|
|
137 |
|
|
138 |
/** |
|
139 |
* @return |
|
140 |
*/ |
|
141 |
protected abstract DbImportMapping<?, ?> getMapping(); |
|
142 |
|
|
143 |
/** |
|
144 |
* @return |
|
145 |
*/ |
|
146 |
protected abstract String getRecordQuery(ErmsImportConfigurator config); |
|
147 |
|
|
148 |
/** |
|
149 |
* @return |
|
150 |
*/ |
|
151 |
protected String getIdQuery(){ |
|
152 |
String result = " SELECT id FROM " + getTableName(); |
|
153 |
return result; |
|
154 |
} |
|
155 |
|
|
156 |
/* (non-Javadoc) |
|
157 |
* @see eu.etaxonomy.cdm.io.berlinModel.in.IPartitionedIO#getPluralString() |
|
158 |
*/ |
|
159 |
public String getPluralString(){ |
|
160 |
return pluralString; |
|
161 |
} |
|
162 |
|
|
163 |
/** |
|
164 |
* @return |
|
165 |
*/ |
|
166 |
protected String getTableName(){ |
|
167 |
return this.dbTableName; |
|
168 |
} |
|
169 |
|
|
170 |
protected boolean doIdCreatedUpdatedNotes(ErmsImportState state, IdentifiableEntity identifiableEntity, ResultSet rs, long id, String namespace) |
|
171 |
throws SQLException{ |
|
172 |
boolean success = true; |
|
173 |
//id |
|
174 |
success &= ImportHelper.setOriginalSource(identifiableEntity, state.getConfig().getSourceReference(), id, namespace); |
|
175 |
//createdUpdateNotes |
|
176 |
success &= doCreatedUpdatedNotes(state, identifiableEntity, rs, namespace); |
|
177 |
return success; |
|
178 |
} |
|
179 |
|
|
180 |
|
|
181 |
protected boolean doCreatedUpdatedNotes(ErmsImportState state, AnnotatableEntity annotatableEntity, ResultSet rs, String namespace) |
|
182 |
throws SQLException{ |
|
183 |
|
|
184 |
ErmsImportConfigurator config = state.getConfig(); |
|
185 |
Object createdWhen = rs.getObject("Created_When"); |
|
186 |
String createdWho = rs.getString("Created_Who"); |
|
187 |
Object updatedWhen = null; |
|
188 |
String updatedWho = null; |
|
189 |
try { |
|
190 |
updatedWhen = rs.getObject("Updated_When"); |
|
191 |
updatedWho = rs.getString("Updated_who"); |
|
192 |
} catch (SQLException e) { |
|
193 |
//Table "Name" has no updated when/who |
|
194 |
} |
|
195 |
String notes = rs.getString("notes"); |
|
196 |
|
|
197 |
boolean success = true; |
|
198 |
|
|
199 |
//Created When, Who, Updated When Who |
|
200 |
if (config.getEditor() == null || config.getEditor().equals(EDITOR.NO_EDITORS)){ |
|
201 |
//do nothing |
|
202 |
}else if (config.getEditor().equals(EDITOR.EDITOR_AS_ANNOTATION)){ |
|
203 |
String createdAnnotationString = "Berlin Model record was created By: " + String.valueOf(createdWho) + " (" + String.valueOf(createdWhen) + ") "; |
|
204 |
if (updatedWhen != null && updatedWho != null){ |
|
205 |
createdAnnotationString += " and updated By: " + String.valueOf(updatedWho) + " (" + String.valueOf(updatedWhen) + ")"; |
|
206 |
} |
|
207 |
Annotation annotation = Annotation.NewInstance(createdAnnotationString, Language.DEFAULT()); |
|
208 |
annotation.setCommentator(config.getCommentator()); |
|
209 |
annotation.setAnnotationType(AnnotationType.TECHNICAL()); |
|
210 |
annotatableEntity.addAnnotation(annotation); |
|
211 |
}else if (config.getEditor().equals(EDITOR.EDITOR_AS_EDITOR)){ |
|
212 |
User creator = getUser(createdWho, state); |
|
213 |
User updator = getUser(updatedWho, state); |
|
214 |
DateTime created = getDateTime(createdWhen); |
|
215 |
DateTime updated = getDateTime(updatedWhen); |
|
216 |
annotatableEntity.setCreatedBy(creator); |
|
217 |
annotatableEntity.setUpdatedBy(updator); |
|
218 |
annotatableEntity.setCreated(created); |
|
219 |
annotatableEntity.setUpdated(updated); |
|
220 |
}else { |
|
221 |
logger.warn("Editor type not yet implemented: " + config.getEditor()); |
|
222 |
} |
|
223 |
|
|
224 |
|
|
225 |
//notes |
|
226 |
if (CdmUtils.isNotEmpty(notes)){ |
|
227 |
String notesString = String.valueOf(notes); |
|
228 |
if (notesString.length() > 65530 ){ |
|
229 |
notesString = notesString.substring(0, 65530) + "..."; |
|
230 |
logger.warn("Notes string is longer than 65530 and was truncated: " + annotatableEntity); |
|
231 |
} |
|
232 |
Annotation notesAnnotation = Annotation.NewInstance(notesString, null); |
|
233 |
//notesAnnotation.setAnnotationType(AnnotationType.EDITORIAL()); |
|
234 |
//notes.setCommentator(bmiConfig.getCommentator()); |
|
235 |
annotatableEntity.addAnnotation(notesAnnotation); |
|
236 |
} |
|
237 |
return success; |
|
238 |
} |
|
239 |
|
|
240 |
private User getUser(String userString, ErmsImportState state){ |
|
241 |
if (CdmUtils.isEmpty(userString)){ |
|
242 |
return null; |
|
243 |
} |
|
244 |
userString = userString.trim(); |
|
245 |
|
|
246 |
User user = state.getUser(userString); |
|
247 |
if (user == null){ |
|
248 |
user = getTransformedUser(userString,state); |
|
249 |
} |
|
250 |
if (user == null){ |
|
251 |
user = makeNewUser(userString, state); |
|
252 |
} |
|
253 |
if (user == null){ |
|
254 |
logger.warn("User is null"); |
|
255 |
} |
|
256 |
return user; |
|
257 |
} |
|
258 |
|
|
259 |
private User getTransformedUser(String userString, ErmsImportState state){ |
|
260 |
Method method = state.getConfig().getUserTransformationMethod(); |
|
261 |
if (method == null){ |
|
262 |
return null; |
|
263 |
} |
|
264 |
try { |
|
265 |
userString = (String)state.getConfig().getUserTransformationMethod().invoke(null, userString); |
|
266 |
} catch (Exception e) { |
|
267 |
logger.warn("Error when trying to transform userString " + userString + ". No transformation done."); |
|
268 |
} |
|
269 |
User user = state.getUser(userString); |
|
270 |
return user; |
|
271 |
} |
|
272 |
|
|
273 |
private User makeNewUser(String userString, ErmsImportState state){ |
|
274 |
String pwd = getPassword(); |
|
275 |
User user = User.NewInstance(userString, pwd); |
|
276 |
state.putUser(userString, user); |
|
277 |
getUserService().save(user); |
|
278 |
logger.info("Added new user: " + userString); |
|
279 |
return user; |
|
280 |
} |
|
281 |
|
|
282 |
private String getPassword(){ |
|
283 |
String result = UUID.randomUUID().toString(); |
|
284 |
return result; |
|
285 |
} |
|
286 |
|
|
287 |
private DateTime getDateTime(Object timeString){ |
|
288 |
if (timeString == null){ |
|
289 |
return null; |
|
290 |
} |
|
291 |
DateTime dateTime = null; |
|
292 |
if (timeString instanceof Timestamp){ |
|
293 |
Timestamp timestamp = (Timestamp)timeString; |
|
294 |
dateTime = new DateTime(timestamp); |
|
295 |
}else{ |
|
296 |
logger.warn("time ("+timeString+") is not a timestamp. Datetime set to current date. "); |
|
297 |
dateTime = new DateTime(); |
|
298 |
} |
|
299 |
return dateTime; |
|
300 |
} |
|
301 |
|
|
302 |
protected boolean resultSetHasColumn(ResultSet rs, String columnName){ |
|
303 |
try { |
|
304 |
ResultSetMetaData metaData = rs.getMetaData(); |
|
305 |
for (int i = 0; i < metaData.getColumnCount(); i++){ |
|
306 |
if (metaData.getColumnName(i + 1).equalsIgnoreCase(columnName)){ |
|
307 |
return true; |
|
308 |
} |
|
309 |
} |
|
310 |
return false; |
|
311 |
} catch (SQLException e) { |
|
312 |
logger.warn("Exception in resultSetHasColumn"); |
|
313 |
return false; |
|
314 |
} |
|
315 |
} |
|
316 |
|
|
317 |
protected boolean checkSqlServerColumnExists(Source source, String tableName, String columnName){ |
|
318 |
String strQuery = "SELECT Count(t.id) as n " + |
|
319 |
" FROM sysobjects AS t " + |
|
320 |
" INNER JOIN syscolumns AS c ON t.id = c.id " + |
|
321 |
" WHERE (t.xtype = 'U') AND " + |
|
322 |
" (t.name = '" + tableName + "') AND " + |
|
323 |
" (c.name = '" + columnName + "')"; |
|
324 |
ResultSet rs = source.getResultSet(strQuery) ; |
|
325 |
int n; |
|
326 |
try { |
|
327 |
rs.next(); |
|
328 |
n = rs.getInt("n"); |
|
329 |
return n>0; |
|
330 |
} catch (SQLException e) { |
|
331 |
e.printStackTrace(); |
|
332 |
return false; |
|
333 |
} |
|
334 |
|
|
335 |
} |
|
336 |
|
|
337 |
/** |
|
338 |
* Returns a map that holds all values of a ResultSet. This is needed if a value needs to |
|
339 |
* be accessed twice |
|
340 |
* @param rs |
|
341 |
* @return |
|
342 |
* @throws SQLException |
|
343 |
*/ |
|
344 |
protected Map<String, Object> getValueMap(ResultSet rs) throws SQLException{ |
|
345 |
try{ |
|
346 |
Map<String, Object> valueMap = new HashMap<String, Object>(); |
|
347 |
int colCount = rs.getMetaData().getColumnCount(); |
|
348 |
for (int c = 0; c < colCount ; c++){ |
|
349 |
Object value = rs.getObject(c+1); |
|
350 |
String label = rs.getMetaData().getColumnLabel(c+1).toLowerCase(); |
|
351 |
if (value != null && ! CdmUtils.Nz(value.toString()).trim().equals("")){ |
|
352 |
valueMap.put(label, value); |
|
353 |
} |
|
354 |
} |
|
355 |
return valueMap; |
|
356 |
}catch(SQLException e){ |
|
357 |
throw e; |
|
358 |
} |
|
359 |
} |
|
360 |
|
|
361 |
protected ExtensionType getExtensionType(UUID uuid, String label, String text, String labelAbbrev){ |
|
362 |
ExtensionType extensionType = (ExtensionType)getTermService().find(uuid); |
|
363 |
if (extensionType == null){ |
|
364 |
extensionType = ExtensionType.NewInstance(text, label, labelAbbrev); |
|
365 |
extensionType.setUuid(uuid); |
|
366 |
getTermService().save(extensionType); |
|
367 |
} |
|
368 |
return extensionType; |
|
369 |
} |
|
370 |
|
|
371 |
protected MarkerType getMarkerType(UUID uuid, String label, String text, String labelAbbrev){ |
|
372 |
MarkerType markerType = (MarkerType)getTermService().find(uuid); |
|
373 |
if (markerType == null){ |
|
374 |
markerType = MarkerType.NewInstance(label, text, labelAbbrev); |
|
375 |
markerType.setUuid(uuid); |
|
376 |
getTermService().save(markerType); |
|
377 |
} |
|
378 |
return markerType; |
|
379 |
} |
|
380 |
|
|
381 |
|
|
382 |
/** |
|
383 |
* Reads a foreign key field from the result set and adds its value to the idSet. |
|
384 |
* @param rs |
|
385 |
* @param teamIdSet |
|
386 |
* @throws SQLException |
|
387 |
*/ |
|
388 |
protected void handleForeignKey(ResultSet rs, Set<String> idSet, String attributeName) |
|
389 |
throws SQLException { |
|
390 |
Object idObj = rs.getObject(attributeName); |
|
391 |
if (idObj != null){ |
|
392 |
String id = String.valueOf(idObj); |
|
393 |
idSet.add(id); |
|
394 |
} |
|
395 |
} |
|
396 |
|
|
397 |
/** |
|
398 |
* Returns true if i is a multiple of recordsPerTransaction |
|
399 |
* @param i |
|
400 |
* @param recordsPerTransaction |
|
401 |
* @return |
|
402 |
*/ |
|
403 |
protected boolean loopNeedsHandling(int i, int recordsPerLoop) { |
|
404 |
startTransaction(); |
|
405 |
return (i % recordsPerLoop) == 0; |
|
406 |
} |
|
407 |
|
|
408 |
protected void doLogPerLoop(int count, int recordsPerLog, String pluralString){ |
|
409 |
if ((count % recordsPerLog ) == 0 && count!= 0 ){ logger.info(pluralString + " handled: " + (count));} |
|
410 |
} |
|
411 |
|
|
412 |
|
|
413 |
|
|
414 |
|
|
415 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportConfigurator.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.pesi.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.IImportConfigurator.DO_REFERENCES; |
|
22 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer; |
|
23 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsGeneralImportValidator; |
|
24 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
25 |
import eu.etaxonomy.cdm.model.reference.Reference; |
|
26 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
|
27 |
|
|
28 |
|
|
29 |
/** |
|
30 |
* @author a.mueller |
|
31 |
* @created 20.03.2008 |
|
32 |
* @version 1.0 |
|
33 |
*/ |
|
34 |
public class ErmsImportConfigurator extends ImportConfiguratorBase<ErmsImportState, Source> implements IImportConfigurator{ |
|
35 |
@SuppressWarnings("unused") |
|
36 |
private static Logger logger = Logger.getLogger(ErmsImportConfigurator.class); |
|
37 |
|
|
38 |
public static ErmsImportConfigurator NewInstance(Source ermsSource, ICdmDataSource destination){ |
|
39 |
return new ErmsImportConfigurator(ermsSource, destination); |
|
40 |
} |
|
41 |
|
|
42 |
/* Max number of records to be saved with one service call */ |
|
43 |
private int recordsPerTransaction = 1000; //defaultValue |
|
44 |
|
|
45 |
//TODO needed ?? |
|
46 |
private Method userTransformationMethod; |
|
47 |
|
|
48 |
private boolean doVernaculars = true; |
|
49 |
private boolean doLinks = true; |
|
50 |
private boolean doNotes = true; |
|
51 |
private boolean doImages = true; |
|
52 |
private boolean doOccurrence = true; |
|
53 |
private DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
|
54 |
private boolean doTaxa = true; |
|
55 |
private boolean doRelTaxa = true; |
|
56 |
|
|
57 |
|
|
58 |
private static IInputTransformer defaultTransformer = new ErmsTransformer(); |
|
59 |
|
|
60 |
protected void makeIoClassList(){ |
|
61 |
ioClassList = new Class[]{ |
|
62 |
ErmsGeneralImportValidator.class |
|
63 |
, ErmsImportRankMap.class |
|
64 |
, ErmsReferenceImport.class |
|
65 |
, ErmsTaxonImport.class |
|
66 |
, ErmsTaxonRelationImport.class |
|
67 |
, ErmsVernacularImport.class |
|
68 |
, ErmsNotesImport.class |
|
69 |
, ErmsVernacularSourcesImport.class |
|
70 |
, ErmsNotesSourcesImport.class |
|
71 |
|
|
72 |
, ErmsAreaImport.class |
|
73 |
, ErmsDrImport.class |
|
74 |
, ErmsSourceUsesImport.class |
|
75 |
, ErmsLinkImport.class //kann weiter hoch |
|
76 |
, ErmsImageImport.class |
|
77 |
}; |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
/* (non-Javadoc) |
|
82 |
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState() |
|
83 |
*/ |
|
84 |
public ImportStateBase getNewState() { |
|
85 |
return new ErmsImportState(this); |
|
86 |
} |
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
/** |
|
91 |
* @param berlinModelSource |
|
92 |
* @param sourceReference |
|
93 |
* @param destination |
|
94 |
*/ |
|
95 |
private ErmsImportConfigurator(Source ermsSource, ICdmDataSource destination) { |
|
96 |
super(defaultTransformer); |
|
97 |
setNomenclaturalCode(NomenclaturalCode.ICZN); //default for ERMS |
|
98 |
setSource(ermsSource); |
|
99 |
setDestination(destination); |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
public Source getSource() { |
|
104 |
return (Source)super.getSource(); |
|
105 |
} |
|
106 |
public void setSource(Source berlinModelSource) { |
|
107 |
super.setSource(berlinModelSource); |
|
108 |
} |
|
109 |
|
|
110 |
/* (non-Javadoc) |
|
111 |
* @see eu.etaxonomy.cdm.io.tcsrdf.IImportConfigurator#getSourceReference() |
|
112 |
*/ |
|
113 |
public Reference getSourceReference() { |
|
114 |
ReferenceFactory refFactory = ReferenceFactory.newInstance(); |
|
115 |
if (sourceReference == null){ |
|
116 |
sourceReference = refFactory.newDatabase(); |
|
117 |
if (getSource() != null){ |
|
118 |
sourceReference.setTitleCache(getSource().getDatabase(), true); |
|
119 |
} |
|
120 |
} |
|
121 |
return sourceReference; |
|
122 |
} |
|
123 |
|
|
124 |
|
|
125 |
/* (non-Javadoc) |
|
126 |
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getSourceNameString() |
|
127 |
*/ |
|
128 |
public String getSourceNameString() { |
|
129 |
if (this.getSource() == null){ |
|
130 |
return null; |
|
131 |
}else{ |
|
132 |
return this.getSource().getDatabase(); |
|
133 |
} |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* @return the userTransformationMethod |
|
138 |
*/ |
|
139 |
public Method getUserTransformationMethod() { |
|
140 |
return userTransformationMethod; |
|
141 |
} |
|
142 |
|
|
143 |
/** |
|
144 |
* @param userTransformationMethod the userTransformationMethod to set |
|
145 |
*/ |
|
146 |
public void setUserTransformationMethod(Method userTransformationMethod) { |
|
147 |
this.userTransformationMethod = userTransformationMethod; |
|
148 |
} |
|
149 |
|
|
150 |
|
|
151 |
/** |
|
152 |
* @return the limitSave |
|
153 |
*/ |
|
154 |
public int getRecordsPerTransaction() { |
|
155 |
return recordsPerTransaction; |
|
156 |
} |
|
157 |
|
|
158 |
/** |
|
159 |
* @param limitSave the limitSave to set |
|
160 |
*/ |
|
161 |
public void setRecordsPerTransaction(int recordsPerTransaction) { |
|
162 |
this.recordsPerTransaction = recordsPerTransaction; |
|
163 |
} |
|
164 |
|
|
165 |
/** |
|
166 |
* @param doVernaculars the doVernaculars to set |
|
167 |
*/ |
|
168 |
public void setDoVernaculars(boolean doVernaculars) { |
|
169 |
this.doVernaculars = doVernaculars; |
|
170 |
} |
|
171 |
|
|
172 |
/** |
|
173 |
* @return the doVernaculars |
|
174 |
*/ |
|
175 |
public boolean isDoVernaculars() { |
|
176 |
return doVernaculars; |
|
177 |
} |
|
178 |
|
|
179 |
|
|
180 |
|
|
181 |
/** |
|
182 |
* @param doLinks the doLinks to set |
|
183 |
*/ |
|
184 |
public void setDoLinks(boolean doLinks) { |
|
185 |
this.doLinks = doLinks; |
|
186 |
} |
|
187 |
|
|
188 |
|
|
189 |
|
|
190 |
/** |
|
191 |
* @return the doLinks |
|
192 |
*/ |
|
193 |
public boolean isDoLinks() { |
|
194 |
return doLinks; |
|
195 |
} |
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
/** |
|
200 |
* @param doNotes the doNotes to set |
|
201 |
*/ |
|
202 |
public void setDoNotes(boolean doNotes) { |
|
203 |
this.doNotes = doNotes; |
|
204 |
} |
|
205 |
|
|
206 |
|
|
207 |
|
|
208 |
/** |
|
209 |
* @return the doNotes |
|
210 |
*/ |
|
211 |
public boolean isDoNotes() { |
|
212 |
return doNotes; |
|
213 |
} |
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
/** |
|
218 |
* @param doImages the doImages to set |
|
219 |
*/ |
|
220 |
public void setDoImages(boolean doImages) { |
|
221 |
this.doImages = doImages; |
|
222 |
} |
|
223 |
|
|
224 |
|
|
225 |
|
|
226 |
/** |
|
227 |
* @return the doImages |
|
228 |
*/ |
|
229 |
public boolean isDoImages() { |
|
230 |
return doImages; |
|
231 |
} |
|
232 |
|
|
233 |
|
|
234 |
public boolean isDoOccurrence() { |
|
235 |
return doOccurrence; |
|
236 |
} |
|
237 |
public void setDoOccurrence(boolean doOccurrence) { |
|
238 |
this.doOccurrence = doOccurrence; |
|
239 |
} |
|
240 |
|
|
241 |
|
|
242 |
public DO_REFERENCES getDoReferences() { |
|
243 |
return doReferences; |
|
244 |
} |
|
245 |
public void setDoReferences(DO_REFERENCES doReferences) { |
|
246 |
this.doReferences = doReferences; |
|
247 |
} |
|
248 |
|
|
249 |
public boolean isDoTaxa() { |
|
250 |
return doTaxa; |
|
251 |
} |
|
252 |
public void setDoTaxa(boolean doTaxa) { |
|
253 |
this.doTaxa = doTaxa; |
|
254 |
} |
|
255 |
|
|
256 |
public boolean isDoRelTaxa() { |
|
257 |
return doRelTaxa; |
|
258 |
} |
|
259 |
public void setDoRelTaxa(boolean doRelTaxa) { |
|
260 |
this.doRelTaxa = doRelTaxa; |
|
261 |
} |
|
262 |
|
|
263 |
|
|
264 |
|
|
265 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportRankMap.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.pesi.erms; |
|
12 |
|
|
13 |
import java.sql.ResultSet; |
|
14 |
import java.sql.SQLException; |
|
15 |
import java.util.HashMap; |
|
16 |
import java.util.Map; |
|
17 |
|
|
18 |
import org.apache.log4j.Logger; |
|
19 |
import org.springframework.stereotype.Component; |
|
20 |
|
|
21 |
import eu.etaxonomy.cdm.io.common.IOValidator; |
|
22 |
import eu.etaxonomy.cdm.io.common.Source; |
|
23 |
import eu.etaxonomy.cdm.io.common.mapping.DbImportMapping; |
|
24 |
import eu.etaxonomy.cdm.io.pesi.erms.validation.ErmsRankImportValidator; |
|
25 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
|
26 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
|
27 |
import eu.etaxonomy.cdm.model.name.Rank; |
|
28 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
|
29 |
|
|
30 |
/** |
|
31 |
* @author a.mueller |
|
32 |
* @created 01.03.2010 |
|
33 |
* @version 1.0 |
|
34 |
*/ |
|
35 |
@Component |
|
36 |
public class ErmsImportRankMap extends ErmsImportBase<Rank>{ |
|
37 |
private static final Logger logger = Logger.getLogger(ErmsImportRankMap.class); |
|
38 |
|
|
39 |
private Map<Integer, Map<Integer,Rank>> rankMap; |
|
40 |
|
|
41 |
/** |
|
42 |
* @param pluralString |
|
43 |
* @param dbTableName |
|
44 |
*/ |
|
45 |
public ErmsImportRankMap() { |
|
46 |
super(null, null, null); |
|
47 |
} |
|
48 |
|
|
49 |
|
|
50 |
/* (non-Javadoc) |
|
51 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#invoke(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
52 |
*/ |
|
53 |
public boolean invoke (ErmsImportState state){ |
|
54 |
rankMap = new HashMap<Integer, Map<Integer,Rank>>(); |
|
55 |
Source source = state.getConfig().getSource() ; |
|
56 |
String strSQL = " SELECT * FROM ranks "; |
|
57 |
ResultSet rs = source.getResultSet(strSQL); |
|
58 |
try { |
|
59 |
while (rs.next()){ |
|
60 |
Integer kingdomId = rs.getInt("kingdom_id"); |
|
61 |
Integer rankId = rs.getInt("rank_id"); |
|
62 |
String rankName = rs.getString("rank_name"); |
|
63 |
NomenclaturalCode nc = ErmsTransformer.kingdomId2NomCode(kingdomId); |
|
64 |
|
|
65 |
Map<Integer, Rank> kingdomMap = makeKingdomMap(rankMap, rankId); |
|
66 |
try { |
|
67 |
rankName = rankName.replace("Forma", "Form").replace("Subforma", "Subform"); |
|
68 |
Rank rank = Rank.getRankByEnglishName(rankName, nc, false); |
|
69 |
if (rank == null){ |
|
70 |
logger.warn("Rank is null: " + rankName); |
|
71 |
} |
|
72 |
kingdomMap.put(kingdomId, rank); |
|
73 |
} catch (UnknownCdmTypeException e) { |
|
74 |
String errorMessage = "Rank '" + rankName + "' is not well mapped for code " + nc + ", kingdom_id = " + kingdomId + ". Rank is ignored!"; |
|
75 |
logger.warn(errorMessage); |
|
76 |
} |
|
77 |
} |
|
78 |
} catch (SQLException e) { |
|
79 |
logger.error(e.getMessage()); |
|
80 |
throw new RuntimeException(e); |
|
81 |
} |
|
82 |
state.setRankMap(rankMap); |
|
83 |
return true; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* Retrieves or creates the kingdom map (mapping kingdom to rank for a defined rank_id) and |
|
88 |
* adds it to the rank map. |
|
89 |
* @param rankMap |
|
90 |
* @param rankId |
|
91 |
* @return |
|
92 |
*/ |
|
93 |
private Map<Integer, Rank> makeKingdomMap(Map<Integer, Map<Integer, Rank>> rankMap, Integer rankId) { |
|
94 |
Map<Integer, Rank> result = rankMap.get(rankId); |
|
95 |
if (result == null){ |
|
96 |
result = new HashMap<Integer, Rank>(); |
|
97 |
rankMap.put(rankId, result); |
|
98 |
} |
|
99 |
return result; |
|
100 |
} |
|
101 |
|
|
102 |
|
|
103 |
/* (non-Javadoc) |
|
104 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
protected boolean doCheck(ErmsImportState state) { |
|
108 |
IOValidator rankImport = new ErmsRankImportValidator(); |
|
109 |
return rankImport.validate(state); |
|
110 |
} |
|
111 |
|
|
112 |
|
|
113 |
/* (non-Javadoc) |
|
114 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getRecordQuery(eu.etaxonomy.cdm.io.erms.ErmsImportConfigurator) |
|
115 |
*/ |
|
116 |
@Override |
|
117 |
protected String getRecordQuery(ErmsImportConfigurator config) { |
|
118 |
// TODO Auto-generated method stub |
|
119 |
return null; |
|
120 |
} |
|
121 |
|
|
122 |
|
|
123 |
/* (non-Javadoc) |
|
124 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IoStateBase) |
|
125 |
*/ |
|
126 |
@Override |
|
127 |
protected boolean isIgnore(ErmsImportState state) { |
|
128 |
return false; //should always be called |
|
129 |
} |
|
130 |
|
|
131 |
|
|
132 |
/* (non-Javadoc) |
|
133 |
* @see eu.etaxonomy.cdm.io.common.IPartitionedIO#getRelatedObjectsForPartition(java.sql.ResultSet) |
|
134 |
*/ |
|
135 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs) { |
|
136 |
return null; // not needed |
|
137 |
} |
|
138 |
|
|
139 |
/* (non-Javadoc) |
|
140 |
* @see eu.etaxonomy.cdm.io.common.mapping.IMappingImport#createObject(java.sql.ResultSet, eu.etaxonomy.cdm.io.common.ImportStateBase) |
|
141 |
*/ |
|
142 |
public Rank createObject(ResultSet rs, ErmsImportState state) |
|
143 |
throws SQLException { |
|
144 |
return null; // not needed |
|
145 |
} |
|
146 |
|
|
147 |
|
|
148 |
/* (non-Javadoc) |
|
149 |
* @see eu.etaxonomy.cdm.io.erms.ErmsImportBase#getMapping() |
|
150 |
*/ |
|
151 |
@Override |
|
152 |
protected DbImportMapping<?, ?> getMapping() { |
|
153 |
return null; //not needed |
|
154 |
} |
|
155 |
|
|
156 |
|
|
157 |
|
|
158 |
} |
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/erms/ErmsImportState.java | ||
---|---|---|
1 |
// $Id$ |
Also available in: Unified diff