Revision b0033901
Added by Patrick Plitzner over 7 years ago
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportClassification.java | ||
---|---|---|
89 | 89 |
makeClassification("Rothmaler", RedListUtil.uuidClassificationR, "Rothmaler", 2011, RedListUtil.uuidClassificationReferenceR, state); |
90 | 90 |
makeClassification("Oberdorfer", RedListUtil.uuidClassificationO, "Oberdorfer", 2001, RedListUtil.uuidClassificationReferenceO, state); |
91 | 91 |
makeClassification("Schmeil-Fitschen", RedListUtil.uuidClassificationS, "Schmeil-Fitschen", 2011, RedListUtil.uuidClassificationReferenceS, state); |
92 |
importFamilies(gesamtListe, checkliste, state); |
|
92 |
// importFamilies(gesamtListe, checkliste, state);
|
|
93 | 93 |
super.doInvoke(state); |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
|
97 | 97 |
private void importFamilies(Classification gesamtListe, Classification checkliste, RedListGefaesspflanzenImportState state) { |
98 |
for(UUID uuid:state.getFamilyMap().values()){ |
|
98 |
for(UUID uuid:state.getFamilyMapGesamtListe().values()){
|
|
99 | 99 |
Taxon familyGL = HibernateProxyHelper.deproxy(getTaxonService().load(uuid, Arrays.asList(new String[]{"*"})), Taxon.class); |
100 | 100 |
Taxon familyCL = (Taxon) familyGL.clone(); |
101 | 101 |
getTaxonService().saveOrUpdate(familyCL); |
102 | 102 |
|
103 |
gesamtListe.addChildTaxon(familyGL, null, null);
|
|
103 |
gesamtListe.addParentChild(null, familyGL, null, null);
|
|
104 | 104 |
familyGL.setSec(gesamtListe.getReference()); |
105 | 105 |
familyGL.setTitleCache(null); |
106 | 106 |
|
107 |
checkliste.addChildTaxon(familyCL, null, null);
|
|
107 |
checkliste.addParentChild(null, familyCL, null, null);
|
|
108 | 108 |
familyCL.setSec(checkliste.getReference()); |
109 | 109 |
familyCL.setTitleCache(null); |
110 | 110 |
|
... | ... | |
184 | 184 |
RedListUtil.logMessage(id, taxonBaseGL+" has no parent but is not a taxon.", logger); |
185 | 185 |
} |
186 | 186 |
else{ |
187 |
Taxon family = (Taxon) state.getRelatedObject(RedListUtil.FAMILY_NAMESPACE, familieString); |
|
187 |
Taxon family = (Taxon) state.getRelatedObject(RedListUtil.FAMILY_NAMESPACE_GESAMTLISTE, familieString);
|
|
188 | 188 |
gesamtListeClassification.addParentChild(family, HibernateProxyHelper.deproxy(taxonBaseGL, Taxon.class), null, null); |
189 |
if(family.getTaxonNodes().isEmpty()){ |
|
190 |
gesamtListeClassification.addChildTaxon(family, null, null); |
|
191 |
} |
|
189 | 192 |
} |
190 | 193 |
} |
191 | 194 |
//add to higher taxon |
... | ... | |
206 | 209 |
RedListUtil.logMessage(id, taxonBaseCL+" has no parent but is not a taxon.", logger); |
207 | 210 |
} |
208 | 211 |
else{ |
209 |
Taxon family = (Taxon) state.getRelatedObject(RedListUtil.FAMILY_NAMESPACE, familieString); |
|
212 |
Taxon family = (Taxon) state.getRelatedObject(RedListUtil.FAMILY_NAMESPACE_CHECKLISTE, familieString);
|
|
210 | 213 |
checklistClassification.addParentChild(family, HibernateProxyHelper.deproxy(taxonBaseCL, Taxon.class), null, null); |
214 |
if(family.getTaxonNodes().isEmpty()){ |
|
215 |
checklistClassification.addChildTaxon(family, null, null); |
|
216 |
} |
|
211 | 217 |
} |
212 | 218 |
} |
213 | 219 |
//add to higher taxon |
... | ... | |
378 | 384 |
result.put(RedListUtil.CLASSIFICATION_NAMESPACE_S, (Map<String, TaxonBase>) getCommonService().getSourcedObjectsByIdInSource(TaxonBase.class, idSet, RedListUtil.CLASSIFICATION_NAMESPACE_S)); |
379 | 385 |
|
380 | 386 |
//add families |
381 |
Map<String, Taxon> familyMap = new HashMap<String, Taxon>(); |
|
382 |
for (Entry<String, UUID> entry: state.getFamilyMap().entrySet()) { |
|
383 |
familyMap.put(entry.getKey(), HibernateProxyHelper.deproxy(getTaxonService().load(entry.getValue()), Taxon.class)); |
|
387 |
//gesamtliste |
|
388 |
Map<String, Taxon> familyMapGL = new HashMap<String, Taxon>(); |
|
389 |
for (Entry<String, UUID> entry: state.getFamilyMapGesamtListe().entrySet()) { |
|
390 |
familyMapGL.put(entry.getKey(), HibernateProxyHelper.deproxy(getTaxonService().load(entry.getValue()), Taxon.class)); |
|
391 |
} |
|
392 |
result.put(RedListUtil.FAMILY_NAMESPACE_GESAMTLISTE, familyMapGL); |
|
393 |
//checkliste |
|
394 |
Map<String, Taxon> familyMapCL = new HashMap<String, Taxon>(); |
|
395 |
for (Entry<String, UUID> entry: state.getFamilyMapCheckliste().entrySet()) { |
|
396 |
familyMapCL.put(entry.getKey(), HibernateProxyHelper.deproxy(getTaxonService().load(entry.getValue()), Taxon.class)); |
|
384 | 397 |
} |
385 |
result.put(RedListUtil.FAMILY_NAMESPACE, familyMap);
|
|
398 |
result.put(RedListUtil.FAMILY_NAMESPACE_CHECKLISTE, familyMapCL);
|
|
386 | 399 |
return result; |
387 | 400 |
} |
388 | 401 |
|
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportFamily.java | ||
---|---|---|
68 | 68 |
|
69 | 69 |
|
70 | 70 |
private void importFamilies(RedListGefaesspflanzenImportState state) throws SQLException { |
71 |
Map<String, UUID> familyMap = new HashMap<>(); |
|
71 |
Map<String, UUID> familyMapGL = new HashMap<>(); |
|
72 |
Map<String, UUID> familyMapCL = new HashMap<>(); |
|
72 | 73 |
|
73 | 74 |
String query = "SELECT DISTINCT f.FAMILIE " |
74 | 75 |
+ " FROM GATTUNG_FAMILIE f"; |
... | ... | |
78 | 79 |
String familieStr = rs.getString("FAMILIE"); |
79 | 80 |
BotanicalName name = BotanicalName.NewInstance(Rank.FAMILY()); |
80 | 81 |
name.setGenusOrUninomial(familieStr); |
81 |
Taxon family = Taxon.NewInstance(name, null); |
|
82 |
familyMap.put(familieStr, family.getUuid()); |
|
83 |
getTaxonService().saveOrUpdate(family); |
|
82 |
Taxon familyGL = Taxon.NewInstance(name, null); |
|
83 |
familyMapGL.put(familieStr, familyGL.getUuid()); |
|
84 |
getTaxonService().saveOrUpdate(familyGL); |
|
85 |
//clone for checkliste |
|
86 |
Taxon familyCL = (Taxon) familyGL.clone(); |
|
87 |
familyMapCL.put(familieStr, familyCL.getUuid()); |
|
88 |
getTaxonService().save(familyCL); |
|
84 | 89 |
} |
85 |
state.setFamilyMap(familyMap); |
|
90 |
state.setFamilyMapGesamtListe(familyMapGL); |
|
91 |
state.setFamilyMapCheckliste(familyMapCL); |
|
86 | 92 |
} |
87 | 93 |
|
88 | 94 |
@Override |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListGefaesspflanzenImportState.java | ||
---|---|---|
29 | 29 |
private static final Logger logger = Logger.getLogger(RedListGefaesspflanzenImportState.class); |
30 | 30 |
|
31 | 31 |
private final Map<String, UUID> authorMap = new HashMap<String, UUID>(); |
32 |
private Map<String, UUID> familyMap = new HashMap<String, UUID>(); |
|
32 |
private Map<String, UUID> familyMapGesamtListe = new HashMap<String, UUID>(); |
|
33 |
private Map<String, UUID> familyMapCheckliste = new HashMap<String, UUID>(); |
|
33 | 34 |
private UUID checklistClassificationUuid; |
34 | 35 |
|
35 | 36 |
protected RedListGefaesspflanzenImportState(RedListGefaesspflanzenImportConfigurator config) { |
... | ... | |
48 | 49 |
return checklistClassificationUuid; |
49 | 50 |
} |
50 | 51 |
|
51 |
public Map<String, UUID> getFamilyMap() { |
|
52 |
return familyMap; |
|
52 |
public Map<String, UUID> getFamilyMapGesamtListe() {
|
|
53 |
return familyMapGesamtListe;
|
|
53 | 54 |
} |
54 | 55 |
|
55 |
public void setFamilyMap(Map<String, UUID> familyMap) { |
|
56 |
this.familyMap = familyMap; |
|
56 |
public void setFamilyMapGesamtListe(Map<String, UUID> familyMap) { |
|
57 |
this.familyMapGesamtListe = familyMap; |
|
58 |
} |
|
59 |
|
|
60 |
public Map<String, UUID> getFamilyMapCheckliste() { |
|
61 |
return familyMapCheckliste; |
|
62 |
} |
|
63 |
|
|
64 |
public void setFamilyMapCheckliste(Map<String, UUID> familyMapCheckliste) { |
|
65 |
this.familyMapCheckliste = familyMapCheckliste; |
|
57 | 66 |
} |
58 | 67 |
|
59 | 68 |
} |
app-import/src/main/java/eu/etaxonomy/cdm/io/redlist/gefaesspflanzen/RedListUtil.java | ||
---|---|---|
64 | 64 |
public static final String CLASSIFICATION_NAMESPACE_R = "classification_namespace_r"; |
65 | 65 |
public static final String CLASSIFICATION_NAMESPACE_O = "classification_namespace_o"; |
66 | 66 |
public static final String CLASSIFICATION_NAMESPACE_S = "classification_namespace_s"; |
67 |
public static final String FAMILY_NAMESPACE = "family_namespace"; |
|
67 |
public static final String FAMILY_NAMESPACE_GESAMTLISTE = "family_namespace_gesamtliste"; |
|
68 |
public static final String FAMILY_NAMESPACE_CHECKLISTE = "family_namespace_checkliste"; |
|
68 | 69 |
|
69 | 70 |
|
70 | 71 |
//cell content |
Also available in: Unified diff
#5448 Improve import of families