diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp index 1ab781c0..a08b12e9 100644 --- a/productMods/edit/forms/addRoleToPersonTwoStage.jsp +++ b/productMods/edit/forms/addRoleToPersonTwoStage.jsp @@ -40,6 +40,8 @@ <%@ page import="edu.cornell.mannlib.vitro.webapp.utils.TitleCase" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartYearBeforeEndYear"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %> @@ -103,9 +105,9 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. }else{ %> <% } -%> - -<%-- There are 4 modes that this form can be in: + +/* + There are 4 modes that this form can be in: 1. Add, there is a subject and a predicate but no role and nothing else. 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on @@ -115,34 +117,17 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. other end of the object's core:roleIn stmt. This should be similar to an add but the form should be expanded. 4. Really bad node. multiple roleIn statements. - ---%> -<% - /* check to see if this is mode 3 */ - int mode = 1; - Individual obj = (Individual)request.getAttribute("object"); - if( obj != null){ - List stmts = obj.getObjectPropertyStatements("http://vivoweb.org/ontology/core#roleIn"); - if( stmts != null){ - if( stmts.size() > 1 ){ - mode = 4; // Multiple roleIn statements, yuck. - }else if( stmts.size() == 0 ){ - mode = 3; // need to repair the role node - }else if(stmts.size() == 1 ){ - mode = 2; - } - } +*/ + + EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#roleIn"); + + if( mode == EditMode.ADD ) { + %> <% + } else if(mode == EditMode.EDIT){ + %> <% + } else if(mode == EditMode.REPAIR){ + %> <% } - if( mode == 1 ) - log.debug("This form will be for an add. Setting mode to " + mode); - else if(mode == 2){ - log.debug("This form will be for a normal edit. Setting mode to " + mode); - %> <% - } else if(mode == 3){ - log.debug("This form will be for the repair of a bad role node. Setting mode to " + mode); - %> <% - }else if(mode == 4) - log.debug("No form will be shown, since there are multiple core:roleIn statements. Setting mode to " + mode); %> @@ -164,8 +149,8 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. <%-- label and type required if we are doing an add or a repair, but not an edit --%> -<%= (mode == 1 || mode == 3) ?"\"nonempty\"," : "" %> -<%= (mode == 1 || mode == 3) ?"\"nonempty\"" : "" %> +<%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ?"\"nonempty\"," : "" %> +<%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ?"\"nonempty\"" : "" %> <%-- @@ -510,7 +495,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp. -<% if( mode == 4 ){ %> +<% if( mode == EditMode.ERROR ){ %>
This form is unable to handle the editing of this role because it is associated with multiple ${param.roleActivityTypeLabel} individuals.
<% }else{ %> diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index b39b9f82..921f5f47 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -19,6 +19,9 @@ <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> +<%@page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> <%@ page import="org.apache.commons.logging.Log" %> <%@ page import="org.apache.commons.logging.LogFactory" %> @@ -37,6 +40,29 @@ request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); + +/* + There are 4 modes that this form can be in: + 1. Add, there is a subject and a predicate but no position and nothing else. + + 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on + the other end of the object's core:personInOrganization stmt. + + 3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the + other end of the object's core:personInOrganization stmt. This should be similar to an add but the form should be expanded. + + 4. Really bad node. multiple core:personInOrganization statements. +*/ + + EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#positionInOrganization"); + + if( mode == EditMode.ADD ) { + %> <% + } else if(mode == EditMode.EDIT){ + %> <% + } else if(mode == EditMode.REPAIR){ + %> <% + } %> @@ -210,24 +236,19 @@ -<%-- Configure add vs. edit --%> -<% - - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { // editing existing entry -%> - - - - -<% - } else { // adding new entry -%> - +<%-- Configure add vs. edit --%> + + -<% } %> + + + + + ${editMode == "repair" ? "" : "" } + + { @@ -356,7 +377,7 @@ <% - log.debug(request.getAttribute("editjson")); + //log.debug(request.getAttribute("editjson")); EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if (editConfig == null) { @@ -375,6 +396,7 @@ Model model = (Model) application.getAttribute("jenaOntModel"); + String objectUri = (String) request.getAttribute("objectUri"); if (objectUri != null) { // editing existing editConfig.prepareForObjPropUpdate(model); } else { // adding new @@ -398,6 +420,11 @@ +<% if( mode == EditMode.ERROR ){ %> +
This form is unable to handle the editing of this position because it is associated with + multiple Position individuals.
+<% }else{ %> +

${titleVerb} position entry for <%= subjectName %>

" > @@ -441,8 +468,10 @@ var customFormData = { acUrl: '${acUrl}', editMode: '${editMode}', - submitButtonTextType: 'compound' + submitButtonTextType: 'compound', + defaultTypeName: 'organization' // used in repair mode, to generate button text and org name field label }; +<% } %>