24 |
24 |
import eu.etaxonomy.cdm.io.common.ImportHelper;
|
25 |
25 |
import eu.etaxonomy.cdm.io.common.ResultSetPartitioner;
|
26 |
26 |
import eu.etaxonomy.cdm.model.common.CdmBase;
|
27 |
|
import eu.etaxonomy.cdm.model.name.NonViralName;
|
|
27 |
import eu.etaxonomy.cdm.model.name.BotanicalName;
|
28 |
28 |
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
29 |
29 |
import eu.etaxonomy.cdm.model.taxon.TaxonBase;
|
30 |
|
import eu.etaxonomy.cdm.strategy.parser.NonViralNameParserImpl;
|
31 |
30 |
|
32 |
31 |
/**
|
33 |
32 |
*
|
... | ... | |
93 |
92 |
private void makeSingleTaxon(RedListGefaesspflanzenImportState state, ResultSet rs, Set<TaxonBase> taxaToSave)
|
94 |
93 |
throws SQLException {
|
95 |
94 |
long id = rs.getLong("NAMNR");
|
96 |
|
String taxonNameString = rs.getString("TAXNAME");
|
97 |
95 |
|
98 |
|
NonViralNameParserImpl parser = NonViralNameParserImpl.NewInstance();
|
99 |
|
NonViralName<?> name = parser.parseFullName(taxonNameString);
|
|
96 |
BotanicalName name = state.getRelatedObject("name", String.valueOf(id), BotanicalName.class);
|
100 |
97 |
TaxonBase taxon = Taxon.NewInstance(name, null);
|
101 |
98 |
|
102 |
99 |
taxaToSave.add(taxon);
|
103 |
100 |
|
104 |
101 |
//id
|
105 |
102 |
ImportHelper.setOriginalSource(taxon, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
|
106 |
|
ImportHelper.setOriginalSource(name, state.getTransactionalSourceReference(), id, TAXON_NAMESPACE);
|
107 |
103 |
}
|
108 |
104 |
|
109 |
105 |
@Override
|
110 |
106 |
public Map<Object, Map<String, ? extends CdmBase>> getRelatedObjectsForPartition(ResultSet rs,
|
111 |
107 |
RedListGefaesspflanzenImportState state) {
|
112 |
108 |
Map<Object, Map<String, ? extends CdmBase>> result = new HashMap<>();
|
113 |
|
// Map<String, TeamOrPersonBase<?>> authorMap = new HashMap<>();
|
114 |
|
// Set<String> authorKombSet = new HashSet<>();
|
115 |
|
// Set<String> referenceIdSet = new HashSet<String>();
|
116 |
|
//
|
117 |
|
// try {
|
118 |
|
// while (rs.next()){
|
119 |
|
// String authorStr = rs.getString("tax_author_name");
|
120 |
|
// authorKombSet.add(authorStr);
|
121 |
|
// handleForeignKey(rs, referenceIdSet, "tax_document");
|
122 |
|
// }
|
123 |
|
// } catch (SQLException e) {
|
124 |
|
// e.printStackTrace();
|
125 |
|
// }
|
126 |
|
//
|
127 |
|
// //Authors
|
128 |
|
// Set<UUID> uuidSet = new HashSet<>();
|
129 |
|
// for (String authorStr : authorKombSet){
|
130 |
|
// UUID uuid = state.getAuthorUuid(authorStr);
|
131 |
|
// uuidSet.add(uuid);
|
132 |
|
// }
|
133 |
|
// List<TeamOrPersonBase<?>> authors = (List)getAgentService().find(uuidSet);
|
134 |
|
// Map<UUID, TeamOrPersonBase<?>> authorUuidMap = new HashMap<>();
|
135 |
|
// for (TeamOrPersonBase<?> author : authors){
|
136 |
|
// authorUuidMap.put(author.getUuid(), author);
|
137 |
|
// }
|
138 |
|
//
|
139 |
|
// for (String authorStr : authorKombSet){
|
140 |
|
// UUID uuid = state.getAuthorUuid(authorStr);
|
141 |
|
// TeamOrPersonBase<?> author = authorUuidMap.get(uuid);
|
142 |
|
// authorMap.put(authorStr, author);
|
143 |
|
// }
|
144 |
|
// result.put(AUTHOR_NAMESPACE, authorMap);
|
145 |
|
//
|
146 |
|
// //reference map
|
147 |
|
// String nameSpace = REFERENCE_NAMESPACE;
|
148 |
|
// Class<?> cdmClass = Reference.class;
|
149 |
|
// Set<String> idSet = referenceIdSet;
|
150 |
|
// Map<String, Reference<?>> referenceMap = (Map<String, Reference<?>>)getCommonService().getSourcedObjectsByIdInSource(cdmClass, idSet, nameSpace);
|
151 |
|
// result.put(nameSpace, referenceMap);
|
152 |
|
//
|
153 |
|
// //secundum
|
154 |
|
// UUID secUuid = state.getConfig().getSecUuid();
|
155 |
|
// Reference<?> secRef = getReferenceService().find(secUuid);
|
156 |
|
// referenceMap.put(secUuid.toString(), secRef);
|
|
109 |
Map<String, BotanicalName> nameMap = new HashMap<String, BotanicalName>();
|
|
110 |
|
|
111 |
|
|
112 |
try {
|
|
113 |
while (rs.next()){
|
|
114 |
long id = rs.getLong("NAMNR");
|
|
115 |
BotanicalName name = (BotanicalName) getCommonService().getSourcedObjectByIdInSource(BotanicalName.class, String.valueOf(id), "name");
|
|
116 |
nameMap.put(String.valueOf(id), name);
|
|
117 |
|
|
118 |
}
|
|
119 |
} catch (SQLException e) {
|
|
120 |
e.printStackTrace();
|
|
121 |
}
|
|
122 |
result.put("name", nameMap);
|
157 |
123 |
|
158 |
124 |
return result;
|
159 |
125 |
}
|
Set name for taxon