Updates for menu management and institutional internal class form

This commit is contained in:
hjkhjk54 2011-07-13 20:45:30 +00:00
parent 55bf137efe
commit 4c215d18d1
5 changed files with 37 additions and 21 deletions

View file

@ -155,8 +155,8 @@ public class MenuManagementEdit extends VitroHttpServlet {
addStatements.write(a, "N3"); addStatements.write(a, "N3");
log.debug(a.toString()); log.debug(a.toString());
a.close(); a.close();
//displayModel.remove(removeStatements); displayModel.remove(removeStatements);
//displayModel.add(addStatements); displayModel.add(addStatements);
} catch(Exception ex) { } catch(Exception ex) {
@ -448,8 +448,11 @@ public class MenuManagementEdit extends VitroHttpServlet {
private void removeMenuName(OntModel displayModel, Model removeModel, VitroRequest vreq, private void removeMenuName(OntModel displayModel, Model removeModel, VitroRequest vreq,
Resource menuItemResource, Resource pageResource) { Resource menuItemResource, Resource pageResource) {
String menuName = vreq.getParameter("menuName"); String menuName = vreq.getParameter("menuName");
removeModel.add(displayModel.listStatements(menuItemResource, DisplayVocabulary.LINK_TEXT, (RDFNode) null)); removeModel.add(displayModel.listStatements(
removeModel.add(removeModel.createStatement( menuItemResource,
DisplayVocabulary.LINK_TEXT,
(RDFNode) null));
removeModel.add(displayModel.listStatements(
pageResource, pageResource,
ResourceFactory.createProperty(DisplayVocabulary.TITLE), ResourceFactory.createProperty(DisplayVocabulary.TITLE),
(RDFNode) null)); (RDFNode) null));
@ -459,6 +462,10 @@ public class MenuManagementEdit extends VitroHttpServlet {
private void generateStatementsForAdd(Model addModel, OntModel displayModel, Resource menuItemResource, Resource pageResource) { private void generateStatementsForAdd(Model addModel, OntModel displayModel, Resource menuItemResource, Resource pageResource) {
//Need to generate the menu item and page in their entirety //Need to generate the menu item and page in their entirety
//Menu item //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, RDF.type, DisplayVocabulary.NAVIGATION_ELEMENT));
addModel.add(addModel.createStatement(menuItemResource, addModel.add(addModel.createStatement(menuItemResource,
DisplayVocabulary.MENU_POSITION, DisplayVocabulary.MENU_POSITION,

View file

@ -39,7 +39,7 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
private static List<String> localNamespaces = new ArrayList<String>(); private static List<String> localNamespaces = new ArrayList<String>();
private static List<VClass> localNamespaceClasses = new ArrayList<VClass>(); private static List<VClass> localNamespaceClasses = new ArrayList<VClass>();
private static final String CREATE_CLASS_PARAM = "createClass"; private static final String CREATE_CLASS_PARAM = "createClass";
private static final String REDIRECT_PAGE = "/siteAdmin";
@Override @Override
protected Actions requiredActions(VitroRequest vreq) { protected Actions requiredActions(VitroRequest vreq) {
return REQUIRED_ACTIONS; return REQUIRED_ACTIONS;
@ -93,7 +93,6 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
} }
private void processCreateOntologies(VitroRequest vreq, Map<String, Object> data) { private void processCreateOntologies(VitroRequest vreq, Map<String, Object> data) {
data.put("ontologiesExist", false);
data.put("submitAction", ""); data.put("submitAction", "");
} }
@ -106,22 +105,22 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
private void processCreateNewClass(VitroRequest vreq, Map<String, Object> data) { 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 //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("submitAction", "createClass");
data.put("createNewClass", true);
} }
private boolean isCreateNewClass(VitroRequest vreq) { private boolean isCreateNewClass(VitroRequest vreq) {
String command = vreq.getParameter("cmd"); String command = vreq.getParameter("cmd");
if(command.equals(CREATE_CLASS_PARAM)) { if(command != null && command.equals(CREATE_CLASS_PARAM)) {
return true; return true;
} }
//If no classes in local namespaces, then need to enable creation of new classes //If local namespace exists but no classes in local namespaces, then need to enable creation of new classes
return(localNamespaceClasses.size() == 0); return(localNamespaces.size() > 0 && localNamespaceClasses.size() == 0);
} }
private void processSelectExistingClass(VitroRequest vreq, Map<String, Object> data) { 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 //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"); data.put("submitAction", "save");
} }
@ -140,8 +139,14 @@ public class InstitutionalInternalClassController extends FreemarkerHttpServlet
data.put("existingLocalNamespaces", localNamespaceClasses); data.put("existingLocalNamespaces", localNamespaceClasses);
String noLocalOntologiesMessage = "There are currently no local ontologies. You must create a new ontology"; String noLocalOntologiesMessage = "There are currently no local ontologies. You must create a new ontology";
data.put("noLocalOntologiesMessage", noLocalOntologiesMessage); data.put("noLocalOntologiesMessage", noLocalOntologiesMessage);
if(localNamespaces.size() > 1) { if(localNamespaces.size() == 0) {
data.put("multipleLocalNamespaces", true); data.put("ontologiesExist", false);
}
else {
data.put("ontologiesExist", true);
if(localNamespaces.size() > 1) {
data.put("multipleLocalNamespaces", true);
}
} }
} }

View file

@ -38,7 +38,7 @@ public class MenuManagementController extends FreemarkerHttpServlet {
private static final Log log = LogFactory.getLog(MenuManagementController.class); private static final Log log = LogFactory.getLog(MenuManagementController.class);
protected final static String SUBMIT_FORM = "/processEditDisplayModel"; 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 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 EDIT_FORM = "testMenuManagement.ftl";
protected final static String CMD_PARAM = "cmd"; protected final static String CMD_PARAM = "cmd";
protected final static String EDIT_PARAM_VALUE = "edit"; 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 //if no menu item passed, return empty data
//TODO: Check if exception needs to be thrown //TODO: Check if exception needs to be thrown
String cmd = getCommand(vreq); String cmd = getCommand(vreq);
String template = EDIT_FORM;
if(cmd.equals(ADD_PARAM_VALUE)) { if(cmd.equals(ADD_PARAM_VALUE)) {
processAddMenuItem(vreq, data); processAddMenuItem(vreq, data);
} else if(cmd.equals(EDIT_PARAM_VALUE)) { } else if(cmd.equals(EDIT_PARAM_VALUE)) {
processEditMenuItem(vreq, data); processEditMenuItem(vreq, data);
} else if(cmd.equals(DELETE_PARAM_VALUE)) { } else if(cmd.equals(DELETE_PARAM_VALUE)) {
processDeleteMenuItem(vreq, data); processDeleteMenuItem(vreq, data);
template = DELETE_FORM;
} else { } else {
//Throw some kind of error or do nothing //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"); data.put("menuAction", "Remove");
//Generate empty values for fields //Generate empty values for fields
//TODO: Remove these if only portion of template utilized //TODO: Remove these if only portion of template utilized
data.put("menuItem", "");
data.put("menuName", "");
data.put("prettyUrl", ""); data.put("prettyUrl", "");
data.put("associatedPage", ""); data.put("associatedPage", "");
data.put("associatedPageURI", ""); data.put("associatedPageURI", "");

View file

@ -26,6 +26,7 @@ public class DisplayVocabulary {
private static final String NS = DISPLAY_NS; private static final String NS = DISPLAY_NS;
/* Individuals */ /* Individuals */
public static final String DEFAULT_MENU = NS + "DefaultMenu";
public static final String SEARCH_INDEX_URI = NS + "SearchIndex"; public static final String SEARCH_INDEX_URI = NS + "SearchIndex";
//bk392 for extracting properties beyond context nodes. //bk392 for extracting properties beyond context nodes.
@ -43,11 +44,13 @@ public class DisplayVocabulary {
public static final String CLASS_INTERSECTION = NS + "intersectsWithClass"; public static final String CLASS_INTERSECTION = NS + "intersectsWithClass";
public static final String HAS_CLASS_INTERSECTION = NS + "hasClassIntersection"; public static final String HAS_CLASS_INTERSECTION = NS + "hasClassIntersection";
public static final String ITEM_TO_PAGE = NS + "toPage"; public static final String ITEM_TO_PAGE = NS + "toPage";
public static final String HAS_ELEMENT = NS + "hasElement";
/**Data Getter object properties **/ /**Data Getter object properties **/
public static final String HAS_DATA_GETTER = NS + "hasDataGetter"; public static final String HAS_DATA_GETTER = NS + "hasDataGetter";
public static final String GETINDIVIDUALS_FOR_CLASS = NS + "getIndividualsForClass"; public static final String GETINDIVIDUALS_FOR_CLASS = NS + "getIndividualsForClass";
public static final String RESTRICT_RESULTS_BY = NS + "restrictResultsByClass"; public static final String RESTRICT_RESULTS_BY = NS + "restrictResultsByClass";
/* Data Properties */ /* Data Properties */
public static final DatatypeProperty URL_MAPPING = m_model.createDatatypeProperty(NS + "urlMapping"); public static final DatatypeProperty URL_MAPPING = m_model.createDatatypeProperty(NS + "urlMapping");

View file

@ -24,7 +24,7 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu
${noLocalOntologiesMessage} ${noLocalOntologiesMessage}
</section> </section>
<#else if useExistingInternalClass = true> <#elseif useExistingInternalClass?has_content>
<section id="existingLocalClass"> <section id="existingLocalClass">
<#--Populated based on class list returned--> <#--Populated based on class list returned-->
<select id="existingLocalClasses" name="existingLocalClasses"> <select id="existingLocalClasses" name="existingLocalClasses">
@ -33,7 +33,7 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu
</#list> </#list>
</select> </select>
</section> </section>
<#else if createNewClass = true> <#elseif createNewClass?has_content>
<section id="createNewLocalClass"> <section id="createNewLocalClass">
<h2>Create a new class</h2> <h2>Create a new class</h2>
<label for="menu-name">Name<span class="requiredHint"> *</span></label> <label for="menu-name">Name<span class="requiredHint"> *</span></label>