From 842faf3a1f3309df669ac4765422764c4f6a3169 Mon Sep 17 00:00:00 2001 From: hjkhjk54 Date: Wed, 13 Jul 2011 18:54:24 +0000 Subject: [PATCH] Adding classes for institutional internal class and updating menu management - also updated query that retrieve class group uri to use data getter instead of page --- .../controller/edit/MenuManagementEdit.java | 79 +++++-- .../edit/utils/LocalNamespaceClassUtils.java | 66 ++++++ .../InstitutionalInternalClassController.java | 203 ++++++++++++++++++ .../freemarker/MenuManagementController.java | 54 +++-- .../vitro/webapp/dao/jena/PageDaoJena.java | 11 + .../utils/pageDataGetter/DataGetterUtils.java | 2 + .../forms/institutionalInternalClassForm.ftl | 72 +++++-- 7 files changed, 432 insertions(+), 55 deletions(-) create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/utils/LocalNamespaceClassUtils.java create mode 100644 webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java 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 35c02387c..022847953 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 @@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.edit; import java.io.File; import java.io.IOException; import java.io.StringReader; +import java.io.StringWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -62,8 +63,8 @@ public class MenuManagementEdit extends VitroHttpServlet { private final static String ADD_PARAM_VALUE = "Add"; private final static String REORDER_PARAM_VALUE = "Reorder"; private final static String REDIRECT_URL = "/individual?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fontologies%2Fdisplay%2F1.1%23DefaultMenu&switchToDisplayModel=true"; - private Model removeStatements = ModelFactory.createDefaultModel(); - private Model addStatements = ModelFactory.createDefaultModel(); + private static Model removeStatements = null; + private static Model addStatements = null; @Override protected void doPost(HttpServletRequest rawRequest, HttpServletResponse resp) @@ -72,12 +73,10 @@ public class MenuManagementEdit extends VitroHttpServlet { RequestDispatcher rd = request .getRequestDispatcher("/edit/postEditCleanUp.jsp"); rd.forward(request, resp);*/ + removeStatements = ModelFactory.createDefaultModel(); + addStatements = ModelFactory.createDefaultModel(); VitroRequest vreq = new VitroRequest(rawRequest); - java.util.Enumeration paramNames = vreq.getParameterNames(); - while(paramNames.hasMoreElements()) { - String pName = (String)paramNames.nextElement(); - System.out.println("Param name is " + pName + " -a nd value is " + vreq.getParameter(pName)); - } + String command = getCommand(vreq); if(command != null) { processCommand(command, vreq); @@ -86,8 +85,9 @@ public class MenuManagementEdit extends VitroHttpServlet { } //Need to redirect correctly if(!isReorder(command)){ - RequestDispatcher rd = rawRequest.getRequestDispatcher(REDIRECT_URL); - rd.forward(rawRequest, resp); + resp.sendRedirect(rawRequest.getContextPath() + REDIRECT_URL); + } else { + //Provide some JSON message back to reorder } } @@ -125,7 +125,7 @@ public class MenuManagementEdit extends VitroHttpServlet { OntModel displayModel = getDisplayModel(vreq); if(displayModel == null) { //Throw some kind of exception - System.out.println("Display model not being retrieved correctly"); + log.error("Display model not being retrieved correctly"); } //if Add, then create new menu item and new page elements, and use the values above @@ -145,11 +145,16 @@ public class MenuManagementEdit extends VitroHttpServlet { //Edits to model occur here displayModel.enterCriticalSection(Lock.WRITE); try { - System.out.println("Statement to be revmoed are "); - removeStatements.write(System.out, "N3"); - - System.out.println("Statements to be added are "); - addStatements.write(System.out, "N3"); + log.debug("Statement to be removed are "); + StringWriter r = new StringWriter(); + removeStatements.write(r, "N3"); + log.debug(r.toString()); + r.close(); + log.debug("Statements to be added are "); + StringWriter a = new StringWriter(); + addStatements.write(a, "N3"); + log.debug(a.toString()); + a.close(); //displayModel.remove(removeStatements); //displayModel.add(addStatements); @@ -218,7 +223,7 @@ public class MenuManagementEdit extends VitroHttpServlet { Resource menuItemResource = getExistingMenuItem(menuItem, displayModel); Resource pageResource = getExistingPage(menuItemResource, displayModel); //What statements should be added and removed - removeStatements = getStatementsToRemove(command, displayModel, menuItemResource, pageResource); + removeStatements.add(getStatementsToRemove(command, displayModel, menuItemResource, pageResource)); //No statements to add } @@ -227,9 +232,24 @@ public class MenuManagementEdit extends VitroHttpServlet { String command, VitroRequest vreq) { Resource menuItemResource = getExistingMenuItem(menuItem, displayModel); Resource pageResource = getExistingPage(menuItemResource, displayModel); - //What statements should be added and removed - removeStatements = getStatementsToRemove(command, displayModel, menuItemResource, pageResource); - addStatements = getStatementsToAdd(vreq, command, displayModel, menuItemResource, pageResource); + //if home page process separately + if(isHomePage(displayModel, pageResource)) { + processHomePage(vreq, displayModel, menuItemResource, pageResource); + } else { + //What statements should be added and removed + removeStatements.add(getStatementsToRemove(command, displayModel, menuItemResource, pageResource)); + addStatements.add(getStatementsToAdd(vreq, command, displayModel, menuItemResource, pageResource)); + } + } + + + //Home page expects only menu name to change + //No other edits are currently supported + private void processHomePage(VitroRequest vreq, OntModel displayModel, Resource menuItemResource, Resource pageResource) { + //remove statements for existing linkText and title + removeMenuName(displayModel, removeStatements, vreq, menuItemResource, pageResource); + //add new statements for link text and title, setting equal to new menu name + updateMenuName(addStatements, vreq, menuItemResource, pageResource); } @@ -238,7 +258,7 @@ public class MenuManagementEdit extends VitroHttpServlet { Resource menuItemResource = createNewMenuItem(menuName, displayModel); Resource pageResource = createNewPage(menuItemResource, displayModel); //no statements to remove, just to add - addStatements = getStatementsToAdd(vreq, command, displayModel, menuItemResource, pageResource); + addStatements.add(getStatementsToAdd(vreq, command, displayModel, menuItemResource, pageResource)); addStatements.add(associateMenuItemToPage(menuItemResource, pageResource)); } @@ -425,6 +445,17 @@ public class MenuManagementEdit extends VitroHttpServlet { } + private void removeMenuName(OntModel displayModel, Model removeModel, VitroRequest vreq, + Resource menuItemResource, Resource pageResource) { + String menuName = vreq.getParameter("menuName"); + removeModel.add(displayModel.listStatements(menuItemResource, DisplayVocabulary.LINK_TEXT, (RDFNode) null)); + removeModel.add(removeModel.createStatement( + pageResource, + ResourceFactory.createProperty(DisplayVocabulary.TITLE), + (RDFNode) null)); + + } + private void generateStatementsForAdd(Model addModel, OntModel displayModel, Resource menuItemResource, Resource pageResource) { //Need to generate the menu item and page in their entirety //Menu item @@ -482,7 +513,7 @@ public class MenuManagementEdit extends VitroHttpServlet { (RDFNode) null)); removeModel.add(displayModel.listStatements( pageResource, - DisplayVocabulary.URL_MAPPING, + DisplayVocabulary.REQUIRES_BODY_TEMPLATE, (RDFNode) null)); //remove data getter properties - the link between page and data getter remains Resource dataGetter = getDataGetterFromDisplayModel(pageResource, displayModel); @@ -553,6 +584,12 @@ public class MenuManagementEdit extends VitroHttpServlet { return (OntModel) getServletContext().getAttribute("http://vitro.mannlib.cornell.edu/default/vitro-kb-displayMetadata"); } } + + //Is home page + private boolean isHomePage(OntModel writeModel, Resource page) { + StmtIterator homePageIt = writeModel.listStatements(page, RDF.type, ResourceFactory.createResource(DisplayVocabulary.HOME_PAGE_TYPE)); + return (homePageIt.hasNext()); + } Log log = LogFactory.getLog(MenuManagementEdit.class); } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/utils/LocalNamespaceClassUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/utils/LocalNamespaceClassUtils.java new file mode 100644 index 000000000..f547ff5f8 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/edit/utils/LocalNamespaceClassUtils.java @@ -0,0 +1,66 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.edit.utils; + +import java.util.LinkedList; +import java.util.List; +import java.util.ArrayList; +import java.util.HashMap; +import edu.cornell.mannlib.vedit.beans.Option; +import edu.cornell.mannlib.vitro.webapp.beans.ResourceBean; +import edu.cornell.mannlib.vitro.webapp.beans.BaseResourceBean; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +public class LocalNamespaceClassUtils { + private static final Log log = LogFactory.getLog(LocalNamespaceClassUtils.class.getName()); + + public static List getLocalNamespacesClasses(VitroRequest vreq, List namespace) { + HashMap namespaceHash = convertToHash(namespace); + List localClasses = new ArrayList(); + List allClasses = vreq.getWebappDaoFactory().getVClassDao().getAllVclasses(); + for(VClass v: allClasses) { + String classNamespace = v.getNamespace(); + String classUri = v.getURI(); + System.out.println("uri is " + classUri + " and namespace is " + classNamespace); + if(namespaceHash.containsKey(classNamespace)){ + localClasses.add(v); + } + } + return localClasses; + } + + private static HashMap convertToHash(List namespaces) { + HashMap namespaceHash = new HashMap(); + for(String n: namespaces){ + namespaceHash.put(n, "true"); + } + return namespaceHash; + } + + //Retrieve all VClasses and sort into local namespaces + //TODO: Check better mechanism utilizing sparql query + public static List getLocalOntologyNamespaces(VitroRequest vreq) { + HashMap foundNamespaces = new HashMap(); + String defaultNamespacePattern = getDefaultOntologyNamespace(vreq); + List localNamespaces = new ArrayList(); + List allClasses = vreq.getWebappDaoFactory().getVClassDao().getAllVclasses(); + for(VClass v: allClasses) { + String namespace = v.getNamespace(); + if(namespace.startsWith(defaultNamespacePattern) && !foundNamespaces.containsKey(namespace)) { + foundNamespaces.put(namespace, "true"); + } + } + localNamespaces.addAll(foundNamespaces.keySet()); + return localNamespaces; + } + + public static String getDefaultOntologyNamespace(VitroRequest vreq) { + String defaultNamespace= vreq.getWebappDaoFactory().getDefaultNamespace(); + defaultNamespace = defaultNamespace.substring(0, defaultNamespace.lastIndexOf("/")) + "ontology/"; + return defaultNamespace; + } +} 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 new file mode 100644 index 000000000..07b5c8980 --- /dev/null +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/InstitutionalInternalClassController.java @@ -0,0 +1,203 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +package edu.cornell.mannlib.vitro.webapp.controller.freemarker; + +import java.util.HashMap; +import java.util.Map; +import java.util.List; +import java.util.ArrayList; +import com.hp.hpl.jena.rdf.model.Model; +import com.hp.hpl.jena.rdf.model.ResourceFactory; +import com.hp.hpl.jena.shared.Lock; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.Actions; +import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageMenus; +import edu.cornell.mannlib.vitro.webapp.beans.VClass; + +import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues; +import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; +import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; +import edu.cornell.mannlib.vitro.webapp.dao.jena.VClassGroupCache; + +import edu.cornell.mannlib.vitro.webapp.dao.jena.ModelContext; +import edu.cornell.mannlib.vitro.webapp.controller.edit.utils.LocalNamespaceClassUtils; +/* + * Custom controller for menu management. This will be replaced later once N3 Editing + * has been successfully refactored and integrated with menu management. + */ +public class InstitutionalInternalClassController extends FreemarkerHttpServlet { + private static final Log log = LogFactory.getLog(InstitutionalInternalClassController.class); + + private static final String EDIT_FORM = "/processInstitutionalInternalClass"; + public final static Actions REQUIRED_ACTIONS = new Actions(new ManageMenus()); + private static final String DISPLAY_FORM = "/institutionalInternalClassForm.ftl"; + private static List localNamespaces = new ArrayList(); + private static List localNamespaceClasses = new ArrayList(); + private static final String CREATE_CLASS_PARAM = "createClass"; + + @Override + protected Actions requiredActions(VitroRequest vreq) { + return REQUIRED_ACTIONS; + } + + @Override + protected ResponseValues processRequest(VitroRequest vreq) { + + //Based on existing of local namespaces and number of local classes present + //as well as command parameter, execute command + + Map data = new HashMap(); + //Get all local classes and namespace information + retrieveLocalClasses(vreq, data); + if(isSelectExistingClass(vreq)) { + //Local namespace(s) exist and user can select an existing class + processSelectExistingClass(vreq, data); + } else if(isCreateNewClass(vreq)) { + //Local namespace(s) exist and user wishes to create a new class + //Either cmd = create new or no local classes exist at all and one must be created + processCreateNewClass(vreq, data); + } else if(isCreateOntologies(vreq)) { + //Not being handled expliclity but message will display indicating + //no local namespaces exist and one must be created + processCreateOntologies(vreq, data); + } else if(isSubmission(vreq)){ + processSubmission(vreq, data); + } else { + + } + //Retrieve local namespaces + + + //Check if existing local namespaces + + data.put("formUrl", EDIT_FORM); + + //if no local namespaces, then provide message to display + //if existing namespace(s), then check + //if single namespace, retrieve all classes belonging to that local namespace + //if multiple namespaces, generate select list with namespaces + //for instertion: VClassDaoJena.insertVClass + // + return new TemplateResponseValues(DISPLAY_FORM, data); + + } + + private boolean isSubmission(VitroRequest vreq) { + String submit = vreq.getParameter("submitForm"); + return(submit!= null && !submit.isEmpty()); + } + + private void processCreateOntologies(VitroRequest vreq, Map data) { + data.put("ontologiesExist", false); + data.put("submitAction", ""); + + } + + private boolean isCreateOntologies(VitroRequest vreq) { + //no local namespaces + return (localNamespaces.size() == 0); + + } + + private void processCreateNewClass(VitroRequest vreq, Map data) { + //this may need to be changed on the basis of how new classes interact with new ontologies + data.put("ontolgiesExist", true); + data.put("submitAction", "createClass"); + } + + private boolean isCreateNewClass(VitroRequest vreq) { + String command = vreq.getParameter("cmd"); + if(command.equals(CREATE_CLASS_PARAM)) { + return true; + } + //If no classes in local namespaces, then need to enable creation of new classes + return(localNamespaceClasses.size() == 0); + } + + private void processSelectExistingClass(VitroRequest vreq, Map data) { + //Check if internal class is already set and be sure to include that in the data to be returned + data.put("ontologiesExist", true); + data.put("submitAction", "save"); + } + + private boolean isSelectExistingClass(VitroRequest vreq) { + //Local namespaces exist and there are existing classes within those namespaces + return (localNamespaces.size() > 0 && localNamespaceClasses.size() > 0); + } + + + + private void retrieveLocalClasses(VitroRequest vreq, Map data) { + localNamespaces = LocalNamespaceClassUtils.getLocalOntologyNamespaces(vreq); + //Get classes for local namespaces + localNamespaceClasses = LocalNamespaceClassUtils.getLocalNamespacesClasses(vreq, localNamespaces); + data.put("existingLocalClasses", localNamespaces); + data.put("existingLocalNamespaces", localNamespaceClasses); + String noLocalOntologiesMessage = "There are currently no local ontologies. You must create a new ontology"; + data.put("noLocalOntologiesMessage", noLocalOntologiesMessage); + if(localNamespaces.size() > 1) { + data.put("multipleLocalNamespaces", true); + } + } + + + //Process submission on submitting form + private void processSubmission(VitroRequest vreq, Map data) { + //If new class, need to generate new class + String classUri = null; + if(isNewClassSubmission(vreq)){ + VClass v= generateNewVClass(vreq.getParameter("localClassName"), vreq.getParameter("existingLocalNamespaces")); + classUri = v.getURI(); + try { + vreq.getWebappDaoFactory().getVClassDao().insertNewVClass(v); + } catch(Exception ex) { + log.error("Insertion of new class " + vreq.getParameter("name") + " resulted in error ", ex); + } + } else { + //Existing class so get URI from that + classUri = getExistingClassUri(vreq); + } + //If existing class, need to simply add a statement specifying existing class is an internal class + if(classUri != null && !classUri.isEmpty()) { + Model writeModel = ModelContext.getBaseOntModelSelector(getServletContext()).getTBoxModel(); + writeModel.enterCriticalSection(Lock.WRITE); + try { + writeModel.add( + writeModel.createStatement( + ResourceFactory.createResource(classUri), + ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), + writeModel.createLiteral("true"))); + } catch(Exception ex) { + log.error("Error occurred in adding statement for " + classUri + " becoming internal class", ex); + } finally { + writeModel.leaveCriticalSection(); + } + } + } + + private VClass generateNewVClass(String newClassName, String namespace) { + VClass newClass = new VClass(); + newClass.setName(newClassName); + newClass.setNamespace(namespace); + String uri = namespace + newClassName.replaceAll(" ", ""); + newClass.setURI(uri); + //How to g + return newClass; + } + + private boolean isNewClassSubmission(VitroRequest vreq) { + String localName = vreq.getParameter("localClassName"); + return (localName != null && !localName.isEmpty()); + } + + private String getExistingClassUri(VitroRequest vreq) { + return vreq.getParameter("existingLocalClasses"); + + } + +} 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 b3e65fba7..1df4407a2 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 @@ -47,7 +47,7 @@ public class MenuManagementController extends FreemarkerHttpServlet { //since forwarding from edit Request dispatch for now protected final static String ITEM_PARAM = "objectUri"; - + public final static Actions REQUIRED_ACTIONS = new Actions(new ManageMenus()); @Override @@ -59,21 +59,22 @@ public class MenuManagementController extends FreemarkerHttpServlet { protected ResponseValues processRequest(VitroRequest vreq) { //Parameters should include the menu item being edited/added/removed/reordered Map data = new HashMap(); + this.initializeData(data, vreq); + //if no menu item passed, return empty data //TODO: Check if exception needs to be thrown String cmd = getCommand(vreq); if(cmd.equals(ADD_PARAM_VALUE)) { - data = processAddMenuItem(vreq); + processAddMenuItem(vreq, data); } else if(cmd.equals(EDIT_PARAM_VALUE)) { - data = processEditMenuItem(vreq); + processEditMenuItem(vreq, data); } else if(cmd.equals(DELETE_PARAM_VALUE)) { - data = processDeleteMenuItem(vreq); + processDeleteMenuItem(vreq, data); } else { //Throw some kind of error or do nothing } - this.initializeData(data, vreq); return new TemplateResponseValues(EDIT_FORM, data); } @@ -84,6 +85,7 @@ public class MenuManagementController extends FreemarkerHttpServlet { data.put("formUrls", vreq.getContextPath() + SUBMIT_FORM); data.put("cancelUrl", vreq.getContextPath() + CANCEL_FORM); data.put("internalClassUri", ""); + } //Based on parameters, ascertain command @@ -101,19 +103,29 @@ public class MenuManagementController extends FreemarkerHttpServlet { return command; } - private Map processDeleteMenuItem(VitroRequest vreq) { + private void processDeleteMenuItem(VitroRequest vreq , Map data) { String menuItem = getMenuItem(vreq); - Map data = new HashMap(); data.put("menuItem", menuItem); data.put("menuAction", "Remove"); - + //Generate empty values for fields + //TODO: Remove these if only portion of template utilized + data.put("menuItem", ""); + data.put("menuName", ""); + data.put("prettyUrl", ""); + data.put("associatedPage", ""); + data.put("associatedPageURI", ""); + data.put("classGroup", new ArrayList()); + //not a page already assigned a class group + data.put("isClassGroupPage", false); + data.put("includeAllClasses", false); + data.put("classGroups", this.getClassGroups()); + data.put("selectedTemplateType", "default"); + // this.getMenuItemData(vreq, menuItem, data); this.getPageData(vreq, data); - return data; } - private Map processAddMenuItem(VitroRequest vreq) { - Map data = new HashMap(); + private void processAddMenuItem(VitroRequest vreq, Map data) { data.put("menuAction", "Add"); //Generate empty values for fields data.put("menuItem", ""); @@ -130,13 +142,11 @@ public class MenuManagementController extends FreemarkerHttpServlet { //defaults to regular class group page //Check whether institutional internal class exists this.checkInstitutionalInternalClass(data); - return data; } - private Map processEditMenuItem(VitroRequest vreq) { - Map data = new HashMap(); + private void processEditMenuItem(VitroRequest vreq, Map data) { if(!hasMenuItem(vreq)) { - return data; + return; } //Get parameter for menu item String menuItem = getMenuItem(vreq); @@ -149,7 +159,6 @@ public class MenuManagementController extends FreemarkerHttpServlet { //Get data for menu item and associated page this.getMenuItemData(vreq, menuItem, data); this.getPageData(vreq, data); - return data; } private String getMenuItem(VitroRequest vreq) { @@ -226,6 +235,13 @@ public class MenuManagementController extends FreemarkerHttpServlet { StmtIterator homePageIt = writeModel.listStatements(page, RDF.type, ResourceFactory.createResource(DisplayVocabulary.HOME_PAGE_TYPE)); if (homePageIt.hasNext()) { data.put("isHomePage", true); + data.put("isClassGroupPage", false); + //Home Page does not have a "group" associated with + data.put("associatedPage", ""); + data.put("associatedPageURI", ""); + data.put("classGroup", new ArrayList()); + data.put("includeAllClasses", false); + } } @@ -247,6 +263,7 @@ public class MenuManagementController extends FreemarkerHttpServlet { //Home can be edited but not removed private void getPageDataGetterInfo(OntModel writeModel, Resource page, Map data) { + //Alternative is to do this via sparql query StmtIterator dataGetterIt = writeModel.listStatements(page, ResourceFactory.createProperty(DisplayVocabulary.HAS_DATA_GETTER), (RDFNode) null); while(dataGetterIt.hasNext()) { @@ -343,9 +360,8 @@ public class MenuManagementController extends FreemarkerHttpServlet { OntModel mainModel = (OntModel) getServletContext().getAttribute("jenaOntModel"); StmtIterator internalIt = mainModel.listStatements(null, ResourceFactory.createProperty(VitroVocabulary.IS_INTERNAL_CLASSANNOT), (RDFNode) null); //List internalClasses = new ArrayList(); - if(internalIt.hasNext()) { - //internalClasses.add(internalIt.nextStatement().getResource().getURI()); - String internalClass = internalIt.nextStatement().getResource().getURI(); + if(internalIt.hasNext()) { + String internalClass = internalIt.nextStatement().getSubject().getURI(); data.put("internalClass", internalClass); data.put("internalClassUri", internalClass); } 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 2dbef0edd..141f2e908 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 @@ -87,9 +87,20 @@ public class PageDaoJena extends JenaBaseDao implements PageDao { " ?pageUri rdf:type <" + DisplayVocabulary.HOME_PAGE_TYPE + "> .\n"+ "} \n" ; + /* static final protected String classGroupPageQueryString = prefixes + "\n" + "SELECT ?classGroup WHERE { ?pageUri <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . }"; + */ + //Updated class group page query string + static final protected String classGroupPageQueryString = + prefixes + "\n" + + "SELECT ?classGroup WHERE {\n" + + " ?pageUri display:hasDataGetter ?dg .\n"+ + " ?dg rdf:type <" + DisplayVocabulary.CLASSGROUP_PAGE_TYPE + ">. \n" + + " ?dg <" + DisplayVocabulary.FOR_CLASSGROUP + "> ?classGroup . \n" + + "} \n" ; + static final protected String classIntersectionPageQueryString = prefixes + "\n" + diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java index a35c4f3ea..0943dcb1d 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/utils/pageDataGetter/DataGetterUtils.java @@ -41,6 +41,8 @@ public class DataGetterUtils { //Get types associated with page Map data = new HashMap(); List dataGetters = (List)page.get("dataGetters"); + //TODO: Change back to debug + log.info("Retrieved data getters for Page " + pageUri + " = " + dataGetters.toString()); if( dataGetters != null ){ for( String dataGetter : dataGetters){ Map moreData = null; diff --git a/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl b/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl index f8f8c04de..604bed6d2 100644 --- a/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl +++ b/webapp/web/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl @@ -2,25 +2,67 @@ <#-- Institutional Internal Class Form +To be associated later (upon completion of N3 Refactoring) with edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.InstitutionalInternalClassForm. - --> -

Set up Institutional Internal Class

+

Institutional Internal Class

-
- -

consectetur adipisicing elit

- - - - - -
- -
- -
+
+ This class will be used to designate those individuals internal to your institution. + This will allow you to limit the individuals displayed on your menu pages (People, Research, etc.) + to only those within your institution. +
+
+
+ + <#if ontologiesExist = false> +
+ ${noLocalOntologiesMessage} +
+ + <#else if useExistingInternalClass = true> +
+ <#--Populated based on class list returned--> + +
+ <#else if createNewClass = true> +
+

Create a new class

+ + + + <#--If more than one local namespace, generate select--> + <#if multipleLocalNamespaces = true> + + <#else> + + + +
+ <#else> + Problematic section as above should all have been handled + + or Cancel +

* required fields

+
+
+ +<#-- Add necessary css files associated with this page +${stylesheets.add('')}--> +${stylesheets.add('')} + +<#-- Add necessary javascript files associated with this page +${scripts.add('')} +-->