Revision 3ef2e1bd
Added by Andreas Müller over 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/app/cyprus/CyprusAltitudeActivator.java | ||
---|---|---|
41 | 41 |
import eu.etaxonomy.cdm.model.reference.Reference; |
42 | 42 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
43 | 43 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
44 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; |
|
45 | 44 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
46 | 45 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
47 | 46 |
|
... | ... | |
206 | 205 |
|
207 | 206 |
private boolean hasSynonym(Taxon t, TaxonBase<?> base) { |
208 | 207 |
if (base.isInstanceOf(Synonym.class)){ |
209 |
for (SynonymRelationship rel : t.getSynonymRelations()){
|
|
210 |
if (rel.getSynonym().equals(base)){
|
|
208 |
for (Synonym syn : t.getSynonyms()){
|
|
209 |
if (syn.equals(base)){
|
|
211 | 210 |
return true; |
212 | 211 |
} |
213 | 212 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/app/util/TestDatabase.java | ||
---|---|---|
47 | 47 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
48 | 48 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
49 | 49 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
50 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
|
50 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
51 | 51 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
52 | 52 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
53 | 53 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
... | ... | |
284 | 284 |
syn12 = Synonym.NewInstance(synName12, sec); |
285 | 285 |
syn2 = Synonym.NewInstance(synName2, sec); |
286 | 286 |
|
287 |
child1.addSynonym(syn11, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
|
|
288 |
child1.addSynonym(syn12, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
|
289 |
child2.addSynonym(syn2, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
|
290 |
freeT.addSynonym(synFree, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF());
|
|
287 |
child1.addSynonym(syn11, SynonymType.HOMOTYPIC_SYNONYM_OF()); |
|
288 |
child1.addSynonym(syn12, SynonymType.HETEROTYPIC_SYNONYM_OF()); |
|
289 |
child2.addSynonym(syn2, SynonymType.HETEROTYPIC_SYNONYM_OF()); |
|
290 |
freeT.addSynonym(synFree, SynonymType.HETEROTYPIC_SYNONYM_OF()); |
|
291 | 291 |
|
292 | 292 |
taxonBases.add(synFree); |
293 | 293 |
taxonBases.add(syn11); |
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/palmae/PalmaePostImportUpdater.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
42 | 42 |
private static final Logger logger = Logger.getLogger(PalmaePostImportUpdater.class); |
43 | 43 |
|
44 | 44 |
static final ICdmDataSource cdmDestination = CdmDestinations.localH2Palmae(); |
45 |
|
|
46 |
|
|
45 |
|
|
46 |
|
|
47 | 47 |
private String relationships = "relationships"; |
48 | 48 |
private String taxonomicAccounts = "taxonomic accounts"; |
49 | 49 |
private String fossilRecord = "fossil record"; |
50 |
|
|
50 |
|
|
51 | 51 |
public boolean updateMissingFeatures(ICdmDataSource dataSource) { |
52 | 52 |
try{ |
53 | 53 |
int count = 0; |
54 | 54 |
UUID featureTreeUuid = PalmaeActivator.featureTreeUuid; |
55 | 55 |
CdmApplicationController cdmApp = CdmApplicationController.NewInstance(dataSource, DbSchemaValidation.VALIDATE); |
56 |
|
|
56 |
|
|
57 | 57 |
TransactionStatus tx = cdmApp.startTransaction(); |
58 |
|
|
58 |
|
|
59 | 59 |
FeatureTree tree = cdmApp.getFeatureTreeService().find(featureTreeUuid); |
60 | 60 |
FeatureNode root = tree.getRoot(); |
61 |
|
|
61 |
|
|
62 | 62 |
List<Feature> featureList = cdmApp.getTermService().list(Feature.class, null, null, null, null); |
63 | 63 |
for (Feature feature : featureList){ |
64 | 64 |
String label = feature.getLabel(); |
... | ... | |
88 | 88 |
logger.error("ERROR in feature tree update"); |
89 | 89 |
return false; |
90 | 90 |
} |
91 |
|
|
91 |
|
|
92 | 92 |
} |
93 |
|
|
93 |
|
|
94 | 94 |
public boolean updateNameUsage(ICdmDataSource dataSource) { |
95 | 95 |
try{ |
96 | 96 |
boolean result = true; |
... | ... | |
102 | 102 |
int count = cdmApp.getTaxonService().count(Taxon.class); |
103 | 103 |
List<TaxonBase> taxonList = cdmApp.getTaxonService().list(TaxonBase.class, 100000, page, null, null); |
104 | 104 |
int i = 0; |
105 |
|
|
105 |
|
|
106 | 106 |
IReference treatmentReference = (IReference) cdmApp.getCommonService().getSourcedObjectByIdInSource(Reference.class, "palm_pub_ed_999999", "PublicationCitation"); |
107 | 107 |
if (treatmentReference == null){ |
108 | 108 |
logger.error("Treatment reference could not be found"); |
... | ... | |
110 | 110 |
}else{ |
111 | 111 |
for (TaxonBase nameUsage : taxonList){ |
112 | 112 |
if ((i++ % 100) == 0){System.out.println(i);}; |
113 |
|
|
113 |
|
|
114 | 114 |
try { |
115 | 115 |
//if not in treatment |
116 | 116 |
if (! isInTreatment(nameUsage, treatmentReference, false)){ |
... | ... | |
156 | 156 |
logger.error("ERROR in name usage update"); |
157 | 157 |
return false; |
158 | 158 |
} |
159 |
|
|
159 |
|
|
160 | 160 |
} |
161 | 161 |
|
162 | 162 |
/** |
163 |
* @param nameUsage
|
|
163 |
* @param nameUsage |
|
164 | 164 |
* @return |
165 | 165 |
*/ |
166 | 166 |
private Taxon getAcceptedTreatmentTaxon(TaxonBase nameUsage, IReference treatmentReference) { |
... | ... | |
174 | 174 |
} |
175 | 175 |
}else if (candidate instanceof Synonym){ |
176 | 176 |
Synonym synonym = (Synonym)candidate; |
177 |
Set<Taxon> accTaxa = synonym.getAcceptedTaxa();
|
|
177 |
Taxon accTaxon = synonym.getAcceptedTaxon();
|
|
178 | 178 |
if (isInTreatment(synonym, treatmentReference, true)){ |
179 | 179 |
hasSynonymInTreatment = true; |
180 | 180 |
} |
181 |
for (Taxon accTaxon : accTaxa){
|
|
181 |
if (accTaxon != null){
|
|
182 | 182 |
if (isInTreatment(accTaxon, treatmentReference, false)){ |
183 | 183 |
return accTaxon; |
184 | 184 |
} |
... | ... | |
195 | 195 |
|
196 | 196 |
/** |
197 | 197 |
* @param taxonBase |
198 |
* @param treatmentReference
|
|
198 |
* @param treatmentReference |
|
199 | 199 |
* @return |
200 | 200 |
*/ |
201 | 201 |
private boolean isInTreatment(TaxonBase taxonBase, IReference treatmentReference, boolean silent) { |
... | ... | |
209 | 209 |
}else if (taxonBase instanceof Synonym){ |
210 | 210 |
Synonym synonym = (Synonym)taxonBase; |
211 | 211 |
boolean hasAccTaxonInTreatment = false; |
212 |
for (Taxon accTaxon : synonym.getAcceptedTaxa()){ |
|
212 |
Taxon accTaxon = synonym.getAcceptedTaxon(); |
|
213 |
if (accTaxon != null){ |
|
213 | 214 |
hasAccTaxonInTreatment |= isInTreatment(accTaxon, treatmentReference, false); |
214 | 215 |
} |
215 | 216 |
if (hasAccTaxonInTreatment == false){ |
... | ... | |
230 | 231 |
}else if (taxonBase instanceof Synonym){ |
231 | 232 |
Synonym synonym = (Synonym)taxonBase; |
232 | 233 |
boolean hasAccTaxonInTreatment = false; |
233 |
for (Taxon accTaxon : synonym.getAcceptedTaxa()){ |
|
234 |
Taxon accTaxon = synonym.getAcceptedTaxon(); |
|
235 |
if (accTaxon != null){ |
|
234 | 236 |
hasAccTaxonInTreatment |= isInTreatment(accTaxon, treatmentReference, false); |
235 | 237 |
} |
236 | 238 |
if (hasAccTaxonInTreatment == true){ |
... | ... | |
243 | 245 |
return false; |
244 | 246 |
} |
245 | 247 |
} |
246 |
|
|
248 |
|
|
247 | 249 |
/** |
248 | 250 |
* @param taxonCandidate |
249 | 251 |
* @param taxon |
... | ... | |
266 | 268 |
myDescription.addElement(textData); |
267 | 269 |
return true; |
268 | 270 |
} |
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
271 | 273 |
/** |
272 | 274 |
* @param args |
273 | 275 |
*/ |
app-import/src/main/java/eu/etaxonomy/cdm/app/wp6/palmae/UseImport.java | ||
---|---|---|
149 | 149 |
ArrayList<String> lstTaxon = new ArrayList<String>(); |
150 | 150 |
while (cells.hasNext()) { |
151 | 151 |
Cell cell = cells.next(); |
152 |
|
|
152 |
|
|
153 | 153 |
int intCellType = cell.getCellType(); |
154 | 154 |
switch (intCellType) { |
155 | 155 |
case 0: |
156 |
int cellValue = (int) cell.getNumericCellValue();
|
|
156 |
int cellValue = (int) cell.getNumericCellValue(); |
|
157 | 157 |
lstTaxon.add(Integer.toString(cellValue)); |
158 | 158 |
break; |
159 | 159 |
case 1: |
... | ... | |
162 | 162 |
} |
163 | 163 |
} |
164 | 164 |
lstUpdates.add(lstTaxon); |
165 |
lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0)));
|
|
165 |
lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0))); |
|
166 | 166 |
} |
167 |
|
|
167 |
|
|
168 | 168 |
List<TaxonBase> taxa = service.findTaxaByID(lstTaxonIDs); |
169 | 169 |
for(TaxonBase idTaxa : taxa) { |
170 | 170 |
//System.out.println(idTaxa.getUuid().toString()); |
171 | 171 |
System.out.println(idTaxa.getName()); |
172 | 172 |
} |
173 |
|
|
174 |
|
|
173 |
|
|
174 |
|
|
175 | 175 |
MarkerType useMarkerType = (MarkerType) termService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
176 | 176 |
Marker useMarker = Marker.NewInstance(useMarkerType, true); |
177 | 177 |
for (ArrayList<String> lstUpdate : lstUpdates) { |
... | ... | |
185 | 185 |
authorTeam.setTitleCache(lstUpdate.get(3)); |
186 | 186 |
citation.setAuthorship(authorTeam); |
187 | 187 |
citation.setTitle(lstUpdate.get(4)); |
188 |
|
|
188 |
|
|
189 | 189 |
//citation. |
190 | 190 |
TimePeriod year = TimePeriod.NewInstance(Integer.parseInt(lstUpdate.get(5))); |
191 | 191 |
citation.setDatePublished(year); |
192 | 192 |
citation.setTitleCache(lstUpdate.get(6)); |
193 | 193 |
//citation. |
194 | 194 |
for(TaxonBase taxon : taxa) { |
195 |
String taxonUUID = taxon.getUuid().toString();
|
|
195 |
String taxonUUID = taxon.getUuid().toString(); |
|
196 | 196 |
//System.out.println(idTaxonToUpdate + "|" + taxonUUID); |
197 | 197 |
if(idTaxonToUpdate.equals(taxonUUID)) { |
198 | 198 |
logger.info("Processing Taxn " + taxon.getTitleCache() + " with UUID: " + taxon.getUuid()); |
199 | 199 |
if(taxon.isInstanceOf(Synonym.class)) { |
200 | 200 |
Taxon bestCandidate = null; |
201 | 201 |
Synonym synonym = CdmBase.deproxy(taxon, Synonym.class); |
202 |
Set<Taxon> acceptetdCandidates = synonym.getAcceptedTaxa(); |
|
203 |
if(!acceptetdCandidates.isEmpty()){ |
|
204 |
bestCandidate = acceptetdCandidates.iterator().next(); |
|
205 |
if(acceptetdCandidates.size() == 1){ |
|
206 |
logger.info(acceptetdCandidates.size() + " Accepted taxa found for synonym " + taxon.getTitleCache() + ", using first one: " + bestCandidate.getTitleCache()); |
|
207 |
Set<TaxonDescription> taxonDescriptions = bestCandidate.getDescriptions(); |
|
208 |
if(!taxonDescriptions.isEmpty()) { |
|
209 |
TaxonDescription firstDescription = taxonDescriptions.iterator().next(); |
|
210 |
//newUseSummary.addSource(null, null, citation, null); |
|
211 |
//firstDescription.addElement(newUseSummary); |
|
212 |
} |
|
213 |
else { |
|
214 |
logger.warn("No description container for: " + bestCandidate.getName()); |
|
215 |
|
|
216 |
} |
|
217 |
} else { |
|
218 |
logger.info("using accepted Taxon " + bestCandidate.getTitleCache() + "for synonym " + taxon.getTitleCache()); |
|
219 |
//List<DescriptionElementBase> descriptionElements = descService.getDescriptionElementsForTaxon((Taxon) bestCandidate, null, null, null, null, null); |
|
220 |
Set<TaxonDescription> taxonDescriptions = bestCandidate.getDescriptions(); |
|
221 |
if(!taxonDescriptions.isEmpty()) { |
|
222 |
TaxonDescription firstDescription = taxonDescriptions.iterator().next(); |
|
223 |
//newUseSummary.addSource(null, null, citation, null); |
|
224 |
//firstDescription.addElement(newUseSummary); |
|
225 |
} |
|
226 |
else { |
|
227 |
logger.warn("No description container for: " + bestCandidate.getName()); |
|
228 |
|
|
229 |
} |
|
202 |
Taxon acceptetdTaxon = synonym.getAcceptedTaxon(); |
|
203 |
if(acceptetdTaxon != null){ |
|
204 |
Set<TaxonDescription> taxonDescriptions = acceptetdTaxon.getDescriptions(); |
|
205 |
if(!taxonDescriptions.isEmpty()) { |
|
206 |
TaxonDescription firstDescription = taxonDescriptions.iterator().next(); |
|
207 |
//newUseSummary.addSource(null, null, citation, null); |
|
208 |
//firstDescription.addElement(newUseSummary); |
|
209 |
} |
|
210 |
else { |
|
211 |
logger.warn("No description container for: " + acceptetdTaxon.getName()); |
|
230 | 212 |
} |
231 | 213 |
} |
232 | 214 |
} |
... | ... | |
243 | 225 |
}*/ |
244 | 226 |
taxonAccepted.addDescription(newUseDescription); |
245 | 227 |
service.saveOrUpdate(taxonAccepted); |
246 |
|
|
228 |
|
|
247 | 229 |
} |
248 | 230 |
} |
249 | 231 |
} |
250 |
|
|
232 |
|
|
251 | 233 |
} |
252 | 234 |
conversation.commit(false); |
253 |
|
|
235 |
|
|
254 | 236 |
} catch (IOException e) { |
255 | 237 |
success = false; |
256 | 238 |
e.printStackTrace(); |
... | ... | |
259 | 241 |
return success; |
260 | 242 |
|
261 | 243 |
} |
262 |
|
|
244 |
|
|
263 | 245 |
private boolean loadUses() throws InvalidFormatException { |
264 | 246 |
boolean success = true; |
265 | 247 |
//String xslUseSummaryPathString = "C://workspace//Matched_UseSummary_referenceIdTaxEd_TaxonName.xls"; |
266 | 248 |
//String xslUseSummaryPathString = "C://workspace//testUseSummaries.xls"; |
267 |
|
|
268 |
|
|
249 |
|
|
250 |
|
|
269 | 251 |
String xslUseSummaryPathString = "//Users//alextheys//Projects//CDM_Trunk//Palm_Use_Data_Extension//CDMLib-apps//cdmlib-apps//UseImport//src//main//resources//Matched_UseSummary_referenceIdTaxEd_TaxonName.xls"; |
270 |
|
|
252 |
|
|
271 | 253 |
//String xslUseRecordPathString = "C://workspace//UseRecordTerms_UseSummaryId.xls"; |
272 | 254 |
//String xslUseRecordPathString = "C://workspace//testUseRecords.xls"; |
273 | 255 |
//String xslUseRecordPathString = "C://workspace//test_useRecord.xls"; |
274 | 256 |
String xslUseRecordPathString = "//Users//alextheys//Projects//CDM_Trunk//Palm_Use_Data_Extension//CDMLib-apps//cdmlib-apps//UseImport//src//main//resources//UseRecordTerms_UseSummaryId.xls"; |
275 |
|
|
257 |
|
|
276 | 258 |
InputStream inputStream = null; |
277 |
|
|
278 |
|
|
259 |
|
|
260 |
|
|
279 | 261 |
CdmApplicationController applicationController = CdmApplicationController.NewInstance(dataSource()); |
280 | 262 |
ConversationHolder conversation = applicationController.NewConversation(); |
281 | 263 |
conversation.startTransaction(); |
282 |
|
|
264 |
|
|
283 | 265 |
ITaxonService taxonService = applicationController.getTaxonService(); |
284 | 266 |
ITermService termService = applicationController.getTermService(); |
285 | 267 |
IDescriptionService descService = applicationController.getDescriptionService(); |
286 | 268 |
IReferenceService referenceService = applicationController.getReferenceService(); |
287 |
|
|
288 |
|
|
269 |
|
|
270 |
|
|
289 | 271 |
ArrayList<ArrayList<String>> lstUseSummaries = loadSpreadsheet(xslUseSummaryPathString); |
290 | 272 |
ArrayList<ArrayList<String>> lstUseRecords = loadSpreadsheet(xslUseRecordPathString); |
291 |
|
|
273 |
|
|
292 | 274 |
MarkerType useMarkerType = (MarkerType) termService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
293 | 275 |
Feature featureUseRecord = (Feature) termService.find(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
294 | 276 |
Feature featureUseSummary = (Feature) termService.find(UUID.fromString("6acb0348-c070-4512-a37c-67bcac016279")); |
295 |
Pager<DefinedTermBase> notAvailModPager = (Pager<DefinedTermBase> ) termService.findByTitle(DefinedTerm.class, "N/A", null, null, null, null, null, null);
|
|
296 |
Pager<DefinedTermBase> notAvailStatePager = (Pager<DefinedTermBase> ) termService.findByTitle(State.class, "N/A", null, null, null, null, null, null);
|
|
277 |
Pager<DefinedTermBase> notAvailModPager = termService.findByTitle(DefinedTerm.class, "N/A", null, null, null, null, null, null); |
|
278 |
Pager<DefinedTermBase> notAvailStatePager = termService.findByTitle(State.class, "N/A", null, null, null, null, null, null); |
|
297 | 279 |
DefinedTerm notAvailMod = (DefinedTerm) notAvailModPager.getRecords().get(0); |
298 | 280 |
State notAvailState = (State) notAvailStatePager.getRecords().get(0); |
299 |
|
|
281 |
|
|
300 | 282 |
int i = 0; |
301 | 283 |
int j = 0; |
302 | 284 |
try { |
... | ... | |
343 | 325 |
stateCatData.putModifyingText(Language.ENGLISH(), "Use Category"); |
344 | 326 |
modifyingText += useCategory.toString() + ";"; |
345 | 327 |
useRecord.addStateData(stateCatData); |
346 |
|
|
347 |
|
|
328 |
|
|
329 |
|
|
348 | 330 |
//useRecord.addState(stateData); |
349 | 331 |
} else { |
350 | 332 |
State useCategory = notAvailState; |
... | ... | |
353 | 335 |
stateCatData.putModifyingText(Language.ENGLISH(), "Use Category"); |
354 | 336 |
modifyingText += useCategory.toString() + ";"; |
355 | 337 |
useRecord.addStateData(stateCatData); |
356 |
|
|
338 |
|
|
357 | 339 |
} |
358 |
|
|
340 |
|
|
359 | 341 |
if(lstUseRecord.get(4) != null && lstUseRecord.get(4).length() > 0) { |
360 | 342 |
Pager<DefinedTermBase> useSubCategoryPager = termService.findByTitle(State.class, lstUseRecord.get(4), null, null, null, null, null, null); |
361 | 343 |
State useSubCategory = null; |
362 | 344 |
if(useSubCategoryPager.getCount() > 0) { |
363 | 345 |
useSubCategory = (State) useSubCategoryPager.getRecords().get(0); |
364 |
|
|
346 |
|
|
365 | 347 |
} else { |
366 | 348 |
useSubCategory = notAvailState; |
367 | 349 |
} |
... | ... | |
370 | 352 |
stateSubCatData.putModifyingText(Language.ENGLISH(), "Use SubCategory"); |
371 | 353 |
modifyingText += useSubCategory.toString() + ";"; |
372 | 354 |
useRecord.addStateData(stateSubCatData); |
373 |
|
|
355 |
|
|
374 | 356 |
} |
375 | 357 |
else { |
376 | 358 |
State useSubCategory = notAvailState; |
... | ... | |
379 | 361 |
stateSubCatData.putModifyingText(Language.ENGLISH(), "Use SubCategory"); |
380 | 362 |
modifyingText += useSubCategory.toString() + ";"; |
381 | 363 |
useRecord.addStateData(stateSubCatData); |
382 |
|
|
364 |
|
|
383 | 365 |
} |
384 | 366 |
if(lstUseRecord.get(5) != null && lstUseRecord.get(5).length() > 0) { |
385 | 367 |
Pager<DefinedTermBase> countryPager = termService.findByTitle(DefinedTerm.class, lstUseRecord.get(5), null, null, null, null, null, null); |
... | ... | |
396 | 378 |
modifyingText += country.toString() + ";"; |
397 | 379 |
useRecord.addModifier(country); |
398 | 380 |
} |
399 |
|
|
381 |
|
|
400 | 382 |
if(lstUseRecord.get(6) != null && lstUseRecord.get(6).length() > 0) { |
401 | 383 |
Pager<DefinedTermBase> plantPartPager = termService.findByTitle(DefinedTerm.class, lstUseRecord.get(6), null, null, null, null, null, null); |
402 | 384 |
DefinedTerm plantPart = null; |
... | ... | |
448 | 430 |
newUseDescription.addElement(useRecord); |
449 | 431 |
} |
450 | 432 |
} |
451 |
|
|
452 |
|
|
453 |
|
|
433 |
|
|
434 |
|
|
435 |
|
|
454 | 436 |
if (taxon.isInstanceOf(Synonym.class)){ |
455 | 437 |
Taxon bestCandidate = null; |
456 | 438 |
Synonym synonym = CdmBase.deproxy(taxon, Synonym.class); |
457 |
Set<Taxon> acceptetdCandidates = synonym.getAcceptedTaxa(); |
|
458 |
if(!acceptetdCandidates.isEmpty()){ |
|
459 |
bestCandidate = acceptetdCandidates.iterator().next(); |
|
460 |
if(acceptetdCandidates.size() == 1){ |
|
461 |
logger.info(acceptetdCandidates.size() + " Accepted taxa found for synonym " + taxon.getTitleCache() + ", using first one: " + bestCandidate.getTitleCache()); |
|
462 |
bestCandidate.addDescription(newUseDescription); |
|
463 |
taxonService.saveOrUpdate(bestCandidate); |
|
464 |
conversation.commit(); |
|
465 |
} |
|
466 |
else { |
|
467 |
logger.info("using accepted Taxon " + bestCandidate.getTitleCache() + "for synonym " + taxon.getTitleCache()); |
|
468 |
bestCandidate.addDescription(newUseDescription); |
|
469 |
taxonService.saveOrUpdate(bestCandidate); |
|
470 |
conversation.commit(); |
|
471 |
} |
|
439 |
Taxon acceptedTaxon = synonym.getAcceptedTaxon(); |
|
440 |
if(acceptedTaxon != null){ |
|
441 |
acceptedTaxon.addDescription(newUseDescription); |
|
442 |
taxonService.saveOrUpdate(bestCandidate); |
|
443 |
conversation.commit(); |
|
472 | 444 |
} |
473 | 445 |
} else { |
474 | 446 |
Taxon taxonAccepted = (Taxon) taxon; |
... | ... | |
481 | 453 |
System.out.println("Processing UseSummary#: " + i + " ID:" + lstUseSummary.get(0)); |
482 | 454 |
} |
483 | 455 |
} |
484 |
|
|
456 |
|
|
485 | 457 |
conversation.close(); |
486 | 458 |
applicationController.close(); |
487 |
|
|
459 |
|
|
488 | 460 |
} catch (Exception e) { |
489 | 461 |
success = false; |
490 | 462 |
e.printStackTrace(); |
491 | 463 |
} |
492 | 464 |
return success; |
493 |
|
|
465 |
|
|
494 | 466 |
} |
495 |
|
|
467 |
|
|
496 | 468 |
//Completed and tested! |
497 | 469 |
private boolean loadTerms() throws InvalidFormatException { |
498 | 470 |
boolean success = true; |
499 |
|
|
471 |
|
|
500 | 472 |
//String xslPathString = "C://workspace//terms.xls"; |
501 | 473 |
String xslPathString = "//Users//alextheys//Projects//CDM_Trunk//Palm_Use_Data_Extension//CDMLib-apps//cdmlib-apps//UseImport//src//main//resources//terms.xls"; |
502 |
|
|
474 |
|
|
503 | 475 |
CdmApplicationController applicationController = CdmApplicationController.NewInstance(dataSource()); |
504 | 476 |
ConversationHolder conversation = applicationController.NewConversation(); |
505 | 477 |
conversation.startTransaction(); |
506 |
|
|
478 |
|
|
507 | 479 |
ITaxonService service = applicationController.getTaxonService(); |
508 | 480 |
ITermService termService = applicationController.getTermService(); |
509 | 481 |
IVocabularyService vocabularyService = applicationController.getVocabularyService(); |
510 |
IReferenceService referenceService = applicationController.getReferenceService();
|
|
511 |
|
|
512 |
TermVocabulary<State> stateVocabulary = (TermVocabulary<State>) vocabularyService.find(UUID.fromString("67430d7c-fd43-4e9d-af5e-d0dca3f74931"));
|
|
513 |
TermVocabulary<DefinedTermBase<?>> countryVocabulary = (TermVocabulary<DefinedTermBase<?>>) vocabularyService.find(UUID.fromString("116c51f1-e63a-46f7-a258-e1149a42868b"));
|
|
514 |
TermVocabulary<DefinedTerm> plantPartVocabulary = (TermVocabulary<DefinedTerm>) vocabularyService.find(UUID.fromString("369914fe-d54b-4063-99ce-abc81d30ad35"));
|
|
515 |
TermVocabulary<DefinedTerm> humanGroupVocabulary = (TermVocabulary<DefinedTerm>) vocabularyService.find(UUID.fromString("ca46cea5-bdf7-438d-9cd8-e2793d2178dc"));
|
|
516 |
|
|
482 |
IReferenceService referenceService = applicationController.getReferenceService(); |
|
483 |
|
|
484 |
TermVocabulary<State> stateVocabulary = vocabularyService.find(UUID.fromString("67430d7c-fd43-4e9d-af5e-d0dca3f74931"));
|
|
485 |
TermVocabulary<DefinedTermBase<?>> countryVocabulary = vocabularyService.find(UUID.fromString("116c51f1-e63a-46f7-a258-e1149a42868b"));
|
|
486 |
TermVocabulary<DefinedTerm> plantPartVocabulary = vocabularyService.find(UUID.fromString("369914fe-d54b-4063-99ce-abc81d30ad35"));
|
|
487 |
TermVocabulary<DefinedTerm> humanGroupVocabulary = vocabularyService.find(UUID.fromString("ca46cea5-bdf7-438d-9cd8-e2793d2178dc")); |
|
488 |
|
|
517 | 489 |
IDescriptionService descService = applicationController.getDescriptionService(); |
518 | 490 |
InputStream inputStream = null; |
519 |
|
|
491 |
|
|
520 | 492 |
try { |
521 | 493 |
inputStream = new FileInputStream(xslPathString); |
522 | 494 |
|
... | ... | |
547 | 519 |
ArrayList<String> lstTerms = new ArrayList<String>(); |
548 | 520 |
while (cells.hasNext()) { |
549 | 521 |
Cell cell = cells.next(); |
550 |
|
|
522 |
|
|
551 | 523 |
int intCellType = cell.getCellType(); |
552 | 524 |
switch (intCellType) { |
553 | 525 |
case 0: |
554 |
int cellValue = (int) cell.getNumericCellValue();
|
|
526 |
int cellValue = (int) cell.getNumericCellValue(); |
|
555 | 527 |
lstTerms.add(Integer.toString(cellValue)); |
556 | 528 |
break; |
557 | 529 |
case 1: |
... | ... | |
560 | 532 |
} |
561 | 533 |
} |
562 | 534 |
lstUpdates.add(lstTerms); |
563 |
//lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0)));
|
|
535 |
//lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0))); |
|
564 | 536 |
} |
565 | 537 |
for (ArrayList<String> lstUpdate : lstUpdates) { |
566 |
int termType = Integer.parseInt(lstUpdate.get(0));
|
|
538 |
int termType = Integer.parseInt(lstUpdate.get(0)); |
|
567 | 539 |
switch (termType) { |
568 | 540 |
//Case 0 = UseCategory |
569 | 541 |
case 0: |
... | ... | |
642 | 614 |
} |
643 | 615 |
conversation.commit(true); |
644 | 616 |
break; |
645 |
|
|
617 |
|
|
646 | 618 |
} |
647 | 619 |
} |
648 |
conversation.close();
|
|
620 |
conversation.close(); |
|
649 | 621 |
applicationController.close(); |
650 |
|
|
622 |
|
|
651 | 623 |
} catch (IOException e) { |
652 | 624 |
success = false; |
653 | 625 |
e.printStackTrace(); |
654 | 626 |
} |
655 | 627 |
return success; |
656 |
|
|
628 |
|
|
657 | 629 |
} |
658 |
|
|
630 |
|
|
659 | 631 |
private ArrayList<ArrayList<String>> loadSpreadsheet(String xslPathString) throws InvalidFormatException { |
660 | 632 |
ArrayList<ArrayList<String>> lstUpdates = new ArrayList<ArrayList<String>>(); |
661 | 633 |
InputStream inputStream = null; |
662 |
|
|
634 |
|
|
663 | 635 |
try { |
664 | 636 |
inputStream = new FileInputStream(xslPathString); |
665 | 637 |
|
... | ... | |
689 | 661 |
ArrayList<String> lstTerms = new ArrayList<String>(); |
690 | 662 |
while (cells.hasNext()) { |
691 | 663 |
Cell cell = cells.next(); |
692 |
|
|
664 |
|
|
693 | 665 |
int intCellType = cell.getCellType(); |
694 | 666 |
switch (intCellType) { |
695 | 667 |
case 0: |
696 |
int cellValue = (int) cell.getNumericCellValue();
|
|
668 |
int cellValue = (int) cell.getNumericCellValue(); |
|
697 | 669 |
lstTerms.add(Integer.toString(cellValue)); |
698 | 670 |
break; |
699 | 671 |
case 1: |
... | ... | |
702 | 674 |
} |
703 | 675 |
} |
704 | 676 |
lstUpdates.add(lstTerms); |
705 |
//lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0)));
|
|
677 |
//lstTaxonIDs.add(Integer.parseInt(lstTaxon.get(0))); |
|
706 | 678 |
} |
707 | 679 |
} catch (IOException e) { |
708 | 680 |
e.printStackTrace(); |
709 | 681 |
} |
710 | 682 |
return lstUpdates; |
711 | 683 |
} |
712 |
|
|
713 |
|
|
684 |
|
|
685 |
|
|
714 | 686 |
private boolean setupNecessaryItems() { |
715 | 687 |
boolean success = false; |
716 | 688 |
CdmApplicationController applicationController = CdmApplicationController.NewInstance(dataSource()); |
717 | 689 |
ConversationHolder conversation = applicationController.NewConversation(); |
718 |
|
|
719 |
|
|
690 |
|
|
691 |
|
|
720 | 692 |
ITaxonService service = applicationController.getTaxonService(); |
721 | 693 |
ITermService termService = applicationController.getTermService(); |
722 | 694 |
IVocabularyService vocabularyService = applicationController.getVocabularyService(); |
723 | 695 |
IFeatureTreeService featureTreeService = applicationController.getFeatureTreeService(); |
724 |
|
|
696 |
|
|
725 | 697 |
MarkerType existingMarkertype = (MarkerType)termService.find(UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
726 | 698 |
Feature featureUseRecord = (Feature) termService.find(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
727 | 699 |
Feature featureUseSummary = (Feature) termService.find(UUID.fromString("6acb0348-c070-4512-a37c-67bcac016279")); |
728 |
TermVocabulary<State> stateVocabulary = (TermVocabulary<State>) vocabularyService.find(UUID.fromString("67430d7c-fd43-4e9d-af5e-d0dca3f74931"));
|
|
729 |
TermVocabulary<DefinedTerm> countryVocabulary = (TermVocabulary<DefinedTerm>) vocabularyService.find(UUID.fromString("116c51f1-e63a-46f7-a258-e1149a42868b"));
|
|
730 |
TermVocabulary<DefinedTerm> plantPartVocabulary = (TermVocabulary<DefinedTerm>) vocabularyService.find(UUID.fromString("369914fe-d54b-4063-99ce-abc81d30ad35"));
|
|
731 |
TermVocabulary<DefinedTerm> humanGroupVocabulary = (TermVocabulary<DefinedTerm>) vocabularyService.find(UUID.fromString("ca46cea5-bdf7-438d-9cd8-e2793d2178dc"));
|
|
732 |
Pager<DefinedTermBase> notAvailModPager = (Pager<DefinedTermBase> ) termService.findByTitle(DefinedTerm.class, "N/A", null, null, null, null, null, null);
|
|
733 |
Pager<DefinedTermBase> notAvailStatePager = (Pager<DefinedTermBase> ) termService.findByTitle(State.class, "N/A", null, null, null, null, null, null);
|
|
734 |
|
|
700 |
TermVocabulary<State> stateVocabulary = vocabularyService.find(UUID.fromString("67430d7c-fd43-4e9d-af5e-d0dca3f74931"));
|
|
701 |
TermVocabulary<DefinedTerm> countryVocabulary = vocabularyService.find(UUID.fromString("116c51f1-e63a-46f7-a258-e1149a42868b"));
|
|
702 |
TermVocabulary<DefinedTerm> plantPartVocabulary = vocabularyService.find(UUID.fromString("369914fe-d54b-4063-99ce-abc81d30ad35"));
|
|
703 |
TermVocabulary<DefinedTerm> humanGroupVocabulary = vocabularyService.find(UUID.fromString("ca46cea5-bdf7-438d-9cd8-e2793d2178dc")); |
|
704 |
Pager<DefinedTermBase> notAvailModPager = termService.findByTitle(DefinedTerm.class, "N/A", null, null, null, null, null, null); |
|
705 |
Pager<DefinedTermBase> notAvailStatePager = termService.findByTitle(State.class, "N/A", null, null, null, null, null, null); |
|
706 |
|
|
735 | 707 |
conversation.startTransaction(); |
736 | 708 |
if (existingMarkertype == null) { |
737 | 709 |
existingMarkertype = MarkerType.NewInstance("use", "use", null); |
738 | 710 |
existingMarkertype.setUuid( UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039")); |
739 |
TermVocabulary<MarkerType> markerTypeVocabulary = (TermVocabulary<MarkerType>)vocabularyService.find((UUID.fromString("19dffff7-e142-429c-a420-5d28e4ebe305")));
|
|
711 |
TermVocabulary<MarkerType> markerTypeVocabulary = vocabularyService.find((UUID.fromString("19dffff7-e142-429c-a420-5d28e4ebe305"))); |
|
740 | 712 |
markerTypeVocabulary.addTerm(existingMarkertype); |
741 | 713 |
vocabularyService.saveOrUpdate(markerTypeVocabulary); |
742 | 714 |
conversation.commit(true); |
743 | 715 |
} |
744 | 716 |
if (stateVocabulary == null) { |
745 |
|
|
717 |
|
|
746 | 718 |
URI termSourceUri = null; |
747 | 719 |
try { |
748 | 720 |
termSourceUri = new URI("eu.etaxonomy.cdm.model.description.State"); |
... | ... | |
792 | 764 |
conversation.commit(true); |
793 | 765 |
} |
794 | 766 |
if(featureUseRecord == null|| featureUseSummary == null) { |
795 |
TermVocabulary<Feature> featureVocabulary = (TermVocabulary<Feature>)vocabularyService.find((UUID.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8")));
|
|
767 |
TermVocabulary<Feature> featureVocabulary = vocabularyService.find((UUID.fromString("b187d555-f06f-4d65-9e53-da7c93f8eaa8"))); |
|
796 | 768 |
FeatureTree palmWebFeatureTree = featureTreeService.find(UUID.fromString("72ccce05-7cc8-4dab-8e47-bf3f5fd848a0")); |
797 | 769 |
//List<FeatureTree> featureTrees = CdmStore.getService(IFeatureTreeService.class).list(FeatureTree.class, null, null, null, null); |
798 |
|
|
770 |
|
|
799 | 771 |
if (featureUseRecord == null ) { |
800 | 772 |
featureUseRecord = Feature.NewInstance("Use Record", "Use Record", null); |
801 | 773 |
featureUseRecord.setUuid(UUID.fromString("8125a59d-b4d5-4485-89ea-67306297b599")); |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelImportConfigurator.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 |
*/ |
... | ... | |
13 | 13 |
import java.lang.reflect.Method; |
14 | 14 |
import java.net.MalformedURLException; |
15 | 15 |
import java.net.URL; |
16 |
import java.util.HashSet; |
|
17 |
import java.util.Set; |
|
18 | 16 |
|
19 | 17 |
import org.apache.log4j.Logger; |
20 | 18 |
|
... | ... | |
26 | 24 |
import eu.etaxonomy.cdm.io.common.Source; |
27 | 25 |
import eu.etaxonomy.cdm.io.common.mapping.IInputTransformer; |
28 | 26 |
import eu.etaxonomy.cdm.model.name.NomenclaturalCode; |
29 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
30 | 27 |
|
31 | 28 |
/** |
32 | 29 |
* @author a.mueller |
33 | 30 |
* @created 20.03.2008 |
34 | 31 |
*/ |
35 | 32 |
public class BerlinModelImportConfigurator extends DbImportConfiguratorBase<BerlinModelImportState> implements IImportConfigurator{ |
36 |
private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class); |
|
33 |
private static final long serialVersionUID = 70300913255425256L; |
|
34 |
|
|
35 |
private static Logger logger = Logger.getLogger(BerlinModelImportConfigurator.class); |
|
37 | 36 |
|
38 | 37 |
public static BerlinModelImportConfigurator NewInstance(Source berlinModelSource, ICdmDataSource destination){ |
39 | 38 |
return new BerlinModelImportConfigurator(berlinModelSource, destination); |
40 | 39 |
} |
41 | 40 |
|
42 | 41 |
private PublishMarkerChooser taxonPublishMarker = PublishMarkerChooser.ALL; |
43 |
|
|
42 |
|
|
44 | 43 |
//TODO |
45 | 44 |
private static IInputTransformer defaultTransformer = null; |
46 |
|
|
45 |
|
|
47 | 46 |
private boolean doNameStatus = true; |
48 | 47 |
private boolean doRelNames = true; |
49 | 48 |
private boolean doCommonNames = true; |
... | ... | |
56 | 55 |
private DO_REFERENCES doReferences = DO_REFERENCES.ALL; |
57 | 56 |
private boolean doTaxonNames = true; |
58 | 57 |
private boolean doTypes = true; |
59 |
|
|
58 |
|
|
60 | 59 |
//taxa |
61 | 60 |
private boolean doTaxa = true; |
62 | 61 |
private boolean doRelTaxa = true; |
... | ... | |
64 | 63 |
private boolean useSingleClassification = false; |
65 | 64 |
private boolean includeFlatClassifications = false; //concepts with no taxon relationship (even no misapplied name or synonym rel) |
66 | 65 |
private boolean includeAllNonMisappliedRelatedClassifications = true; //all concepts with any relationship except for misapplied name relationships |
67 |
|
|
66 |
|
|
68 | 67 |
//occurrences |
69 | 68 |
private boolean isSplitTdwgCodes = true; |
70 |
|
|
69 |
|
|
71 | 70 |
private boolean useEmAreaVocabulary = false; |
72 | 71 |
|
73 | 72 |
private boolean includesEmCode = true; // in Campanula we do not have an EMCOde |
74 |
private boolean allowInfraSpecTaxonRank = true;
|
|
73 |
private boolean allowInfraSpecTaxonRank = true; |
|
75 | 74 |
|
76 | 75 |
private Method namerelationshipTypeMethod; |
77 | 76 |
private Method uuidForDefTermMethod; |
78 | 77 |
private Method nameTypeDesignationStatusMethod; |
79 |
|
|
80 |
private Set<Synonym> proParteSynonyms = new HashSet<Synonym>(); |
|
81 |
private Set<Synonym> partialSynonyms = new HashSet<Synonym>(); |
|
82 |
|
|
78 |
|
|
83 | 79 |
// NameFact stuff |
84 | 80 |
private URL mediaUrl; |
85 | 81 |
private File mediaPath; |
... | ... | |
87 | 83 |
private boolean isIgnore0AuthorTeam = false; |
88 | 84 |
|
89 | 85 |
private boolean switchSpeciesGroup = false; |
90 |
|
|
86 |
|
|
91 | 87 |
//Term labels |
92 | 88 |
private String infrGenericRankAbbrev = null; |
93 | 89 |
private String infrSpecificRankAbbrev = null; |
94 |
|
|
90 |
|
|
95 | 91 |
private boolean removeHttpMapsAnchor = false; |
96 |
|
|
92 |
|
|
97 | 93 |
//Data Filter |
98 | 94 |
|
99 | 95 |
private String taxonTable = "PTaxon"; |
... | ... | |
109 | 105 |
private String occurrenceFilter = null; |
110 | 106 |
private String occurrenceSourceFilter = null; |
111 | 107 |
private String webMarkerFilter = null; |
112 |
|
|
108 |
|
|
113 | 109 |
//specific functions |
114 | 110 |
private Method makeUrlForTaxon = null; |
115 | 111 |
|
116 |
protected void makeIoClassList(){ |
|
112 |
@Override |
|
113 |
protected void makeIoClassList(){ |
|
117 | 114 |
ioClassList = new Class[]{ |
118 | 115 |
BerlinModelGeneralImportValidator.class |
119 | 116 |
, BerlinModelUserImport.class |
... | ... | |
134 | 131 |
, BerlinModelOccurrenceSourceImport.class |
135 | 132 |
, BerlinModelWebMarkerCategoryImport.class |
136 | 133 |
, BerlinModelWebMarkerImport.class |
137 |
};
|
|
134 |
}; |
|
138 | 135 |
} |
139 |
|
|
140 |
|
|
141 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
142 | 139 |
/* (non-Javadoc) |
143 | 140 |
* @see eu.etaxonomy.cdm.io.common.IImportConfigurator#getNewState() |
144 | 141 |
*/ |
145 |
public BerlinModelImportState getNewState() { |
|
142 |
@Override |
|
143 |
public BerlinModelImportState getNewState() { |
|
146 | 144 |
return new BerlinModelImportState(this); |
147 | 145 |
} |
148 | 146 |
|
... | ... | |
156 | 154 |
protected BerlinModelImportConfigurator(Source berlinModelSource, ICdmDataSource destination) { |
157 | 155 |
super(berlinModelSource, destination, NomenclaturalCode.ICNAFP, defaultTransformer); //default for Berlin Model |
158 | 156 |
} |
159 |
|
|
160 |
|
|
157 |
|
|
158 |
|
|
161 | 159 |
/** |
162 | 160 |
* Import name relationships yes/no?. |
163 | 161 |
* @return |
... | ... | |
168 | 166 |
public void setDoRelNames(boolean doRelNames) { |
169 | 167 |
this.doRelNames = doRelNames; |
170 | 168 |
} |
171 |
|
|
172 |
|
|
173 |
|
|
174 |
protected void addProParteSynonym(Synonym proParteSynonym){ |
|
175 |
this.proParteSynonyms.add(proParteSynonym); |
|
176 |
} |
|
177 |
|
|
178 |
protected boolean isProParteSynonym(Synonym synonym){ |
|
179 |
return this.proParteSynonyms.contains(synonym); |
|
180 |
} |
|
181 |
|
|
182 |
protected void addPartialSynonym(Synonym partialSynonym){ |
|
183 |
this.partialSynonyms.add(partialSynonym); |
|
184 |
} |
|
185 |
|
|
186 |
protected boolean isPartialSynonym(Synonym synonym){ |
|
187 |
return this.partialSynonyms.contains(synonym); |
|
188 |
} |
|
189 | 169 |
|
190 | 170 |
/** |
191 | 171 |
* @return the mediaUrl |
... | ... | |
214 | 194 |
public void setMediaPath(File mediaPath) { |
215 | 195 |
this.mediaPath = mediaPath; |
216 | 196 |
} |
217 |
|
|
197 |
|
|
218 | 198 |
public void setMediaPath(String mediaPathString){ |
219 | 199 |
this.mediaPath = new File(mediaPathString); |
220 | 200 |
} |
... | ... | |
236 | 216 |
|
237 | 217 |
/** |
238 | 218 |
* set to 0 for unlimited |
239 |
*
|
|
219 |
* |
|
240 | 220 |
* @param maximumNumberOfNameFacts the maximumNumberOfNameFacts to set |
241 | 221 |
*/ |
242 | 222 |
public void setMaximumNumberOfNameFacts(int maximumNumberOfNameFacts) { |
... | ... | |
271 | 251 |
public void setNamerelationshipTypeMethod(Method namerelationshipTypeMethod) { |
272 | 252 |
this.namerelationshipTypeMethod = namerelationshipTypeMethod; |
273 | 253 |
} |
274 |
|
|
254 |
|
|
275 | 255 |
/** |
276 | 256 |
* @return the taxonPublishMarker |
277 | 257 |
*/ |
... | ... | |
321 | 301 |
Method nameTypeDesignationStatusMethod) { |
322 | 302 |
this.nameTypeDesignationStatusMethod = nameTypeDesignationStatusMethod; |
323 | 303 |
} |
324 |
|
|
304 |
|
|
325 | 305 |
public boolean isDoNameStatus() { |
326 | 306 |
return doNameStatus; |
327 | 307 |
} |
328 | 308 |
public void setDoNameStatus(boolean doNameStatus) { |
329 | 309 |
this.doNameStatus = doNameStatus; |
330 | 310 |
} |
331 |
|
|
332 |
|
|
311 |
|
|
312 |
|
|
333 | 313 |
public boolean isDoCommonNames() { |
334 | 314 |
return doCommonNames; |
335 | 315 |
} |
... | ... | |
340 | 320 |
*/ |
341 | 321 |
public void setDoCommonNames(boolean doCommonNames) { |
342 | 322 |
this.doCommonNames = doCommonNames; |
343 |
|
|
323 |
|
|
344 | 324 |
} |
345 |
|
|
325 |
|
|
346 | 326 |
public boolean isDoFacts() { |
347 | 327 |
return doFacts; |
348 | 328 |
} |
... | ... | |
350 | 330 |
this.doFacts = doFacts; |
351 | 331 |
} |
352 | 332 |
|
353 |
|
|
333 |
|
|
354 | 334 |
public boolean isDoOccurrence() { |
355 | 335 |
return doOccurrence; |
356 | 336 |
} |
... | ... | |
373 | 353 |
public void setDoUser(boolean doUser) { |
374 | 354 |
this.doUser = doUser; |
375 | 355 |
} |
376 |
|
|
356 |
|
|
377 | 357 |
public boolean isDoNameFacts() { |
378 | 358 |
return doNameFacts; |
379 | 359 |
} |
380 | 360 |
public void setDoNameFacts(boolean doNameFacts) { |
381 | 361 |
this.doNameFacts = doNameFacts; |
382 | 362 |
} |
383 |
|
|
363 |
|
|
384 | 364 |
public boolean isDoAuthors() { |
385 | 365 |
return doAuthors; |
386 | 366 |
} |
... | ... | |
394 | 374 |
public void setDoReferences(DO_REFERENCES doReferences) { |
395 | 375 |
this.doReferences = doReferences; |
396 | 376 |
} |
397 |
|
|
377 |
|
|
398 | 378 |
public boolean isDoTaxonNames() { |
399 | 379 |
return doTaxonNames; |
400 | 380 |
} |
... | ... | |
484 | 464 |
public String getFactFilter() { |
485 | 465 |
return factFilter; |
486 | 466 |
} |
487 |
|
|
467 |
|
|
488 | 468 |
public void setRefDetailFilter(String refDetailFilter) { |
489 | 469 |
this.refDetailFilter = refDetailFilter; |
490 | 470 |
} |
... | ... | |
620 | 600 |
} |
621 | 601 |
public void setIncludesEmCode(boolean includesEmCode) { |
622 | 602 |
this.includesEmCode = includesEmCode; |
623 |
|
|
603 |
|
|
624 | 604 |
} |
625 | 605 |
|
626 | 606 |
|
... | ... | |
639 | 619 |
this.includeAllNonMisappliedRelatedClassifications = includeAllNonMisappliedRelatedClassifications; |
640 | 620 |
} |
641 | 621 |
|
642 |
|
|
622 |
|
|
643 | 623 |
public boolean isUseEmAreaVocabulary() { |
644 | 624 |
return useEmAreaVocabulary; |
645 | 625 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonImport.java | ||
---|---|---|
186 | 186 |
synonym = Synonym.NewInstance(taxonName, reference); |
187 | 187 |
taxonBase = synonym; |
188 | 188 |
if (statusFk == T_STATUS_PRO_PARTE_SYN){ |
189 |
config.addProParteSynonym(synonym);
|
|
189 |
synonym.setProParte(true);
|
|
190 | 190 |
} |
191 | 191 |
if (statusFk == T_STATUS_PARTIAL_SYN){ |
192 |
config.addPartialSynonym(synonym);
|
|
192 |
synonym.setPartial(true);
|
|
193 | 193 |
} |
194 | 194 |
}else{ |
195 | 195 |
logger.warn("TaxonStatus " + statusFk + " not yet implemented. Taxon (RIdentifier = " + taxonId + ") left out."); |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/in/BerlinModelTaxonRelationImport.java | ||
---|---|---|
46 | 46 |
import eu.etaxonomy.cdm.model.reference.Reference; |
47 | 47 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
48 | 48 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
49 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; |
|
50 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; |
|
49 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
51 | 50 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
52 | 51 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
53 | 52 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
... | ... | |
299 | 298 |
} |
300 | 299 |
handleAllRelatedTaxa(state, toTaxon, classificationMap, treeRefFk); |
301 | 300 |
Synonym synonym = (Synonym)taxon1; |
302 |
SynonymRelationship synRel = getSynRel(relQualifierFk, toTaxon, synonym, citation, microcitation); |
|
303 |
taxonRelationship = synRel; |
|
301 |
makeSynRel(relQualifierFk, toTaxon, synonym, citation, microcitation); |
|
302 |
if (isNotBlank(notes)){ |
|
303 |
logger.warn("Notes for synonym relationship or unknown taxon relationship not handled"); |
|
304 |
} |
|
304 | 305 |
|
305 | 306 |
if (relQualifierFk == TAX_REL_IS_SYNONYM_OF || |
306 | 307 |
relQualifierFk == TAX_REL_IS_HOMOTYPIC_SYNONYM_OF || |
307 | 308 |
relQualifierFk == TAX_REL_IS_HETEROTYPIC_SYNONYM_OF){ |
308 |
addProParteAndPartial(synRel, synonym, config);
|
|
309 |
//pro parte already set by taxon mapping
|
|
309 | 310 |
}else if (relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF || |
310 | 311 |
relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF || |
311 | 312 |
relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF ){ |
312 |
synRel.setProParte(true);
|
|
313 |
synonym.setProParte(true);
|
|
313 | 314 |
}else if(relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF || |
314 | 315 |
relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF || |
315 | 316 |
relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF ){ |
316 |
synRel.setPartial(true);
|
|
317 |
synonym.setPartial(true);
|
|
317 | 318 |
}else{ |
318 | 319 |
success = false; |
319 | 320 |
logger.warn("Proparte/Partial not yet implemented for TaxonRelationShipType " + relQualifierFk); |
... | ... | |
343 | 344 |
} |
344 | 345 |
} catch (UnknownCdmTypeException e) { |
345 | 346 |
logger.warn("TaxonRelationShipType " + relQualifierFk + " (conceptRelationship) not yet implemented"); |
346 |
success = false; |
|
347 |
success = false;
|
|
347 | 348 |
} |
348 | 349 |
}else { |
349 | 350 |
logger.warn("TaxonRelationShipType " + relQualifierFk + " not yet implemented: RelPTaxonId = " + relPTaxonId ); |
350 | 351 |
success = false; |
351 | 352 |
} |
352 | 353 |
|
353 |
doNotes(taxonRelationship, notes); |
|
354 |
if (taxonRelationship != null){ |
|
355 |
doNotes(taxonRelationship, notes); |
|
356 |
}else if (isNotBlank(notes)){ |
|
357 |
logger.warn("Notes for synonym relationship or unknown taxon relationship not handled"); |
|
358 |
} |
|
354 | 359 |
taxaToSave.add(taxon2); |
355 | 360 |
|
356 | 361 |
//TODO |
... | ... | |
548 | 553 |
} |
549 | 554 |
|
550 | 555 |
|
551 |
private SynonymRelationship getSynRel (int relQualifierFk, Taxon toTaxon, Synonym synonym, Reference citation, String microcitation){ |
|
552 |
SynonymRelationship result; |
|
553 |
if (relQualifierFk == TAX_REL_IS_HOMOTYPIC_SYNONYM_OF || |
|
556 |
private void makeSynRel (int relQualifierFk, Taxon toTaxon, Synonym synonym, Reference citation, String microcitation){ |
|
557 |
if (citation != null && !citation.equals(synonym.getSec())){ |
|
558 |
logger.warn("A synonym relationship citation is given and differs from synonym secundum. This can not be handled in CDM"); |
|
559 |
} |
|
560 |
if (isNotBlank(microcitation) && !microcitation.equals(synonym.getSecMicroReference())){ |
|
561 |
logger.warn("A synonym relationship microcitation is given and differs from synonym secundum micro reference. This can not be handled in CDM"); |
|
562 |
} |
|
563 |
if (relQualifierFk == TAX_REL_IS_HOMOTYPIC_SYNONYM_OF || |
|
554 | 564 |
relQualifierFk == TAX_REL_IS_PROPARTE_HOMOTYPIC_SYNONYM_OF || |
555 | 565 |
relQualifierFk == TAX_REL_IS_PARTIAL_HOMOTYPIC_SYNONYM_OF){ |
556 |
result = toTaxon.addHomotypicSynonym(synonym, citation, microcitation);
|
|
566 |
toTaxon.addHomotypicSynonym(synonym);
|
|
557 | 567 |
}else if (relQualifierFk == TAX_REL_IS_HETEROTYPIC_SYNONYM_OF || |
558 | 568 |
relQualifierFk == TAX_REL_IS_PROPARTE_HETEROTYPIC_SYNONYM_OF || |
559 | 569 |
relQualifierFk == TAX_REL_IS_PARTIAL_HETEROTYPIC_SYNONYM_OF){ |
560 |
result = toTaxon.addSynonym(synonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), citation, microcitation);
|
|
570 |
toTaxon.addSynonym(synonym, SynonymType.HETEROTYPIC_SYNONYM_OF());
|
|
561 | 571 |
}else if (relQualifierFk == TAX_REL_IS_SYNONYM_OF || |
562 | 572 |
relQualifierFk == TAX_REL_IS_PROPARTE_SYN_OF || |
563 | 573 |
relQualifierFk == TAX_REL_IS_PARTIAL_SYN_OF){ |
564 |
result = toTaxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF(), citation, microcitation);
|
|
574 |
toTaxon.addSynonym(synonym, SynonymType.SYNONYM_OF());
|
|
565 | 575 |
}else{ |
566 | 576 |
logger.warn("SynonymyRelationShipType could not be defined for relQualifierFk " + relQualifierFk + ". 'Unknown'-Type taken instead."); |
567 |
result = toTaxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF(), citation, microcitation);
|
|
577 |
toTaxon.addSynonym(synonym, SynonymType.SYNONYM_OF());
|
|
568 | 578 |
} |
569 |
return result;
|
|
579 |
return; |
|
570 | 580 |
|
571 | 581 |
} |
572 | 582 |
|
... | ... | |
596 | 606 |
} |
597 | 607 |
} |
598 | 608 |
|
599 |
private void addProParteAndPartial(SynonymRelationship synRel, Synonym synonym, BerlinModelImportConfigurator bmiConfig){ |
|
600 |
if (bmiConfig.isPartialSynonym(synonym)){ |
|
601 |
synRel.setPartial(true); |
|
602 |
} |
|
603 |
if (bmiConfig.isProParteSynonym(synonym)){ |
|
604 |
synRel.setProParte(true); |
|
605 |
} |
|
606 |
} |
|
607 |
|
|
608 | 609 |
private TaxonNode makeTaxonomicallyIncluded(BerlinModelImportState state, Map<Integer, Classification> classificationMap, int treeRefFk, Taxon child, Taxon parent, Reference citation, String microCitation){ |
609 | 610 |
Classification tree = getClassificationTree(state, classificationMap, treeRefFk); |
610 | 611 |
return tree.addParentChild(parent, child, citation, microCitation); |
app-import/src/main/java/eu/etaxonomy/cdm/io/berlinModel/out/BerlinModelTaxonRelationExport.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 |
*/ |
... | ... | |
25 | 25 |
import eu.etaxonomy.cdm.io.common.mapping.out.MethodMapper; |
26 | 26 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
27 | 27 |
import eu.etaxonomy.cdm.model.common.RelationshipBase; |
28 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; |
|
29 | 28 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
30 | 29 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationship; |
31 | 30 |
|
... | ... | |
48 | 47 |
public BerlinModelTaxonRelationExport(){ |
49 | 48 |
super(); |
50 | 49 |
} |
51 |
|
|
50 |
|
|
52 | 51 |
/* (non-Javadoc) |
53 | 52 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#doCheck(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
54 | 53 |
*/ |
... | ... | |
58 | 57 |
logger.warn("Checking for " + pluralString + " not yet implemented"); |
59 | 58 |
//result &= checkArticlesWithoutJournal(bmiConfig); |
60 | 59 |
//result &= checkPartOfJournal(bmiConfig); |
61 |
|
|
60 |
|
|
62 | 61 |
return result; |
63 | 62 |
} |
64 |
|
|
63 |
|
|
65 | 64 |
private CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> getMapping(){ |
66 | 65 |
String tableName = dbTableName; |
67 | 66 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = new CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer>(tableName); |
68 | 67 |
// mapping.addMapper(IdMapper.NewInstance("RelPTaxonId")); //is Identity column |
69 |
|
|
68 |
|
|
70 | 69 |
mapping.addMapper(MethodMapper.NewInstance("PTNameFk1", this.getClass(), "getPTNameFk1", standardMethodParameter, DbExportStateBase.class)); |
71 | 70 |
mapping.addMapper(MethodMapper.NewInstance("PTRefFk1", this.getClass(), "getPTRefFk1", standardMethodParameter, DbExportStateBase.class)); |
72 |
|
|
71 |
|
|
73 | 72 |
mapping.addMapper(MethodMapper.NewInstance("PTNameFk2", this.getClass(), "getPTNameFk2", standardMethodParameter, DbExportStateBase.class)); |
74 | 73 |
mapping.addMapper(MethodMapper.NewInstance("PTRefFk2", this.getClass(), "getPTRefFk2", standardMethodParameter, DbExportStateBase.class)); |
75 |
|
|
74 |
|
|
76 | 75 |
mapping.addMapper(MethodMapper.NewInstance("RelQualifierFk", this)); |
77 |
|
|
76 |
|
|
78 | 77 |
mapping.addMapper(DbObjectMapper.NewInstance("citation", "RelRefFk")); |
79 | 78 |
// mapping.addMapper(RefDetailMapper.NewInstance("citationMicroReference","citation", "FactRefDetailFk")); |
80 | 79 |
mapping.addMapper(CreatedAndNotesMapper.NewInstance()); |
81 | 80 |
|
82 | 81 |
return mapping; |
83 | 82 |
} |
84 |
|
|
85 |
protected void doInvoke(BerlinModelExportState state){ |
|
83 |
|
|
84 |
@Override |
|
85 |
protected void doInvoke(BerlinModelExportState state){ |
|
86 | 86 |
try{ |
87 | 87 |
logger.info("start make " + pluralString + " ..."); |
88 | 88 |
boolean success = true ; |
89 | 89 |
doDelete(state); |
90 |
|
|
90 |
|
|
91 | 91 |
TransactionStatus txStatus = startTransaction(true); |
92 |
|
|
92 |
|
|
93 | 93 |
List<RelationshipBase> list = getTaxonService().getAllRelationships(100000000, 0); |
94 |
|
|
94 |
|
|
95 | 95 |
CdmDbExportMapping<BerlinModelExportState, BerlinModelExportConfigurator, IExportTransformer> mapping = getMapping(); |
96 | 96 |
mapping.initialize(state); |
97 |
|
|
97 |
|
|
98 | 98 |
int count = 0; |
99 | 99 |
for (RelationshipBase<?,?,?> rel : list){ |
100 | 100 |
if (rel.isInstanceOf(TaxonRelationship.class) || rel.isInstanceOf(SynonymRelationship.class)){ |
... | ... | |
116 | 116 |
} |
117 | 117 |
} |
118 | 118 |
|
119 |
|
|
119 |
|
|
120 | 120 |
protected boolean doDelete(BerlinModelExportState state){ |
121 | 121 |
BerlinModelExportConfigurator bmeConfig = state.getConfig(); |
122 |
|
|
122 |
|
|
123 | 123 |
String sql; |
124 | 124 |
Source destination = bmeConfig.getDestination(); |
125 | 125 |
//RelPTaxon |
... | ... | |
129 | 129 |
|
130 | 130 |
return true; |
131 | 131 |
} |
132 |
|
|
133 |
|
|
132 |
|
|
133 |
|
|
134 | 134 |
/* (non-Javadoc) |
135 | 135 |
* @see eu.etaxonomy.cdm.io.common.CdmIoBase#isIgnore(eu.etaxonomy.cdm.io.common.IImportConfigurator) |
136 | 136 |
*/ |
137 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
137 |
@Override |
|
138 |
protected boolean isIgnore(BerlinModelExportState state){ |
|
138 | 139 |
return ! state.getConfig().isDoRelTaxa(); |
139 | 140 |
} |
140 |
|
|
141 |
|
|
141 | 142 |
//called by MethodMapper |
142 | 143 |
@SuppressWarnings("unused") |
143 | 144 |
private static Integer getRelQualifierFk(RelationshipBase<?, ?, ?> rel){ |
144 | 145 |
return BerlinModelTransformer.taxRelation2relPtQualifierFk(rel); |
145 | 146 |
} |
146 |
|
|
147 |
|
|
147 | 148 |
@SuppressWarnings("unused") |
148 | 149 |
private static Integer getPTNameFk1(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
149 | 150 |
return getObjectFk(rel, state, true, true); |
150 | 151 |
} |
151 |
|
|
152 |
|
|
152 | 153 |
@SuppressWarnings("unused") |
153 | 154 |
private static Integer getPTRefFk1(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
154 | 155 |
return getObjectFk(rel, state, false, true); |
155 | 156 |
} |
156 |
|
|
157 |
|
|
157 | 158 |
@SuppressWarnings("unused") |
158 | 159 |
private static Integer getPTNameFk2(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
159 | 160 |
return getObjectFk(rel, state, true, false); |
160 | 161 |
} |
161 |
|
|
162 |
|
|
162 | 163 |
@SuppressWarnings("unused") |
163 | 164 |
private static Integer getPTRefFk2(RelationshipBase<?, ?, ?> rel, DbExportStateBase<?, IExportTransformer> state){ |
164 | 165 |
return getObjectFk(rel, state, false, false); |
... | ... | |
180 | 181 |
logger.warn("No taxon found for relationship: " + rel.toString()); |
181 | 182 |
return null; |
182 | 183 |
} |
183 |
|
|
184 |
|
|
184 |
|
|
185 |
|
|
185 | 186 |
/* (non-Javadoc) |
186 | 187 |
* @see eu.etaxonomy.cdm.io.berlinModel.out.BerlinModelExportBase#getStandardMethodParameter() |
187 | 188 |
*/ |
app-import/src/main/java/eu/etaxonomy/cdm/io/caryo/CaryoTaxonImport.java | ||
---|---|---|
45 | 45 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
46 | 46 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
47 | 47 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
48 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
|
48 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
49 | 49 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
50 | 50 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
51 | 51 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
... | ... | |
203 | 203 |
} |
204 | 204 |
name.addBasionym(basionym); |
205 | 205 |
Synonym syn = Synonym.NewInstance(basionym, state.getTransactionalSourceReference()); |
206 |
taxon.addSynonym(syn, SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF());
|
|
206 |
taxon.addSynonym(syn, SynonymType.HOMOTYPIC_SYNONYM_OF()); |
|
207 | 207 |
getTaxonService().save(syn); |
208 | 208 |
} |
209 | 209 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/cuba/CubaExcelImport.java | ||
---|---|---|
58 | 58 |
import eu.etaxonomy.cdm.model.reference.ReferenceFactory; |
59 | 59 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
60 | 60 |
import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; |
61 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationship;
|
|
62 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
|
61 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
|
62 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
63 | 63 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
64 | 64 |
import eu.etaxonomy.cdm.model.taxon.TaxonNode; |
65 | 65 |
import eu.etaxonomy.cdm.model.taxon.TaxonRelationshipType; |
... | ... | |
429 | 429 |
name.addSource(makeOriginalSource(state)); |
430 | 430 |
NomenclaturalStatus status = NomenclaturalStatus.NewInstance( NomenclaturalStatusType.INVALID()); |
431 | 431 |
name.addStatus(status); |
432 |
SynonymRelationship sr = state.getCurrentTaxon().addSynonymName(name, SynonymRelationshipType.SYNONYM_OF());
|
|
433 |
sr.getSynonym().addSource(makeOriginalSource(state));
|
|
432 |
Synonym syn = state.getCurrentTaxon().addSynonymName(name, SynonymType.SYNONYM_OF());
|
|
433 |
syn.addSource(makeOriginalSource(state));
|
|
434 | 434 |
}else if (sphalmMatcher.matches()){ |
435 | 435 |
String firstPart = sphalmMatcher.group(1); |
436 | 436 |
String sphalmPart = synonymStr.replace(firstPart, "").replace("“","").replace("”","").trim(); |
... | ... | |
438 | 438 |
// NomenclaturalStatus status = NomenclaturalStatus.NewInstance( NomenclaturalStatusType.INVALID()); |
439 | 439 |
// name.addStatus(status); |
440 | 440 |
name.addSource(makeOriginalSource(state)); |
441 |
SynonymRelationship sr = state.getCurrentTaxon().addSynonymName(name, SynonymRelationshipType.SYNONYM_OF());
|
|
442 |
sr.getSynonym().setAppendedPhrase(sphalmPart);
|
|
443 |
sr.getSynonym().setSec(null);
|
|
444 |
sr.getSynonym().addSource(makeOriginalSource(state));
|
|
441 |
Synonym syn = state.getCurrentTaxon().addSynonymName(name, SynonymType.SYNONYM_OF());
|
|
442 |
syn.setAppendedPhrase(sphalmPart);
|
|
443 |
syn.setSec(null);
|
|
444 |
syn.addSource(makeOriginalSource(state));
|
|
445 | 445 |
}else if (acceptedMatcher.matches()){ |
446 | 446 |
String firstPart = acceptedMatcher.group(1); |
447 | 447 |
String homonymPart = acceptedMatcher.groupCount() < 2 ? null : acceptedMatcher.group(2); |
... | ... | |
461 | 461 |
if (isHomonym){ |
462 | 462 |
homonyms.add(synName); |
463 | 463 |
} |
464 |
SynonymRelationship sr = state.getCurrentTaxon().addHeterotypicSynonymName(synName);
|
|
465 |
sr.getSynonym().setDoubtful(isDoubtful);
|
|
466 |
sr.getSynonym().addSource(makeOriginalSource(state));
|
|
464 |
Synonym syn = state.getCurrentTaxon().addHeterotypicSynonymName(synName);
|
|
465 |
syn.setDoubtful(isDoubtful);
|
|
466 |
syn.addSource(makeOriginalSource(state));
|
|
467 | 467 |
List<BotanicalName> list = handleHomotypicGroup(secondPart, state, synName, true, homonyms, homonymPart, isDoubtful); |
468 | 468 |
checkFirstSynonym(state, list, isFirstSynonym, synonymStr, true); |
469 | 469 |
|
... | ... | |
472 | 472 |
if (synName.isProtectedTitleCache()){ |
473 | 473 |
logger.warn(line + "Special heterotypic synonym could not be parsed correctly:" + synonymStr); |
474 | 474 |
} |
475 |
SynonymRelationship sr = state.getCurrentTaxon().addHeterotypicSynonymName(synName);
|
|
476 |
sr.getSynonym().addSource(makeOriginalSource(state));
|
|
475 |
Synonym syn = state.getCurrentTaxon().addHeterotypicSynonymName(synName);
|
|
476 |
syn.addSource(makeOriginalSource(state));
|
|
477 | 477 |
}else{ |
478 | 478 |
logger.warn(line + "Synonym entry does not match: " + synonymStr); |
479 | 479 |
} |
... | ... | |
615 | 615 |
homonyms.add(newName); |
616 | 616 |
} |
617 | 617 |
if (isHeterotypic){ |
618 |
SynonymRelationship sr = state.getCurrentTaxon().addHeterotypicSynonymName(newName, homotypicGroup, null, null);
|
|
619 |
sr.getSynonym().setDoubtful(isDoubtful);
|
|
620 |
sr.getSynonym().addSource(makeOriginalSource(state));
|
|
618 |
Synonym syn = state.getCurrentTaxon().addHeterotypicSynonymName(newName, null, null, homotypicGroup);
|
|
619 |
syn.setDoubtful(isDoubtful);
|
|
620 |
syn.addSource(makeOriginalSource(state));
|
|
621 | 621 |
// newName.addBasionym(homotypicName); |
622 | 622 |
}else{ |
623 |
state.getCurrentTaxon().addHomotypicSynonymName(newName, null, null);
|
|
623 |
state.getCurrentTaxon().addHomotypicSynonymName(newName); |
|
624 | 624 |
} |
625 | 625 |
handleBasionym(state, homotypicNameList, homonyms, newName); |
626 | 626 |
homotypicNameList.add(newName); |
app-import/src/main/java/eu/etaxonomy/cdm/io/cyprus/CyprusExcelImport.java | ||
---|---|---|
39 | 39 |
import eu.etaxonomy.cdm.model.reference.Reference; |
40 | 40 |
import eu.etaxonomy.cdm.model.taxon.Classification; |
41 | 41 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
42 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
|
42 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
43 | 43 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
44 | 44 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
45 | 45 |
import eu.etaxonomy.cdm.strategy.parser.INonViralNameParser; |
... | ... | |
333 | 333 |
if (! speciesIsExisting){ |
334 | 334 |
makeHigherTaxa(state, taxonLight, speciesTaxon, citation, microCitation); |
335 | 335 |
} |
336 |
makeHomotypicSynonyms(state, citation, microCitation, homotypicSynonymList, mainTaxon);
|
|
337 |
makeHeterotypicSynonyms(state, citation, microCitation, heterotypicSynonymList, mainTaxon);
|
|
336 |
makeHomotypicSynonyms(state, homotypicSynonymList, mainTaxon); |
|
337 |
makeHeterotypicSynonyms(state, heterotypicSynonymList, mainTaxon); |
|
338 | 338 |
makeSystematics(systematicsString, mainTaxon); |
339 | 339 |
makeEndemism(endemismString, mainTaxon); |
340 | 340 |
makeStatus(statusString, mainTaxon); |
... | ... | |
378 | 378 |
|
379 | 379 |
|
380 | 380 |
private void makeHomotypicSynonyms(CyprusImportState state, |
381 |
Reference citation, String microCitation, List<String> homotypicSynonymList, Taxon mainTaxon) {
|
|
381 |
List<String> homotypicSynonymList, Taxon mainTaxon) { |
|
382 | 382 |
for (String homotypicSynonym: homotypicSynonymList){ |
383 | 383 |
if (StringUtils.isNotBlank(homotypicSynonym)){ |
384 | 384 |
Synonym synonym = (Synonym)createTaxon(state, null, homotypicSynonym, Synonym.class, nc); |
385 |
mainTaxon.addHomotypicSynonym(synonym, citation, microCitation);
|
|
385 |
mainTaxon.addHomotypicSynonym(synonym); |
|
386 | 386 |
} |
387 | 387 |
} |
388 | 388 |
} |
389 | 389 |
|
390 | 390 |
|
391 |
private void makeHeterotypicSynonyms(CyprusImportState state, Reference citation, String microCitation, List<String> heterotypicSynonymList, Taxon mainTaxon) {
|
|
391 |
private void makeHeterotypicSynonyms(CyprusImportState state, List<String> heterotypicSynonymList, Taxon mainTaxon) { |
|
392 | 392 |
for (String heterotypicSynonym: heterotypicSynonymList){ |
393 | 393 |
if (StringUtils.isNotBlank(heterotypicSynonym)){ |
394 | 394 |
Synonym synonym = (Synonym)createTaxon(state, null, heterotypicSynonym, Synonym.class, nc); |
395 |
mainTaxon.addSynonym(synonym, SynonymRelationshipType.HETEROTYPIC_SYNONYM_OF(), citation, microCitation);
|
|
395 |
mainTaxon.addSynonym(synonym, SynonymType.HETEROTYPIC_SYNONYM_OF());
|
|
396 | 396 |
} |
397 | 397 |
} |
398 | 398 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseClassificationImport.java | ||
---|---|---|
128 | 128 |
// logger.warn(message); |
129 | 129 |
// }else{ |
130 | 130 |
// Taxon accepted = CdmBase.deproxy(parent, Taxon.class); |
131 |
//// accepted.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF());
|
|
131 |
//// accepted.addSynonym(synonym, SynonymType.SYNONYM_OF()); |
|
132 | 132 |
// taxaToSave.add(accepted); |
133 | 133 |
// } |
134 | 134 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/edaphobase/EdaphobaseSynonymyImport.java | ||
---|---|---|
24 | 24 |
import eu.etaxonomy.cdm.model.common.CdmBase; |
25 | 25 |
import eu.etaxonomy.cdm.model.reference.Reference; |
26 | 26 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
27 |
import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType;
|
|
27 |
import eu.etaxonomy.cdm.model.taxon.SynonymType; |
|
28 | 28 |
import eu.etaxonomy.cdm.model.taxon.Taxon; |
29 | 29 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase; |
30 | 30 |
|
... | ... | |
41 | 41 |
|
42 | 42 |
private static final String tableName = "tax_synonym"; |
43 | 43 |
|
44 |
private static final String pluralString = "synonym relationships";
|
|
44 |
private static final String pluralString = "related synonyms";
|
|
45 | 45 |
|
46 | 46 |
|
47 | 47 |
/** |
... | ... | |
92 | 92 |
if (synonymCandidate == null){ |
93 | 93 |
logger.warn("Synonym " + synId + " not found for synonymRelations (tax_synonym): " + id); |
94 | 94 |
}else if (synonymCandidate.isInstanceOf(Taxon.class)){ |
95 |
String message = "Synonym ("+synId+") is not synonym but accepted (valid). Can't add synonym relationship for tax_synonym: "+id;
|
|
95 |
String message = "Synonym ("+synId+") is not synonym but accepted (valid). Can't add synonym for tax_synonym: "+id; |
|
96 | 96 |
logger.warn(message); |
97 | 97 |
}else{ |
98 | 98 |
Synonym synonym = CdmBase.deproxy(synonymCandidate, Synonym.class); |
... | ... | |
100 | 100 |
if (accepted == null){ |
101 | 101 |
logger.warn("Accepted(parent) taxon " + accId + " not found for tax_synonym " + id ); |
102 | 102 |
}else if(accepted.isInstanceOf(Synonym.class)){ |
103 |
String message = "Taxon ("+accId+") is not accepted but synonym. Can't add synonym relationship for tax_synonym: "+id;
|
|
103 |
String message = "Taxon ("+accId+") is not accepted but synonym. Can't add synonym for tax_synonym: "+id; |
|
104 | 104 |
logger.warn(message); |
105 | 105 |
}else{ |
106 | 106 |
Taxon taxon = CdmBase.deproxy(accepted, Taxon.class); |
107 |
taxon.addSynonym(synonym, SynonymRelationshipType.SYNONYM_OF());
|
|
107 |
taxon.addSynonym(synonym, SynonymType.SYNONYM_OF()); |
|
108 | 108 |
taxaToSave.add(synonym); |
109 | 109 |
taxaToSave.add(taxon); |
110 | 110 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/globis/GlobisSpecTaxImport.java | ||
---|---|---|
54 | 54 |
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationType; |
55 | 55 |
import eu.etaxonomy.cdm.model.reference.Reference; |
56 | 56 |
import eu.etaxonomy.cdm.model.taxon.Synonym; |
Also available in: Unified diff
ref #5974 Remove synonym relationships (not finished yet)