NIHVIVO-1989 ; fixes lack of labels for individuals returned from getIndividualsByVClass() in SDB

This commit is contained in:
bjl23 2011-02-02 20:55:08 +00:00
parent 6e00e1e997
commit c8ec6c9067

View file

@ -125,25 +125,33 @@ public class IndividualDaoSDB extends IndividualDaoJena {
ResultSet rs =QueryExecutionFactory.create(
QueryFactory.create(query), dataset)
.execSelect();
Resource res = null;
String uri = null;
String label = null;
String moniker = null;
while (rs.hasNext()) {
QuerySolution sol = rs.nextSolution();
Resource currRes = sol.getResource("ind");
if ((res == null || !res.equals(currRes))
&& !currRes.isAnon()) {
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());
if (currRes.isAnon()) {
continue;
}
Literal moniker = sol.getLiteral("moniker");
if (moniker != null) {
ent.setMoniker(moniker.getLexicalForm());
if (uri != null && !uri.equals(currRes.getURI())) {
ents.add(makeIndividual(uri, label, moniker));
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 {
@ -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
public Individual getIndividualByURI(String entityURI) {
if( entityURI == null || entityURI.length() == 0 ) {