Revision 48014773
Added by Andreas Müller almost 9 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonNameExport.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 |
*/ |
... | ... | |
57 | 57 |
public BerlinModelTaxonNameExport(){ |
58 | 58 |
super(); |
59 | 59 |
} |
60 |
|
|
60 |
|
|
61 | 61 |
/* (non-Javadoc) |
62 | 62 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
63 | 63 |
*/ |
... | ... | |
67 | 67 |
logger.warn("Checking for " + pluralString + " not yet fully implemented"); |
68 | 68 |
List<TaxonNameBase> list = getObjectList(); |
69 | 69 |
checkRank(list); |
70 |
|
|
70 |
|
|
71 | 71 |
//result &= checkRank(config); |
72 |
|
|
72 |
|
|
73 | 73 |
return result; |
74 | 74 |
} |
75 |
|
|
75 |
|
|
76 | 76 |
private boolean checkRank(List<TaxonNameBase> list){ |
77 | 77 |
List<TaxonNameBase> errorNames = new ArrayList<TaxonNameBase>(); |
78 | 78 |
for (TaxonNameBase<?,?> name : list){ |
79 |
if (name.getRank() == null); |
|
79 |
if (name.getRank() == null) { |
|
80 |
; |
|
81 |
} |
|
80 | 82 |
errorNames.add(name); |
81 | 83 |
} |
82 | 84 |
if (errorNames.size() >0){ |
83 | 85 |
System.out.println("The following names have no Rank:\n======================="); |
84 | 86 |
for (TaxonNameBase<?,?> name : errorNames){ |
85 | 87 |
System.out.println(" " + name.toString()); |
86 |
System.out.println(" " + name.getUuid());
|
|
87 |
System.out.println(" " + name.getTitleCache());
|
|
88 |
System.out.println(" " + name.getUuid()); |
|
89 |
System.out.println(" " + name.getTitleCache()); |
|
88 | 90 |
} |
89 | 91 |
return false; |
90 | 92 |
}else{ |
91 | 93 |
return true; |
92 | 94 |
} |
93 | 95 |
} |
94 |
|
|
96 |
|
|
95 | 97 |
private CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> getMapping(){ |
96 | 98 |
String tableName = dbTableName; |
97 | 99 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = new CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer>(tableName); |
... | ... | |
111 | 113 |
mapping.addMapper(DbBooleanMapper.NewInstance("isBinomHybrid", "BinomHybFlag", false, false)); |
112 | 114 |
mapping.addMapper(DbBooleanMapper.NewInstance("isTrinomHybrid", "TrinomHybFlag", false, false)); |
113 | 115 |
mapping.addMapper(DbStringMapper.NewFacultativeInstance("cultivarName", "CultivarName")); |
114 |
|
|
115 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("combinationAuthorTeam", "AuthorTeamFk"));
|
|
116 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("exCombinationAuthorTeam", "ExAuthorTeamFk"));
|
|
117 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("basionymAuthorTeam", "BasAuthorTeamFk"));
|
|
118 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("exBasionymAuthorTeam", "ExBasAuthorTeamFk"));
|
|
116 |
|
|
117 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("combinationAuthorship", "AuthorTeamFk"));
|
|
118 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("exCombinationAuthorship", "ExAuthorTeamFk"));
|
|
119 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("basionymAuthorship", "BasAuthorTeamFk"));
|
|
120 |
mapping.addMapper(TeamOrPersonMapper.NewInstance("exBasionymAuthorship", "ExBasAuthorTeamFk"));
|
|
119 | 121 |
|
120 | 122 |
mapping.addMapper(DbObjectMapper.NewInstance("nomenclaturalReference", "NomRefFk")); |
121 | 123 |
mapping.addMapper(RefDetailMapper.NewInstance("nomenclaturalMicroReference","nomenclaturalReference", "NomRefDetailFk")); |
... | ... | |
125 | 127 |
mapping.addMapper(DbExtensionMapper.NewInstance(sourceAccExtensionType, "Source_Acc")); |
126 | 128 |
} |
127 | 129 |
mapping.addCollectionMapping(getNomStatusMapping()); |
128 |
|
|
129 |
|
|
130 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
131 | 133 |
//TODO |
132 | 134 |
//CultivarGroupName |
133 | 135 |
//NameSourceRefFk |
134 | 136 |
// ,[Source_ACC] |
135 |
|
|
137 |
|
|
136 | 138 |
//publicationYear |
137 | 139 |
//originalPublicationYear |
138 | 140 |
//breed |
... | ... | |
140 | 142 |
//n.getNomenclaturalMicroReference() |
141 | 143 |
return mapping; |
142 | 144 |
} |
143 |
|
|
145 |
|
|
144 | 146 |
private CollectionExportMapping getNomStatusMapping(){ |
145 | 147 |
String tableName = "NomStatusRel"; |
146 | 148 |
String collectionAttribute = "status"; |
... | ... | |
154 | 156 |
|
155 | 157 |
return mapping; |
156 | 158 |
} |
157 |
|
|
158 |
protected void doInvoke(BerlinModelExportState state){ |
|
159 |
|
|
160 |
@Override |
|
161 |
protected void doInvoke(BerlinModelExportState state){ |
|
159 | 162 |
try{ |
160 | 163 |
logger.info("start make "+pluralString+" ..."); |
161 | 164 |
boolean success = true ; |
162 | 165 |
doDelete(state); |
163 |
|
|
166 |
|
|
164 | 167 |
TransactionStatus txStatus = startTransaction(true); |
165 | 168 |
logger.info("load "+pluralString+" ..."); |
166 | 169 |
List<TaxonNameBase> names = getObjectList(); |
167 |
|
|
170 |
|
|
168 | 171 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = getMapping(); |
169 | 172 |
mapping.initialize(state); |
170 | 173 |
logger.info("save "+pluralString+" ..."); |
... | ... | |
176 | 179 |
} |
177 | 180 |
commitTransaction(txStatus); |
178 | 181 |
logger.info("end make " + pluralString+ " ..." + getSuccessString(success)); |
179 |
|
|
182 |
|
|
180 | 183 |
if (!success){ |
181 | 184 |
state.setUnsuccessfull(); |
182 | 185 |
} |
... | ... | |
194 | 197 |
return list; |
195 | 198 |
} |
196 | 199 |
|
197 |
|
|
200 |
|
|
198 | 201 |
protected boolean doDelete(BerlinModelExportState state){ |
199 | 202 |
BerlinModelExportConfigurator bmeConfig = state.getConfig(); |
200 |
|
|
203 |
|
|
201 | 204 |
String sql; |
202 | 205 |
Source destination = bmeConfig.getDestination(); |
203 | 206 |
//RelPTaxon |
... | ... | |
212 | 215 |
sql = "DELETE FROM PTaxon"; |
213 | 216 |
destination.setQuery(sql); |
214 | 217 |
destination.update(sql); |
215 |
|
|
218 |
|
|
216 | 219 |
//NameHistory |
217 | 220 |
sql = "DELETE FROM NameHistory"; |
218 | 221 |
destination.setQuery(sql); |
... | ... | |
231 | 234 |
destination.update(sql); |
232 | 235 |
return true; |
233 | 236 |
} |
234 |
|
|
235 |
|
|
237 |
|
|
238 |
|
|
236 | 239 |
/* (non-Javadoc) |
237 | 240 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
238 | 241 |
*/ |
239 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
242 |
@Override |
|
243 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
240 | 244 |
return ! state.getConfig().isDoTaxonNames(); |
241 | 245 |
} |
242 |
|
|
246 |
|
|
243 | 247 |
//called by MethodMapper |
244 | 248 |
@SuppressWarnings("unused") |
245 | 249 |
private static Integer getRankFk(NonViralName<?> name){ |
... | ... | |
250 | 254 |
} |
251 | 255 |
return result; |
252 | 256 |
} |
253 |
|
|
257 |
|
|
254 | 258 |
//called by MethodMapper |
255 | 259 |
@SuppressWarnings("unused") |
256 | 260 |
private static Integer getNomStatusFk(NomenclaturalStatus status){ |
257 | 261 |
return BerlinModelTransformer.nomStatus2nomStatusFk(status.getType()); |
258 | 262 |
} |
259 |
|
|
263 |
|
|
260 | 264 |
//called by MethodMapper |
261 | 265 |
@SuppressWarnings("unused") |
262 | 266 |
private static String getSupraGenericName(NonViralName<?> name){ |
... | ... | |
266 | 270 |
return null; |
267 | 271 |
} |
268 | 272 |
} |
269 |
|
|
273 |
|
|
270 | 274 |
//called by MethodMapper |
271 | 275 |
@SuppressWarnings("unused") |
272 | 276 |
private static String getGenus(NonViralName<?> name){ |
... | ... | |
296 | 300 |
return null; |
297 | 301 |
} |
298 | 302 |
} |
299 |
|
|
303 |
|
|
300 | 304 |
//called by MethodMapper |
301 | 305 |
@SuppressWarnings("unused") |
302 | 306 |
private static Boolean getPreliminaryFlag(NonViralName<?> name){ |
... | ... | |
309 | 313 |
return false; |
310 | 314 |
} |
311 | 315 |
} |
312 |
|
|
313 |
|
|
316 |
|
|
317 |
|
|
314 | 318 |
|
315 | 319 |
/* (non-Javadoc) |
316 | 320 |
* @see eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportBase#getStandardMethodParameter() |
... | ... | |
319 | 323 |
public Class<? extends CdmBase> getStandardMethodParameter() { |
320 | 324 |
return standardMethodParameter; |
321 | 325 |
} |
322 |
|
|
326 |
|
|
323 | 327 |
} |
Also available in: Unified diff
Rename NonViralName authorteams to authorship #4968