diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp
index ebdc5309..5eb2c30b 100644
--- a/productMods/edit/forms/addRoleToPersonTwoStage.jsp
+++ b/productMods/edit/forms/addRoleToPersonTwoStage.jsp
@@ -47,7 +47,12 @@
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
-
+<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement"%>
+
+<%!
+public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addRoleToPersonTwoStage.jsp");
+%>
+
<%--
@@ -66,7 +71,6 @@
${! empty param.numDateFields ? param.numDateFields : 2 }
<%
-
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
@@ -92,6 +96,47 @@
%> <%
}
%>
+
+<%-- 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 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");
+ %> <%
+ } else if(mode == 3){
+ log.debug("This form will be for the repair of a bad role node");
+ %> <%
+ }else if(mode == 4)
+ log.debug("No form will be shown, since there are multiple core:roleIn statements");
+%>
+
@@ -99,7 +144,7 @@
<%--blank triggers default URI generation behavior --%>
<%-- label is required if we are doing an update --%>
-<%= request.getAttribute("objectUri")== null?"":"\"nonempty\"," %>
+<%= mode == 2 ?"\"nonempty\"," : "" %>
<%--
@@ -143,6 +188,11 @@
?roleActivity a ?roleActivityType .
+
+ @prefix core: <${vivoCore}> .
+ ?role core:roleIn ?roleActivity .
+
+
?roleActivity <${label}> ?activityLabel .
@@ -241,7 +291,7 @@
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
- "assertions" : [ ]
+ "assertions" : [ "${n3ForRoleToActivity}" ]
},
"existingActivityLabel" : { /* Needed iff we return from an invalid submission */
"newResource" : "false",
@@ -329,9 +379,8 @@
- ">
-
-
+ ">
+
@@ -343,58 +392,65 @@
-
${titleText} ${roleActivityTypeLabel} entry for <%= subjectName %>
+<% if( mode == 4 ){ %>
+
This form is unable to handle the editing of this role because it is associated with
+ multiple ${param.roleActivityTypeLabel} individuals.
+<% }else{ %>
+
+
${titleText} ${roleActivityTypeLabel} entry for <%= subjectName %>
+
+ <%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
+ " >
+
+
+
+
+
+
+
+
+ <%-- RY maybe make this a label and input field. See what looks best. --%>
+
" class="verifyMatch">(Verify this match)
+
+ <%-- Needed iff we return from an invalid submission --%>
+
+
+
+
+
+
+
+
+
+
Years of Participation in
+
+
+
+
+
+
+
+
+
+
* required fields
+
+
+
+
+
+ <%-- Must be all one line for JavaScript. --%>
+
+ SELECT ?indUri WHERE {<${subjectUri}> <${predicateUri}> ?role . ?role <${vivoCore}roleIn> ?indUri .}
+
+
+
+<% } %>
-<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
-" >
-
-
-
-
-
-
-
-
- <%-- RY maybe make this a label and input field. See what looks best. --%>
-
" class="verifyMatch">(Verify this match)
-
- <%-- Needed iff we return from an invalid submission --%>
-
-
-
-
-
-
-
-
-
-
Years of Participation in
-
-
-
-
-
-
-
-
-
-
* required fields
-
-
-
-
-
-<%-- Must be all one line for JavaScript. --%>
-
-SELECT ?indUri WHERE {<${subjectUri}> <${predicateUri}> ?role . ?role <${vivoCore}roleIn> ?indUri .}
-
-
-
\ No newline at end of file
diff --git a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js
index 6340f98c..ee7de99c 100644
--- a/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js
+++ b/productMods/edit/forms/js/customFormWithAdvanceTypeSelection.js
@@ -74,6 +74,8 @@ var customForm = {
} else {
this.formSteps = 2;
}
+ if( this.editMode == 'repair')
+ this.formSteps = 2;
this.bindEventListeners();
@@ -89,7 +91,7 @@ var customForm = {
// Put this case first, because in edit mode with
// validation errors we just want initFormFullView.
- if (this.editMode == 'edit') {
+ if (this.editMode == 'edit' || this.editMode == 'repair') {
this.initFormFullView();
}
else if (this.findValidationErrors()) {