NIHVIVO-2959 improvement to data property statement retrieval by property for individuals
This commit is contained in:
parent
36a9dc22e6
commit
df5d11e60d
2 changed files with 18 additions and 7 deletions
|
@ -172,14 +172,27 @@ public class DataPropertyStatementDaoJena extends JenaBaseDao implements DataPro
|
||||||
public Collection<DataPropertyStatement> getDataPropertyStatementsForIndividualByDataPropertyURI(Individual entity,
|
public Collection<DataPropertyStatement> getDataPropertyStatementsForIndividualByDataPropertyURI(Individual entity,
|
||||||
String datapropURI) {
|
String datapropURI) {
|
||||||
Collection<DataPropertyStatement> edList = new ArrayList<DataPropertyStatement>();
|
Collection<DataPropertyStatement> edList = new ArrayList<DataPropertyStatement>();
|
||||||
if (entity.getURI() == null) {
|
if (entity.getURI() == null || datapropURI == null) {
|
||||||
return edList;
|
return edList;
|
||||||
}
|
}
|
||||||
|
// do something nicer if we're not dealing with a blank node
|
||||||
|
Resource res = ResourceFactory.createResource(entity.getURI());
|
||||||
|
if (!VitroVocabulary.PSEUDO_BNODE_NS.equals(entity.getNamespace())) {
|
||||||
|
for (Literal lit : this.getDataPropertyValuesForIndividualByProperty(res.getURI(), datapropURI)) {
|
||||||
|
DataPropertyStatement ed = new DataPropertyStatementImpl();
|
||||||
|
fillDataPropertyStatementWithJenaLiteral(ed, lit);
|
||||||
|
ed.setIndividualURI(entity.getURI());
|
||||||
|
ed.setIndividual(entity);
|
||||||
|
ed.setDatapropURI(datapropURI);
|
||||||
|
edList.add(ed);
|
||||||
|
}
|
||||||
|
return edList;
|
||||||
|
}
|
||||||
|
// do something annoying if we are dealing with a blank node
|
||||||
try {
|
try {
|
||||||
getOntModel().enterCriticalSection(Lock.READ);
|
getOntModel().enterCriticalSection(Lock.READ);
|
||||||
OntResource ontRes = (VitroVocabulary.PSEUDO_BNODE_NS.equals(entity.getNamespace()))
|
OntResource ontRes = (OntResource) getOntModel().createResource(
|
||||||
? (OntResource) getOntModel().createResource(new AnonId(entity.getLocalName())).as(OntResource.class)
|
new AnonId(entity.getLocalName())).as(OntResource.class);
|
||||||
: getOntModel().getOntResource(entity.getURI());
|
|
||||||
if (ontRes == null) {
|
if (ontRes == null) {
|
||||||
return edList;
|
return edList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,9 +129,7 @@ public class IndividualSDB extends IndividualImpl implements Individual {
|
||||||
String getStatements =
|
String getStatements =
|
||||||
"CONSTRUCT " +
|
"CONSTRUCT " +
|
||||||
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
||||||
"> ?ooo. \n" +
|
"> ?ooo \n" +
|
||||||
"<"+individualURI+"> <" + VitroVocabulary.MONIKER +
|
|
||||||
"> ?moniker \n" +
|
|
||||||
"} WHERE {" +
|
"} WHERE {" +
|
||||||
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
"{ <"+individualURI+"> <" + RDFS.label.getURI() +
|
||||||
"> ?ooo } \n" +
|
"> ?ooo } \n" +
|
||||||
|
|
Loading…
Add table
Reference in a new issue