Revision d4e4df3f
Added by Patrick Plitzner almost 5 years ago
cdmlib-io/src/main/java/eu/etaxonomy/cdm/io/descriptive/owl/in/OwlImportUtil.java | ||
---|---|---|
166 | 166 |
|
167 | 167 |
// import sources |
168 | 168 |
Set<IdentifiableSource> sources = new HashSet<>(); |
169 |
termResource.listProperties(OwlUtil.propTermHasSource).forEachRemaining(sourceStatement->sources.add(OwlImportUtil.createSource(sourceStatement, model))); |
|
169 |
termResource.listProperties(OwlUtil.propTermHasSource).forEachRemaining(sourceStatement->sources.add(OwlImportUtil.createSource(sourceStatement, repo, model)));
|
|
170 | 170 |
sources.forEach(source->term.addSource(source)); |
171 | 171 |
|
172 | 172 |
// add import source |
... | ... | |
194 | 194 |
return repo.getFeatureNodeService().find(uuid); |
195 | 195 |
} |
196 | 196 |
|
197 |
private static Reference findReference(Resource resource, ICdmRepository repo){ |
|
198 |
UUID uuid = UUID.fromString(resource.getProperty(OwlUtil.propUuid).getString()); |
|
199 |
return repo.getReferenceService().find(uuid); |
|
200 |
} |
|
201 |
|
|
202 |
static Media findMedia(Resource resource, ICdmRepository repo){ |
|
203 |
UUID uuid = UUID.fromString(resource.getProperty(OwlUtil.propUuid).getString()); |
|
204 |
return repo.getMediaService().find(uuid); |
|
205 |
} |
|
206 |
|
|
197 | 207 |
static Feature createFeature(Resource termResource, ICdmRepository repo, Model model, StructureTreeOwlImportState state){ |
198 | 208 |
Feature feature = findTerm(Feature.class, termResource, repo, model, state); |
199 | 209 |
if(feature==null){ |
... | ... | |
229 | 239 |
return term; |
230 | 240 |
} |
231 | 241 |
|
232 |
static IdentifiableSource createSource(Statement sourceStatement, Model model) { |
|
242 |
static IdentifiableSource createSource(Statement sourceStatement, ICdmRepository repo, Model model) {
|
|
233 | 243 |
Resource sourceResource = model.createResource(sourceStatement.getObject().toString()); |
234 | 244 |
|
235 | 245 |
String typeString = sourceResource.getProperty(OwlUtil.propSourceType).getString(); |
... | ... | |
247 | 257 |
} |
248 | 258 |
if(!citationStatements.isEmpty()){ |
249 | 259 |
Statement citationStatement = citationStatements.iterator().next(); |
250 |
source.setCitation(createReference(citationStatement, model)); |
|
260 |
Resource citationResource = model.createResource(citationStatement.getObject().toString()); |
|
261 |
Reference reference = findReference(citationResource, repo); |
|
262 |
if(reference==null){ |
|
263 |
reference = createReference(citationResource, model); |
|
264 |
} |
|
265 |
source.setCitation(reference); |
|
251 | 266 |
} |
252 | 267 |
return source; |
253 | 268 |
} |
254 | 269 |
|
255 |
static Reference createReference(Statement citationStatement, Model model){ |
|
256 |
Resource citationResource = model.createResource(citationStatement.getObject().toString()); |
|
270 |
static Reference createReference(Resource citationResource, Model model){ |
|
257 | 271 |
String titleString = citationResource.getProperty(OwlUtil.propReferenceTitle).getString(); |
258 | 272 |
Reference citation = ReferenceFactory.newGeneric(); |
259 | 273 |
citation.setTitle(titleString); |
Also available in: Unified diff
ref #8248 Check for existing media and references