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
This commit is contained in:
parent
d4323b5c30
commit
842faf3a1f
7 changed files with 432 additions and 55 deletions
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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<VClass> getLocalNamespacesClasses(VitroRequest vreq, List<String> namespace) {
|
||||
HashMap<String, String> namespaceHash = convertToHash(namespace);
|
||||
List<VClass> localClasses = new ArrayList<VClass>();
|
||||
List<VClass> 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<String, String> convertToHash(List<String> namespaces) {
|
||||
HashMap<String, String> namespaceHash = new HashMap<String, String>();
|
||||
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<String> getLocalOntologyNamespaces(VitroRequest vreq) {
|
||||
HashMap<String, String> foundNamespaces = new HashMap<String, String>();
|
||||
String defaultNamespacePattern = getDefaultOntologyNamespace(vreq);
|
||||
List<String> localNamespaces = new ArrayList<String>();
|
||||
List<VClass> 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;
|
||||
}
|
||||
}
|
|
@ -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<String> localNamespaces = new ArrayList<String>();
|
||||
private static List<VClass> localNamespaceClasses = new ArrayList<VClass>();
|
||||
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<String, Object> data = new HashMap<String,Object>();
|
||||
//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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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<String, Object> 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");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -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<String, Object> data = new HashMap<String,Object>();
|
||||
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<String, Object> processDeleteMenuItem(VitroRequest vreq) {
|
||||
private void processDeleteMenuItem(VitroRequest vreq , Map<String, Object> data) {
|
||||
String menuItem = getMenuItem(vreq);
|
||||
Map<String, Object> data = new HashMap<String,Object>();
|
||||
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<String>());
|
||||
//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<String, Object> processAddMenuItem(VitroRequest vreq) {
|
||||
Map<String, Object> data = new HashMap<String,Object>();
|
||||
private void processAddMenuItem(VitroRequest vreq, Map<String, Object> 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<String, Object> processEditMenuItem(VitroRequest vreq) {
|
||||
Map<String, Object> data = new HashMap<String,Object>();
|
||||
private void processEditMenuItem(VitroRequest vreq, Map<String, Object> 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<String>());
|
||||
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<String, Object> 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<String> internalClasses = new ArrayList<String>();
|
||||
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);
|
||||
}
|
||||
|
|
|
@ -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" +
|
||||
|
|
|
@ -41,6 +41,8 @@ public class DataGetterUtils {
|
|||
//Get types associated with page
|
||||
Map<String,Object> data = new HashMap<String,Object>();
|
||||
List<String> dataGetters = (List<String>)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<String,Object> moreData = null;
|
||||
|
|
|
@ -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.
|
||||
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<h2>Set up Institutional Internal Class</h2>
|
||||
<h3>Institutional Internal Class</h3>
|
||||
|
||||
<form class="editForm" action = "${editConfiguration.submitToUrl}">
|
||||
|
||||
<p>consectetur adipisicing elit</p>
|
||||
|
||||
<input type="text" name="internalClassUri" size="80" />
|
||||
|
||||
<input type="hidden" name="editKey" value="${editConfiguration.editKey}" />
|
||||
|
||||
<div style="margin-top: 0.2em">
|
||||
<input type="submit" value="submit" />
|
||||
</div>
|
||||
|
||||
</form>
|
||||
<section id="introMessage" role="region">
|
||||
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.
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<form method="POST" action="${formUrl}" class="customForm">
|
||||
<input type="hidden" name="submitForm" id="submitForm" value="true" />
|
||||
<#if ontologiesExist = false>
|
||||
<section id="noLocalOntologyExists">
|
||||
${noLocalOntologiesMessage}
|
||||
</section>
|
||||
|
||||
<#else if useExistingInternalClass = true>
|
||||
<section id="existingLocalClass">
|
||||
<#--Populated based on class list returned-->
|
||||
<select id="existingLocalClasses" name="existingLocalClasses">
|
||||
<#list localClasses as localClass>
|
||||
<option value="${localClass.URI}" <#if existingInternalClass.URI = localClass.URI>selected</#if> >${localClass.name}</option>
|
||||
</#list>
|
||||
</select>
|
||||
</section>
|
||||
<#else if createNewClass = true>
|
||||
<section id="createNewLocalClass">
|
||||
<h2>Create a new class</h2>
|
||||
<label for="menu-name">Name<span class="requiredHint"> *</span></label>
|
||||
<input type="text" id="localClassName" name="localClassName" value="" />
|
||||
|
||||
<#--If more than one local namespace, generate select-->
|
||||
<#if multipleLocalNamespaces = true>
|
||||
<select id="existingLocalNamespaces" name="existingLocalNamespaces">
|
||||
<#list existingLocalNamespaces as existingNamespace>
|
||||
<option value="${existingNamespace.URI}">"${existingNamespace.URI}"</option>
|
||||
</#list>
|
||||
</select>
|
||||
<#else>
|
||||
<input type="hidden" id="existingLocalNamespaces" name="existingLocalNamespaces" value="{existingLocalNamespaces[0]}"/>
|
||||
</#if>
|
||||
|
||||
</section>
|
||||
<#else>
|
||||
Problematic section as above should all have been handled
|
||||
</#if>
|
||||
<input type="submit" name="submit-internalClass" value="${submitAction}" class="submit" /> or <a class="cancel" href="${cancelUrl}">Cancel</a>
|
||||
<p class="requiredHint">* required fields</p>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<#-- Add necessary css files associated with this page
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/css/institutional.css" />')}-->
|
||||
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
|
||||
|
||||
<#-- Add necessary javascript files associated with this page
|
||||
${scripts.add('<script type="text/javascript" src="${urls.base}/js/institutional.js"></script>')}
|
||||
-->
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue