NIHVIVO-1989 ; fixes lack of labels for individuals returned from getIndividualsByVClass() in SDB
This commit is contained in:
parent
6e00e1e997
commit
c8ec6c9067
1 changed files with 33 additions and 16 deletions
|
@ -125,25 +125,33 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
ResultSet rs =QueryExecutionFactory.create(
|
ResultSet rs =QueryExecutionFactory.create(
|
||||||
QueryFactory.create(query), dataset)
|
QueryFactory.create(query), dataset)
|
||||||
.execSelect();
|
.execSelect();
|
||||||
Resource res = null;
|
String uri = null;
|
||||||
|
String label = null;
|
||||||
|
String moniker = null;
|
||||||
while (rs.hasNext()) {
|
while (rs.hasNext()) {
|
||||||
QuerySolution sol = rs.nextSolution();
|
QuerySolution sol = rs.nextSolution();
|
||||||
Resource currRes = sol.getResource("ind");
|
Resource currRes = sol.getResource("ind");
|
||||||
if ((res == null || !res.equals(currRes))
|
if (currRes.isAnon()) {
|
||||||
&& !currRes.isAnon()) {
|
continue;
|
||||||
res = currRes;
|
|
||||||
Individual ent = new IndividualSDB(currRes.getURI(),
|
|
||||||
this.dwf, datasetMode, getWebappDaoFactory(),
|
|
||||||
SKIP_INITIALIZATION);
|
|
||||||
Literal label = sol.getLiteral("label");
|
|
||||||
if (label != null) {
|
|
||||||
ent.setName(label.getLexicalForm());
|
|
||||||
}
|
}
|
||||||
Literal moniker = sol.getLiteral("moniker");
|
if (uri != null && !uri.equals(currRes.getURI())) {
|
||||||
if (moniker != null) {
|
ents.add(makeIndividual(uri, label, moniker));
|
||||||
ent.setMoniker(moniker.getLexicalForm());
|
uri = currRes.getURI();
|
||||||
|
label = null;
|
||||||
|
moniker = null;
|
||||||
|
} else if (uri == null) {
|
||||||
|
uri = currRes.getURI();
|
||||||
}
|
}
|
||||||
ents.add(ent);
|
Literal labelLit = sol.getLiteral("label");
|
||||||
|
if (labelLit != null) {
|
||||||
|
label = labelLit.getLexicalForm();
|
||||||
|
}
|
||||||
|
Literal monikerLit = sol.getLiteral("moniker");
|
||||||
|
if (monikerLit != null) {
|
||||||
|
moniker = monikerLit.getLexicalForm();
|
||||||
|
}
|
||||||
|
if (!rs.hasNext()) {
|
||||||
|
ents.add(makeIndividual(uri, label, moniker));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -166,6 +174,15 @@ public class IndividualDaoSDB extends IndividualDaoJena {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Individual makeIndividual(String uri, String label, String moniker) {
|
||||||
|
Individual ent = new IndividualSDB(uri,
|
||||||
|
this.dwf, datasetMode, getWebappDaoFactory(),
|
||||||
|
SKIP_INITIALIZATION);
|
||||||
|
ent.setName(label);
|
||||||
|
ent.setMoniker(moniker);
|
||||||
|
return ent;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Individual getIndividualByURI(String entityURI) {
|
public Individual getIndividualByURI(String entityURI) {
|
||||||
if( entityURI == null || entityURI.length() == 0 ) {
|
if( entityURI == null || entityURI.length() == 0 ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue