From 14d6dc9b70778734b094643ae2fba642cc66be68 Mon Sep 17 00:00:00 2001 From: bjl23 Date: Mon, 4 Oct 2010 15:52:44 +0000 Subject: [PATCH] merging basic union class support to trunk --- .../webapp/dao/jena/IndividualDaoJena.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java index b235e551b..913bca539 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/IndividualDaoJena.java @@ -24,6 +24,7 @@ import org.joda.time.DateTime; import com.hp.hpl.jena.ontology.OntClass; import com.hp.hpl.jena.ontology.OntModel; import com.hp.hpl.jena.ontology.OntResource; +import com.hp.hpl.jena.ontology.UnionClass; import com.hp.hpl.jena.query.Query; import com.hp.hpl.jena.query.QueryExecution; import com.hp.hpl.jena.query.QueryExecutionFactory; @@ -153,15 +154,23 @@ public class IndividualDaoJena extends JenaBaseDao implements IndividualDao { getOntModel().enterCriticalSection(Lock.READ); try { - StmtIterator stmtIt = getOntModel().listStatements((Resource) null, RDF.type, theClass); - try { - while (stmtIt.hasNext()) { - Statement stmt = stmtIt.nextStatement(); - OntResource ind = (OntResource) stmt.getSubject().as(OntResource.class); - ents.add(new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); - } - } finally { - stmtIt.close(); + if (theClass.isAnon() && theClass.canAs(UnionClass.class)) { + UnionClass u = (UnionClass) theClass.as(UnionClass.class); + for (OntClass operand : u.listOperands().toList()) { + VClass vc = new VClassJena(operand, getWebappDaoFactory()); + ents.addAll(getIndividualsByVClass(vc)); + } + } else { + StmtIterator stmtIt = getOntModel().listStatements((Resource) null, RDF.type, theClass); + try { + while (stmtIt.hasNext()) { + Statement stmt = stmtIt.nextStatement(); + OntResource ind = (OntResource) stmt.getSubject().as(OntResource.class); + ents.add(new IndividualJena(ind, (WebappDaoFactoryJena) getWebappDaoFactory())); + } + } finally { + stmtIt.close(); + } } } finally { getOntModel().leaveCriticalSection();