18 |
18 |
|
19 |
19 |
import org.apache.log4j.Logger;
|
20 |
20 |
import org.springframework.stereotype.Component;
|
|
21 |
import org.springframework.transaction.TransactionStatus;
|
21 |
22 |
|
22 |
23 |
import eu.etaxonomy.cdm.api.service.ITermService;
|
23 |
24 |
import eu.etaxonomy.cdm.common.CdmUtils;
|
... | ... | |
84 |
85 |
|
85 |
86 |
|
86 |
87 |
private static List<String> expectedKeys= Arrays.asList(new String[]{
|
87 |
|
"Unique ID","Group","Family","Genus","Species","Species Author","Subspecies","Subspecies Author",
|
|
88 |
"Unique ID","uuid","Group","Family","Genus","Species","Species Author","Subspecies","Subspecies Author",
|
88 |
89 |
"IoI","NPi","SPi","Pe","StE","EC","NC","NE","NAe","WAe","Kik","KK","EAe",
|
89 |
90 |
STATUS,CHOROLOGICAL_CATEGOGY,LIFE_FORM,"A","C","G","H","M","P","R","W", "Taxon"
|
90 |
91 |
});
|
... | ... | |
98 |
99 |
return "valid taxa names";
|
99 |
100 |
}
|
100 |
101 |
|
|
102 |
|
|
103 |
private boolean isFirst = true;
|
|
104 |
private TransactionStatus tx = null;
|
101 |
105 |
/**
|
102 |
106 |
* {@inheritDoc}
|
103 |
107 |
*/
|
104 |
108 |
@Override
|
105 |
109 |
protected void firstPass(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
110 |
if (isFirst){
|
|
111 |
tx = this.startTransaction();
|
|
112 |
isFirst = false;
|
|
113 |
}
|
106 |
114 |
initAreaVocabulary(state);
|
107 |
115 |
initLifeformVocabulary(state);
|
108 |
116 |
initHabitatVocabulary(state);
|
... | ... | |
138 |
146 |
state.putTaxon(noStr, taxon);
|
139 |
147 |
}
|
140 |
148 |
|
|
149 |
|
|
150 |
@Override
|
|
151 |
protected void secondPass(SimpleExcelTaxonImportState<CONFIG> state) {
|
|
152 |
if (tx != null){
|
|
153 |
this.commitTransaction(tx);
|
|
154 |
tx = null;
|
|
155 |
}
|
|
156 |
}
|
|
157 |
|
|
158 |
|
141 |
159 |
boolean hasFeatureTree = false;
|
142 |
160 |
/**
|
143 |
161 |
* @param state
|
... | ... | |
373 |
391 |
String speciesAuthorStr = getValue(record, "Species Author");
|
374 |
392 |
String subSpeciesStr = getValue(record, "Subspecies");
|
375 |
393 |
String subSpeciesAuthorStr = getValue(record, "Subspecies Author");
|
|
394 |
String uuidStr = getValue(record, "uuid");
|
|
395 |
UUID uuid = UUID.fromString(uuidStr);
|
376 |
396 |
boolean isSubSpecies = isNotBlank(subSpeciesStr);
|
377 |
397 |
boolean isAutonym = isSubSpecies && speciesStr.equals(subSpeciesStr);
|
378 |
398 |
if (isSubSpecies && ! isAutonym && isBlank(subSpeciesAuthorStr)){
|
... | ... | |
399 |
419 |
Taxon taxon = Taxon.NewInstance(name, getSecReference(state));
|
400 |
420 |
taxon.addImportSource(noStr, getWorksheetName(), getSourceCitation(state), null);
|
401 |
421 |
// String parentStr = isSubSpecies ? makeSpeciesKey(genusStr, speciesStr, speciesAuthorStr) : genusStr;
|
|
422 |
taxon.setUuid(uuid);
|
402 |
423 |
String parentStr = genusStr;
|
403 |
424 |
boolean genusAsBefore = genusStr.equals(lastGenus);
|
404 |
425 |
boolean speciesAsBefore = speciesStr.equals(lastSpecies);
|
... | ... | |
906 |
927 |
//FIXME
|
907 |
928 |
// addMapping(greece, xx "mex_adm0", "iso", "MEX");
|
908 |
929 |
|
909 |
|
addArea(state, "IoI", "Ionian Islands", FloraHellenicaTransformer.uuidAreaIoI);
|
910 |
|
addArea(state, "NPi", "North Pindos", FloraHellenicaTransformer.uuidAreaNPi);
|
911 |
|
addArea(state, "SPi", "South Pindos", FloraHellenicaTransformer.uuidAreaSPi);
|
912 |
|
addArea(state, "Pe", "Peloponnisos", FloraHellenicaTransformer.uuidAreaPe);
|
913 |
|
addArea(state, "StE", "Sterea Ellas", FloraHellenicaTransformer.uuidAreaStE);
|
914 |
|
addArea(state, "EC", "East Central Greece", FloraHellenicaTransformer.uuidAreaEC);
|
915 |
|
addArea(state, "NC", "North Central Greece", FloraHellenicaTransformer.uuidAreaNC);
|
916 |
|
addArea(state, "NE", "North-East Greece", FloraHellenicaTransformer.uuidAreaNE);
|
917 |
|
addArea(state, "NAe", "North Aegean islands", FloraHellenicaTransformer.uuidAreaNAe);
|
918 |
|
addArea(state, "WAe", "West Aegean islands", FloraHellenicaTransformer.uuidAreaWAe);
|
919 |
|
addArea(state, "Kik", "Kiklades", FloraHellenicaTransformer.uuidAreaKik);
|
920 |
|
addArea(state, "KK", "Kriti and Karpathos", FloraHellenicaTransformer.uuidAreaKK);
|
921 |
|
addArea(state, "EAe", "East Aegean islands", FloraHellenicaTransformer.uuidAreaEAe);
|
|
930 |
addArea(state, "IoI", "Ionian Islands", 4, FloraHellenicaTransformer.uuidAreaIoI);
|
|
931 |
addArea(state, "NPi", "North Pindos", 13, FloraHellenicaTransformer.uuidAreaNPi);
|
|
932 |
addArea(state, "SPi", "South Pindos", 11, FloraHellenicaTransformer.uuidAreaSPi);
|
|
933 |
addArea(state, "Pe", "Peloponnisos", 1, FloraHellenicaTransformer.uuidAreaPe);
|
|
934 |
addArea(state, "StE", "Sterea Ellas", 12, FloraHellenicaTransformer.uuidAreaStE);
|
|
935 |
addArea(state, "EC", "East Central Greece", 5, FloraHellenicaTransformer.uuidAreaEC);
|
|
936 |
addArea(state, "NC", "North Central Greece", 2, FloraHellenicaTransformer.uuidAreaNC);
|
|
937 |
addArea(state, "NE", "North-East Greece", 10, FloraHellenicaTransformer.uuidAreaNE);
|
|
938 |
addArea(state, "NAe", "North Aegean islands", 7, FloraHellenicaTransformer.uuidAreaNAe);
|
|
939 |
addArea(state, "WAe", "West Aegean islands", 9, FloraHellenicaTransformer.uuidAreaWAe);
|
|
940 |
addArea(state, "Kik", "Kiklades", 8, FloraHellenicaTransformer.uuidAreaKik);
|
|
941 |
addArea(state, "KK", "Kriti and Karpathos", 6, FloraHellenicaTransformer.uuidAreaKK);
|
|
942 |
addArea(state, "EAe", "East Aegean islands", 3, FloraHellenicaTransformer.uuidAreaEAe);
|
922 |
943 |
|
923 |
944 |
this.getVocabularyService().save(areasVoc);
|
924 |
945 |
return;
|
925 |
946 |
}
|
926 |
947 |
|
927 |
|
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, UUID uuid) {
|
928 |
|
addArea(state, abbrevLabel, areaLabel, uuid, areaLabel); //short cut if label and mapping label are equal
|
|
948 |
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel,
|
|
949 |
Integer id, UUID uuid) {
|
|
950 |
addArea(state, abbrevLabel, areaLabel, uuid, String.valueOf(id)); //short cut if label and mapping label are equal
|
929 |
951 |
}
|
930 |
952 |
|
931 |
953 |
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel,
|
... | ... | |
939 |
961 |
* @param string
|
940 |
962 |
* @param uuidaguascalientes
|
941 |
963 |
*/
|
942 |
|
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel, UUID uuid, String mappingLabel, Integer id1) {
|
|
964 |
private void addArea(SimpleExcelTaxonImportState<CONFIG> state, String abbrevLabel, String areaLabel,
|
|
965 |
UUID uuid, String mappingLabel, Integer id1) {
|
943 |
966 |
NamedArea newArea = NamedArea.NewInstance(
|
944 |
967 |
areaLabel, areaLabel, abbrevLabel);
|
945 |
968 |
newArea.setIdInVocabulary(abbrevLabel);
|
... | ... | |
948 |
971 |
newArea.setLevel(null);
|
949 |
972 |
newArea.setType(NamedAreaType.NATURAL_AREA());
|
950 |
973 |
areasVoc.addTerm(newArea);
|
951 |
|
//FIXME
|
952 |
|
if (id1 != null){
|
953 |
|
addMapping(newArea, "mex_adm1", "id_1", String.valueOf(id1));
|
954 |
|
}else if (mappingLabel != null){
|
955 |
|
addMapping(newArea, "mex_adm1", "name_1", mappingLabel);
|
|
974 |
if (mappingLabel != null){
|
|
975 |
addMapping(newArea, "phytogeographical_regions_of_greece", "id", mappingLabel);
|
956 |
976 |
}
|
957 |
977 |
}
|
958 |
978 |
|
ref #6286 FloraHellenica import transactional