Updates for menu management and institutional internal class form
This commit is contained in:
parent
55bf137efe
commit
4c215d18d1
5 changed files with 37 additions and 21 deletions
|
@ -155,8 +155,8 @@ public class MenuManagementEdit extends VitroHttpServlet {
|
|||
addStatements.write(a, "N3");
|
||||
log.debug(a.toString());
|
||||
a.close();
|
||||
//displayModel.remove(removeStatements);
|
||||
//displayModel.add(addStatements);
|
||||
displayModel.remove(removeStatements);
|
||||
displayModel.add(addStatements);
|
||||
|
||||
} catch(Exception ex) {
|
||||
|
||||
|
@ -448,8 +448,11 @@ 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(
|
||||
removeModel.add(displayModel.listStatements(
|
||||
menuItemResource,
|
||||
DisplayVocabulary.LINK_TEXT,
|
||||
(RDFNode) null));
|
||||
removeModel.add(displayModel.listStatements(
|
||||
pageResource,
|
||||
ResourceFactory.createProperty(DisplayVocabulary.TITLE),
|
||||
(RDFNode) null));
|
||||
|
@ -459,6 +462,10 @@ public class MenuManagementEdit extends VitroHttpServlet {
|
|||
private void generateStatementsForAdd(Model addModel, OntModel displayModel, Resource menuItemResource, Resource pageResource) {
|
||||
//Need to generate the menu item and page in their entirety
|
||||
//Menu item
|
||||
addModel.add(addModel.createStatement(
|
||||
ResourceFactory.createResource(DisplayVocabulary.DEFAULT_MENU)
|
||||
,ResourceFactory.createProperty(DisplayVocabulary.HAS_ELEMENT),
|
||||
menuItemResource));
|
||||
addModel.add(addModel.createStatement(menuItemResource, RDF.type, DisplayVocabulary.NAVIGATION_ELEMENT));
|
||||
addModel.add(addModel.createStatement(menuItemResource,
|
||||
DisplayVocabulary.MENU_POSITION,
|
||||
|
|
|
@ -39,7 +39,7 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
|
|||
private static List<String> localNamespaces = new ArrayList<String>();
|
||||
private static List<VClass> localNamespaceClasses = new ArrayList<VClass>();
|
||||
private static final String CREATE_CLASS_PARAM = "createClass";
|
||||
|
||||
private static final String REDIRECT_PAGE = "/siteAdmin";
|
||||
@Override
|
||||
protected Actions requiredActions(VitroRequest vreq) {
|
||||
return REQUIRED_ACTIONS;
|
||||
|
@ -93,7 +93,6 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
|
|||
}
|
||||
|
||||
private void processCreateOntologies(VitroRequest vreq, Map<String, Object> data) {
|
||||
data.put("ontologiesExist", false);
|
||||
data.put("submitAction", "");
|
||||
|
||||
}
|
||||
|
@ -106,22 +105,22 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
|
|||
|
||||
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");
|
||||
data.put("createNewClass", true);
|
||||
}
|
||||
|
||||
private boolean isCreateNewClass(VitroRequest vreq) {
|
||||
String command = vreq.getParameter("cmd");
|
||||
if(command.equals(CREATE_CLASS_PARAM)) {
|
||||
if(command != null && 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);
|
||||
//If local namespace exists but no classes in local namespaces, then need to enable creation of new classes
|
||||
return(localNamespaces.size() > 0 && 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("useExistingInternalClass", true);
|
||||
data.put("submitAction", "save");
|
||||
}
|
||||
|
||||
|
@ -140,10 +139,16 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
|
|||
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() == 0) {
|
||||
data.put("ontologiesExist", false);
|
||||
}
|
||||
else {
|
||||
data.put("ontologiesExist", true);
|
||||
if(localNamespaces.size() > 1) {
|
||||
data.put("multipleLocalNamespaces", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Process submission on submitting form
|
||||
|
|
|
@ -38,7 +38,7 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
private static final Log log = LogFactory.getLog(MenuManagementController.class);
|
||||
protected final static String SUBMIT_FORM = "/processEditDisplayModel";
|
||||
protected final static String CANCEL_FORM = "/individual?uri=http%3A%2F%2Fvitro.mannlib.cornell.edu%2Fontologies%2Fdisplay%2F1.1%23DefaultMenu&switchToDisplayModel=true";
|
||||
|
||||
protected final static String DELETE_FORM = "menuManagement-remove.ftl";
|
||||
protected final static String EDIT_FORM = "testMenuManagement.ftl";
|
||||
protected final static String CMD_PARAM = "cmd";
|
||||
protected final static String EDIT_PARAM_VALUE = "edit";
|
||||
|
@ -64,18 +64,19 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
//if no menu item passed, return empty data
|
||||
//TODO: Check if exception needs to be thrown
|
||||
String cmd = getCommand(vreq);
|
||||
|
||||
String template = EDIT_FORM;
|
||||
if(cmd.equals(ADD_PARAM_VALUE)) {
|
||||
processAddMenuItem(vreq, data);
|
||||
} else if(cmd.equals(EDIT_PARAM_VALUE)) {
|
||||
processEditMenuItem(vreq, data);
|
||||
} else if(cmd.equals(DELETE_PARAM_VALUE)) {
|
||||
processDeleteMenuItem(vreq, data);
|
||||
template = DELETE_FORM;
|
||||
} else {
|
||||
//Throw some kind of error or do nothing
|
||||
}
|
||||
|
||||
return new TemplateResponseValues(EDIT_FORM, data);
|
||||
return new TemplateResponseValues(template, data);
|
||||
|
||||
}
|
||||
|
||||
|
@ -109,8 +110,8 @@ public class MenuManagementController extends FreemarkerHttpServlet {
|
|||
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", "");
|
||||
|
|
|
@ -26,6 +26,7 @@ public class DisplayVocabulary {
|
|||
private static final String NS = DISPLAY_NS;
|
||||
|
||||
/* Individuals */
|
||||
public static final String DEFAULT_MENU = NS + "DefaultMenu";
|
||||
public static final String SEARCH_INDEX_URI = NS + "SearchIndex";
|
||||
|
||||
//bk392 for extracting properties beyond context nodes.
|
||||
|
@ -43,6 +44,8 @@ public class DisplayVocabulary {
|
|||
public static final String CLASS_INTERSECTION = NS + "intersectsWithClass";
|
||||
public static final String HAS_CLASS_INTERSECTION = NS + "hasClassIntersection";
|
||||
public static final String ITEM_TO_PAGE = NS + "toPage";
|
||||
public static final String HAS_ELEMENT = NS + "hasElement";
|
||||
|
||||
/**Data Getter object properties **/
|
||||
public static final String HAS_DATA_GETTER = NS + "hasDataGetter";
|
||||
public static final String GETINDIVIDUALS_FOR_CLASS = NS + "getIndividualsForClass";
|
||||
|
|
|
@ -24,7 +24,7 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu
|
|||
${noLocalOntologiesMessage}
|
||||
</section>
|
||||
|
||||
<#else if useExistingInternalClass = true>
|
||||
<#elseif useExistingInternalClass?has_content>
|
||||
<section id="existingLocalClass">
|
||||
<#--Populated based on class list returned-->
|
||||
<select id="existingLocalClasses" name="existingLocalClasses">
|
||||
|
@ -33,7 +33,7 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu
|
|||
</#list>
|
||||
</select>
|
||||
</section>
|
||||
<#else if createNewClass = true>
|
||||
<#elseif createNewClass?has_content>
|
||||
<section id="createNewLocalClass">
|
||||
<h2>Create a new class</h2>
|
||||
<label for="menu-name">Name<span class="requiredHint"> *</span></label>
|
||||
|
|
Loading…
Add table
Reference in a new issue