NIHVIVO-1871 Added repair mode to personInPosition custom form. Consolidated common code to determine mode into a method in FrontEndEditingUtils and removed from individual forms.
This commit is contained in:
parent
8b51f4552b
commit
c80ba7eaf3
2 changed files with 64 additions and 50 deletions
|
@ -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{
|
||||
%> <c:set var="inversePredicate"></c:set> <%
|
||||
}
|
||||
%>
|
||||
|
||||
<%-- 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<ObjectPropertyStatement> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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);
|
||||
EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#roleIn");
|
||||
|
||||
if( mode == EditMode.ADD ) {
|
||||
%> <c:set var="editMode" value="add"/><%
|
||||
} else if(mode == EditMode.EDIT){
|
||||
%> <c:set var="editMode" value="edit"/><%
|
||||
} 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 == EditMode.REPAIR){
|
||||
%> <c:set var="editMode" value="repair"/><%
|
||||
}else if(mode == 4)
|
||||
log.debug("No form will be shown, since there are multiple core:roleIn statements. Setting mode to " + mode);
|
||||
}
|
||||
%>
|
||||
|
||||
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
|
||||
|
@ -164,8 +149,8 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
<c:set var="intervalToEnd" value="${vivoCore}end"/>
|
||||
|
||||
<%-- label and type required if we are doing an add or a repair, but not an edit --%>
|
||||
<c:set var="labelRequired" ><%= (mode == 1 || mode == 3) ?"\"nonempty\"," : "" %></c:set>
|
||||
<c:set var="typeRequired" ><%= (mode == 1 || mode == 3) ?"\"nonempty\"" : "" %></c:set>
|
||||
<c:set var="labelRequired" ><%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ?"\"nonempty\"," : "" %></c:set>
|
||||
<c:set var="typeRequired" ><%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ?"\"nonempty\"" : "" %></c:set>
|
||||
|
||||
<%--
|
||||
<c:choose>
|
||||
|
@ -510,7 +495,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
|||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
<% if( mode == 4 ){ %>
|
||||
<% if( mode == EditMode.ERROR ){ %>
|
||||
<div>This form is unable to handle the editing of this role because it is associated with
|
||||
multiple ${param.roleActivityTypeLabel} individuals.</div>
|
||||
<% }else{ %>
|
||||
|
|
|
@ -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 ) {
|
||||
%> <c:set var="editMode" value="add"/><%
|
||||
} else if(mode == EditMode.EDIT){
|
||||
%> <c:set var="editMode" value="edit"/><%
|
||||
} else if(mode == EditMode.REPAIR){
|
||||
%> <c:set var="editMode" value="repair"/><%
|
||||
}
|
||||
%>
|
||||
|
||||
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
|
||||
|
@ -211,23 +237,18 @@
|
|||
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||
|
||||
<%-- Configure add vs. edit --%>
|
||||
<%
|
||||
|
||||
String objectUri = (String) request.getAttribute("objectUri");
|
||||
if (objectUri != null) { // editing existing entry
|
||||
%>
|
||||
<c:set var="editMode" value="edit" />
|
||||
<c:set var="titleVerb" value="Edit" />
|
||||
<c:set var="submitButtonText" value="Edit Position" />
|
||||
<c:set var="disabledVal" value="disabled" />
|
||||
<%
|
||||
} else { // adding new entry
|
||||
%>
|
||||
<c:set var="editMode" value="add" />
|
||||
<c:choose>
|
||||
<c:when test='${editMode == "add"}'>
|
||||
<c:set var="titleVerb" value="Create" />
|
||||
<c:set var="submitButtonText" value="Position" />
|
||||
<c:set var="disabledVal" value="" />
|
||||
<% } %>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
<c:set var="titleVerb" value="Edit" />
|
||||
<c:set var="submitButtonText" value="Edit Position" />
|
||||
<c:set var="disabledVal">${editMode == "repair" ? "" : "" }</c:set>
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
<c:set var="editjson" scope="request">
|
||||
{
|
||||
|
@ -356,7 +377,7 @@
|
|||
</c:set>
|
||||
|
||||
<%
|
||||
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 @@
|
|||
|
||||
<jsp:include page="${preForm}" />
|
||||
|
||||
<% if( mode == EditMode.ERROR ){ %>
|
||||
<div>This form is unable to handle the editing of this position because it is associated with
|
||||
multiple Position individuals.</div>
|
||||
<% }else{ %>
|
||||
|
||||
<h2>${titleVerb} position entry for <%= subjectName %></h2>
|
||||
|
||||
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||
|
@ -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
|
||||
};
|
||||
</script>
|
||||
<% } %>
|
||||
|
||||
<jsp:include page="${postForm}"/>
|
||||
|
|
Loading…
Add table
Reference in a new issue