NIHVIVO-1023 Change position history custom form to use autocomplete rather than select list for related organization
This commit is contained in:
parent
03fd89842f
commit
56856f0704
8 changed files with 167 additions and 227 deletions
|
@ -263,14 +263,14 @@ PREFIX core: <${vivoCore}>
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||||
"/js/browserUtils.js",
|
"/js/browserUtils.js",
|
||||||
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
"/edit/forms/js/customFormWithAutocomplete.js"
|
||||||
));
|
));
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
||||||
Css.CUSTOM_FORM.path(),
|
Css.CUSTOM_FORM.path(),
|
||||||
"/edit/forms/css/autocomplete.css",
|
"/edit/forms/css/autocomplete.css",
|
||||||
"/edit/forms/css/customFormWithAdvanceTypeSelection.css"
|
"/edit/forms/css/customFormWithAutocomplete.css"
|
||||||
));
|
));
|
||||||
request.setAttribute("customCss", customCss);
|
request.setAttribute("customCss", customCss);
|
||||||
%>
|
%>
|
||||||
|
|
|
@ -211,14 +211,14 @@ SPARQL queries for existing values. --%>
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||||
"/js/browserUtils.js",
|
"/js/browserUtils.js",
|
||||||
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
"/edit/forms/js/customFormWithAutocomplete.js"
|
||||||
));
|
));
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
||||||
Css.CUSTOM_FORM.path(),
|
Css.CUSTOM_FORM.path(),
|
||||||
"/edit/forms/css/autocomplete.css",
|
"/edit/forms/css/autocomplete.css",
|
||||||
"/edit/forms/css/customFormWithAdvanceTypeSelection.css"
|
"/edit/forms/css/customFormWithAutocomplete.css"
|
||||||
));
|
));
|
||||||
request.setAttribute("customCss", customCss);
|
request.setAttribute("customCss", customCss);
|
||||||
%>
|
%>
|
||||||
|
|
|
@ -151,16 +151,6 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
<c:set var="labelRequired" ><%= (mode == 1 || mode == 3) ?"\"nonempty\"," : "" %></c:set>
|
<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="typeRequired" ><%= (mode == 1 || mode == 3) ?"\"nonempty\"" : "" %></c:set>
|
||||||
|
|
||||||
<%--
|
|
||||||
<c:choose>
|
|
||||||
<c:when test="${numDateFields == 1}">
|
|
||||||
<c:set var="startYearPredicate" value="${vivoCore}year" />
|
|
||||||
</c:when>
|
|
||||||
<c:otherwise>
|
|
||||||
<c:set var="startYearPredicate" value="${vivoCore}startYear" />
|
|
||||||
</c:otherwise>
|
|
||||||
</c:choose>
|
|
||||||
--%>
|
|
||||||
<c:set var="startYearPredicate">
|
<c:set var="startYearPredicate">
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<c:when test="${numDateFields == 1}">${vivoCore}year</c:when>
|
<c:when test="${numDateFields == 1}">${vivoCore}year</c:when>
|
||||||
|
@ -168,12 +158,12 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
</c:choose>
|
</c:choose>
|
||||||
</c:set>
|
</c:set>
|
||||||
<v:jsonset var="startYearAssertion" >
|
<v:jsonset var="startYearAssertion" >
|
||||||
?role <${startYearPredicate}> ?startYear .
|
?role <${startYearPredicate}> ?startYear .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<c:set var="endYearPredicate" value="${vivoCore}endYear" />
|
<c:set var="endYearPredicate" value="${vivoCore}endYear" />
|
||||||
<v:jsonset var="endYearAssertion" >
|
<v:jsonset var="endYearAssertion" >
|
||||||
?role <${endYearPredicate}> ?endYear .
|
?role <${endYearPredicate}> ?endYear .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="roleLabelAssertion" >
|
<v:jsonset var="roleLabelAssertion" >
|
||||||
|
@ -359,30 +349,30 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
|
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||||
JavaScript.CUSTOM_FORM_UTILS.path(),
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||||
"/edit/forms/js/customFormWithAdvanceTypeSelection.js"
|
"/edit/forms/js/customFormWithAutocomplete.js"
|
||||||
));
|
));
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
||||||
Css.CUSTOM_FORM.path(),
|
Css.CUSTOM_FORM.path(),
|
||||||
"/edit/forms/css/autocomplete.css",
|
"/edit/forms/css/autocomplete.css",
|
||||||
"/edit/forms/css/customFormWithAdvanceTypeSelection.css"
|
"/edit/forms/css/customFormWithAutocomplete.css"
|
||||||
));
|
));
|
||||||
request.setAttribute("customCss", customCss);
|
request.setAttribute("customCss", customCss);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||||
<c:set var="yearMonthHint" value="<span class='hint'>(YYYY-MM)</span>" />
|
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||||
|
|
||||||
<c:choose>
|
<c:choose>
|
||||||
<%-- Includes edit AND repair mode --%>
|
<%-- Includes edit AND repair mode --%>
|
||||||
<c:when test="<%= request.getAttribute(\"objectUri\")!=null %>">
|
<c:when test="<%= request.getAttribute(\"objectUri\")!=null %>">
|
||||||
<c:set var="titleText" value="Edit" />
|
<c:set var="titleVerb" value="Edit" />
|
||||||
<c:set var="submitButtonText" value="Edit ${buttonLabel}" />
|
<c:set var="submitButtonText" value="Edit ${buttonLabel}" />
|
||||||
<c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set>
|
<c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set>
|
||||||
</c:when>
|
</c:when>
|
||||||
<c:otherwise>
|
<c:otherwise>
|
||||||
<c:set var="titleText" value="Create" />
|
<c:set var="titleVerb" value="Create" />
|
||||||
<c:set var="editMode" value="add" />
|
<c:set var="editMode" value="add" />
|
||||||
<c:set var="submitButtonText" value="${buttonLabel}" />
|
<c:set var="submitButtonText" value="${buttonLabel}" />
|
||||||
<c:set var="disabledVal" value="" />
|
<c:set var="disabledVal" value="" />
|
||||||
|
@ -396,7 +386,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
multiple ${param.roleActivityTypeLabel} individuals.</div>
|
multiple ${param.roleActivityTypeLabel} individuals.</div>
|
||||||
<% }else{ %>
|
<% }else{ %>
|
||||||
|
|
||||||
<h2>${titleText} ${roleActivityTypeLabel} entry for <%= subjectName %></h2>
|
<h2>${titleVerb} ${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! --%>
|
||||||
<form id="addRoleForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
<form id="addRoleForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
|
|
||||||
|
@ -416,7 +406,7 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
<div class="acSelection">
|
<div class="acSelection">
|
||||||
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
||||||
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
|
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
|
||||||
<v:input type="hidden" id="roleActivityURI" name="roleActivity" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
<v:input type="hidden" id="roleActivityUri" name="roleActivity" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p><v:input type="text" id="newIndLabel" name="roleLabel" label="Role in ### ${requiredHint}" size="50" /></p>
|
<p><v:input type="text" id="newIndLabel" name="roleLabel" label="Role in ### ${requiredHint}" size="50" /></p>
|
||||||
|
@ -440,11 +430,9 @@ public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<c:url var="acUrl" value="/autocomplete?tokenize=true&stem=true" />
|
<c:url var="acUrl" value="/autocomplete?tokenize=true&stem=true" />
|
||||||
<c:url var="sparqlQueryUrl" value="/admin/sparqlquery" />
|
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var customFormData = {
|
var customFormData = {
|
||||||
sparqlQueryUrl: '${sparqlQueryUrl}',
|
|
||||||
acUrl: '${acUrl}',
|
acUrl: '${acUrl}',
|
||||||
editMode: '${editMode}',
|
editMode: '${editMode}',
|
||||||
submitButtonTextType: 'compound'
|
submitButtonTextType: 'compound'
|
||||||
|
|
|
@ -1,9 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
#endYearHint {
|
|
||||||
margin-left: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content form p.inline.year input {
|
|
||||||
margin-left: 12em;
|
|
||||||
}
|
|
|
@ -15,7 +15,8 @@
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartYearBeforeEndYear"%>
|
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.StartYearBeforeEndYear"%>
|
||||||
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasPositionValidator"%>
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
|
||||||
|
|
||||||
<%@ page import="org.apache.commons.logging.Log" %>
|
<%@ page import="org.apache.commons.logging.Log" %>
|
||||||
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||||
|
@ -41,87 +42,97 @@
|
||||||
<c:set var="positionClass" value="${vivoCore}Position" />
|
<c:set var="positionClass" value="${vivoCore}Position" />
|
||||||
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
|
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
|
||||||
|
|
||||||
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
|
<%-- Define predicates used in n3 assertions and sparql queries --%>
|
||||||
to convey that the expression is used to retrieve any existing value for the field in an existing individual.
|
|
||||||
Each of these must then be referenced in the sparqlForExistingLiterals section of the JSON block below
|
|
||||||
and in the literalsOnForm --%>
|
|
||||||
<c:set var="titlePred" value="${vivoCore}titleOrRole" />
|
<c:set var="titlePred" value="${vivoCore}titleOrRole" />
|
||||||
<v:jsonset var="titleExisting" >
|
|
||||||
SELECT ?titleExisting WHERE {
|
|
||||||
?positionUri <${titlePred}> ?titleExisting }
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- Pair the "existing" query with the skeleton of what will be asserted for a new statement involving this field.
|
|
||||||
The actual assertion inserted in the model will be created via string substitution into the ? variables.
|
|
||||||
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
|
|
||||||
<v:jsonset var="titleAssertion" >
|
|
||||||
?positionUri <${titlePred}> ?title ;
|
|
||||||
<${label}> ?title.
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="startYearPred" value="${vivoCore}startYear" />
|
<c:set var="startYearPred" value="${vivoCore}startYear" />
|
||||||
<v:jsonset var="startYearExisting" >
|
|
||||||
SELECT ?startYearExisting WHERE {
|
|
||||||
?positionUri <${startYearPred}> ?startYearExisting }
|
|
||||||
</v:jsonset>
|
|
||||||
<v:jsonset var="startYearAssertion" >
|
|
||||||
?positionUri <${startYearPred}> ?startYear .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="endYearPred" value="${vivoCore}endYear" />
|
<c:set var="endYearPred" value="${vivoCore}endYear" />
|
||||||
<v:jsonset var="endYearExisting" >
|
|
||||||
SELECT ?endYearExisting WHERE {
|
|
||||||
?positionUri <${endYearPred}> ?endYearExisting }
|
|
||||||
</v:jsonset>
|
|
||||||
<v:jsonset var="endYearAssertion" >
|
|
||||||
?positionUri <${endYearPred}> ?endYear .
|
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<%-- Note there is really no difference in how things are set up for an object property except
|
|
||||||
below in the n3ForEdit section, in whether the ..Existing variable goes in SparqlForExistingLiterals
|
|
||||||
or in the SparqlForExistingUris, as well as perhaps in how the options are prepared --%>
|
|
||||||
<c:set var="positionInOrgPred" value="${vivoCore}positionInOrganization" />
|
<c:set var="positionInOrgPred" value="${vivoCore}positionInOrganization" />
|
||||||
<c:set var="orgForPositionPred" value="${vivoCore}organizationForPosition" />
|
<c:set var="orgForPositionPred" value="${vivoCore}organizationForPosition" />
|
||||||
<v:jsonset var="organizationUriExisting" >
|
|
||||||
SELECT ?existingOrgUri WHERE {
|
<%-- Assertions for adding a new role --%>
|
||||||
?positionUri <${positionInOrgPred}> ?existingOrgUri }
|
|
||||||
</v:jsonset>
|
<v:jsonset var="orgTypeAssertion">
|
||||||
<v:jsonset var="organizationUriAssertion" >
|
?org a ?orgType .
|
||||||
?positionUri <${positionInOrgPred}> ?organizationUri .
|
|
||||||
?organizationUri <${orgForPositionPred}> ?positionUri .
|
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="positionTypeExisting">
|
<v:jsonset var="orgLabelAssertion">
|
||||||
SELECT ?existingPositionType WHERE {
|
?org <${label}> ?orgLabel .
|
||||||
?positionUri a ?existingPositionType }
|
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="positionTitleAssertion" >
|
||||||
|
?position <${titlePred}> ?positionTitle ;
|
||||||
|
<${label}> ?positionTitle .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="positionTypeAssertion">
|
<v:jsonset var="positionTypeAssertion">
|
||||||
?positionUri a ?positionType .
|
?position a ?positionType .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="newOrgNameAssertion">
|
<v:jsonset var="startYearAssertion" >
|
||||||
?newOrg <${label}> ?newOrgName .
|
?position <${startYearPred}> ?startYear .
|
||||||
</v:jsonset>
|
|
||||||
<v:jsonset var="newOrgTypeAssertion">
|
|
||||||
?newOrg a ?newOrgType .
|
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForStmtToPerson">
|
<v:jsonset var="endYearAssertion" >
|
||||||
@prefix core: <${vivoCore}> .
|
?position <${endYearPred}> ?endYear .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
?person core:personInPosition ?positionUri .
|
<v:jsonset var="n3ForNewPosition">
|
||||||
|
@prefix core: <${vivoCore}> .
|
||||||
|
|
||||||
|
?person core:personInPosition ?position .
|
||||||
|
|
||||||
?positionUri core:positionForPerson ?person ;
|
?position a ?positionType ;
|
||||||
a ?positionType .
|
core:positionForPerson ?person ;
|
||||||
|
<${positionInOrgPred}> ?org .
|
||||||
|
|
||||||
|
?org <${orgForPositionPred}> ?position .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForNewOrg">
|
<v:jsonset var="n3ForPositionToOrg" >
|
||||||
?positionUri <${positionInOrgPred}> ?newOrg .
|
?position <${positionInOrgPred}> ?org .
|
||||||
|
?org <${orgForPositionPred}> ?position .
|
||||||
?newOrg <${label}> ?newOrgName ;
|
</v:jsonset>
|
||||||
a ?newOrgType ;
|
|
||||||
<${orgForPositionPred}> ?positionUri .
|
|
||||||
|
|
||||||
|
|
||||||
|
<%-- Queries for editing an existing role --%>
|
||||||
|
|
||||||
|
<v:jsonset var="orgQuery" >
|
||||||
|
SELECT ?existingOrg WHERE {
|
||||||
|
?position <${positionInOrgPred}> ?existingOrg . }
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="orgLabelQuery" >
|
||||||
|
SELECT ?existingOrgLabel WHERE {
|
||||||
|
?position <${positionInOrgPred}> ?existingOrg .
|
||||||
|
?existingOrg <${label}> ?existingOrgLabel .
|
||||||
|
}
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="orgTypeQuery" >
|
||||||
|
SELECT ?existingOrgType WHERE {
|
||||||
|
?position <${positionInOrgPred}> ?existingOrg .
|
||||||
|
?existingOrg a ?existingOrgType .
|
||||||
|
}
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="positionTitleQuery" >
|
||||||
|
SELECT ?existingPositionTitle WHERE {
|
||||||
|
?position <${titlePred}> ?existingPositionTitle . }
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="positionTypeQuery">
|
||||||
|
SELECT ?existingPositionType WHERE {
|
||||||
|
?position a ?existingPositionType . }
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="startYearQuery" >
|
||||||
|
SELECT ?existingStartYear WHERE {
|
||||||
|
?position <${startYearPred}> ?existingStartYear . }
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="endYearQuery" >
|
||||||
|
SELECT ?existingEndYear WHERE {
|
||||||
|
?position <${endYearPred}> ?existingEndYear . }
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="positionClassUriJson">${positionClass}</v:jsonset>
|
<v:jsonset var="positionClassUriJson">${positionClass}</v:jsonset>
|
||||||
|
@ -135,35 +146,35 @@
|
||||||
|
|
||||||
"subject" : ["person", "${subjectUriJson}" ],
|
"subject" : ["person", "${subjectUriJson}" ],
|
||||||
"predicate" : ["predicate", "${predicateUriJson}" ],
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||||
"object" : ["positionUri", "${objectUriJson}", "URI" ],
|
"object" : ["position", "${objectUriJson}", "URI" ],
|
||||||
|
|
||||||
"n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ],
|
"n3required" : [ "${n3ForNewPosition}", "${positionTitleAssertion}", "${positionTypeAssertion}", "${startYearAssertion}" ],
|
||||||
|
|
||||||
"n3optional" : [ "${organizationUriAssertion}",
|
"n3optional" : [ "${orgLabelAssertion}", "${orgTypeAssertion}", "${endYearAssertion}" ],
|
||||||
"${n3ForNewOrg}", "${newOrgNameAssertion}", "${newOrgTypeAssertion}",
|
|
||||||
"${endYearAssertion}"],
|
"newResources" : { "position" : "${defaultNamespace}",
|
||||||
|
"org" : "${defaultNamespace}" },
|
||||||
"newResources" : { "positionUri" : "${defaultNamespace}",
|
|
||||||
"newOrg" : "${defaultNamespace}" },
|
|
||||||
|
|
||||||
"urisInScope" : { },
|
"urisInScope" : { },
|
||||||
"literalsInScope": { },
|
"literalsInScope": { },
|
||||||
"urisOnForm" : [ "organizationUri", "newOrgType", "positionType" ],
|
"urisOnForm" : [ "org", "orgType", "positionType" ],
|
||||||
"literalsOnForm" : [ "title", "newOrgName", "startYear", "endYear" ],
|
"literalsOnForm" : [ "positionTitle", "orgLabel", "startYear", "endYear" ],
|
||||||
"filesOnForm" : [ ],
|
"filesOnForm" : [ ],
|
||||||
"sparqlForLiterals" : { },
|
"sparqlForLiterals" : { },
|
||||||
"sparqlForUris" : { },
|
"sparqlForUris" : { },
|
||||||
"sparqlForExistingLiterals" : {
|
"sparqlForExistingLiterals" : {
|
||||||
"title" : "${titleExisting}",
|
"orgLabel" : "${orgLabelQuery}",
|
||||||
"startYear" : "${startYearExisting}",
|
"positionTitle" : "${positionTitleQuery}",
|
||||||
"endYear" : "${endYearExisting}"
|
"startYear" : "${startYearQuery}",
|
||||||
|
"endYear" : "${endYearQuery}"
|
||||||
},
|
},
|
||||||
"sparqlForExistingUris" : {
|
"sparqlForExistingUris" : {
|
||||||
"organizationUri" : "${organizationUriExisting}",
|
"org" : "${orgQuery}",
|
||||||
"positionType" : "${positionTypeExisting}"
|
"orgType" : "${orgTypeQuery}",
|
||||||
|
"positionType" : "${positionTypeQuery}"
|
||||||
},
|
},
|
||||||
"fields" : {
|
"fields" : {
|
||||||
"title" : {
|
"positionTitle" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
"validators" : [ "nonempty" ],
|
"validators" : [ "nonempty" ],
|
||||||
"optionsType" : "UNDEFINED",
|
"optionsType" : "UNDEFINED",
|
||||||
|
@ -172,7 +183,7 @@
|
||||||
"objectClassUri" : "",
|
"objectClassUri" : "",
|
||||||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${titleAssertion}" ]
|
"assertions" : [ "${positionTitleAssertion}" ]
|
||||||
},
|
},
|
||||||
"positionType" : {
|
"positionType" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
|
@ -185,7 +196,7 @@
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${positionTypeAssertion}" ]
|
"assertions" : [ "${positionTypeAssertion}" ]
|
||||||
},
|
},
|
||||||
"organizationUri" : {
|
"org" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
"validators" : [ ],
|
"validators" : [ ],
|
||||||
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
|
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
|
||||||
|
@ -194,9 +205,9 @@
|
||||||
"objectClassUri" : "${orgClassUriJson}",
|
"objectClassUri" : "${orgClassUriJson}",
|
||||||
"rangeDatatypeUri" : "",
|
"rangeDatatypeUri" : "",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${organizationUriAssertion}" ]
|
"assertions" : [ "${n3ForPositionToOrg}" ]
|
||||||
},
|
},
|
||||||
"newOrgName" : {
|
"orgLabel" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
"validators" : [ ],
|
"validators" : [ ],
|
||||||
"optionsType" : "UNDEFINED",
|
"optionsType" : "UNDEFINED",
|
||||||
|
@ -205,9 +216,9 @@
|
||||||
"objectClassUri" : "",
|
"objectClassUri" : "",
|
||||||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${n3ForNewOrg}" ]
|
"assertions" : [ "${orgLabelAssertion}" ]
|
||||||
},
|
},
|
||||||
"newOrgType" : {
|
"orgType" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
"validators" : [ ],
|
"validators" : [ ],
|
||||||
"optionsType" : "CHILD_VCLASSES",
|
"optionsType" : "CHILD_VCLASSES",
|
||||||
|
@ -216,7 +227,7 @@
|
||||||
"objectClassUri" : "${orgClassUriJson}",
|
"objectClassUri" : "${orgClassUriJson}",
|
||||||
"rangeDatatypeUri" : "",
|
"rangeDatatypeUri" : "",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${newOrgTypeAssertion}" ]
|
"assertions" : [ "${orgTypeAssertion}" ]
|
||||||
},
|
},
|
||||||
"startYear" : {
|
"startYear" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
|
@ -252,9 +263,8 @@
|
||||||
EditConfiguration.putConfigInSession(editConfig,session);
|
EditConfiguration.putConfigInSession(editConfig,session);
|
||||||
}
|
}
|
||||||
|
|
||||||
editConfig.addValidator(new PersonHasPositionValidator() );
|
|
||||||
editConfig.addValidator(new StartYearBeforeEndYear("startYear","endYear") );
|
editConfig.addValidator(new StartYearBeforeEndYear("startYear","endYear") );
|
||||||
|
|
||||||
Model model = (Model) application.getAttribute("jenaOntModel");
|
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||||
String objectUri = (String) request.getAttribute("objectUri");
|
String objectUri = (String) request.getAttribute("objectUri");
|
||||||
if (objectUri != null) { // editing existing
|
if (objectUri != null) { // editing existing
|
||||||
|
@ -270,80 +280,82 @@
|
||||||
<%
|
<%
|
||||||
if (objectUri != null) { // editing existing entry
|
if (objectUri != null) { // editing existing entry
|
||||||
%>
|
%>
|
||||||
<c:set var="editType" value="edit" />
|
<c:set var="editMode" value="edit" />
|
||||||
<c:set var="formSteps" value="1" />
|
<c:set var="titleVerb" value="Edit" />
|
||||||
<c:set var="title" value="Edit position entry for ${subjectName}" />
|
<c:set var="submitButtonText" value="Edit Position" />
|
||||||
<%-- NB This will be the button text when Javascript is disabled. --%>
|
<c:set var="disabledVal" value="disabled" />
|
||||||
<c:set var="submitLabel" value="Save changes" />
|
|
||||||
<%
|
<%
|
||||||
} else { // adding new entry
|
} else { // adding new entry
|
||||||
%>
|
%>
|
||||||
<c:set var="editType" value="add" />
|
<c:set var="editMode" value="add" />
|
||||||
<c:set var="formSteps" value="2" />
|
<c:set var="titleVerb" value="Create" />
|
||||||
<c:set var="title" value="Create position entry for ${subjectName}" />
|
<c:set var="submitButtonText" value="Position" />
|
||||||
<%-- NB This will be the button text when Javascript is disabled. --%>
|
<c:set var="disabledVal" value="" />
|
||||||
<c:set var="submitLabel" value="Create position" />
|
|
||||||
<% }
|
<% }
|
||||||
|
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList("/js/utils.js",
|
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
|
||||||
"/js/customFormUtils.js",
|
JavaScript.CUSTOM_FORM_UTILS.path(),
|
||||||
"/edit/forms/js/customForm.js"
|
"/edit/forms/js/customFormWithAutocomplete.js"
|
||||||
//, "/edit/forms/js/customFormTwoStep.js"
|
));
|
||||||
));
|
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList("/edit/forms/css/customForm.css"
|
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
|
||||||
, "/edit/forms/css/personHasPositionHistory.css"
|
Css.CUSTOM_FORM.path(),
|
||||||
));
|
"/edit/forms/css/autocomplete.css",
|
||||||
request.setAttribute("customCss", customCss);
|
"/edit/forms/css/customFormWithAutocomplete.css"
|
||||||
|
));
|
||||||
|
request.setAttribute("customCss", customCss);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
|
||||||
<c:set var="view" value='<%= vreq.getAttribute("view") %>' />
|
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
|
||||||
|
|
||||||
<jsp:include page="${preForm}" />
|
<jsp:include page="${preForm}" />
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${titleVerb} position entry for <%= subjectName %></h2>
|
||||||
|
|
||||||
<form class="${editType}" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
<form class="${editMode}" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
|
|
||||||
|
<p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p>
|
||||||
|
|
||||||
|
<div class="fullViewOnly">
|
||||||
|
|
||||||
|
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
|
||||||
|
|
||||||
<div class="relatedIndividual">
|
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
|
||||||
<div class="existing">
|
returning from a validation error, we retain the values. --%>
|
||||||
<v:input type="select" label="Select Existing Organization ${requiredHint}" id="organizationUri" /><span class="existingOrNew">or</span>
|
<c:if test="${editMode == 'edit'}">
|
||||||
|
<v:input type="hidden" id="orgType" />
|
||||||
|
<v:input type="hidden" id="orgLabel" />
|
||||||
|
</c:if>
|
||||||
|
|
||||||
|
<div class="acSelection">
|
||||||
|
<%-- RY maybe make this a label and input field. See what looks best. --%>
|
||||||
|
<p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
|
||||||
|
<v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="addNewLink">
|
<v:input type="text" label="Position Title ${requiredHint}" name="positionTitle" id="newIndLabel" size="30" />
|
||||||
If your organization is not listed, please <a href="#">add a new organization</a>.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="new">
|
|
||||||
<h6>Add a New Organization</h6>
|
|
||||||
<v:input type="text" label="Organization Name ${requiredHint}" id="newOrgName" size="30" />
|
|
||||||
<v:input type="select" label="Select Organization Type ${requiredHint}" id="newOrgType" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="entry">
|
|
||||||
<v:input type="text" label="Position Title ${requiredHint}" id="title" size="30" />
|
|
||||||
<v:input type="select" label="Position Type ${requiredHint}" id="positionType" />
|
<v:input type="select" label="Position Type ${requiredHint}" id="positionType" />
|
||||||
|
|
||||||
<p class="inline year"><v:input type="text" label="Start Year ${requiredHint} <span class='hint'>(YYYY)</span>" id="startYear" size="4" /></p>
|
<v:input type="text" label="Start Year ${requiredHint} <span class='hint'>(YYYY)</span>" id="startYear" size="4" />
|
||||||
<p class="inline year"><v:input type="text" label="End Year <span id='endYearHint' class='hint'>(YYYY)</span>" id="endYear" size="4" /></p>
|
<v:input type="text" label="End Year <span class='hint'>(YYYY)</span>" id="endYear" size="4" />
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Processing information for Javascript -->
|
</div>
|
||||||
<input type="hidden" name="editType" value="${editType}" />
|
|
||||||
<input type="hidden" name="entryType" value="position" />
|
|
||||||
<input type="hidden" name="secondaryType" value="organization" />
|
|
||||||
<%-- RY If set steps to 1 when editType == 'edit', may be able to combine the
|
|
||||||
step 1 and edit cases in the Javascript. --%>
|
|
||||||
<input type="hidden" name="steps" value="${formSteps}" />
|
|
||||||
<input type="hidden" name="view" value="${view}" />
|
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true"/></p>
|
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
|
||||||
|
|
||||||
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
<p id="requiredLegend" class="requiredHint">* required fields</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
<c:url var="acUrl" value="/autocomplete?tokenize=true&stem=true" />
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var customFormData = {
|
||||||
|
acUrl: '${acUrl}',
|
||||||
|
editMode: '${editMode}',
|
||||||
|
submitButtonTextType: 'compound'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<jsp:include page="${postForm}"/>
|
||||||
|
|
|
@ -1,51 +0,0 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
|
||||||
|
|
||||||
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.hp.hpl.jena.rdf.model.Literal;
|
|
||||||
|
|
||||||
public class PersonHasPositionValidator implements N3Validator {
|
|
||||||
|
|
||||||
private static String DUPLICATE_ERROR = "Must select an existing organization or create a new one, not both.";
|
|
||||||
private static String MISSING_ORG_ERROR = "Must either select an existing organization or create a new one.";
|
|
||||||
private static String MISSING_ORG_TYPE_ERROR = "Must select a type for the new organization.";
|
|
||||||
private static String MISSING_ORG_NAME_ERROR = "Must specify a name for the new organization.";
|
|
||||||
|
|
||||||
public Map<String,String> validate(EditConfiguration editConfig, EditSubmission editSub){
|
|
||||||
// Map<String,String> existingUris = editConfig.getUrisInScope();
|
|
||||||
// Map<String,Literal> existingLiterals = editConfig.getLiteralsInScope();
|
|
||||||
Map<String,String> urisFromForm = editSub.getUrisFromForm();
|
|
||||||
Map<String,Literal> literalsFromForm = editSub.getLiteralsFromForm();
|
|
||||||
|
|
||||||
Literal newOrgName = literalsFromForm.get("newOrgName");
|
|
||||||
if( newOrgName.getLexicalForm() != null && "".equals(newOrgName.getLexicalForm()) )
|
|
||||||
newOrgName = null;
|
|
||||||
String newOrgType = urisFromForm.get("newOrgType");
|
|
||||||
if( "".equals(newOrgType ) )
|
|
||||||
newOrgType = null;
|
|
||||||
String organizationUri = urisFromForm.get("organizationUri");
|
|
||||||
if( "".equals(organizationUri))
|
|
||||||
organizationUri = null;
|
|
||||||
|
|
||||||
Map<String,String> errors = new HashMap<String,String>();
|
|
||||||
if( organizationUri != null && (newOrgName != null || newOrgType != null) ){
|
|
||||||
errors.put("newOrgName", DUPLICATE_ERROR);
|
|
||||||
errors.put("organizationUri", DUPLICATE_ERROR);
|
|
||||||
} else if ( organizationUri == null && newOrgName == null && newOrgType == null) {
|
|
||||||
errors.put("newOrgName", MISSING_ORG_ERROR);
|
|
||||||
errors.put("organizationUri", MISSING_ORG_ERROR);
|
|
||||||
}else if( organizationUri == null && newOrgName != null && newOrgType == null) {
|
|
||||||
errors.put("newOrgType", MISSING_ORG_TYPE_ERROR);
|
|
||||||
}else if( organizationUri == null && newOrgName == null && newOrgType != null) {
|
|
||||||
errors.put("newOrgName", MISSING_ORG_NAME_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
if( errors.size() != 0 )
|
|
||||||
return errors;
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue