Merge to trunk. changing forms for addRoleToPersonTwoStage.jsp so that it can edit a role with out a core:roleIn statement. NIHVIVO-863

This commit is contained in:
bdc34 2010-07-22 00:42:44 +00:00
parent 59db70e8e0
commit f8a9ffe9c5
2 changed files with 119 additions and 61 deletions

View file

@ -47,7 +47,12 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" /> <%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement"%><c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
<%!
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addRoleToPersonTwoStage.jsp");
%>
<c:set var="vivoCore" value="${vivoOnt}/core#" /> <c:set var="vivoCore" value="${vivoOnt}/core#" />
<%-- <%--
@ -66,7 +71,6 @@
<c:set var="numDateFields">${! empty param.numDateFields ? param.numDateFields : 2 }</c:set> <c:set var="numDateFields">${! empty param.numDateFields ? param.numDateFields : 2 }</c:set>
<% <%
VitroRequest vreq = new VitroRequest(request); VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory(); WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior //vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
@ -92,6 +96,47 @@
%> <c:set var="inversePredicate"></c:set> <% %> <c:set var="inversePredicate"></c:set> <%
} }
%> %>
<%-- 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
the other end of the object's core:roleIn 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: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");
else if(mode == 2){
log.debug("This form will be for a normal 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");
%> <c:set var="editMode" value="repair"/><%
}else if(mode == 4)
log.debug("No form will be shown, since there are multiple core:roleIn statements");
%>
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" /> <c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
<c:set var="vivoCore" value="${vivoOnt}/core#" /> <c:set var="vivoCore" value="${vivoOnt}/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" /> <c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
@ -99,7 +144,7 @@
<c:set var="defaultNamespace" value=""/> <%--blank triggers default URI generation behavior --%> <c:set var="defaultNamespace" value=""/> <%--blank triggers default URI generation behavior --%>
<%-- label is required if we are doing an update --%> <%-- label is required if we are doing an update --%>
<c:set var="labelRequired" ><%= request.getAttribute("objectUri")== null?"":"\"nonempty\"," %></c:set> <c:set var="labelRequired" ><%= mode == 2 ?"\"nonempty\"," : "" %></c:set>
<%-- <%--
<c:choose> <c:choose>
@ -143,6 +188,11 @@
?roleActivity a ?roleActivityType . ?roleActivity a ?roleActivityType .
</v:jsonset> </v:jsonset>
<v:jsonset var="n3ForRoleToActivity">
@prefix core: <${vivoCore}> .
?role core:roleIn ?roleActivity .
</v:jsonset>
<v:jsonset var="n3ForActivityLabel"> <v:jsonset var="n3ForActivityLabel">
?roleActivity <${label}> ?activityLabel . ?roleActivity <${label}> ?activityLabel .
</v:jsonset> </v:jsonset>
@ -241,7 +291,7 @@
"objectClassUri" : "", "objectClassUri" : "",
"rangeDatatypeUri" : "", "rangeDatatypeUri" : "",
"rangeLang" : "", "rangeLang" : "",
"assertions" : [ ] "assertions" : [ "${n3ForRoleToActivity}" ]
}, },
"existingActivityLabel" : { /* Needed iff we return from an invalid submission */ "existingActivityLabel" : { /* Needed iff we return from an invalid submission */
"newResource" : "false", "newResource" : "false",
@ -331,7 +381,6 @@
<c:choose> <c:choose>
<c:when test="<%= request.getAttribute(\"objectUri\")!=null %>"> <c:when test="<%= request.getAttribute(\"objectUri\")!=null %>">
<c:set var="titleText" value="Edit" /> <c:set var="titleText" value="Edit" />
<c:set var="editMode" value="edit" />
<c:set var="submitButtonText" value="Edit ${roleActivityTitleCase}" /> <c:set var="submitButtonText" value="Edit ${roleActivityTitleCase}" />
</c:when> </c:when>
<c:otherwise> <c:otherwise>
@ -343,6 +392,11 @@
<jsp:include page="${preForm}" /> <jsp:include page="${preForm}" />
<% if( mode == 4 ){ %>
<div>This form is unable to handle the editing of this role because it is associated with
multiple ${param.roleActivityTypeLabel} individuals.</div>
<% }else{ %>
<h2>${titleText}&nbsp;${roleActivityTypeLabel} entry for <%= subjectName %></h2> <h2>${titleText}&nbsp;${roleActivityTypeLabel} entry for <%= subjectName %></h2>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> <%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
@ -397,4 +451,6 @@ var customFormData = {
submitButtonTextType: 'compound' submitButtonTextType: 'compound'
}; };
</script> </script>
<% } %>
<jsp:include page="${postForm}"/> <jsp:include page="${postForm}"/>

View file

@ -74,6 +74,8 @@ var customForm = {
} else { } else {
this.formSteps = 2; this.formSteps = 2;
} }
if( this.editMode == 'repair')
this.formSteps = 2;
this.bindEventListeners(); this.bindEventListeners();
@ -89,7 +91,7 @@ var customForm = {
// Put this case first, because in edit mode with // Put this case first, because in edit mode with
// validation errors we just want initFormFullView. // validation errors we just want initFormFullView.
if (this.editMode == 'edit') { if (this.editMode == 'edit' || this.editMode == 'repair') {
this.initFormFullView(); this.initFormFullView();
} }
else if (this.findValidationErrors()) { else if (this.findValidationErrors()) {