NIHVIVO-193. Work on custom form for person has position history. Generalized css and javascript to work with other custom forms that will be built for version 1.0 (see NIHVIVO-141).
This commit is contained in:
parent
1b4b52954d
commit
3f09ddf7d2
6 changed files with 484 additions and 94 deletions
51
productMods/edit/forms/css/customForm.css
Normal file
51
productMods/edit/forms/css/customForm.css
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
/* Some of these styles should most likely apply to all forms. */
|
||||||
|
|
||||||
|
#content form {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content form div {
|
||||||
|
clear: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
#addNewLink {
|
||||||
|
float: right;
|
||||||
|
margin-right: 18em;
|
||||||
|
margin-top: .8em;
|
||||||
|
width: 30%;
|
||||||
|
padding: .6em 0 .6em 1.5em;
|
||||||
|
border: 1px solid #9c9c9c;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#content form #existing {
|
||||||
|
float: left;
|
||||||
|
clear: none;
|
||||||
|
/* width: 300px;*/
|
||||||
|
display: inline-block;
|
||||||
|
}
|
||||||
|
|
||||||
|
#new {
|
||||||
|
padding: .6em 0 .6em 1.5em;
|
||||||
|
border: 1px solid #9c9c9c;
|
||||||
|
}
|
||||||
|
|
||||||
|
#content form p.inline input {
|
||||||
|
margin-right: 50em;
|
||||||
|
margin-top: -1.75em;
|
||||||
|
float: right;
|
||||||
|
clear: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
#content form p {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This div starts off hidden in case Javascript is disabled. Javascript will show it. */
|
||||||
|
.addNewLink {
|
||||||
|
display: none;
|
||||||
|
}
|
|
@ -1,22 +1,2 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
#content form div {
|
|
||||||
clear: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content form #existing {
|
|
||||||
float: left;
|
|
||||||
clear: none;
|
|
||||||
/* width: 300px;*/
|
|
||||||
display: inline-block;
|
|
||||||
}
|
|
||||||
|
|
||||||
#content form #notListed {
|
|
||||||
float: left;
|
|
||||||
clear: none;
|
|
||||||
width: 200px;
|
|
||||||
margin-left: 4em;
|
|
||||||
padding: 10px 0px 10px 16px;
|
|
||||||
border: 1px solid #9c9c9c;
|
|
||||||
|
|
||||||
}
|
|
42
productMods/edit/forms/js/customForm.js
Normal file
42
productMods/edit/forms/js/customForm.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
|
var customForm = {
|
||||||
|
|
||||||
|
onLoad: function() {
|
||||||
|
|
||||||
|
var button = $('#submit');
|
||||||
|
var addNewLink = $('#addNewLink');
|
||||||
|
var existing = $('#existing');
|
||||||
|
var addNew = $('#new');
|
||||||
|
var entry = $('#entry');
|
||||||
|
var editType = $("input[name='editType']").val();
|
||||||
|
var entryType = $("input[name='entryType']").val();
|
||||||
|
|
||||||
|
if (editType == 'add') {
|
||||||
|
// Set up form for step 1
|
||||||
|
addNewLink.show();
|
||||||
|
addNew.hide();
|
||||||
|
entry.hide();
|
||||||
|
button.val('Continue');
|
||||||
|
|
||||||
|
// Add event listeners
|
||||||
|
button.bind('click', function() {
|
||||||
|
entry.show();
|
||||||
|
addNewLink.hide();
|
||||||
|
$(this).val('Create ' + entryType);
|
||||||
|
$(this).unbind('click');
|
||||||
|
return false;
|
||||||
|
|
||||||
|
});
|
||||||
|
} else { // editing existing entry
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
customForm.onLoad();
|
||||||
|
});
|
|
@ -1,14 +1,2 @@
|
||||||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||||
|
|
||||||
var personHasPositionHistory = {
|
|
||||||
|
|
||||||
onLoad: function() {
|
|
||||||
$("#newOrg").hide();
|
|
||||||
$("#position").hide();
|
|
||||||
$("#submit").val("Continue");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$(document).ready(function(){
|
|
||||||
personHasPositionHistory.onLoad();
|
|
||||||
});
|
|
||||||
|
|
|
@ -15,9 +15,15 @@
|
||||||
<%@ 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="org.apache.commons.logging.Log" %>
|
||||||
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||||
|
|
||||||
<%@ 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" %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.personHasPositionHistory.jsp");
|
||||||
|
%>
|
||||||
<%
|
<%
|
||||||
VitroRequest vreq = new VitroRequest(request);
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
|
@ -37,7 +43,9 @@
|
||||||
|
|
||||||
<c:set var="vivo" value="http://vivoweb.org/ontology/core#" />
|
<c:set var="vivo" value="http://vivoweb.org/ontology/core#" />
|
||||||
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
|
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
|
||||||
<c:set var="rdfs" value="<% VitroVocabulary.RDFS %>" />
|
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
|
||||||
|
<c:set var="label" value="${rdfs}label" />
|
||||||
|
<c:set var="type" value="${rdf}type" />
|
||||||
|
|
||||||
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
|
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
|
||||||
to convey that the expression is used to retrieve any existing value for the field in an existing individual.
|
to convey that the expression is used to retrieve any existing value for the field in an existing individual.
|
||||||
|
@ -54,16 +62,7 @@
|
||||||
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
|
NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%>
|
||||||
<v:jsonset var="titleAssertion" >
|
<v:jsonset var="titleAssertion" >
|
||||||
?positionUri <${titlePred}> ?title .
|
?positionUri <${titlePred}> ?title .
|
||||||
?positionUri <${rdf}label> ?title.
|
?positionUri <${label}> ?title.
|
||||||
</v:jsonset>
|
|
||||||
|
|
||||||
<c:set var="involvedOrgNamePred" value="${vivo}involvedOrganizationName" />
|
|
||||||
<v:jsonset var="organizationNameExisting" >
|
|
||||||
SELECT ?existingOrgName WHERE {
|
|
||||||
?positionUri <${involvedOrgNamePred}> ?existingOrgName }
|
|
||||||
</v:jsonset>
|
|
||||||
<v:jsonset var="organizationNameAssertion" >
|
|
||||||
?positionUri <${involvedOrgNamePred}> ?organizationName .
|
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<c:set var="startYearPred" value="${vivo}startYear" />
|
<c:set var="startYearPred" value="${vivo}startYear" />
|
||||||
|
@ -88,23 +87,41 @@
|
||||||
below in the n3ForEdit section, in whether the ..Existing variable goes in SparqlForExistingLiterals
|
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 --%>
|
or in the SparqlForExistingUris, as well as perhaps in how the options are prepared --%>
|
||||||
<c:set var="positionInOrgPred" value="${vivo}positionInOrganization" />
|
<c:set var="positionInOrgPred" value="${vivo}positionInOrganization" />
|
||||||
|
<c:set var="orgForPositionPred" value="${vivo}organizationForPosition" />
|
||||||
<v:jsonset var="organizationUriExisting" >
|
<v:jsonset var="organizationUriExisting" >
|
||||||
SELECT ?existingOrgUri WHERE {
|
SELECT ?existingOrgUri WHERE {
|
||||||
?positionUri <${positionInOrgPred}> ?existingOrgUri }
|
?positionUri <${positionInOrgPred}> ?existingOrgUri }
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
<v:jsonset var="organizationUriAssertion" >
|
<v:jsonset var="organizationUriAssertion" >
|
||||||
?positionUri <${positionInOrgPred}> ?organizationUri .
|
?positionUri <${positionInOrgPred}> ?organizationUri .
|
||||||
?organizationUri <${vivo}organizationForPosition> ?positionUri .
|
?organizationUri <${orgForPositionPred}> ?positionUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="n3ForStmtToPerson" >
|
<v:jsonset var="newOrgNameAssertion">
|
||||||
@prefix rdf: <${rdf}>.
|
?newOrg <${label}> ?newOrgName .
|
||||||
@prefix core: <${vivo}>.
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="newOrgTypeAssertion">
|
||||||
|
?newOrg <${type}> ?newOrgType .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="n3ForStmtToPerson">
|
||||||
|
@prefix core: <${vivo}> .
|
||||||
|
|
||||||
?person core:personInPosition ?positionUri .
|
?person core:personInPosition ?positionUri .
|
||||||
?positionUri core:positionForPerson ?person .
|
?positionUri core:positionForPerson ?person .
|
||||||
?positionUri rdf:type core:Position .
|
?positionUri <${type}> core:Position .
|
||||||
?positionUri rdf:type <${flagURI}> .
|
?positionUri <${type}> <${flagURI}> .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="n3ForNewOrg">
|
||||||
|
@prefix rdf: <${rdf}> .
|
||||||
|
@prefix rdfs: <${rdfs}> .
|
||||||
|
|
||||||
|
?newOrg <${label}> ?newOrgName .
|
||||||
|
?newOrg <${type}> ?newOrgType .
|
||||||
|
?positionUri <${positionInOrgPred}> ?newOrg .
|
||||||
|
?newOrg <${orgForPositionPred}> ?positionUri .
|
||||||
</v:jsonset>
|
</v:jsonset>
|
||||||
|
|
||||||
<v:jsonset var="postionClass">http://vivoweb.org/ontology/core#Position</v:jsonset>
|
<v:jsonset var="postionClass">http://vivoweb.org/ontology/core#Position</v:jsonset>
|
||||||
|
@ -122,13 +139,18 @@
|
||||||
"object" : ["positionUri", "${objectUriJson}", "URI" ],
|
"object" : ["positionUri", "${objectUriJson}", "URI" ],
|
||||||
|
|
||||||
"n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ],
|
"n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ],
|
||||||
"n3optional" : [ "${organizationNameAssertion}","${organizationUriAssertion}",
|
|
||||||
|
"n3optional" : [ "${organizationUriAssertion}",
|
||||||
|
"${n3ForNewOrg}", "${newOrgNameAsertion}", "${newOrgTypeAssertion}",
|
||||||
"${endYearAssertion}"],
|
"${endYearAssertion}"],
|
||||||
"newResources" : { "positionUri" : "${defaultNamespace}" },
|
|
||||||
|
"newResources" : { "positionUri" : "${defaultNamespace}",
|
||||||
|
"newOrg" : "${defaultNamespace}" },
|
||||||
|
|
||||||
"urisInScope" : { },
|
"urisInScope" : { },
|
||||||
"literalsInScope": { },
|
"literalsInScope": { },
|
||||||
"urisOnForm" : [ "organizationUri" ],
|
"urisOnForm" : [ "organizationUri", "newOrgType" ],
|
||||||
"literalsOnForm" : [ "title", "organizationName",
|
"literalsOnForm" : [ "title", "newOrgName",
|
||||||
"startYear", "endYear" ],
|
"startYear", "endYear" ],
|
||||||
"filesOnForm" : [ ],
|
"filesOnForm" : [ ],
|
||||||
"sparqlForLiterals" : { },
|
"sparqlForLiterals" : { },
|
||||||
|
@ -165,8 +187,8 @@
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${organizationUriAssertion}" ]
|
"assertions" : [ "${organizationUriAssertion}" ]
|
||||||
},
|
},
|
||||||
"organizationName" : {
|
"newOrgName" : {
|
||||||
"newResource" : "false",
|
"newResource" : "true",
|
||||||
"validators" : [ ],
|
"validators" : [ ],
|
||||||
"optionsType" : "UNDEFINED",
|
"optionsType" : "UNDEFINED",
|
||||||
"literalOptions" : [ ],
|
"literalOptions" : [ ],
|
||||||
|
@ -174,7 +196,18 @@
|
||||||
"objectClassUri" : "",
|
"objectClassUri" : "",
|
||||||
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||||
"rangeLang" : "",
|
"rangeLang" : "",
|
||||||
"assertions" : [ "${organizationNameAssertion}" ]
|
"assertions" : [ "${newOrgNameAssertion}" ]
|
||||||
|
},
|
||||||
|
"newOrgType" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ ],
|
||||||
|
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
|
||||||
|
"literalOptions" : [ "Select one" ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "${organizationClass}",
|
||||||
|
"rangeDatatypeUri" : "",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : [ "${newOrgTypeAssertion}" ]
|
||||||
},
|
},
|
||||||
"startYear" : {
|
"startYear" : {
|
||||||
"newResource" : "false",
|
"newResource" : "false",
|
||||||
|
@ -202,38 +235,48 @@
|
||||||
}
|
}
|
||||||
</c:set>
|
</c:set>
|
||||||
<%
|
<%
|
||||||
|
log.debug(request.getAttribute("editjson"));
|
||||||
|
|
||||||
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
||||||
if (editConfig == null) {
|
if (editConfig == null) {
|
||||||
editConfig = new EditConfiguration(
|
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
|
||||||
(String) request
|
|
||||||
.getAttribute("editjson"));
|
|
||||||
EditConfiguration.putConfigInSession(editConfig,session);
|
EditConfiguration.putConfigInSession(editConfig,session);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (objectUri != null) { // editing existing
|
||||||
editConfig.prepareForObjPropUpdate(model);
|
editConfig.prepareForObjPropUpdate(model);
|
||||||
} else {
|
} else { // adding new
|
||||||
editConfig.prepareForNonUpdate(model);
|
editConfig.prepareForNonUpdate(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepare the page title and text for the submit button */
|
|
||||||
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||||
String submitLabel = "";
|
%>
|
||||||
if (objectUri != null) {
|
|
||||||
request.setAttribute("title","Edit position entry for "+ subjectName);
|
|
||||||
submitLabel = "Save changes";
|
|
||||||
} else {
|
|
||||||
request.setAttribute("title","Create a new position entry for " + subjectName);
|
|
||||||
submitLabel = "Create new position history entry";
|
|
||||||
}
|
|
||||||
|
|
||||||
List<String> customJs = new ArrayList<String>(Arrays.asList("forms/js/personHasPositionHistory.js"));
|
<c:set var="subjectName" value="<%= subjectName %>" />
|
||||||
|
<%
|
||||||
|
if (objectUri != null) { // editing existing entry
|
||||||
|
%>
|
||||||
|
<c:set var="editType" value="edit" />
|
||||||
|
<c:set var="title" value="Edit position entry for ${subjectName}" />
|
||||||
|
<c:set var="submitLabel" value="Save changes" />
|
||||||
|
<%
|
||||||
|
} else { // adding new entry
|
||||||
|
%>
|
||||||
|
<c:set var="editType" value="add" />
|
||||||
|
<c:set var="title" value="Create a new position entry for ${subjectName}" />
|
||||||
|
<c:set var="submitLabel" value="position" />
|
||||||
|
<% }
|
||||||
|
|
||||||
|
List<String> customJs = new ArrayList<String>(Arrays.asList("forms/js/customForm.js"
|
||||||
|
//, "forms/js/personHasPositionHistory.js"
|
||||||
|
));
|
||||||
request.setAttribute("customJs", customJs);
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
List<String> customCss = new ArrayList<String>(Arrays.asList("forms/css/personHasPositionHistory.css"));
|
List<String> customCss = new ArrayList<String>(Arrays.asList("forms/css/customForm.css"
|
||||||
|
//, "forms/css/personHasPositionHistory.css"
|
||||||
|
));
|
||||||
request.setAttribute("customCss", customCss);
|
request.setAttribute("customCss", customCss);
|
||||||
%>
|
%>
|
||||||
|
|
||||||
|
@ -241,28 +284,38 @@
|
||||||
|
|
||||||
<h2>${title}</h2>
|
<h2>${title}</h2>
|
||||||
|
|
||||||
<form action="<c:url value="/edit/processRdfForm2.jsp"/>"
|
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
|
<c:if test="${editType == 'add'}">
|
||||||
|
|
||||||
|
<!-- Hide on initial load in case JavaScript turned off. -->
|
||||||
|
<div id="addNewLink">
|
||||||
|
If your organization is not listed, please <a href="#">add a new organization</a>.
|
||||||
|
</div>
|
||||||
|
</c:if>
|
||||||
|
|
||||||
<div id="existing">
|
<div id="existing">
|
||||||
<v:input type="select" label="Organization" id="organizationUri" />
|
<v:input type="select" label="Organization" id="organizationUri" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="notListed">
|
<div id="new">
|
||||||
If your organization is not listed, please <a href="#">add a new organization</a>.
|
<h6>Add a New Organization</h6>
|
||||||
|
<v:input type="text" label="Organization Name" id="newOrgName" />
|
||||||
|
<v:input type="select" label="Select Organization Type" id="newOrgType" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="newOrg">
|
<div id="entry">
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div id="position">
|
|
||||||
<v:input type="text" label="Position Title" id="title" size="30" />
|
<v:input type="text" label="Position Title" id="title" size="30" />
|
||||||
<v:input type="select" label="Position Type" id="type" />
|
<v:input type="select" label="Position Type" id="type" />
|
||||||
|
|
||||||
<v:input type="text" label="Start Year" id="startYear" size="4"/>
|
<p class="inline"><v:input type="text" label="Start Year" id="startYear" size="4" /></p>
|
||||||
<v:input type="text" label="End Year" id="endYear" size="4"/>
|
<p class="inline"><v:input type="text" label="End Year" id="endYear" size="4" /></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/></p>
|
<!-- For Javascript -->
|
||||||
|
<input type="hidden" name="editType" value="add" />
|
||||||
|
<input type="hidden" name="entryType" value="position" />
|
||||||
|
|
||||||
|
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="${param.subjectUri}"/></p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<jsp:include page="${postForm}"/>
|
<jsp:include page="${postForm}"/>
|
||||||
|
|
276
productMods/edit/forms/personHasPositionHistory.old.jsp
Normal file
276
productMods/edit/forms/personHasPositionHistory.old.jsp
Normal file
|
@ -0,0 +1,276 @@
|
||||||
|
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
|
||||||
|
|
||||||
|
<%@ page import="java.util.List" %>
|
||||||
|
<%@ page import="java.util.ArrayList" %>
|
||||||
|
<%@ page import="java.util.Arrays" %>
|
||||||
|
|
||||||
|
<%@ page import="com.hp.hpl.jena.rdf.model.Literal"%>
|
||||||
|
<%@ page import="com.hp.hpl.jena.rdf.model.Model"%>
|
||||||
|
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
|
||||||
|
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||||
|
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
||||||
|
|
||||||
|
<%@ page import="org.apache.commons.logging.Log" %>
|
||||||
|
<%@ page import="org.apache.commons.logging.LogFactory" %>
|
||||||
|
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
||||||
|
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
|
||||||
|
|
||||||
|
<%!
|
||||||
|
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.personHasPositionHistory.jsp");
|
||||||
|
%>
|
||||||
|
<%
|
||||||
|
VitroRequest vreq = new VitroRequest(request);
|
||||||
|
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||||
|
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
|
||||||
|
|
||||||
|
String flagURI = null;
|
||||||
|
if (vreq.getAppBean().isFlag1Active()) {
|
||||||
|
flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing";
|
||||||
|
} else {
|
||||||
|
flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering
|
||||||
|
}
|
||||||
|
vreq.setAttribute("flagURI",flagURI);
|
||||||
|
|
||||||
|
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
|
||||||
|
request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
|
||||||
|
%>
|
||||||
|
|
||||||
|
<c:set var="vivo" value="http://vivoweb.org/ontology/core#" />
|
||||||
|
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
|
||||||
|
<c:set var="rdfs" value="<% VitroVocabulary.RDFS %>" />
|
||||||
|
|
||||||
|
<%-- Then enter a SPARQL query for each field, by convention concatenating the field id with "Existing"
|
||||||
|
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="${vivo}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 .
|
||||||
|
?positionUri <${rdf}label> ?title.
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<c:set var="involvedOrgNamePred" value="${vivo}involvedOrganizationName" />
|
||||||
|
<v:jsonset var="organizationNameExisting" >
|
||||||
|
SELECT ?existingOrgName WHERE {
|
||||||
|
?positionUri <${involvedOrgNamePred}> ?existingOrgName }
|
||||||
|
</v:jsonset>
|
||||||
|
<v:jsonset var="organizationNameAssertion" >
|
||||||
|
?positionUri <${involvedOrgNamePred}> ?organizationName .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<c:set var="startYearPred" value="${vivo}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="${vivo}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="${vivo}positionInOrganization" />
|
||||||
|
<v:jsonset var="organizationUriExisting" >
|
||||||
|
SELECT ?existingOrgUri WHERE {
|
||||||
|
?positionUri <${positionInOrgPred}> ?existingOrgUri }
|
||||||
|
</v:jsonset>
|
||||||
|
<v:jsonset var="organizationUriAssertion" >
|
||||||
|
?positionUri <${positionInOrgPred}> ?organizationUri .
|
||||||
|
?organizationUri <${vivo}organizationForPosition> ?positionUri .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="n3ForStmtToPerson" >
|
||||||
|
@prefix rdf: <${rdf}>.
|
||||||
|
@prefix core: <${vivo}>.
|
||||||
|
|
||||||
|
?person core:personInPosition ?positionUri .
|
||||||
|
?positionUri core:positionForPerson ?person .
|
||||||
|
?positionUri rdf:type core:Position .
|
||||||
|
?positionUri rdf:type <${flagURI}> .
|
||||||
|
</v:jsonset>
|
||||||
|
|
||||||
|
<v:jsonset var="postionClass">http://vivoweb.org/ontology/core#Position</v:jsonset>
|
||||||
|
<v:jsonset var="organizationClass">http://xmlns.com/foaf/0.1/Organization</v:jsonset>
|
||||||
|
|
||||||
|
|
||||||
|
<c:set var="editjson" scope="request">
|
||||||
|
{
|
||||||
|
"formUrl" : "${formUrl}",
|
||||||
|
"editKey" : "${editKey}",
|
||||||
|
"urlPatternToReturnTo" : "/entity",
|
||||||
|
|
||||||
|
"subject" : ["person", "${subjectUriJson}" ],
|
||||||
|
"predicate" : ["predicate", "${predicateUriJson}" ],
|
||||||
|
"object" : ["positionUri", "${objectUriJson}", "URI" ],
|
||||||
|
|
||||||
|
"n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ],
|
||||||
|
"n3optional" : [ "${organizationNameAssertion}","${organizationUriAssertion}",
|
||||||
|
"${endYearAssertion}"],
|
||||||
|
"newResources" : { "positionUri" : "${defaultNamespace}" },
|
||||||
|
"urisInScope" : { },
|
||||||
|
"literalsInScope": { },
|
||||||
|
"urisOnForm" : [ "organizationUri" ],
|
||||||
|
"literalsOnForm" : [ "title", "organizationName",
|
||||||
|
"startYear", "endYear" ],
|
||||||
|
"filesOnForm" : [ ],
|
||||||
|
"sparqlForLiterals" : { },
|
||||||
|
"sparqlForUris" : { },
|
||||||
|
"sparqlForExistingLiterals" : {
|
||||||
|
"title" : "${titleExisting}",
|
||||||
|
"organizationName" : "${organizationNameExisting}",
|
||||||
|
"startYear" : "${startYearExisting}",
|
||||||
|
"endYear" : "${endYearExisting}"
|
||||||
|
},
|
||||||
|
"sparqlForExistingUris" : {
|
||||||
|
"organizationUri" : "${organizationUriExisting}"
|
||||||
|
},
|
||||||
|
"fields" : {
|
||||||
|
"title" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ "nonempty" ],
|
||||||
|
"optionsType" : "UNDEFINED",
|
||||||
|
"literalOptions" : [ ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "",
|
||||||
|
"rangeDatatypeUri" : "",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : [ "${titleAssertion}" ]
|
||||||
|
},
|
||||||
|
"organizationUri" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ ],
|
||||||
|
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
|
||||||
|
"literalOptions" : [ "Select one" ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "${organizationClass}",
|
||||||
|
"rangeDatatypeUri" : "",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : [ "${organizationUriAssertion}" ]
|
||||||
|
},
|
||||||
|
"organizationName" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ ],
|
||||||
|
"optionsType" : "UNDEFINED",
|
||||||
|
"literalOptions" : [ ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "",
|
||||||
|
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : [ "${organizationNameAssertion}" ]
|
||||||
|
},
|
||||||
|
"startYear" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ],
|
||||||
|
"optionsType" : "UNDEFINED",
|
||||||
|
"literalOptions" : [ ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "",
|
||||||
|
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : ["${startYearAssertion}"]
|
||||||
|
},
|
||||||
|
"endYear" : {
|
||||||
|
"newResource" : "false",
|
||||||
|
"validators" : [ "datatype:${gYearDatatypeUriJson}" ],
|
||||||
|
"optionsType" : "UNDEFINED",
|
||||||
|
"literalOptions" : [ ],
|
||||||
|
"predicateUri" : "",
|
||||||
|
"objectClassUri" : "",
|
||||||
|
"rangeDatatypeUri" : "${gYearDatatypeUriJson}",
|
||||||
|
"rangeLang" : "",
|
||||||
|
"assertions" : ["${endYearAssertion}"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</c:set>
|
||||||
|
<%
|
||||||
|
log.debug(request.getAttribute("editjson"));
|
||||||
|
|
||||||
|
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
|
||||||
|
if (editConfig == null) {
|
||||||
|
editConfig = new EditConfiguration(
|
||||||
|
(String) request
|
||||||
|
.getAttribute("editjson"));
|
||||||
|
EditConfiguration.putConfigInSession(editConfig,session);
|
||||||
|
}
|
||||||
|
|
||||||
|
Model model = (Model) application.getAttribute("jenaOntModel");
|
||||||
|
String objectUri = (String) request.getAttribute("objectUri");
|
||||||
|
if (objectUri != null) {
|
||||||
|
editConfig.prepareForObjPropUpdate(model);
|
||||||
|
} else {
|
||||||
|
editConfig.prepareForNonUpdate(model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* prepare the page title and text for the submit button */
|
||||||
|
String subjectName = ((Individual) request.getAttribute("subject")).getName();
|
||||||
|
String submitLabel = "";
|
||||||
|
if (objectUri != null) {
|
||||||
|
request.setAttribute("title","Edit position entry for "+ subjectName);
|
||||||
|
submitLabel = "Save changes";
|
||||||
|
} else {
|
||||||
|
request.setAttribute("title","Create a new position entry for " + subjectName);
|
||||||
|
submitLabel = "Create new position history entry";
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> customJs = new ArrayList<String>(Arrays.asList("forms/js/personHasPositionHistory.js"));
|
||||||
|
request.setAttribute("customJs", customJs);
|
||||||
|
|
||||||
|
List<String> customCss = new ArrayList<String>(Arrays.asList("forms/css/personHasPositionHistory.css"));
|
||||||
|
request.setAttribute("customCss", customCss);
|
||||||
|
%>
|
||||||
|
|
||||||
|
<jsp:include page="${preForm}" />
|
||||||
|
|
||||||
|
<h2>${title}</h2>
|
||||||
|
|
||||||
|
<form action="<c:url value="/edit/processRdfForm2.jsp"/>" >
|
||||||
|
<div id="orgNotListed">
|
||||||
|
If your organization is not listed, please <a href="#">add a new organization</a>.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="existingOrg">
|
||||||
|
<v:input type="select" label="Organization" id="organizationUri" />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="newOrg">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="position">
|
||||||
|
<v:input type="text" label="Position Title" id="title" size="30" />
|
||||||
|
<v:input type="select" label="Position Type" id="type" />
|
||||||
|
|
||||||
|
<v:input type="text" label="Start Year" id="startYear" size="4"/>
|
||||||
|
<v:input type="text" label="End Year" id="endYear" size="4"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="${param.subjectUri}"/></p>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<jsp:include page="${postForm}"/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue