Revision 8422c0cd
Added by Andreas Müller almost 8 years ago
cdm-pesi/src/main/java/eu/etaxonomy/cdm/io/pesi/indexFungorum/IndexFungorumSupraGeneraImport.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
17 | 17 |
import org.springframework.stereotype.Component; |
18 | 18 |
import org.springframework.transaction.TransactionStatus; |
19 | 19 |
|
20 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
21 | 20 |
import eu.etaxonomy.cdm.io.pesi.out.PesiTransformer; |
22 | 21 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
23 | 22 |
import eu.etaxonomy.cdm.model.name.BotanicalName; |
... | ... | |
34 | 33 |
@Component |
35 | 34 |
public class IndexFungorumSupraGeneraImport extends IndexFungorumImportBase { |
36 | 35 |
private static final Logger logger = Logger.getLogger(IndexFungorumSupraGeneraImport.class); |
37 |
|
|
36 |
|
|
38 | 37 |
private static final String pluralString = "Supragenera"; |
39 | 38 |
private static final String dbTableName = "tblSupragenericNames"; |
40 | 39 |
|
... | ... | |
45 | 44 |
|
46 | 45 |
@Override |
47 | 46 |
protected String getRecordQuery(IndexFungorumImportConfigurator config) { |
48 |
String strRecordQuery =
|
|
49 |
" SELECT * " +
|
|
47 |
String strRecordQuery = |
|
48 |
" SELECT * " + |
|
50 | 49 |
" FROM [tblSupragenericNames] " + |
51 | 50 |
// " WHERE ( dr.id IN (" + ID_LIST_TOKEN + ") )"; |
52 | 51 |
""; |
53 | 52 |
return strRecordQuery; |
54 | 53 |
} |
55 | 54 |
|
56 |
|
|
55 |
|
|
57 | 56 |
@Override |
58 | 57 |
protected void doInvoke(IndexFungorumImportState state) { |
59 |
|
|
60 |
|
|
58 |
|
|
59 |
|
|
61 | 60 |
//handle source reference first |
62 | 61 |
Reference sourceReference = state.getConfig().getSourceReference(); |
63 | 62 |
getReferenceService().save(sourceReference); |
64 |
|
|
63 |
|
|
65 | 64 |
//query |
66 | 65 |
String sql = getRecordQuery(state.getConfig()); |
67 | 66 |
ResultSet rs = state.getConfig().getSource().getResultSet(sql); |
68 |
|
|
67 |
|
|
69 | 68 |
//transaction and related objects |
70 | 69 |
TransactionStatus tx = startTransaction(); |
71 |
state.setRelatedObjects((Map)getRelatedObjectsForPartition(null, state));
|
|
70 |
state.setRelatedObjects(getRelatedObjectsForPartition(null, state)); |
|
72 | 71 |
sourceReference = state.getRelatedObject(NAMESPACE_REFERENCE, SOURCE_REFERENCE, Reference.class); |
73 |
|
|
72 |
|
|
74 | 73 |
try { |
75 | 74 |
while (rs.next()){ |
76 | 75 |
|
... | ... | |
78 | 77 |
//DisplayName, NomRefCache |
79 | 78 |
|
80 | 79 |
Double id = (Double)rs.getObject("RECORD NUMBER"); |
81 |
|
|
80 |
|
|
82 | 81 |
String supragenericNames = rs.getString("Suprageneric names"); |
83 | 82 |
//String preferredName = rs.getString("PreferredName"); |
84 | 83 |
Integer rankFk = rs.getInt("PESI_RankFk"); |
85 |
|
|
84 |
|
|
86 | 85 |
//name |
87 | 86 |
Rank rank = state.getTransformer().getRankByKey(String.valueOf(rankFk)); |
88 | 87 |
NonViralName<?> name = BotanicalName.NewInstance(rank); |
... | ... | |
90 | 89 |
/*if (preferredName != null && !preferredName.equals(supragenericNames)){ |
91 | 90 |
logger.warn("Suprageneric names and preferredName is not equal. This case is not yet handled by IF import. I take SupragenericNames for import. RECORD NUMBER" +id); |
92 | 91 |
}*/ |
93 |
|
|
92 |
|
|
94 | 93 |
//taxon |
95 | 94 |
Taxon taxon = Taxon.NewInstance(name, sourceReference); |
96 | 95 |
//author + nom.ref. |
... | ... | |
104 | 103 |
getTaxonService().saveOrUpdate(taxon); |
105 | 104 |
} |
106 | 105 |
|
107 |
|
|
106 |
|
|
108 | 107 |
} catch (Exception e) { |
109 | 108 |
e.printStackTrace(); |
110 | 109 |
logger.error(e.getMessage()); |
... | ... | |
113 | 112 |
} |
114 | 113 |
commitTransaction(tx); |
115 | 114 |
return; |
116 |
|
|
115 |
|
|
117 | 116 |
} |
118 | 117 |
|
119 | 118 |
|
... | ... | |
127 | 126 |
@Override |
128 | 127 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, IndexFungorumImportState state) { |
129 | 128 |
HashMap<Object, Map<String, ? extends CdmBase>> result = new HashMap<Object, Map<String,? extends CdmBase>>(); //not needed here |
130 |
|
|
129 |
|
|
131 | 130 |
//sourceReference |
132 |
Reference<?> sourceReference = getReferenceService().find(PesiTransformer.uuidSourceRefIndexFungorum);
|
|
131 |
Reference sourceReference = getReferenceService().find(PesiTransformer.uuidSourceRefIndexFungorum); |
|
133 | 132 |
Map<String, Reference> referenceMap = new HashMap<String, Reference>(); |
134 | 133 |
referenceMap.put(SOURCE_REFERENCE, sourceReference); |
135 | 134 |
result.put(NAMESPACE_REFERENCE, referenceMap); |
136 | 135 |
|
137 | 136 |
return result; |
138 | 137 |
} |
139 |
|
|
138 |
|
|
140 | 139 |
@Override |
141 | 140 |
protected boolean doCheck(IndexFungorumImportState state){ |
142 | 141 |
return true; |
143 | 142 |
} |
144 |
|
|
143 |
|
|
145 | 144 |
@Override |
146 | 145 |
protected boolean isIgnore(IndexFungorumImportState state){ |
147 | 146 |
return ! state.getConfig().isDoTaxa(); |
Also available in: Unified diff
Remove generics from Reference in cdmlib-app #5830