continue;\r
}\r
\r
+ DescriptionElementBase deb;\r
+\r
if (state.getConfig().isMcl()) {\r
if (categoryFkInt.equals(20)) {\r
- handleMclState(state, taxonDescription, fact);\r
+ deb = handleMclState(state, taxonDescription, fact);\r
}else if (categoryFkInt.equals(21)) {\r
- handleMclDistribution(state, taxonDescription, fact);\r
+ deb = handleMclDistribution(state, taxonDescription, fact);\r
}else {\r
throw new RuntimeException("Unhandled fact category: " + categoryFkInt);\r
}\r
continue;\r
+ }else {\r
+\r
+ //textData\r
+ TextData textData = null;\r
+ boolean newTextData = true;\r
+\r
+ // For Cichorieae DB: If fact category is 31 (Systematics) and there is already a Systematics TextData\r
+ // description element append the fact text to the existing TextData\r
+ if(categoryFkInt.equals(31)) {\r
+ Set<DescriptionElementBase> descriptionElements = taxonDescription.getElements();\r
+ for (DescriptionElementBase descriptionElement : descriptionElements) {\r
+ String featureString = descriptionElement.getFeature().getRepresentation(Language.DEFAULT()).getLabel();\r
+ if (descriptionElement instanceof TextData && featureString.equals("Systematics")) { // TODO: test\r
+ textData = (TextData)descriptionElement;\r
+ String factTextStr = textData.getText(Language.DEFAULT());\r
+ // FIXME: Removing newlines doesn't work\r
+ if (factTextStr.contains("\\r\\n")) {\r
+ factTextStr = factTextStr.replaceAll("\\r\\n","");\r
+ }\r
+ StringBuilder factText = new StringBuilder(factTextStr);\r
+ factText.append(fact);\r
+ fact = factText.toString();\r
+ newTextData = false;\r
+ break;\r
+ }\r
+ }\r
+ }\r
+\r
+ if (taxonDescription.isImageGallery()){\r
+ newTextData = false;\r
+ textData = (TextData)taxonDescription.getElements().iterator().next();\r
+ }\r
+ if(newTextData == true) {\r
+ textData = TextData.NewInstance();\r
+ }else if (textData == null){\r
+ throw new RuntimeException("Textdata must not be null"); //does not happen, only to avoid potential NPE warnings\r
+ }\r
+\r
+\r
+ //for diptera database\r
+ if (categoryFkInt.equals(99) && notes.contains("<OriginalName>")){\r
+ fact = notes + ": " + fact ;\r
+ }\r
+ //for E+M maps\r
+ if (categoryFkInt.equals(14) && state.getConfig().isRemoveHttpMapsAnchor() && fact.contains("<a href")){\r
+ //example <a href="http://euromed.luomus.fi/euromed_map.php?taxon=280629&size=medium">distribution</a>\r
+ fact = fact.replace("<a href=\"", "").replace("\">distribution</a>", "");\r
+ }\r
+\r
+ //TODO textData.putText(fact, bmiConfig.getFactLanguage()); //doesn't work because bmiConfig.getFactLanguage() is not not a persistent Language Object\r
+ //throws in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.common.Language; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.common.Language\r
+\r
+ Language lang = Language.DEFAULT();\r
+ if (state.getConfig().isSalvador()){\r
+ lang = getSalvadorFactLanguage(categoryFkInt);\r
+ }\r
+ if (! taxonDescription.isImageGallery()){\r
+ textData.putText(lang, fact);\r
+ textData.setFeature(feature);\r
+ }\r
+\r
+ deb = textData;\r
+\r
+ if (state.getConfig().isSalvador()){\r
+ if (categoryFkInt == 306){\r
+ NamedArea area = null; // for now we do not set an area as it can not be disabled in dataportals via css yet\r
+ deb = CommonTaxonName.NewInstance(fact, Language.SPANISH_CASTILIAN(), area);\r
+ }else if (categoryFkInt == 307){\r
+ Distribution salvadorDistribution = salvadorDistributionFromMuestrasDeHerbar(state, (Taxon)taxonBase, fact);\r
+ if (salvadorDistribution != null){\r
+ //id\r
+ doId(state, salvadorDistribution, factId, "Fact");\r
+ mergeSalvadorDistribution(taxonDescription, salvadorDistribution);\r
+ }\r
+ }\r
+ }\r
}\r
\r
- //textData\r
- TextData textData = null;\r
- boolean newTextData = true;\r
-\r
- // For Cichorieae DB: If fact category is 31 (Systematics) and there is already a Systematics TextData\r
- // description element append the fact text to the existing TextData\r
- if(categoryFkInt.equals(31)) {\r
- Set<DescriptionElementBase> descriptionElements = taxonDescription.getElements();\r
- for (DescriptionElementBase descriptionElement : descriptionElements) {\r
- String featureString = descriptionElement.getFeature().getRepresentation(Language.DEFAULT()).getLabel();\r
- if (descriptionElement instanceof TextData && featureString.equals("Systematics")) { // TODO: test\r
- textData = (TextData)descriptionElement;\r
- String factTextStr = textData.getText(Language.DEFAULT());\r
- // FIXME: Removing newlines doesn't work\r
- if (factTextStr.contains("\\r\\n")) {\r
- factTextStr = factTextStr.replaceAll("\\r\\n","");\r
- }\r
- StringBuilder factText = new StringBuilder(factTextStr);\r
- factText.append(fact);\r
- fact = factText.toString();\r
- newTextData = false;\r
- break;\r
- }\r
- }\r
- }\r
-\r
- if (taxonDescription.isImageGallery()){\r
- newTextData = false;\r
- textData = (TextData)taxonDescription.getElements().iterator().next();\r
- }\r
- if(newTextData == true) {\r
- textData = TextData.NewInstance();\r
- }else if (textData == null){\r
- throw new RuntimeException("Textdata must not be null"); //does not happen, only to avoid potential NPE warnings\r
- }\r
-\r
-\r
- //for diptera database\r
- if (categoryFkInt.equals(99) && notes.contains("<OriginalName>")){\r
- fact = notes + ": " + fact ;\r
- }\r
- //for E+M maps\r
- if (categoryFkInt.equals(14) && state.getConfig().isRemoveHttpMapsAnchor() && fact.contains("<a href")){\r
- //example <a href="http://euromed.luomus.fi/euromed_map.php?taxon=280629&size=medium">distribution</a>\r
- fact = fact.replace("<a href=\"", "").replace("\">distribution</a>", "");\r
- }\r
-\r
- //TODO textData.putText(fact, bmiConfig.getFactLanguage()); //doesn't work because bmiConfig.getFactLanguage() is not not a persistent Language Object\r
- //throws in thread "main" org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.common.Language; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: eu.etaxonomy.cdm.model.common.Language\r
-\r
- Language lang = Language.DEFAULT();\r
- if (state.getConfig().isSalvador()){\r
- lang = getSalvadorFactLanguage(categoryFkInt);\r
- }\r
- if (! taxonDescription.isImageGallery()){\r
- textData.putText(lang, fact);\r
- textData.setFeature(feature);\r
- }\r
-\r
- DescriptionElementBase deb = textData;\r
-\r
- if (state.getConfig().isSalvador()){\r
- if (categoryFkInt == 306){\r
- NamedArea area = null; // for now we do not set an area as it can not be disabled in dataportals via css yet\r
- deb = CommonTaxonName.NewInstance(fact, Language.SPANISH_CASTILIAN(), area);\r
- }else if (categoryFkInt == 307){\r
- Distribution salvadorDistribution = salvadorDistributionFromMuestrasDeHerbar(state, (Taxon)taxonBase, fact);\r
- if (salvadorDistribution != null){\r
- //id\r
- doId(state, salvadorDistribution, factId, "Fact");\r
- mergeSalvadorDistribution(taxonDescription, salvadorDistribution);\r
- }\r
- }\r
- }\r
-\r
\r
//reference\r
Reference citation = null;\r
return success;\r
}\r
\r
- private void handleMclDistribution(BerlinModelImportState state, TaxonDescription taxonDescription, String fact) {\r
+ private Distribution handleMclDistribution(BerlinModelImportState state, TaxonDescription taxonDescription, String fact) {\r
String areaStr = fact.substring(0, 2);\r
NamedArea mclArea = mclAreaUuid(state, areaStr);\r
String statusStr = fact.substring(2);\r
\r
Distribution distribution = Distribution.NewInstance(mclArea, status);\r
taxonDescription.addElement(distribution);\r
+ return distribution;\r
}\r
\r
private NamedArea mclAreaUuid(BerlinModelImportState state, String areaStr) {\r
}\r
}\r
\r
- private void handleMclState(BerlinModelImportState state, TaxonDescription taxonDescription, String fact) {\r
+ private Distribution handleMclState(BerlinModelImportState state, TaxonDescription taxonDescription, String fact) {\r
NamedArea mclArea = getNamedArea(state, UUID.fromString("f0500f01-0a59-4a6b-83cf-4070182f7266"), null, null, null, null, null, null, null, null);\r
PresenceAbsenceTerm status;\r
if (fact.equals("E")) {\r
status = PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA();\r
}else {\r
status = getPresenceTerm(state, BerlinModelTransformer.uuidStatusXenophyte,\r
- "Xenophyte", "Xenophyte in the overall area", "X", false, PresenceAbsenceTerm.PRESENT().getVocabulary());\r
+ "xenophyte", "Xenophyte in the overall area", "X", false, PresenceAbsenceTerm.PRESENT().getVocabulary());\r
}\r
Distribution distribution = Distribution.NewInstance(mclArea, status);\r
taxonDescription.addElement(distribution);\r
+ return distribution;\r
}\r
\r
private void mergeSalvadorDistribution(TaxonDescription taxonDescription,\r
return taxonDescription;\r
}\r
\r
-\r
- /**\r
- * @param categoryFk\r
- * @return\r
- */\r
private boolean isPublicFeature(Integer categoryFk) {\r
return ! (categoryFk == 1800 || categoryFk == 1900 || categoryFk == 2000);\r
}\r
\r
-\r
@Override\r
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs, BerlinModelImportState state) {\r
\r