From 7e4cf9a5c7956b214af2229bcf29857f95e0fb44 Mon Sep 17 00:00:00 2001 From: hjkhjk54 Date: Thu, 14 Jul 2011 21:52:16 +0000 Subject: [PATCH] updates for menu management --- webapp/ontologies/app/application.owl | 134 ++++++++++++++++ .../ontologies/app/menuload/displayDisplay.n3 | 96 ++++++++++++ webapp/ontologies/app/menuload/displayTBOX.n3 | 85 ++++++++++ .../controller/edit/MenuManagementEdit.java | 16 +- .../freemarker/IndividualListController.java | 3 +- .../InstitutionalInternalClassController.java | 2 +- .../freemarker/MenuManagementController.java | 33 ++-- .../controller/freemarker/PageController.java | 4 +- .../vitro/webapp/dao/DisplayVocabulary.java | 1 + .../mannlib/vitro/webapp/dao/PageDao.java | 6 +- .../vitro/webapp/dao/jena/PageDaoJena.java | 146 ++++++++++-------- 11 files changed, 429 insertions(+), 97 deletions(-) create mode 100644 webapp/ontologies/app/application.owl create mode 100644 webapp/ontologies/app/menuload/displayDisplay.n3 create mode 100644 webapp/ontologies/app/menuload/displayTBOX.n3 diff --git a/webapp/ontologies/app/application.owl b/webapp/ontologies/app/application.owl new file mode 100644 index 000000000..18f1d8b90 --- /dev/null +++ b/webapp/ontologies/app/application.owl @@ -0,0 +1,134 @@ + + + + + + + + +]> + + + + + + + + + + + This represents a menu item or other general navigation item. + + + + + + + + + + + + + + individual-menu.ftl + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Indicates that a page requires a body template. + + + + + + + + + Values from HttpRequest.getPathInfo() will be mapped to values from urlMapping. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/webapp/ontologies/app/menuload/displayDisplay.n3 b/webapp/ontologies/app/menuload/displayDisplay.n3 new file mode 100644 index 000000000..bda8b4566 --- /dev/null +++ b/webapp/ontologies/app/menuload/displayDisplay.n3 @@ -0,0 +1,96 @@ +@prefix rdfs: . +@prefix xsd: . +@prefix owl: . +@prefix rdf: . + + + + """# $This file is distributed under the terms of the license in /doc/license.txt$ + +@prefix owl: . +@prefix display: . +@prefix rdf: . +@prefix core: . +@prefix vivoweb: . + +### This file defines the default menu for vivo. ### + +#### Default Menu #### + +display:DefaultMenu + a display:MainMenu ; + display:hasElement display:EventsMenuItem ; + display:hasElement display:HomeMenuItem ; + display:hasElement display:OrganizationsMenuItem ; + display:hasElement display:PeopleMenuItem ; + display:hasElement display:ResearchMenuItem . + +#### Menu Items for Default Menu #### + +display:HomeMenuItem + a display:NavigationElement ; + display:menuPosition 1; + display:linkText \"Home\"; + display:toPage display:Home . + +display:PeopleMenuItem + a display:NavigationElement ; + display:menuPosition 2; + display:linkText \"People\"; + display:toPage display:People . + +display:OrganizationsMenuItem + a display:NavigationElement ; + display:menuPosition 3; + display:linkText \"Organizations\"; + display:toPage display:Organizations . + +display:ResearchMenuItem + a display:NavigationElement ; + display:menuPosition 4; + display:linkText \"Research\"; + display:toPage display:Research . + +display:EventsMenuItem + a display:NavigationElement ; + display:menuPosition 5; + display:linkText \"Events\"; + display:toPage display:Events . + +########## Pages ############ + +display:Home + a display:HomePage ; + a display:Page ; + display:title \"Home\" ; + display:urlMapping \"/\" . + +display:Events + a display:Page ; + a display:ClassGroupPage; + display:forClassGroup vivoweb:vitroClassGroupevents ; + display:title \"Events\" ; + display:urlMapping \"/events\" . + +display:Organizations + a display:Page ; + a display:ClassGroupPage; + display:forClassGroup vivoweb:vitroClassGrouporganizations ; + display:title \"Organizations\" ; + display:urlMapping \"/organizations\" . + +display:People + a display:Page ; + a display:ClassGroupPage; + display:forClassGroup vivoweb:vitroClassGrouppeople ; + display:requiresBodyTemplate \"menupage--classgroup-people.ftl\" ; + display:title \"People\" ; + display:urlMapping \"/people\" . + +display:Research + a display:Page ; + a display:ClassGroupPage; + display:forClassGroup vivoweb:vitroClassGrouppublications ; + display:title \"Research\" ; + display:urlMapping \"/research\" . +""" . diff --git a/webapp/ontologies/app/menuload/displayTBOX.n3 b/webapp/ontologies/app/menuload/displayTBOX.n3 new file mode 100644 index 000000000..b0361a9e1 --- /dev/null +++ b/webapp/ontologies/app/menuload/displayTBOX.n3 @@ -0,0 +1,85 @@ +@prefix rdfs: . +@prefix xsd: . +@prefix owl: . +@prefix rdf: . + +owl:Ontology + a owl:Class . + +rdfs:range + a owl:ObjectProperty . + +owl:AnnotationProperty + a owl:Class . + + + a owl:DatatypeProperty . + + + a owl:DatatypeProperty . + + + a owl:ObjectProperty . + +rdfs:label + a owl:DatatypeProperty . + + + a owl:ObjectProperty . + +owl:DatatypeProperty + a owl:Class . + +rdfs:comment + a owl:DatatypeProperty . + + + a owl:ObjectProperty . + + + a owl:DatatypeProperty . + + + a owl:Class . + + + a owl:Class . + + + a owl:ObjectProperty . + + + a owl:Class . + +owl:Class + a owl:Class . + + + a owl:ObjectProperty . + + + a owl:DatatypeProperty . + +owl:ObjectProperty + a owl:Class . + + + a owl:Class . + +rdfs:domain + a owl:ObjectProperty . + +owl:versionInfo + a owl:DatatypeProperty . + + + a owl:DatatypeProperty . + + + a owl:DatatypeProperty . + + + a owl:Class . + + + a owl:DatatypeProperty . diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java index 2b661bb81..b59494a77 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/MenuManagementEdit.java @@ -349,10 +349,16 @@ public class MenuManagementEdit extends VitroHttpServlet { if(!internalClassSelected(vreq) && allClassesSelected(vreq)) { dataGetterModel = getClassGroupDataGetter(vreq, dataGetterResource, addModel, displayModel); } else { - dataGetterModel = getIndividualsForClassesDataGetter(vreq, dataGetterResource, addModel, displayModel); + dataGetterModel = getIndividualsForClassesDataGetter(vreq, dataGetterResource, addModel, displayModel, pageResource); } + addModel.add(dataGetterModel); + //Also add special template to page + addModel.add(addModel.createStatement(pageResource, + DisplayVocabulary.REQUIRES_BODY_TEMPLATE, + addModel.createTypedLiteral(DisplayVocabulary.INTERNAL_CLASS_TEMPLATE))); + } @@ -369,12 +375,12 @@ public class MenuManagementEdit extends VitroHttpServlet { } private Model getIndividualsForClassesDataGetter(VitroRequest vreq, Resource dataGetterResource, - Model addModel, OntModel displayModel) { + Model addModel, OntModel displayModel, Resource pageResource) { String[] selectedClasses = vreq.getParameterValues("classInClassGroup"); Model dgModel = ModelFactory.createDefaultModel(); dgModel.add(dgModel.createStatement(dataGetterResource, RDF.type, - ResourceFactory.createResource(DisplayVocabulary.CLASSINDIVIDUALS_PAGE_TYPE))); + ResourceFactory.createResource(DisplayVocabulary.CLASSINDIVIDUALS_INTERNAL_TYPE))); for(String classUri: selectedClasses) { dgModel.add(dgModel.createStatement( dataGetterResource, @@ -388,8 +394,8 @@ public class MenuManagementEdit extends VitroHttpServlet { //The value should be the internal class uri dgModel.add(dgModel.createStatement( dataGetterResource, - ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY), - ResourceFactory.createResource(internalClass))); + ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL), + dgModel.createLiteral("true"))); } return dgModel; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java index 70be0b993..a5221e867 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualListController.java @@ -204,7 +204,8 @@ public class IndividualListController extends FreemarkerHttpServlet { Map rvMap = new HashMap(); try{ // make query for multiple rdf types - SolrQuery query = getQuery(vclassURIs, alpha); + SolrQuery query = getQuery(vclassURIs, alpha); + log.debug("Executed solr query for " + vclassURIs.toString()); rvMap = getResultsForVClassQuery(query, page, alpha, indDao, context); List individuals = (List) rvMap.get("entities"); if (individuals == null) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java index f62ae7704..be57bc539 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java @@ -242,7 +242,7 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet //Get current internal class private String retrieveCurrentInternalClass() { String internalClassUri = ""; - OntModel mainModel = (OntModel) getServletContext().getAttribute("jenaOntModel"); + Model mainModel = ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel();; StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/MenuManagementController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/MenuManagementController.java index 9f32381ea..2628a612a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/MenuManagementController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/MenuManagementController.java @@ -276,7 +276,7 @@ public class MenuManagementController extends FreemarkerHttpServlet { String dataGetterType = dataGetterTypes.nextStatement().getResource().getURI(); if(dataGetterType.equals(DisplayVocabulary.CLASSGROUP_PAGE_TYPE)) { this.retrieveClassGroupPage(writeModel, dataGetter, data); - } else if(dataGetterType.equals(DisplayVocabulary.CLASSINDIVIDUALS_PAGE_TYPE)) { + } else if(dataGetterType.equals(DisplayVocabulary.CLASSINDIVIDUALS_INTERNAL_TYPE)) { this.retrieveIndividualsForClassesPage(writeModel, dataGetter, data); } else { //Not sure what to do here @@ -286,13 +286,14 @@ public class MenuManagementController extends FreemarkerHttpServlet { } + //Based on institutional internal page and not general individualsForClasses private void retrieveIndividualsForClassesPage(OntModel writeModel, Resource dataGetter, Map data) { data.put("isIndividualsForClassesPage", true); data.put("isClassGroupPage", false); data.put("includeAllClasses", false); //Get the classes and put them here - this.getClassesForDataGetter(writeModel, dataGetter, data); + this.getClassesForInternalDataGetter(writeModel, dataGetter, data); //Also save the class group for display this.getClassGroupForDataGetter(writeModel, dataGetter, data); this.checkIfPageInternal(writeModel, data); @@ -301,12 +302,10 @@ public class MenuManagementController extends FreemarkerHttpServlet { private void checkIfPageInternal(OntModel writeModel, Map data) { - if(data.containsKey("internalClass") && data.containsKey("restrictClasses")) { - List restrictClasses = (List)data.get("restrictClasses"); - String internalClass = (String) data.get("internalClass"); - if(restrictClasses.contains(internalClass)) { - data.put("pageInternalOnly", true); - } + //if internal class exists, and data getter indicates page is internal + if(data.containsKey("internalClass") && data.containsKey("isInternal")) { + data.put("pageInternalOnly", true); + } } @@ -324,7 +323,7 @@ public class MenuManagementController extends FreemarkerHttpServlet { //Instead of returning vclasses, just returning class Uris as vclasses appear to need their own template //to show up correctly - private void getClassesForDataGetter(OntModel writeModel, Resource dataGetter, + private void getClassesForInternalDataGetter(OntModel writeModel, Resource dataGetter, Map data) { @@ -344,22 +343,20 @@ public class MenuManagementController extends FreemarkerHttpServlet { //This checks whether restrict classes returned and include institutional internal class //TODO: Create separate method to get restricted classes //Get restrict classes - specifically internal class - List restrictClassUris = new ArrayList(); - StmtIterator restrictClassesIt = writeModel.listStatements(dataGetter, - ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY), - (RDFNode) null); - while(restrictClassesIt.hasNext()) { - String restrictClassUri = restrictClassesIt.nextStatement().getResource().getURI(); - restrictClassUris.add(restrictClassUri); - } - data.put("restrictClasses", restrictClassUris); + StmtIterator internalIt = writeModel.listStatements(dataGetter, + ResourceFactory.createProperty(DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL), + (RDFNode) null); + if(internalIt.hasNext()) { + data.put("isInternal", internalIt.nextStatement().getLiteral().getString()); + } } //Check whether any classes exist with internal class restrictions private void checkInstitutionalInternalClass(Map data) { + //TODO: replace with more generic ModelContext retrieval method OntModel mainModel = (OntModel) getServletContext().getAttribute("jenaOntModel"); StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null); //List internalClasses = new ArrayList(); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java index ec062797c..086aaf1d6 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/PageController.java @@ -24,6 +24,7 @@ import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.BrowseDataGetter; import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.PageDataGetter; import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.ClassGroupPageData; import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.IndividualsForClassesDataGetter; +import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.InternalClassesDataGetter; import edu.cornell.mannlib.vitro.webapp.utils.pageDataGetter.DataGetterUtils; /** * Controller for getting data for pages defined in the display model. @@ -140,9 +141,10 @@ public class PageController extends FreemarkerHttpServlet{ getPageDataGetterMap(context).put(cgpd.getType(), cgpd); BrowseDataGetter bdg = new BrowseDataGetter(); getPageDataGetterMap(context).put(bdg.getType(), bdg); - //TODO: Check if can include by type here IndividualsForClassesDataGetter cidg = new IndividualsForClassesDataGetter(); getPageDataGetterMap(context).put(cidg.getType(), cidg); + InternalClassesDataGetter internalCdg = new InternalClassesDataGetter(); + getPageDataGetterMap(context).put(internalCdg.getType(), internalCdg); } } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/DisplayVocabulary.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/DisplayVocabulary.java index 9a3abfb00..a2d2e8743 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/DisplayVocabulary.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/DisplayVocabulary.java @@ -120,6 +120,7 @@ public class DisplayVocabulary { //URL for menu management public static final String PROCESS_MENU_MANAGEMENT_URL = "/processEditDisplayModel"; public static final String REORDER_MENU_URL = PROCESS_MENU_MANAGEMENT_URL + "?cmd=Reorder&" + SWITCH_TO_DISPLAY_MODEL + "=true"; + public static final String INTERNAL_CLASS_TEMPLATE = "menupage--individualsforclasses.ftl"; /* URIs for some individuals in the dispaly ontology */ diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/PageDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/PageDao.java index 860780301..94c3bbf6a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/PageDao.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/PageDao.java @@ -22,9 +22,9 @@ public interface PageDao { String getHomePageUri(); String getClassGroupPage(String pageUri); - - Map> getClassIntersections(String pageUri); - + Map> getClassesAndRestrictionsForPage(String pageUri); + Map getClassesAndCheckInternal(String pageUri); + } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java index 141f2e908..2e0304d80 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/PageDaoJena.java @@ -43,6 +43,8 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { static protected Query classIntersectionPageQuery; static protected Query individualsForClassesQuery; static protected Query individualsForClassesRestrictedQuery; + static protected Query institutionalInternalClassQuery; + static protected Query individualsForClassesInternalQuery; static final String prefixes = @@ -100,17 +102,7 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { " ?dg rdf:type <" + DisplayVocabulary.CLASSGROUP_PAGE_TYPE + ">. \n" + " ?dg <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" + "} \n" ; - - - static final protected String classIntersectionPageQueryString = - prefixes + "\n" + - "SELECT ?classIntersection ?label ?class ?WHERE { ?pageUri <" + DisplayVocabulary.HAS_CLASS_INTERSECTION + "> ?classIntersection . \n " + - " ?classIntersection <" + DisplayVocabulary.CLASS_INTERSECTION + "> ?class . \n "+ - " ?classIntersection rdfs:label ?label . \n" + - "}"; - //prefixes + "\n" + - //"SELECT ?classIntersection WHERE { ?pageUri <" + DisplayVocabulary.CLASS_INTERSECTION + "> ?classIntersection . }"; - + //Query to get what classes are to be employed on the page static final protected String individualsForClassesDataGetterQueryString = prefixes + "\n" + @@ -122,14 +114,30 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { "} \n" ; //Given a data getter, check if results are to be restricted by class - //Also possible to merge these two into the same query - static final protected String individualsForClassesRestrictedQueryString = prefixes + "\n" + "SELECT ?restrictClass WHERE {\n" + " ?dg <"+ DisplayVocabulary.RESTRICT_RESULTS_BY + "> ?restrictClass .\n" + "} \n" ; - // " ?pageUri display:hasDataGetter ?dg .\n"+ + + //Is this data getter using internal class + static final protected String institutionalInternalClassQueryString = + prefixes + "\n" + + "SELECT ?restrictByInternalClass WHERE {\n" + + " ?dg <"+ DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?restrictsByInternalClass .\n" + + "} \n" ; + + //Query to get classes employed on internal class page + //Query to get what classes are to be employed on the page + static final protected String individualsForClassesInternalQueryString = + prefixes + "\n" + + "SELECT ?dg ?class ?isInternal WHERE {\n" + + " ?pageUri display:hasDataGetter ?dg .\n"+ + " ?dg rdf:type <" + DisplayVocabulary.CLASSINDIVIDUALS_INTERNAL_TYPE + ">. \n" + + " ?dg <" + DisplayVocabulary.GETINDIVIDUALS_FOR_CLASS + "> ?class . \n" + + " ?dg <"+ DisplayVocabulary.RESTRICT_RESULTS_BY_INTERNAL + "> ?isInternal .\n" + + "} \n" ; + static{ try{ @@ -167,14 +175,7 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { }catch(Throwable th){ log.error("could not create SPARQL query for classGroupPageQuery " + th.getMessage()); log.error(classGroupPageQueryString); - } - try{ - classIntersectionPageQuery=QueryFactory.create(classIntersectionPageQueryString); - }catch(Throwable th){ - log.error("could not create SPARQL query for classIntersectionPageQuery " + th.getMessage()); - log.error(classIntersectionPageQueryString); - } - + } try{ individualsForClassesQuery=QueryFactory.create(individualsForClassesDataGetterQueryString); }catch(Throwable th){ @@ -188,6 +189,23 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { log.error("could not create SPARQL query for individualsForClassesRestrictedQuery " + th.getMessage()); log.error(individualsForClassesDataGetterQueryString); } + //Check if data getter uses internal class + try{ + institutionalInternalClassQuery=QueryFactory.create(institutionalInternalClassQueryString); + }catch(Throwable th){ + log.error("could not create SPARQL query for institutionalInternalClassQuery " + th.getMessage()); + log.error(institutionalInternalClassQueryString); + } + //Check which classes set for page and whether or not page should only have internal classes + try{ + individualsForClassesInternalQuery = QueryFactory.create(individualsForClassesInternalQueryString); + }catch(Throwable th){ + log.error("could not create SPARQL query for individualsForClassesInternalQuery " + th.getMessage()); + log.error(individualsForClassesInternalQueryString); + } + + + } public PageDaoJena(WebappDaoFactoryJena wadf) { @@ -350,52 +368,6 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { } } - /** - * Get the set of intersections for page - each intersection has a label and includes names of the classes for class intersection. Multiple classes possible. - */ - public Map> getClassIntersections(String pageUri) { - Map> classIntersectionsMap = new HashMap>(); - QuerySolutionMap initialBindings = new QuerySolutionMap(); - initialBindings.add("pageUri", ResourceFactory.createResource(pageUri)); - - Model displayModel = getOntModelSelector().getDisplayModel(); - displayModel.enterCriticalSection(false); - try{ - QueryExecution qexec = QueryExecutionFactory.create( classIntersectionPageQuery, displayModel , initialBindings); - try{ - //Assuming unique labels or could use URI itself? - //TODO: Review whether to use labels or URIs - - - ResultSet resultSet = qexec.execSelect(); - while(resultSet.hasNext()){ - QuerySolution soln = resultSet.next(); - //Results format should be ?page hasClassIntersection . intersectsWithClass ?c; intersects With Class ?e. - String intersectionLabel = nodeToString(soln.get("label")); - - //first time encountering label, set up - if(!classIntersectionsMap.containsKey(intersectionLabel)) { - classIntersectionsMap.put(intersectionLabel, new ArrayList()); - } - - List classes = classIntersectionsMap.get(intersectionLabel); - classes.add(nodeToString(soln.get("class"))); - //classIntersections.add( nodeToString(soln.get("classIntersection")) ); - } - if( classIntersectionsMap.size() == 0 ){ - log.debug("No class intersections info defined in display model for "+ pageUri); - return null; - } - - return classIntersectionsMap; - }finally{ - qexec.close(); - } - }finally{ - displayModel.leaveCriticalSection(); - } - } - /* * Get the classes for which to get individuals returned. This should return a list of class uris. @@ -448,6 +420,44 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { } } + //Get classes for page along with whether or not internal class + public Map getClassesAndCheckInternal(String pageUri) { + Map classesAndRestrictions = new HashMap(); + QuerySolutionMap initialBindings = new QuerySolutionMap(); + initialBindings.add("pageUri", ResourceFactory.createResource(pageUri)); + List classes = new ArrayList(); + + Model displayModel = getOntModelSelector().getDisplayModel(); + displayModel.enterCriticalSection(false); + try{ + QueryExecution qexec = QueryExecutionFactory.create( individualsForClassesInternalQuery, displayModel , initialBindings); + try{ + ResultSet resultSet = qexec.execSelect(); + while(resultSet.hasNext()){ + QuerySolution soln = resultSet.next(); + String dg = nodeToString(soln.get("dg")); + classes.add(nodeToString(soln.get("class"))); + String isInternal = nodeToString(soln.get("isInternal")); + if(isInternal != null && !isInternal.isEmpty()) { + log.debug("Internal value is "+ isInternal); + //Retrieve and add internal class + classesAndRestrictions.put("isInternal", isInternal); + } + } + + if( classes.size() == 0 ){ + log.debug("No classes defined in display model for "+ pageUri); + return null; + } + classesAndRestrictions.put("classes", classes); + return classesAndRestrictions; + }finally{ + qexec.close(); + } + }finally{ + displayModel.leaveCriticalSection(); + } + }