NIHVIVO-3530: Deleted old custom forms jsp files. This is what I have done for VIVO:

1-Deleted all the js, css, and js from VIVO/productMods/forms
2-Moved css and js to from VIVO/productMods/forms to VIVO/templates/freemarker/forms
3-Updated css and js path files for all the ftl files at VIVO/templates/freemarker/forms, which contains the new custom forms.
This commit is contained in:
manolobevia 2012-01-09 19:42:09 +00:00
parent 8d9a59c1bf
commit 59672b5156
52 changed files with 1523 additions and 5567 deletions

View file

@ -1,26 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="attended" />
<jsp:param name="typeSelectorLabel" value="event type" />
<jsp:param name="buttonText" value="attendees" />
<jsp:param name="numDateFields" value="1" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#AttendeeRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select one"],
[ "http://purl.org/NET/c4dm/event.owl#Event", "Event" ],
[ "http://vivoweb.org/ontology/core#Competition", "Competition" ],
[ "http://purl.org/ontology/bibo/Conference", "Conference" ],
[ "http://vivoweb.org/ontology/core#Course", "Course" ],
[ "http://vivoweb.org/ontology/core#Exhibit", "Exhibit" ],
[ "http://vivoweb.org/ontology/core#Meeting", "Meeting" ],
[ "http://vivoweb.org/ontology/core#Presentation", "Presentation" ],
[ "http://vivoweb.org/ontology/core#InvitedTalk", "Invited Talk" ],
[ "http://purl.org/ontology/bibo/Workshop", "Workshop" ],
[ "http://vivoweb.org/ontology/core#EventSeries", "Event Series" ],
[ "http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series" ],
[ "http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series" ],
[ "http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series" ]' />
</jsp:include>

View file

@ -1,427 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding authors to information resources
Classes:
core:InformationResource - the information resource being edited
core:Authorship - primary new individual being created
foaf:Person - new or existing individual being linked to
Data properties of Authorship:
core:authorRank
Object properties (domain : range):
core:informationResourceInAuthorship (InformationResource : Authorship)
core:linkedInformationResource (Authorship : InformationResource) - inverse of informationResourceInAuthorship
core:linkedAuthor (Authorship : Person)
core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Collections" %>
<%@ 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.beans.DataPropertyComparator" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidatorOld" %>
<%@ 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="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.lang.StringUtils" %>
<%@ page import="org.json.JSONObject" %>
<%@ 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.addAuthorsToInformationResource.jsp");
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
String intDatatypeUri = XSD.xint.toString();
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
%>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="foaf" value="http://xmlns.com/foaf/0.1/" />
<c:set var="personClassUri" value="${foaf}Person" />
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
SPARQL queries for existing values. --%>
<%-- Data properties --%>
<v:jsonset var="newPersonFirstNameAssertion">
@prefix foaf: <${foaf}> .
?newPerson foaf:firstName ?firstName .
</v:jsonset>
<v:jsonset var="newPersonMiddleNameAssertion">
@prefix core: <${vivoCore}> .
?newPerson core:middleName ?middleName .
</v:jsonset>
<v:jsonset var="newPersonLastNameAssertion">
@prefix foaf: <${foaf}> .
?newPerson foaf:lastName ?lastName .
</v:jsonset>
<v:jsonset var="authorshipRankAssertion">
@prefix core: <${vivoCore}> .
?authorshipUri core:authorRank ?rank .
</v:jsonset>
<%-- This applies to both a new and an existing person --%>
<v:jsonset var="n3ForNewAuthorship">
@prefix core: <${vivoCore}> .
?authorshipUri a core:Authorship ;
core:linkedInformationResource ?infoResource ;
core:authorRank ?rank .
?infoResource core:informationResourceInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="n3ForExistingPerson">
@prefix core: <${vivoCore}> .
?authorshipUri core:linkedAuthor ?personUri .
?personUri core:authorInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="n3ForNewPerson">
@prefix foaf: <${foaf}> .
@prefix core: <${vivoCore}> .
?newPerson a foaf:Person ;
<${label}> ?label .
?authorshipUri core:linkedAuthor ?newPerson .
?newPerson core:authorInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="personClassUriJson">${personClassUri}</v:jsonset>
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "${returnPathAfterSubmit}",
"subject" : ["infoResource", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["authorshipUri", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewAuthorship}", "${authorshipRankAssertion}" ],
"n3optional" : [ "${newPersonFirstNameAssertion}", "${newPersonMiddleNameAssertion}",
"${newPersonLastNameAssertion}",
"${n3ForNewPerson}", "${n3ForExistingPerson}" ],
"newResources" : { "authorshipUri" : "${defaultNamespace}",
"newPerson" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "personUri" ],
"literalsOnForm" : [ "firstName", "middleName", "lastName", "rank", "label" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { },
"sparqlForExistingUris" : { },
"fields" : {
"label" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${n3ForNewPerson}" ]
},
"firstName" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${newPersonFirstNameAssertion}" ]
},
"middleName" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${newPersonMiddleNameAssertion}" ]
},
"lastName" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${newPersonLastNameAssertion}" ]
},
"rank" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${intDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${authorshipRankAssertion}"]
},
"personUri" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "${personClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForExistingPerson}"]
}
}
}
</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);
}
editConfig.addValidator(new PublicationHasAuthorValidatorOld());
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
//for some reason we are comming from the add new and that is working
//but we also come from the edit, and that is not working.
editConfig.setObject(""); //this will force the edit config to always be an add, never an update
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
String vivoCore = "http://vivoweb.org/ontology/core#";
//Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
Individual infoResource = ((Individual) request.getAttribute("subject"));
vreq.setAttribute("infoResourceName", infoResource.getName());
List<Individual> authorships = infoResource.getRelatedIndividuals(predicateUri);
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/js/browserUtils.js",
"/edit/forms/js/addAuthorsToInformationResource.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/autocomplete.css",
"/edit/forms/css/addAuthorsToInformationResource.css"
));
request.setAttribute("customCss", customCss);
String ulClass = "";
List<String> ulClasses = new ArrayList<String>();
if (authorships.size() > 1) {
// This class triggers application of dd styles. Don't wait for js to add
// the ui-sortable class, because then the page flashes as the styles are updated.
ulClasses.add("dd");
}
if (ulClasses.size() > 0) {
ulClass="class=\"" + StringUtils.join(ulClasses, " ") + "\"";
}
%>
<c:set var="title" value="<em>${infoResourceName}</em>"/>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="initialHint" value="<span class='hint'>(initial okay)</span>" />
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<h2>${title}</h2>
<%@ include file="unsupportedBrowserMessage.jsp" %>
<div class="noIE67">
<h3>Manage Authors</h3>
<ul id="authorships" <%= ulClass %>>
<%
String rankPredicateUri = vivoCore + "authorRank";
DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri);
Collections.sort(authorships, comp);
int maxRank = 0;
int authorshipCount = authorships.size();
%>
<script type="text/javascript">
var authorshipData = [];
</script>
<%
for ( Individual authorship : authorships ) {
request.setAttribute("authorshipUri", authorship.getURI());
request.setAttribute("authorshipName", authorship.getName());
DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri);
if (rankStmt != null) {
maxRank = Integer.parseInt(rankStmt.getData());
}
request.setAttribute("author", authorship.getRelatedIndividual(vivoCore + "linkedAuthor"));
%>
<li class="authorship">
<%-- span.author will be used in the next phase, when we display a message that the author has been
removed. That text will replace the a.authorName, which will be removed. --%>
<span class="author">
<%-- This span is here to assign a width to. We can't assign directly to the a.authorName,
for the case when it's followed by an em tag - we want the width to apply to the whole thing. --%>
<span class="authorNameWrapper">
<c:choose>
<c:when test="${!empty author}">
<c:set var="authorUri" value="${author.URI}" />
<c:set var="authorName" value="${author.name}" />
<c:url var="authorHref" value="/individual">
<c:param name="uri" value="${authorUri}"/>
</c:url>
<span class="authorName">${authorName}</span>
</c:when>
<c:otherwise>
<c:set var="authorUri" value="" />
<c:set var="authorName" value="" />
<c:url var="authorshipHref" value="/individual">
<c:param name="uri" value="${authorshipUri}"/>
</c:url>
<span class="authorName">${authorshipName}</span><em> (no linked author)</em>
</c:otherwise>
</c:choose>
</span>
<c:url var="deleteAuthorshipHref" value="/edit/primitiveDelete" />
<a href="${deleteAuthorshipHref}" class="remove">Remove</a>
<%-- <a href="${undoHref}" class="undo">Undo</a> --%>
</span>
</li>
<script type="text/javascript">
authorshipData.push({
"authorshipUri": "${authorshipUri}",
"authorUri": "${authorUri}",
"authorName": "${authorName}"
});
</script>
<%
}
// A new author will be ranked last when added.
// This value is now inserted by JavaScript, but leave it here as a safety net in case page
// load reordering returns an error.
request.setAttribute("newRank", maxRank + 1);
request.setAttribute("rankPredicate", rankPredicateUri);
%>
</ul>
<% if (authorshipCount == 0) { %>
<p>This publication currently has no authors specified.</p>
<% } %>
<div id="showAddForm">
<v:input type="submit" value="Add Author" id="showAddFormButton" cancel="true" cancelLabel="Return to Publication" cancelUrl="/individual" />
</div>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addAuthorForm" class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<h3>Add an Author</h3>
<p class="inline"><v:input type="text" id="lastName" label="Last name ${requiredHint}" cssClass="acSelector" size="35" /></p>
<p class="inline"><v:input type="text" id="firstName" label="First name ${requiredHint} ${initialHint}" size="20" /></p>
<p class="inline"><v:input type="text" id="middleName" label="Middle name ${initialHint}" size="20" /></p>
<input type="hidden" id="label" name="label" value="" /> <!-- Field value populated by JavaScript -->
<div id="selectedAuthor" class="acSelection">
<%-- RY maybe make this a label and input field. See what looks best. --%>
<p class="inline"><label>Selected author: </label><span class="acSelectionInfo" id="selectedAuthorName"></span></p>
<input type="hidden" id="personUri" name="personUri" value="" /> <!-- Field value populated by JavaScript -->
</div>
<input type="hidden" name="rank" id="rank" value="${newRank}" />
<p class="submit"><v:input type="submit" id="submit" value="Add Author" cancel="true" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
</div>
<c:url var="acUrl" value="/autocomplete?type=${foaf}Person&tokenize=false" />
<c:url var="reorderUrl" value="/edit/reorder" />
<script type="text/javascript">
var customFormData = {
rankPredicate: '${rankPredicate}',
acUrl: '${acUrl}',
reorderUrl: '${reorderUrl}'
};
</script>
<jsp:include page="${postForm}"/>

View file

@ -1,13 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="clinical activity" />
<jsp:param name="typeSelectorLabel" value="clinical activity type" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#ClinicalRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select one"],
["http://vivoweb.org/ontology/core#Project", "Project" ],
[ "http://vivoweb.org/ontology/core#Service","Service"] ' />
</jsp:include>

View file

@ -1,301 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding or editing a webpage associated with an individual. The primary page,
manageWebpagesForIndividual.jsp, forwards to this page if: (a) we are adding a new page, or
(b) an edit link in the Manage Webpages view has been clicked.
Object properties:
core:webpage (range: core:URLLink)
core:webpageOf (domain: core:URLLink) (inverse of core:webpage)
Class:
core:URLLink - the link to be added to the individual
Data properties of core:URLLink:
core:linkURI
core:linkAnchorText
core:rank
--%>
<%@ 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="com.hp.hpl.jena.query.ResultSet" %>
<%@ page import="com.hp.hpl.jena.rdf.model.RDFNode" %>
<%@ page import="com.hp.hpl.jena.query.QuerySolution" %>
<%@ page import="com.hp.hpl.jena.query.Dataset" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils" %>
<%@ 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.addEditWebpageForm.jsp");
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
String subjectUri = (String) request.getAttribute("subjectUri");
String propertyUri = (String) request.getAttribute("predicateUri");
String objectUri = (String) request.getAttribute("objectUri");
String stringDatatypeUriJson = MiscWebUtils.escape(XSD.xstring.toString());
String uriDatatypeUriJson = MiscWebUtils.escape(XSD.anyURI.toString());
String intDatatypeUriJson = MiscWebUtils.escape(XSD.xint.toString());
%>
<c:set var="stringDatatypeUriJson" value="<%= stringDatatypeUriJson %>" />
<c:set var="uriDatatypeUriJson" value="<%= uriDatatypeUriJson %>" />
<c:set var="intDatatypeUriJson" value="<%= intDatatypeUriJson %>" />
<c:set var="core" value="http://vivoweb.org/ontology/core#" />
<c:set var="linkClass" value="${core}URLLink" />
<c:set var="webpageProperty" value="${core}webpage" />
<c:set var="inverseProperty" value="${core}webpageOf" />
<c:set var="linkUrl" value="${core}linkURI" />
<c:set var="linkAnchor" value="${core}linkAnchorText" />
<c:set var="rank" value="${core}rank" />
<%-- Enter here any class names to be used for constructing INDIVIDUALS_VIA_VCLASS pick lists
These are then referenced in the field's ObjectClassUri but not elsewhere.
NOTE that this class may not exist in the model, in which the only choice of type
that will show up is "web page", which will insert no new statements and just create
links of type vitro:Link --%>
<%-- 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 --%>
<v:jsonset var="urlQuery" >
SELECT ?urlExisting
WHERE { ?link <${linkUrl}> ?urlExisting }
</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="urlAssertion" >
?link <${linkUrl}> ?url .
</v:jsonset>
<v:jsonset var="anchorQuery" >
SELECT ?anchorExisting
WHERE { ?link <${linkAnchor}> ?anchorExisting }
</v:jsonset>
<v:jsonset var="anchorAssertion" >
?link <${linkAnchor}> ?anchor .
</v:jsonset>
<v:jsonset var="rankQuery" >
SELECT ?rankExisting
WHERE { ?link <${rank}> ?rankExisting }
</v:jsonset>
<v:jsonset var="rankAssertion" >
?link <${rank}> ?rank .
</v:jsonset>
<%-- When not retrieving a literal via a datatype property, put the SPARQL statement into
the SparqlForExistingUris --%>
<v:jsonset var="n3ForEdit">
?subject <${webpageProperty}> ?link .
?link <${inverseProperty}> ?subject .
?link a <${linkClass}> ;
<${linkUrl}> ?url .
</v:jsonset>
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}&view=manage" />
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "${returnPathAfterSubmit}",
"subject" : ["subject", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["link", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForEdit}" ],
"n3optional" : [ "${rankAssertion}", "${anchorAssertion}" ],
"newResources" : { "link" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope" : { },
"urisOnForm" : [ ],
"literalsOnForm" : [ "url", "anchor", "rank" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"url" : "${urlQuery}",
"anchor" : "${anchorQuery}",
"rank" : "${rankQuery}"
},
"sparqlForExistingUris" : { },
"fields" : {
"url" : {
"newResource" : "false",
"validators" : [ "nonempty", "datatype:${uriDatatypeUriJson}" , "httpUrl" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${uriDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${urlAssertion}" ]
},
"anchor" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${anchorAssertion}" ]
},
"rank" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${intDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${rankAssertion}" ]
}
}
}
</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");
if( objectUri != null ){
editConfig.prepareForObjPropUpdate(model);
} else {
editConfig.prepareForNonUpdate(model);
}
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path()
));
request.setAttribute("customCss", customCss);
String subjectName = ((Individual)request.getAttribute("subject")).getName();
// Get largest existing rank value to compute hidden rank field value
int newRank = getMaxRank(objectUri, subjectUri, vreq) + 1;
%>
<c:choose>
<c:when test="${ ! empty objectUri }">
<c:set var="editMode" value="edit" />
<c:set var="title" value="Edit webpage of" />
<c:set var="submitButtonText" value="Save changes" />
<c:set var="cancelUrl" value="" />
</c:when>
<c:otherwise>
<c:set var="editMode" value="add" />
<c:set var="title" value="Add a webpage for" />
<c:set var="submitButtonText" value="Add webpage" />
<%-- Cancel to where ever we came from: either directly from the profile page, or from
the Manage Web Pages screen. The latter has added a url param to signal itself. --%>
<c:set var="cancelUrl" value="${ param.cancelTo == 'manage' ? '' : '/individual' }" />
</c:otherwise>
</c:choose>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<jsp:include page="${preForm}"/>
<h1>JSP form, must be removed for the 1.4!</h1>
<h2>${title}&nbsp;<%= subjectName %></h2>
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<v:input type="text" label="URL ${requiredHint}" id="url" size="70"/>
<v:input type="text" label="Webpage Name" id="anchor" size="70"/>
<p><em>If left blank, the URL will be used when displaying a link to this webpage.</em></p>
<c:if test="${editMode == 'add'}">
<input type="hidden" name="rank" value="<%= newRank %>" />
</c:if>
<p class="submit">
<v:input type="submit" id="submit" value="${submitButtonText}" cancel="true" cancelUrl="${cancelUrl}" />
</p>
</form>
<jsp:include page="${postForm}"/>
<%!
/* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned,
* since it's ranked highest. Preventing that would require getting all the ranks and sorting in Java,
* throwing out non-int values.
*/
private static String RANK_QUERY = ""
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "SELECT DISTINCT ?rank WHERE { \n"
+ " ?subject core:webpage ?link . \n"
+ " ?link core:rank ?rank .\n"
+ "} ORDER BY DESC(?rank) LIMIT 1";
private int getMaxRank(String objectUri, String subjectUri, VitroRequest vreq) {
int maxRank = 0; // default value
if (objectUri == null) { // adding new webpage
String queryStr = QueryUtils.subUriForQueryVar(RANK_QUERY, "subject", subjectUri);
log.debug("Query string is: " + queryStr);
try {
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
if (results != null && results.hasNext()) { // there is at most one result
QuerySolution soln = results.next();
RDFNode node = soln.get("rank");
if (node != null && node.isLiteral()) {
// node.asLiteral().getInt() won't return an xsd:string that
// can be parsed as an int.
int rank = Integer.parseInt(node.asLiteral().getLexicalForm());
if (rank > maxRank) {
log.debug("setting maxRank to " + rank);
maxRank = rank;
}
}
}
} catch (NumberFormatException e) {
log.error("Invalid rank returned from query: not an integer value.");
} catch (Exception e) {
log.error(e, e);
}
}
return maxRank;
}
%>

View file

@ -1,13 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="collection or series editor role" />
<jsp:param name="typeSelectorLabel" value="editor role in" />
<jsp:param name="showRoleLabelField" value="false" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#EditorRole" />
<jsp:param name="roleToActivityPredicate" value="http://vivoweb.org/ontology/core#forInformationResource" />
<jsp:param name="activityToRolePredicate" value="http://vivoweb.org/ontology/core#linkedRole" />
<jsp:param name="roleActivityType_optionsType" value="CHILD_VCLASSES" />
<jsp:param name="roleActivityType_objectClassUri" value="http://purl.org/ontology/bibo/Collection" />
<jsp:param name="roleActivityType_literalOptions" value="[ 'Select type' ]" />
</jsp:include>

View file

@ -1,469 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole
and hasPrincipalInvestigatorRole.
This is intended to create a set of statements like:
?person core:hasPrincipalInvestigatorRole ?newRole.
?newRole rdf:type core:PrincipalInvestigatorRole ;
core:relatedRole ?someGrant .
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ 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.configuration.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="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
String intDatatypeUri = XSD.xint.toString();
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
String predicateUri = (String)request.getAttribute("predicateUri");
ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri );
if( op != null && op.getURIInverse() != null ){
%>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%><c:set var="inversePredicate"><%=op.getURIInverse()%></c:set> <%
}else{
%> <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 core:roleIn statements.
*/
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 == EditMode.REPAIR){
%> <c:set var="editMode" value="repair"/><%
}
%>
<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%><c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
<c:set var="vivoCore" value="${vivoOnt}/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="startYearPred" value="${vivoCore}startYear" />
<c:set var="endYearPred" value="${vivoCore}endYear" />
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
<c:set var="roleToInterval" value="${vivoCore}dateTimeInterval"/>
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
<c:set var="intervalToStart" value="${vivoCore}start"/>
<c:set var="intervalToEnd" value="${vivoCore}end"/>
<% // set role type based on predicate
String subjectName = ((Individual) request.getAttribute("subject")).getName();
if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#PrincipalInvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Principal Investigator</c:set>
<c:set var="formHeading">principal investigator entry for <%= subjectName %></c:set>
<% }else if ( ((String)request.getAttribute("predicateUri")).endsWith("hasCo-PrincipalInvestigatorRole") ) { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Co-Principal Investigator</c:set>
<c:set var="formHeading">co-principal investigator entry for <%= subjectName %></c:set>
<% }else { %>
<v:jsonset var="roleType">http://vivoweb.org/ontology/core#InvestigatorRole</v:jsonset>
<c:set var="submitButtonLabel">Investigator</c:set>
<c:set var="formHeading">investigator entry for <%= subjectName %></c:set>
<% } %>
<%-- Configure add vs. edit --%>
<c:choose>
<c:when test='${editMode == "add"}'>
<c:set var="formHeading" value="Create ${formHeading}" />
<c:set var="labelRequired" value="\"nonempty\"," />
<c:set var="disabledVal" value="" />
</c:when>
<c:otherwise>
<c:set var="formHeading" value="Edit ${formHeading}" />
<c:set var="submitButtonLabel" value="Edit ${submitButtonLabel}" />
<c:choose>
<c:when test='{editMode == "edit"}'>
<c:set var="labelRequired" value="" />
<c:set var="disabledVal" value="disabled" />
</c:when>
<c:otherwise> <%-- editMode == "repair" --%>
<c:set var="labelRequired" value="\"nonempty\"," />
<c:set var="disabledVal" value="" />
</c:otherwise>
</c:choose>
</c:otherwise>
</c:choose>
<v:jsonset var="n3ForGrantRole">
@prefix core: <${vivoCore}> .
@prefix rdf: <${rdf}> .
?person ?rolePredicate ?role.
?role a ?roleType ;
core:roleIn ?grant .
?grant a core:Grant ;
core:relatedRole ?role .
</v:jsonset>
<v:jsonset var="n3ForInverse">
?role ?inverseRolePredicate ?person.
</v:jsonset>
<v:jsonset var="n3ForStart">
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?startField-value .
?startNode <${dateTimePrecision}> ?startField-precision .
</v:jsonset>
<v:jsonset var="n3ForEnd">
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?endField-value .
?endNode <${dateTimePrecision}> ?endField-precision .
</v:jsonset>
<v:jsonset var="n3ForGrantLabel">
@prefix rdfs: <${rdfs}> .
?grant rdfs:label ?grantLabel .
</v:jsonset>
<v:jsonset var="grantLabelQuery">
PREFIX core: <${vivoCore}>
PREFIX rdfs: <${rdfs}>
SELECT ?existingGrantLabel WHERE {
?role core:roleIn ?existingGrant .
?existingGrant rdfs:label ?existingGrantLabel . }
</v:jsonset>
<v:jsonset var="grantQuery">
PREFIX core: <${vivoCore}>
SELECT ?existingGrant WHERE { ?role core:roleIn ?existingGrant . }
</v:jsonset>
<v:jsonset var="grantTypeUriJson">${vivoOnt}#Grant</v:jsonset>
<v:jsonset var="existingIntervalNodeQuery" >
SELECT ?existingIntervalNode WHERE {
?role <${roleToInterval}> ?existingIntervalNode .
?existingIntervalNode <${type}> <${intervalType}> . }
</v:jsonset>
<v:jsonset var="existingStartNodeQuery" >
SELECT ?existingStartNode WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?existingStartNode .
?existingStartNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingStartDateQuery" >
SELECT ?existingDateStart WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?existingDateStart . }
</v:jsonset>
<v:jsonset var="existingStartPrecisionQuery" >
SELECT ?existingStartPrecision WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
</v:jsonset>
<v:jsonset var="existingEndNodeQuery" >
SELECT ?existingEndNode WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?existingEndNode .
?existingEndNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingEndDateQuery" >
SELECT ?existingEndDate WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?existingEndDate . }
</v:jsonset>
<v:jsonset var="existingEndPrecisionQuery" >
SELECT ?existingEndPrecision WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/individual",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["rolePredicate", "${predicateUriJson}" ],
"object" : ["role", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForGrantRole}" ],
"n3optional" : [ "${n3ForGrantLabel}", "${n3ForInverse}", "${n3ForStart}", "${n3ForEnd}" ],
"newResources" : { "role" : "${defaultNamespace}",
"grant" : "${defaultNamespace}",
"intervalNode" : "${defaultNamespace}",
"startNode" : "${defaultNamespace}",
"endNode" : "${defaultNamespace}" },
"urisInScope" : { "roleType" : "${roleType}",
"inverseRolePredicate" : "${inversePredicate}" },
"literalsInScope": { },
"urisOnForm" : [ "grant" ],
"literalsOnForm" : [ "grantLabel", "existingGrantLabel" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"grantLabel":"${grantLabelQuery}" ,
"startField-value" : "${existingStartDateQuery}",
"endField-value" : "${existingEndDateQuery}"
},
"sparqlForExistingUris" : {
"grant":"${grantQuery}",
"intervalNode" : "${existingIntervalNodeQuery}",
"startNode" : "${existingStartNodeQuery}",
"endNode" : "${existingEndNodeQuery}",
"startField-precision": "${existingStartPrecisionQuery}",
"endField-precision" : "${existingEndPrecisionQuery}"
},
"fields" : {
"grant" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "${grantTypeUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForGrantRole}" ]
},
"grantLabel" : {
"newResource" : "false",
"validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${n3ForGrantLabel}", "${n3ForGrantRole}" ]
},
"existingGrantLabel" : { /* Needed iff we return from an invalid submission */
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ ]
},
"startField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForStart}" ]
},
"endField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForEnd}" ]
}
}
}
</c:set>
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
//setup date time edit elements
Field startField = editConfig.getField("startField");
startField.setEditElement(
new DateTimeWithPrecision(startField,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri()));
Field endField = editConfig.getField("endField");
endField.setEditElement(
new DateTimeWithPrecision(endField,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri()));
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
}
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) {
editConfig.prepareForObjPropUpdate(model);
// Return browser to person individual after editing an existing role.
} else {
editConfig.prepareForNonUpdate(model);
// NIHVIVO-1014 Return browser to person individual after editing an existing role.
// Return the browser to the new activity entity after adding a new role.
// editConfig.setEntityToReturnTo("?grant");
}
String subjectUri = vreq.getParameter("subjectUri");
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/js/browserUtils.js",
"/edit/forms/js/customFormWithAutocomplete.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/customFormWithAutocomplete.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<% 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>${formHeading}</h2>
<%@ include file="unsupportedBrowserMessage.jsp" %>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addGrantRoleToPerson" class="customForm noIE67" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p><v:input type="text" id="relatedIndLabel" name="grantLabel" label="Grant Name ${requiredHint}" cssClass="acSelector" size="50" disabled="${disabledVal}" /></p>
<%-- Store this value in a hidden field, because the displayed field is disabled and doesn't submit. This ensures that when
returning from a validation error, we retain the value. --%>
<c:if test="${editMode == 'edit'}">
<v:input type="hidden" id="grantLabel" />
</c:if>
<div class="acSelection">
<p class="inline"><label>Selected Grant:</label><span class="acSelectionInfo"></span><a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p>
<v:input type="hidden" id="grant" name="grant" cssClass="acUriReceiver" /> <%-- Field value populated by JavaScript --%>
<v:input type="hidden" id="existingGrantLabel" name="existingGrantLabel" cssClass="acLabelReceiver" /> <%-- Needed iff we return from an invalid submission --%>
</div>
<h4>Years of Participation in Grant</h4>
<v:input id="startField" label="Start Year ${yearHint}" />
<v:input id="endField" label="End Year ${yearHint}" />
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonLabel}" cancel="true" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<c:url var="acUrl" value="/autocomplete?tokenize=true" />
<c:url var="sparqlQueryUrl" value="/ajax/sparqlQuery" />
<%-- Must be all one line for JavaScript. --%>
<c:set var="sparqlForAcFilter">
PREFIX core: <${vivoCore}> SELECT ?grantUri WHERE {<${subjectUri}> <${predicateUri}> ?grantRole . ?grantRole core:roleIn ?grantUri .}
</c:set>
<script type="text/javascript">
var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}',
acType: '${vivoCore}Grant',
editMode: '${editMode}',
submitButtonTextType: 'compound',
typeName: 'Grant'
};
</script>
<% } %>
<jsp:include page="${postForm}"/>

View file

@ -1,41 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="head of" />
<jsp:param name="typeSelectorLabel" value="head of" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#LeaderRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select type"],
[ "http://vivoweb.org/ontology/core#Association", "Association" ],
[ "http://vivoweb.org/ontology/core#Center", "Center" ],
[ "http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization" ],
[ "http://vivoweb.org/ontology/core#College", "College" ],
[ "http://vivoweb.org/ontology/core#Committee", "Committee" ],
[ "http://vivoweb.org/ontology/core#Consortium", "Consortium" ],
[ "http://vivoweb.org/ontology/core#Department", "Department" ],
[ "http://vivoweb.org/ontology/core#Division", "Division" ],
[ "http://purl.org/NET/c4dm/event.owl#Event", "Event" ],
[ "http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit" ],
[ "http://vivoweb.org/ontology/core#Foundation", "Foundation" ],
[ "http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization" ],
[ "http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency" ],
[ "http://vivoweb.org/ontology/core#Hospital", "Hospital" ],
[ "http://vivoweb.org/ontology/core#Institute", "Institute" ],
[ "http://vivoweb.org/ontology/core#Laboratory", "Laboratory" ],
[ "http://vivoweb.org/ontology/core#Library", "Library" ],
[ "http://vivoweb.org/ontology/core#Museum", "Museum" ],
[ "http://xmlns.com/foaf/0.1/Organization", "Organization" ],
[ "http://vivoweb.org/ontology/core#PrivateCompany", "Private Company" ],
[ "http://vivoweb.org/ontology/core#Program", "Program" ],
[ "http://vivoweb.org/ontology/core#Project", "Project" ],
[ "http://vivoweb.org/ontology/core#Publisher", "Publisher" ],
[ "http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization" ],
[ "http://vivoweb.org/ontology/core#School", "School" ],
[ "http://vivoweb.org/ontology/core#Service","Service"],
[ "http://vivoweb.org/ontology/core#Team", "Team" ],
[ "http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization" ],
[ "http://vivoweb.org/ontology/core#University", "University" ]' />
</jsp:include>

View file

@ -1,10 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="membership" />
<jsp:param name="typeSelectorLabel" value="membership in" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#MemberRole" />
<jsp:param name="roleActivityType_optionsType" value="VCLASSGROUP" />
<jsp:param name="roleActivityType_objectClassUri" value="http://vivoweb.org/ontology#vitroClassGrouporganizations" />
<jsp:param name="roleActivityType_literalOptions" value="[ 'Select type' ]" />
</jsp:include>

View file

@ -1,26 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="organizer of" />
<jsp:param name="typeSelectorLabel" value="organizer of" />
<jsp:param name="showRoleLabelField" value="false" />
<jsp:param name="buttonText" value="organizer role" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#OrganizerRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select type"],
[ "http://purl.org/NET/c4dm/event.owl#Event", "Event" ],
[ "http://vivoweb.org/ontology/core#Competition", "Competition" ],
[ "http://purl.org/ontology/bibo/Conference", "Conference" ],
[ "http://vivoweb.org/ontology/core#Course", "Course" ],
[ "http://vivoweb.org/ontology/core#Exhibit", "Exhibit" ],
[ "http://vivoweb.org/ontology/core#Meeting", "Meeting" ],
[ "http://vivoweb.org/ontology/core#Presentation", "Presentation" ],
[ "http://vivoweb.org/ontology/core#InvitedTalk", "Invited Talk" ],
[ "http://purl.org/ontology/bibo/Workshop", "Workshop" ],
[ "http://vivoweb.org/ontology/core#EventSeries", "Event Series" ],
[ "http://vivoweb.org/ontology/core#ConferenceSeries", "Conference Series" ],
[ "http://vivoweb.org/ontology/core#SeminarSeries", "Seminar Series" ],
[ "http://vivoweb.org/ontology/core#WorkshopSeries", "Workshop Series" ]' />
</jsp:include>

View file

@ -1,40 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="outreach & community service" />
<jsp:param name="typeSelectorLabel" value="outreach & community service in" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#OutreachProviderRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select type"],
[ "http://vivoweb.org/ontology/core#Association", "Association" ],
[ "http://vivoweb.org/ontology/core#Center", "Center" ],
[ "http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization" ],
[ "http://vivoweb.org/ontology/core#College", "College" ],
[ "http://vivoweb.org/ontology/core#Committee", "Committee" ],
[ "http://vivoweb.org/ontology/core#Consortium", "Consortium" ],
[ "http://vivoweb.org/ontology/core#Department", "Department" ],
[ "http://vivoweb.org/ontology/core#Division", "Division" ],
[ "http://purl.org/NET/c4dm/event.owl#Event", "Event" ],
[ "http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit" ],
[ "http://vivoweb.org/ontology/core#Foundation", "Foundation" ],
[ "http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization" ],
[ "http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency" ],
[ "http://vivoweb.org/ontology/core#Hospital", "Hospital" ],
[ "http://vivoweb.org/ontology/core#Institute", "Institute" ],
[ "http://vivoweb.org/ontology/core#Laboratory", "Laboratory" ],
[ "http://vivoweb.org/ontology/core#Library", "Library" ],
[ "http://vivoweb.org/ontology/core#Museum", "Museum" ],
[ "http://xmlns.com/foaf/0.1/Organization", "Organization" ],
[ "http://vivoweb.org/ontology/core#PrivateCompany", "Private Company" ],
[ "http://vivoweb.org/ontology/core#Program", "Program" ],
[ "http://vivoweb.org/ontology/core#Project", "Project" ],
[ "http://vivoweb.org/ontology/core#Publisher", "Publisher" ],
[ "http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization" ],
[ "http://vivoweb.org/ontology/core#Team", "Team" ],
[ "http://vivoweb.org/ontology/core#School", "School" ],
[ "http://vivoweb.org/ontology/core#Service","Service"],
[ "http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization" ],
[ "http://vivoweb.org/ontology/core#University", "University" ]' />
</jsp:include>

View file

@ -1,17 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="presentation" />
<jsp:param name="typeSelectorLabel" value="presentation type" />
<jsp:param name="buttonText" value="presentation role" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#PresenterRole" />
<jsp:param name="numDateFields" value="1" />
<jsp:param name="roleExamples" value="Moderator, Speaker, Panelist" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select one"],
["http://vivoweb.org/ontology/core#Presentation", "Presentation" ],
[ "http://vivoweb.org/ontology/core#InvitedTalk","Invited Talk"] ' />
</jsp:include>

View file

@ -1,352 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding a publication to an author
Classes:
foaf:Person - the individual being edited
core:Authorship - primary new individual being created
Object properties (domain : range):
core:authorInAuthorship (Person : Authorship)
core:linkedAuthor (Authorship : Person) - inverse of authorInAuthorship
core:linkedInformationResource (Authorship : InformationResource)
core:informationResourceInAuthorship (InformationResource : Authorship) - inverse of linkedInformationResource
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ 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.ObjectPropertyStatement"%>
<%@ 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.configuration.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasPublicationValidatorOld" %>
<%@ 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="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ 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" %>
<%@ 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.addAuthorsToInformationResource.jsp");
public static String nodeToPubProp = "http://vivoweb.org/ontology/core#linkedInformationResource";
%>
<%
VitroRequest vreq = new VitroRequest(request);
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
String objectUri = vreq.getParameter("objectUri");
Individual obj = (Individual) request.getAttribute("object");
EditMode mode = FrontEndEditingUtils.getEditMode(request, nodeToPubProp);
/*
There are 3 modes that this form can be in:
1. Add. There is a subject and a predicate but no position and nothing else.
2. Repair a bad role node. There is a subject, predicate and object but there is no individual on the
other end of the object's core:linkedInformationResource stmt. This should be similar to an add but the form should be expanded.
3. Really bad node. Multiple core:authorInAuthorship statements.
This form does not currently support normal edit mode where there is a subject, an object, and an individual on
the other end of the object's core:linkedInformationResource statement. We redirect to the publication profile
to edit the publication.
*/
if( mode == EditMode.ADD ) {
%> <c:set var="editMode" value="add"/><%
} else if(mode == EditMode.EDIT){
// Because it's edit mode, we already know there's one and only one statement
ObjectPropertyStatement ops = obj.getObjectPropertyStatements(nodeToPubProp).get(0);
String pubUri = ops.getObjectURI();
String forwardToIndividual = pubUri != null ? pubUri : objectUri;
%>
<jsp:forward page="/individual">
<jsp:param value="<%= forwardToIndividual %>" name="uri"/>
</jsp:forward>
<%
} else if(mode == EditMode.REPAIR){
%> <c:set var="editMode" value="repair"/><%
}
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
Individual subject = (Individual) request.getAttribute("subject");
String subjectName = subject.getName();
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
String intDatatypeUri = XSD.xint.toString();
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
%>
<c:set var="vivoOnt" value="http://vivoweb.org/ontology" />
<c:set var="vivoCore" value="${vivoOnt}/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="infoResourceClassUri" value="${vivoCore}InformationResource" />
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
SPARQL queries for existing values. --%>
<v:jsonset var="newPubTypeAssertion">
?pubUri a ?pubType .
</v:jsonset>
<v:jsonset var="newPubNameAssertion">
?pubUri <${label}> ?title .
</v:jsonset>
<%-- This applies to both a new and an existing publication --%>
<v:jsonset var="n3ForNewAuthorship">
@prefix core: <${vivoCore}> .
?authorshipUri a core:Authorship ;
core:linkedAuthor ?person .
?person core:authorInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="n3ForExistingPub">
@prefix core: <${vivoCore}> .
?authorshipUri core:linkedInformationResource ?pubUri .
?pubUri core:informationResourceInAuthorship ?authorshipUri .
</v:jsonset>
<v:jsonset var="n3ForNewPub">
@prefix core: <${vivoCore}> .
?pubUri a ?pubType ;
<${label}> ?title .
?authorshipUri core:linkedInformationResource ?pubUri .
?pubUri core:informationResourceInAuthorship ?authorshipUri .
</v:jsonset>
<c:set var="publicationTypeLiteralOptions">
["", "Select one"],
["http://purl.org/ontology/bibo/AcademicArticle", "Academic Article"],
["http://purl.org/ontology/bibo/Article", "Article"],
["http://purl.org/ontology/bibo/AudioDocument", "Audio Document"],
["http://vivoweb.org/ontology/core#BlogPosting", "Blog Posting"],
["http://purl.org/ontology/bibo/Book", "Book"],
["http://vivoweb.org/ontology/core#CaseStudy", "Case Study"],
["http://vivoweb.org/ontology/core#Catalog", "Catalog"],
["http://purl.org/ontology/bibo/Chapter", "Chapter"],
["http://vivoweb.org/ontology/core#ConferencePaper", "Conference Paper"],
["http://vivoweb.org/ontology/core#ConferencePoster", "Conference Poster"],
["http://vivoweb.org/ontology/core#Database", "Database"],
["http://purl.org/ontology/bibo/EditedBook", "Edited Book"],
["http://vivoweb.org/ontology/core#EditorialArticle", "Editorial Article"],
["http://purl.org/ontology/bibo/Film", "Film"],
["http://vivoweb.org/ontology/core#Newsletter", "Newsletter"],
["http://vivoweb.org/ontology/core#NewsRelease", "News Release"],
["http://purl.org/ontology/bibo/Patent", "Patent"],
["http://purl.obolibrary.org/obo/OBI_0000272", "Protocol"],
["http://purl.org/ontology/bibo/Report", "Report"],
["http://vivoweb.org/ontology/core#ResearchProposal", "Research Proposal"],
["http://vivoweb.org/ontology/core#Review", "Review"],
["http://vivoweb.org/ontology/core#Software", "Software"],
["http://vivoweb.org/ontology/core#Speech", "Speech"],
["http://purl.org/ontology/bibo/Thesis", "Thesis"],
["http://vivoweb.org/ontology/core#Video", "Video"],
["http://purl.org/ontology/bibo/Webpage", "Webpage"],
["http://purl.org/ontology/bibo/Website", "Website"],
["http://vivoweb.org/ontology/core#WorkingPaper", "Working Paper"]
</c:set>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/individual",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["authorshipUri", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewAuthorship}" ],
"n3optional" : [ "${n3ForExistingPub}", "${n3ForNewPub}",
"${newPubNameAssertion}", "${newPubTypeAssertion}" ],
"newResources" : { "authorshipUri" : "${defaultNamespace}",
"pubUri" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "pubUri", "pubType" ],
"literalsOnForm" : [ "title" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { },
"sparqlForExistingUris" : { },
"fields" : {
"title" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${n3ForNewPub}" ]
},
"pubType" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "HARDCODED_LITERALS",
"literalOptions" : [ ${publicationTypeLiteralOptions} ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${newPubTypeAssertion}" ]
},
"pubUri" : {
"newResource" : "true",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "${personClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForExistingPub}"]
}
}
}
</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);
}
editConfig.addValidator(new PersonHasPublicationValidatorOld());
Model model = (Model) application.getAttribute("jenaOntModel");
if (objectUri != null) { // editing existing (in this case, only repair is currently provided by the form)
editConfig.prepareForObjPropUpdate(model);
} else { // adding new
editConfig.prepareForNonUpdate(model);
}
// Return to person, not publication. See NIHVIVO-1464.
// editConfig.setEntityToReturnTo("?pubUri");
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/js/browserUtils.js",
"/edit/forms/js/customFormWithAutocomplete.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/customFormWithAutocomplete.css"
));
request.setAttribute("customCss", customCss);
%>
<%-- Configure add vs. edit --%>
<c:choose>
<c:when test='${editMode == "add"}'>
<c:set var="titleVerb" value="Create" />
<c:set var="submitButtonText" value="Publication" />
</c:when>
<c:otherwise>
<c:set var="titleVerb" value="Edit" />
<c:set var="submitButtonText" value="Edit Publication" />
</c:otherwise>
</c:choose>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<% 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} publication entry for <%= subjectName %></h2>
<%@ include file="unsupportedBrowserMessage.jsp" %>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addPublicationForm" class="customForm noIE67" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p class="inline"><v:input type="select" label="Publication Type ${requiredHint}" name="pubType" id="typeSelector" /></p>
<div class="fullViewOnly">
<p><v:input type="text" id="relatedIndLabel" name="title" label="Title ${requiredHint}" cssClass="acSelector" size="50" /></p>
<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>
<input type="hidden" id="pubUri" name="pubUri" class="acUriReceiver" value="" /> <!-- Field value populated by JavaScript -->
</div>
</div>
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<c:url var="acUrl" value="/autocomplete?tokenize=true" />
<c:url var="sparqlQueryUrl" value="/ajax/sparqlQuery" />
<%-- Must be all one line for JavaScript. --%>
<c:set var="sparqlForAcFilter">
PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri . ?authorshipUri core:linkedInformationResource ?pubUri .}
</c:set>
<script type="text/javascript">
var customFormData = {
sparqlForAcFilter: '${sparqlForAcFilter}',
sparqlQueryUrl: '${sparqlQueryUrl}',
acUrl: '${acUrl}',
submitButtonTextType: 'simple',
editMode: '${editMode}',
defaultTypeName: 'publication' // used in repair mode to generate button text
};
</script>
<% } %>
<jsp:include page="${postForm}"/>

View file

@ -1,13 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="research activity" />
<jsp:param name="typeSelectorLabel" value="research activity type" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#ResearcherRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select one"],
["http://vivoweb.org/ontology/core#Grant", "Grant" ],
[ "http://vivoweb.org/ontology/core#Project","Project"] ' />
</jsp:include>

View file

@ -1,14 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="reviewer of" />
<jsp:param name="typeSelectorLabel" value="reviewer of" />
<jsp:param name="buttonText" value="reviewer role" />
<jsp:param name="showRoleLabelField" value="false" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#ReviewerRole" />
<jsp:param name="roleToActivityPredicate" value="http://vivoweb.org/ontology/core#forInformationResource" />
<jsp:param name="activityToRolePredicate" value="http://vivoweb.org/ontology/core#linkedRole" />
<jsp:param name="roleActivityType_optionsType" value="CHILD_VCLASSES" />
<jsp:param name="roleActivityType_objectClassUri" value="http://vivoweb.org/ontology/core#InformationResource" />
<jsp:param name="roleActivityType_literalOptions" value="[ 'Select type' ]" />
</jsp:include>

View file

@ -1,673 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%--
Custom two stage form for adding a Role to a Person.
Stage one is selecting the type of the non-person thing
associated with the Role with the intention of reducing the
number of Individuals that the user has to select from.
Stage two is selecting the non-person Individual to associate
with the Role.
This is intended to create a set of statements like:
?person core:hasResearchActivityRole ?newRole.
?newRole rdf:type core:ResearchActivityRole ;
roleToActivityPredicate ?someActivity .
?someActivity rdf:type core:ResearchActivity .
?someActivity rdfs:label "activity title" .
Important: This form cannot be directly used as a custom form. It has parameters that must be set.
See addClinicalRoleToPerson.jsp for an example.
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Set" %>
<%@ page import="java.util.HashSet" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
<%@ page import="org.json.JSONObject" %>
<%@ page import="org.json.JSONException" %>
<%@ page import="org.json.JSONArray" %>
<%@ 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.configuration.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="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.TitleCase" %>
<%@ 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="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils"%>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ 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" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
<%!
public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addRoleToPersonTwoStage.jsp");
%>
<%-- REQUIRED PARAMETERS --%>
<c:set var="roleDescriptor">${param.roleDescriptor}</c:set> <%-- Used in textual references to the role --%>
<c:set var="roleType">${param.roleType}</c:set> <%-- uri of role individual type --%>
<%-- For creating the role activity type select list: --%>
<c:set var="roleActivityType_optionsType" >${param.roleActivityType_optionsType}</c:set>
<c:set var="roleActivityType_objectClassUri" >${param.roleActivityType_objectClassUri}</c:set>
<c:set var="roleActivityType_literalOptions" >${param.roleActivityType_literalOptions}</c:set>
<%-- OPTIONAL PARAMETERS --%>
<c:set var="typeSelectorLabel" scope="request"> <%-- label for type selector field --%>
${! empty param.typeSelectorLabel ? param.typeSelectorLabel : param.roleDescriptor }
</c:set>
<c:set var="buttonText" scope="request">
${! empty param.buttonText ? param.buttonText : param.roleDescriptor }
</c:set>
<c:set var="roleToActivityPredicate" scope="request">
${! empty param.roleToActivityPredicate ? param.roleToActivityPredicate : "http://vivoweb.org/ontology/core#roleIn" }
</c:set>
<c:set var="activityToRolePredicate">
${! empty param.activityToRolePredicate ? param.activityToRolePredicate : "http://vivoweb.org/ontology/core#relatedRole" }
</c:set>
<c:set var="numDateFields">${! empty param.numDateFields ? param.numDateFields : 2 }</c:set>
<c:set var="showRoleLabelField">
${! empty param.showRoleLabelField ? param.showRoleLabelField : true }
</c:set>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
String subjectName = ((Individual) request.getAttribute("subject")).getName();
vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri));
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
String intDatatypeUri = XSD.xint.toString();
vreq.setAttribute("intDatatypeUri", intDatatypeUri);
vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri));
vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString()));
vreq.setAttribute("typeSelectorLabelTitleCase",
TitleCase.toTitleCase( (String)vreq.getAttribute("typeSelectorLabel"), false));
String buttonText = (String) vreq.getAttribute("buttonText");
vreq.setAttribute("buttonText", TitleCase.toTitleCase(buttonText));
ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri );
if( op != null && op.getURIInverse() != null ){
%> <c:set var="inversePredicate"><%=op.getURIInverse()%></c:set> <%
}else{
%> <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 roleToActivity stmt.
3. Repair a bad role node. There is a subject, predicate and object but there is no individual on the
other end of the object's roleToActivity stmt. This should be similar to an add but the form should be expanded.
4. Really bad node. multiple roleToActivity statements.
*/
String roleToActivityPredicate = (String) vreq.getAttribute("roleToActivityPredicate");
log.debug("roleToActivityPredicate = " + roleToActivityPredicate);
EditMode mode = FrontEndEditingUtils.getEditMode(request, roleToActivityPredicate);
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#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="vitro" value="<%= VitroVocabulary.vitroURI %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="defaultNamespace" value=""/> <%--blank triggers default URI generation behavior --%>
<c:set var="startYearPred" value="${vivoCore}startYear" />
<c:set var="endYearPred" value="${vivoCore}endYear" />
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
<c:set var="roleToInterval" value="${vivoCore}dateTimeInterval"/>
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
<c:set var="intervalToStart" value="${vivoCore}start"/>
<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 == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"," : "" %></c:set>
<c:set var="typeRequired" ><%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"" : "" %></c:set>
<c:set var="roleLabelRequired">${showRoleLabelField ? "\"nonempty\"," : "" }</c:set>
<v:jsonset var="roleLabelAssertion" >
?role <${label}> ?roleLabel .
</v:jsonset>
<v:jsonset var="n3ForNewRole">
@prefix core: <${vivoCore}> .
?person ?rolePredicate ?role.
?role a <${roleType}> .
?role <${roleToActivityPredicate}> ?roleActivity .
?roleActivity <${activityToRolePredicate}> ?role .
</v:jsonset>
<v:jsonset var="n3ForActivityType">
?roleActivity a ?roleActivityType .
</v:jsonset>
<v:jsonset var="n3ForRoleToActivity">
@prefix core: <${vivoCore}> .
?role <${roleToActivityPredicate}> ?roleActivity .
?roleActivity <${activityToRolePredicate}> ?role .
</v:jsonset>
<v:jsonset var="n3ForActivityLabel">
?roleActivity <${label}> ?activityLabel .
</v:jsonset>
<v:jsonset var="n3ForInverse">
?role ?inverseRolePredicate ?person.
</v:jsonset>
<v:jsonset var="n3ForStart">
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?startField-value .
?startNode <${dateTimePrecision}> ?startField-precision .
</v:jsonset>
<v:jsonset var="n3ForEnd">
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?endField-value .
?endNode <${dateTimePrecision}> ?endField-precision .
</v:jsonset>
<v:jsonset var="activityLabelQuery">
PREFIX core: <${vivoCore}>
PREFIX rdfs: <${rdfs}>
SELECT ?existingTitle WHERE {
?role <${roleToActivityPredicate}> ?existingActivity .
?existingActivity rdfs:label ?existingTitle . }
</v:jsonset>
<v:jsonset var="activityQuery">
PREFIX core: <${vivoCore}>
SELECT ?existingActivity WHERE { ?role <${roleToActivityPredicate}> ?existingActivity . }
</v:jsonset>
<v:jsonset var="roleLabelQuery">
SELECT ?existingRoleLabel WHERE { ?role <${label}> ?existingRoleLabel . }
</v:jsonset>
<%
request.setAttribute("typeQuery", getActivityTypeQuery(vreq));
log.debug("TYPE QUERY: " + vreq.getAttribute("typeQuery"));
%>
<v:jsonset var="activityTypeQuery">${typeQuery}</v:jsonset>
<%--
<v:jsonset var="activityTypeQuery">
PREFIX core: <${vivoCore}>
PREFIX vitro: <${vitro}>
SELECT ?existingActivityType WHERE {
?role <${roleToActivityPredicate}> ?existingActivity .
?existingActivity vitro:mostSpecificType ?existingActivityType .
}
</v:jsonset>
--%>
<v:jsonset var="existingIntervalNodeQuery" >
SELECT ?existingIntervalNode WHERE {
?role <${roleToInterval}> ?existingIntervalNode .
?existingIntervalNode <${type}> <${intervalType}> . }
</v:jsonset>
<v:jsonset var="existingStartNodeQuery" >
SELECT ?existingStartNode WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?existingStartNode .
?existingStartNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingStartDateQuery" >
SELECT ?existingDateStart WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?existingDateStart . }
</v:jsonset>
<v:jsonset var="existingStartPrecisionQuery" >
SELECT ?existingStartPrecision WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
</v:jsonset>
<v:jsonset var="existingEndNodeQuery" >
SELECT ?existingEndNode WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?existingEndNode .
?existingEndNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingEndDateQuery" >
SELECT ?existingEndDate WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?existingEndDate . }
</v:jsonset>
<v:jsonset var="existingEndPrecisionQuery" >
SELECT ?existingEndPrecision WHERE {
?role <${roleToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/individual",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["rolePredicate", "${predicateUriJson}" ],
"object" : ["role", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewRole}" ],
"n3optional" : [ "${n3ForActivityLabel}", "${n3ForActivityType}", "${n3ForInverse}",
"${n3ForStart}", "${n3ForEnd}", "${roleLabelAssertion}" ],
"newResources" : { "role" : "${defaultNamespace}",
"roleActivity" : "${defaultNamespace}",
"intervalNode" : "${defaultNamespace}",
"startNode" : "${defaultNamespace}",
"endNode" : "${defaultNamespace}" },
"urisInScope" : { "inverseRolePredicate" : "${inversePredicate}" },
"literalsInScope": { },
"urisOnForm" : [ "roleActivity", "roleActivityType" ],
"literalsOnForm" : [ "activityLabel", "roleLabel" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"activityLabel":"${activityLabelQuery}",
"roleLabel":"${roleLabelQuery}",
"startField-value" : "${existingStartDateQuery}",
"endField-value" : "${existingEndDateQuery}"
},
"sparqlForExistingUris" : {
"roleActivity":"${activityQuery}" ,
"roleActivityType":"${activityTypeQuery}" ,
"intervalNode" : "${existingIntervalNodeQuery}",
"startNode" : "${existingStartNodeQuery}",
"endNode" : "${existingEndNodeQuery}",
"startField-precision": "${existingStartPrecisionQuery}",
"endField-precision" : "${existingEndPrecisionQuery}"
},
"fields" : {
"activityLabel" : {
"newResource" : "false",
"validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${n3ForActivityLabel}" ]
},
"roleActivityType" : {
"newResource" : "true",
"validators" : [ ${typeRequired} ],
"optionsType" : "${roleActivityType_optionsType}",
"literalOptions" : [ ${roleActivityType_literalOptions } ],
"predicateUri" : "",
"objectClassUri" : "${roleActivityType_objectClassUri}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForActivityType}" ]
},
"roleActivity" : {
"newResource" : "true",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForRoleToActivity}" ]
},
"roleLabel" : {
"newResource" : "false",
"validators" : [ ${roleLabelRequired} "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${roleLabelAssertion}" ]
},
"startField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForStart}" ]
},
"endField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForEnd}" ]
}
}
}
</c:set>
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
//set up date time edit elements
Field startField = editConfig.getField("startField");
startField.setEditElement(
new DateTimeWithPrecision(startField,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri()));
Field endField = editConfig.getField("endField");
endField.setEditElement(
new DateTimeWithPrecision(endField,
VitroVocabulary.Precision.YEAR.uri(),
VitroVocabulary.Precision.NONE.uri()));
}
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) {
editConfig.prepareForObjPropUpdate(model);
// Return browser to person individual after editing an existing role.
} else {
editConfig.prepareForNonUpdate(model);
// NIHVIVO-1014 Return browser to person individual after editing an existing role.
// Return the browser to the new activity entity after adding a new role.
// editConfig.setEntityToReturnTo("?roleActivity");
}
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/edit/forms/js/customFormWithAutocomplete.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/customFormWithAutocomplete.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<c:choose>
<%-- Includes edit AND repair mode --%>
<c:when test="<%= request.getAttribute(\"objectUri\")!=null %>">
<c:set var="titleVerb" value="Edit" />
<c:set var="submitButtonText" value="Edit ${buttonText}" />
<c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set>
</c:when>
<c:otherwise>
<c:set var="titleVerb" value="Create" />
<c:set var="editMode" value="add" />
<c:set var="submitButtonText" value="${buttonText}" />
<c:set var="disabledVal" value="" />
</c:otherwise>
</c:choose>
<c:if test="${ ! empty param.roleExamples}">
<c:set var="roleExamples" value="(e.g., ${param.roleExamples})" />
</c:if>
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<% if( mode == EditMode.ERROR ){ %>
<div>This form is unable to handle the editing of this role because it is associated with
multiple ${param.roleDescriptor} individuals.</div>
<% }else{ %>
<h2>${titleVerb}&nbsp;${roleDescriptor} entry for <%= subjectName %></h2>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<form id="addRoleForm" class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<p class="inline"><v:input type="select" label="${typeSelectorLabelTitleCase} ${requiredHint}" name="roleActivityType" disabled="${disabledVal}" id="typeSelector" /></p>
<div class="fullViewOnly">
<p><v:input type="text" id="relatedIndLabel" name="activityLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
returning from a validation error, we retain the values. --%>
<c:if test="${editMode == 'edit'}">
<v:input type="hidden" id="roleActivityType" />
<v:input type="hidden" id="activityLabel" />
</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="roleActivityUri" name="roleActivity" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript -->
</div>
<c:if test="${showRoleLabelField}">
<p><v:input type="text" id="roleLabel" label="Role in ### ${requiredHint} ${roleExamples}" size="50" /></p>
</c:if>
<c:choose>
<c:when test="${numDateFields == 1}">
<v:input id="startField" label="Year ${yearHint}" size="7"/>
</c:when>
<c:otherwise>
<h4 class="label">Years of Participation in ###</h4>
<v:input id="startField" label="Start Year ${yearHint}" size="7"/>
<v:input id="endField" label="End Year ${yearHint}" size="7"/>
</c:otherwise>
</c:choose>
</div>
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<c:url var="acUrl" value="/autocomplete?tokenize=true" />
<script type="text/javascript">
var customFormData = {
acUrl: '${acUrl}',
editMode: '${editMode}',
submitButtonTextType: 'compound',
defaultTypeName: 'activity' // used in repair mode, to generate button text and org name field label
};
</script>
<% } %>
<jsp:include page="${postForm}"/>
<%!
private static final String VIVO_CORE = "http://vivoweb.org/ontology/core#";
private static final String DEFAULT_ACTIVITY_TYPE_QUERY =
"PREFIX core: <" + VIVO_CORE + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE { \n" +
" ?role ?predicate ?existingActivity . \n" +
" ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" +
"}";
private static final String SUBCLASS_ACTIVITY_TYPE_QUERY =
"PREFIX core: <" + VIVO_CORE + ">\n" +
"PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE {\n" +
" ?role ?predicate ?existingActivity . \n" +
" ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" +
" ?existingActivityType rdfs:subClassOf ?objectClassUri . \n" +
"}";
private static final String CLASSGROUP_ACTIVITY_TYPE_QUERY =
"PREFIX core: <" + VIVO_CORE + ">\n" +
"PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" +
"SELECT ?existingActivityType WHERE { \n" +
" ?role ?predicate ?existingActivity . \n" +
" ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" +
" ?existingActivityType vitro:inClassGroup ?classgroup . \n" +
"}";
/*
* The activity type query results must be limited to the values in the activity type select element.
* Sometimes the query returns a superclass such as owl:Thing instead.
* Make use of vitro:mostSpecificType so that, for example, an individual is both a
* core:InvitedTalk and a core:Presentation, core:InvitedTalk is selected.
* vitro:mostSpecificType alone may not suffice, since it does not guarantee that the value returned
* is in the select list.
* We could still have problems if the value from the select list is not a vitro:mostSpecificType,
* but that is unlikely.
*/
private String getActivityTypeQuery(VitroRequest vreq) {
String activityTypeQuery = null;
String optionsType = vreq.getParameter("roleActivityType_optionsType");
// Note that this value is overloaded to specify either object class uri or classgroup uri
String objectClassUri = vreq.getParameter("roleActivityType_objectClassUri");
if (StringUtils.isNotBlank(objectClassUri)) {
log.debug("objectClassUri = " + objectClassUri);
if ("VCLASSGROUP".equals(optionsType)) {
activityTypeQuery = CLASSGROUP_ACTIVITY_TYPE_QUERY;
activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "classgroup", objectClassUri);
} else if ("CHILD_VCLASSES".equals(optionsType)) {
activityTypeQuery = SUBCLASS_ACTIVITY_TYPE_QUERY;
activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "objectClassUri", objectClassUri);
} else {
activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY;
}
// Select options are hardcoded
} else if ("HARDCODED_LITERALS".equals(optionsType)) {
String typeLiteralOptions = vreq.getParameter("roleActivityType_literalOptions");
if (StringUtils.isNotBlank(typeLiteralOptions)) {
try {
JSONObject json = new JSONObject("{values: [" + typeLiteralOptions + "]}");
Set<String> typeUris = new HashSet<String>();
JSONArray values = json.getJSONArray("values");
int valueCount = values.length();
for (int i = 0; i < valueCount; i++) {
JSONArray option = values.getJSONArray(i);
String uri = option.getString(0);
if (StringUtils.isNotBlank(uri)) {
typeUris.add("(?existingActivityType = <" + uri + ">)");
}
}
String typeFilters = "FILTER (" + StringUtils.join(typeUris, "||") + ")";
activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY.replaceAll("}$", "") + typeFilters + "}";
} catch (JSONException e) {
activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY;
}
} else {
activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY;
}
} else {
activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY;
}
String roleToActivityPredicate = (String) vreq.getAttribute("roleToActivityPredicate");
activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "predicate", roleToActivityPredicate);
log.debug("Activity type query: " + activityTypeQuery);
return activityTypeQuery;
}
%>

View file

@ -1,41 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="service to the profession" />
<jsp:param name="typeSelectorLabel" value="service to the profession in" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#ServiceProviderRole" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select type"],
[ "http://vivoweb.org/ontology/core#Association", "Association" ],
[ "http://vivoweb.org/ontology/core#Center", "Center" ],
[ "http://vivoweb.org/ontology/core#ClinicalOrganization", "Clinical Organization" ],
[ "http://vivoweb.org/ontology/core#College", "College" ],
[ "http://vivoweb.org/ontology/core#Committee", "Committee" ],
[ "http://vivoweb.org/ontology/core#Consortium", "Consortium" ],
[ "http://vivoweb.org/ontology/core#Department", "Department" ],
[ "http://vivoweb.org/ontology/core#Division", "Division" ],
[ "http://purl.org/NET/c4dm/event.owl#Event", "Event" ],
[ "http://vivoweb.org/ontology/core#ExtensionUnit", "Extension Unit" ],
[ "http://vivoweb.org/ontology/core#Foundation", "Foundation" ],
[ "http://vivoweb.org/ontology/core#FundingOrganization", "Funding Organization" ],
[ "http://vivoweb.org/ontology/core#GovernmentAgency", "Government Agency" ],
[ "http://vivoweb.org/ontology/core#Hospital", "Hospital" ],
[ "http://vivoweb.org/ontology/core#Institute", "Institute" ],
[ "http://vivoweb.org/ontology/core#Laboratory", "Laboratory" ],
[ "http://vivoweb.org/ontology/core#Library", "Library" ],
[ "http://vivoweb.org/ontology/core#Museum", "Museum" ],
[ "http://xmlns.com/foaf/0.1/Organization", "Organization" ],
[ "http://vivoweb.org/ontology/core#PrivateCompany", "Private Company" ],
[ "http://vivoweb.org/ontology/core#Program", "Program" ],
[ "http://vivoweb.org/ontology/core#Project", "Project" ],
[ "http://vivoweb.org/ontology/core#Publisher", "Publisher" ],
[ "http://vivoweb.org/ontology/core#ResearchOrganization", "Research Organization" ],
[ "http://vivoweb.org/ontology/core#Team", "Team" ],
[ "http://vivoweb.org/ontology/core#School", "School" ],
[ "http://vivoweb.org/ontology/core#Service","Service"],
[ "http://vivoweb.org/ontology/core#StudentOrganization", "Student Organization" ],
[ "http://vivoweb.org/ontology/core#University", "University" ]' />
</jsp:include>

View file

@ -1,15 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<jsp:include page="addRoleToPersonTwoStage.jsp">
<jsp:param name="roleDescriptor" value="teaching activity" />
<jsp:param name="typeSelectorLabel" value="teaching activity type" />
<jsp:param name="roleType" value="http://vivoweb.org/ontology/core#TeacherRole" />
<jsp:param name="roleExamples" value="Instructor, Facilitator, Assistant" />
<jsp:param name="roleActivityType_optionsType" value="HARDCODED_LITERALS" />
<jsp:param name="roleActivityType_objectClassUri" value="" />
<jsp:param name="roleActivityType_literalOptions"
value='["", "Select one"],
["http://purl.org/ontology/bibo/Conference", "Conference" ],
[ "http://vivoweb.org/ontology/core#Course","Course"],
[ "http://purl.org/ontology/bibo/Workshop","Workshop"] ' />
</jsp:include>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 234 B

View file

@ -1,226 +0,0 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var manageWebpages = {
/* *** Initial page setup *** */
onLoad: function() {
this.mixIn();
this.initPage();
},
mixIn: function() {
// Get the custom form data from the page
$.extend(this, customFormData);
},
// Initial page setup. Called only at page load.
initPage: function() {
this.initWebpageData();
this.bindEventListeners();
this.initDragAndDrop();
if ($('.webpage').length) { // make sure we have at least one webpage
// Reorder web pages on page load so that previously unranked items get a rank. Otherwise,
// when we add a new web page, it will get put ahead of any previously unranked web pages, instead
// of at the end of the list. (It is also helpful to normalize the data before we get started.)
this.reorder();
}
},
// On page load, associate data with each list item. Then we don't
// have to keep retrieving data from or modifying the DOM as we manipulate the
// items.
initWebpageData: function() {
$('.webpage').each(function(index) {
$(this).data(webpageData[index]);
// RY We might still need position to put back an element after reordering
// failure. Rank might already have been reset? Check.
$(this).data('position', index+1);
});
},
bindEventListeners: function() {
$('.remove').click(function() {
manageWebpages.removeWebpage(this);
return false;
});
},
/* *** Ajax initializations *** */
/* Drag-and-drop */
initDragAndDrop: function() {
var webpages = $('#webpageList');
// No DD if < 2 items
if (webpages.children('li') < 2) {
return;
}
$('.webpageName').each(function() {
$(this).attr('title', 'Drag and drop to reorder web pages');
});
webpages.sortable({
cursor: 'move',
update: function(event, ui) {
manageWebpages.reorder(event, ui);
}
});
},
// Reorder webpages. Called on page load and after drag-and-drop and remove.
// Event and ui parameters are defined only in the case of drag-and-drop.
reorder: function(event, ui) {
var webpages = $('li.webpage').map(function(index, el) {
return $(this).data('webpageUri');
}).get();
$.ajax({
url: manageWebpages.reorderUrl,
data: {
predicate: manageWebpages.rankPredicate,
individuals: webpages
},
traditional: true, // serialize the array of individuals for the server
dataType: 'json',
type: 'POST',
success: function(data, status, request) {
var pos;
$('.webpage').each(function(index){
pos = index + 1;
// Set the new position for this element. The only function of this value
// is so we can reset an element to its original position in case reordering fails.
manageWebpages.setPosition(this, pos);
});
},
error: function(request, status, error) {
// ui is undefined on page load and after a webpage removal.
if (ui) {
// Put the moved item back to its original position.
// Seems we need to do this by hand. Can't see any way to do it with jQuery UI. ??
var pos = manageWebpages.getPosition(ui.item),
nextpos = pos + 1,
webpages = $('#webpageList'),
next = manageWebpages.findWebpage('position', nextpos);
if (next.length) {
ui.item.insertBefore(next);
}
else {
ui.item.appendTo(webpages);
}
alert('Reordering of web pages failed.');
}
}
});
},
getPosition: function(webpage) {
return $(webpage).data('position');
},
setPosition: function(webpage, pos) {
$(webpage).data('position', pos);
},
findWebpage: function(key, value) {
var matchingWebpage = $(); // if we don't find one, return an empty jQuery set
$('.webpage').each(function() {
var webpage = $(this);
if ( webpage.data(key) === value ) {
matchingWebpage = webpage;
return false; // stop the loop
}
});
return matchingWebpage;
},
removeWebpage: function(link) {
// RY Upgrade this to a modal window
var removeLast = false,
message = 'Are you sure you want to remove this web page?';
if (!confirm(message)) {
return false;
}
if ($(link)[0] === $('.remove:last')[0]) {
removeLast = true;
}
$.ajax({
url: $(link).attr('href'),
type: 'POST',
data: {
deletion: $(link).parents('.webpage').data('webpageUri')
},
dataType: 'json',
context: link, // context for callback
complete: function(request, status) {
var webpage;
if (status === 'success') {
webpage = $(this).parents('.webpage');
webpage.fadeOut(400, function() {
var numWebpages;
// Remove from the DOM
$(this).remove();
// Actions that depend on the webpage having been removed from the DOM:
numWebpages = $('.webpage').length; // retrieve the new length after removing webpage from the DOM
// If removed item not last, reorder to remove any gaps
if (numWebpages > 0 && ! removeLast) {
manageWebpages.reorder();
}
// If fewer than two webpages remaining, disable drag-drop
if (numWebpages < 2) {
manageWebpages.disableDD();
}
});
} else {
alert('Error processing request: web page not removed');
}
}
});
},
// Disable DD and associated cues if only one item remains
disableDD: function() {
var webpages = $('#webpageList');
$('#webpageList').sortable({ disable: true } )
/* Use class dd rather than jQuery UI's class ui-sortable, so that we can remove
* the class if there's fewer than one webpage. We don't want to remove the ui-sortable
* class, in case we want to re-enable DD without a page reload (e.g., if implementing
* adding a webpage via Ajax request).
*/
.removeClass('dd');
$('.webpageName').removeAttr('title');
}
};
$(document).ready(function() {
manageWebpages.onLoad();
});

View file

@ -1,200 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Landing page for managing web pages associated with an individual. From here, we do one of three things:
1. If arriving here by clicking add link on profile, go directly to add form.
2. If arriving here by edit link on the profile page, stay here for web page management (can add, edit, or delete).
3. If arriving here after an add/edit form submission, stay here for additional web page management.
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Map" %>
<%@ page import="com.hp.hpl.jena.rdf.model.Literal" %>
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
<%@ page import="com.hp.hpl.jena.query.ResultSet" %>
<%@ page import="com.hp.hpl.jena.rdf.model.RDFNode" %>
<%@ page import="com.hp.hpl.jena.query.QuerySolution" %>
<%@ page import="com.hp.hpl.jena.query.Dataset" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils" %>
<%@ page import="org.apache.commons.lang.StringUtils" %>
<%@ 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.manageWebpagesForIndividual.jsp");
%>
<%
String objectUri = (String) request.getAttribute("objectUri");
String view = request.getParameter("view");
if ( "form".equals(view) || // the url specifies form view
( view == null && objectUri == null ) ) { // add form always starts with form
%> <jsp:forward page="addEditWebpageForm.jsp" /> <%
} // else stay here to manage webpages
VitroRequest vreq = new VitroRequest(request);
//WebappDaoFactory wdf = vreq.getWebappDaoFactory();
//vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace());
String subjectName = ((Individual)request.getAttribute("subject")).getName();
String subjectUri = (String) request.getAttribute("subjectUri");
String predicateUri = (String) request.getAttribute("predicateUri");
List<Map<String, String>> webpages = getWebpages(subjectUri, vreq);
vreq.setAttribute("webpages", webpages);
String ulClass = "";
List<String> ulClasses = new ArrayList<String>();
if (webpages.size() > 1) {
// This class triggers application of dd styles. Don't wait for js to add
// the ui-sortable class, because then the page flashes as the styles are updated.
ulClasses.add("dd");
}
if (ulClasses.size() > 0) {
ulClass="class=\"" + StringUtils.join(ulClasses, " ") + "\"";
}
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
"/edit/forms/js/manageWebpagesForIndividual.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/manageWebpagesForIndividual.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="subjectUri" value="<%= subjectUri %>" />
<c:set var="rankPredicate" value="http://vivoweb.org/ontology/core#rank" />
<c:url var="returnToIndividualUrl" value="/individual?uri=${subjectUri}" />
<c:url var="baseEditWebpageUrl" value="/edit/editRequestDispatch.jsp">
<c:param name="subjectUri" value="<%= subjectUri %>" />
<c:param name="predicateUri" value="<%= predicateUri %>" />
<c:param name="view" value="form" />
</c:url>
<c:url var="deleteWebpageUrl" value="/edit/primitiveDelete" />
<c:url var="reorderUrl" value="/edit/reorder" />
<c:url var="showAddFormUrl" value="/edit/editRequestDispatch.jsp">
<c:param name="subjectUri" value="<%= subjectUri %>" />
<c:param name="predicateUri" value="<%= predicateUri %>" />
<c:param name="cancelTo" value="manage" />
</c:url>
<jsp:include page="${preForm}"/>
<h1>JSP form, must be removed for the 1.4!</h1>
<h2><em><%= subjectName %></em></h2>
<h3>Manage Web Pages</h3>
<script type="text/javascript">
var webpageData = [];
</script>
<ul id="webpageList" <%= ulClass %>>
<c:if test="${ empty webpages }">
<p>This individual currently has no web pages specified. Add a new web page by clicking on the button below.</p>
</c:if>
<c:forEach var="webpage" items="${webpages}">
<li class="webpage">
<c:set var="anchor">${ empty webpage.anchor ? webpage.url : webpage.anchor }</c:set>
<span class="webpageName">
<a href="${webpage.url}">${anchor}</a>
</span>
<span class="editingLinks">
<a href="${baseEditWebpageUrl}&objectUri=${webpage.link}" class="edit">Edit</a> |
<a href="${deleteWebpageUrl}" class="remove">Delete</a>
</span>
</li>
<script type="text/javascript">
webpageData.push({
"webpageUri": "${webpage.link}"
});
</script>
</c:forEach>
</ul>
<div id="addAndCancelLinks">
<%-- There is no editConfig at this stage, so we don't need to go through postEditCleanup.jsp on cancel.
These can just be ordinary links, rather than a v:input element, as in
addAuthorsToInformationResource.jsp. --%>
<a href="${showAddFormUrl}" id="showAddForm" class="button green">Add Web Page</a>
<a href="${returnToIndividualUrl}" id="returnToIndividual" class="return">Return to Individual</a>
</div>
<script type="text/javascript">
var customFormData = {
rankPredicate: '${rankPredicate}',
reorderUrl: '${reorderUrl}'
};
</script>
<jsp:include page="${postForm}"/>
<%!
private static String WEBPAGE_QUERY = ""
+ "PREFIX core: <http://vivoweb.org/ontology/core#> \n"
+ "SELECT DISTINCT ?link ?url ?anchor ?rank WHERE { \n"
+ " ?subject core:webpage ?link . \n"
+ " OPTIONAL { ?link core:linkURI ?url } \n"
+ " OPTIONAL { ?link core:linkAnchorText ?anchor } \n"
+ " OPTIONAL { ?link core:rank ?rank } \n"
+ "} ORDER BY ?rank";
private List<Map<String, String>> getWebpages(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(WEBPAGE_QUERY, "subject", subjectUri);
log.debug("Query string is: " + queryStr);
List<Map<String, String>> webpages = new ArrayList<Map<String, String>>();
try {
ResultSet results = QueryUtils.getQueryResults(queryStr, vreq);
while (results.hasNext()) {
QuerySolution soln = results.nextSolution();
RDFNode node = soln.get("link");
if (node.isURIResource()) {
webpages.add(QueryUtils.querySolutionToStringValueMap(soln));
}
}
} catch (Exception e) {
log.error(e, e);
}
return webpages;
}
%>

View file

@ -1,195 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding a new Individual from the siteAdmin page.
This form is not associated with an object property, it is reached because the
html:form on dataInput.jsp has an input element like:
<input type="hidden" name="editForm" value="newIndividualForm.jsp"/>
This form is intended to only do the addition of an individual. It is not configured with sparql
for existing so it cannot handle an update. It will not have a subject, predicate or object
parameter set up by editRequestDispatch.
--%>
<%@ 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.VClass"%>
<%@ 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.configuration.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="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor"%>
<%@ 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.newIndividualForm");
public static String FOAF_PERSON = "http://xmlns.com/foaf/0.1/Person";
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
VClass type = wdf.getVClassDao().getVClassByURI(vreq.getParameter("typeOfNew"));
Boolean isPersonType = Boolean.FALSE;
List<String> superTypes = wdf.getVClassDao().getAllSuperClassURIs(vreq.getParameter("typeOfNew"));
if( superTypes != null ){
for( String typeUri : superTypes){
if( FOAF_PERSON.equals(typeUri)) {
isPersonType = Boolean.TRUE;
break;
}
}
}
List<String> customCss = new ArrayList<String>(Arrays.asList("/edit/forms/css/customForm.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="typeName" ><%= type.getName() %></c:set>
<c:set var="isPersonType" ><%= isPersonType %></c:set>
<c:set var="labelValidation" value="${ isPersonType ? '' : '\"nonempty\"' }"/>
<c:set var="nameValidation" value="${ isPersonType ? '\"nonempty\"' : '' }"/>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="rdf" value="<%= VitroVocabulary.RDF %>" />
<c:set var="foaf" value="http://xmlns.com/foaf/0.1/" />
<v:jsonset var="n3ForType">
@prefix rdf: <${rdf}> .
?newInd rdf:type <${param.typeOfNew}> .
</v:jsonset>
<v:jsonset var="n3ForPersonNames">
@prefix foaf: <${foaf}> .
?newInd foaf:firstName ?firstName ;
foaf:lastName ?lastName .
</v:jsonset>
<v:jsonset var="n3ForNonPersonRdfsLabel">
@prefix rdfs: <${rdfs}> .
?newInd rdfs:label ?label .
</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/individual",
"subject" : ["subjectNotUsed", "" ],
"predicate" : ["predicateNotUsed", "" ],
"object" : ["objectNotUsed", "", "URI" ],
"n3required" : [ "${n3ForType}" ],
"n3optional" : [ "${n3ForPersonNames}" , "${n3ForNonPersonRdfsLabel}" ],
"newResources" : { "newInd" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ ],
"literalsOnForm" : [ "label", "firstName", "lastName" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { },
"sparqlForExistingUris" : { },
"fields" : {
"label" : {
"newResource" : "false",
"validators" : [ ${labelValidation} ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ ]
},
"firstName" : {
"newResource" : "false",
"validators" : [ ${nameValidation} ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ ]
},
"lastName" : {
"newResource" : "false",
"validators" : [ ${nameValidation} ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ ]
}
}
}
</c:set>
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
}
editConfig.setEntityToReturnTo("?newInd");
//deal with rdfs:labe for firstname/lastname
editConfig.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor());
//this form always is always doing a non-update:
Model model = (Model) application.getAttribute("jenaOntModel");
editConfig.prepareForNonUpdate(model);
%>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<h2>Create a new ${typeName}</h2>
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<c:if test="${! isPersonType}">
<v:input type="text" label="Name ${requiredHint}" id="label" size="30" />
</c:if>
<c:if test="${isPersonType}">
<v:input type="text" label="First Name ${requiredHint}" id="firstName" size="30" />
<v:input type="text" label="Last Name ${requiredHint}" id="lastName" size="30" />
</c:if>
<c:set var="submitLabel" value="Create ${typeName}" />
<p class="submit"><v:input type="submit" id="submit" value="${submitLabel}" cancel="true" cancelUrl="/siteAdmin" /></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<jsp:include page="${postForm}"/>

View file

@ -1,336 +0,0 @@
<%-- $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.configuration.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.beans.ObjectProperty"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %>
<%-- This form is for the object property between Organizations and Positions. --%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
%>
<%-- Define predicates used in n3 assertions and sparql queries --%>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="label" value="<%= VitroVocabulary.LABEL %>" />
<c:set var="positionInOrgPred" value="${vivoCore}positionInOrganization" />
<c:set var="orgForPositionPred" value="${vivoCore}organizationForPosition" />
<c:set var="positionType" value="${vivoCore}Position" />
<c:set var="positionForPerson" value="${vivoCore}positionForPerson" />
<c:set var="personInPosition" value="${vivoCore}personInPosition" />
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="edToDateTime" value="${vivoCore}dateTimeInterval"/>
<c:set var="positionToInterval" value="${vivoCore}dateTimeInterval"/>
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
<c:set var="intervalToStart" value="${vivoCore}start"/>
<c:set var="intervalToEnd" value="${vivoCore}end"/>
<v:jsonset var="personClassUri">http://xmlns.com/foaf/0.1/Person</v:jsonset>
<%-- 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 --%>
<v:jsonset var="titleExisting" >
SELECT ?titleExisting WHERE {
?positionUri <${label}> ?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 <${label}> ?title.
</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 --%>
<v:jsonset var="personUriExisting" >
SELECT ?existingPersonUri WHERE {
?positionUri <${positionForPerson}> ?existingPersonUri }
</v:jsonset>
<v:jsonset var="personUriAssertion" >
?positionUri <${positionForPerson}> ?personUri .
?personUri <${personInPosition}> ?positionUri .
</v:jsonset>
<v:jsonset var="n3ForStmtToOrg" >
?organizationUri <${orgForPositionPred}> ?positionUri .
?positionUri <${positionInOrgPred}> ?organizationUri .
?positionUri a ?positionType .
</v:jsonset>
<v:jsonset var="n3ForStart">
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?startField-value .
?startNode <${dateTimePrecision}> ?startField-precision .
</v:jsonset>
<v:jsonset var="n3ForEnd">
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?endField-value .
?endNode <${dateTimePrecision}> ?endField-precision .
</v:jsonset>
<v:jsonset var="existingIntervalNodeQuery" >
SELECT ?existingIntervalNode WHERE {
?positionUri <${positionToInterval}> ?existingIntervalNode .
?existingIntervalNode <${type}> <${intervalType}> . }
</v:jsonset>
<v:jsonset var="existingStartNodeQuery" >
SELECT ?existingStartNode WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?existingStartNode .
?existingStartNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingStartDateQuery" >
SELECT ?existingDateStart WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?existingDateStart . }
</v:jsonset>
<v:jsonset var="existingStartPrecisionQuery" >
SELECT ?existingStartPrecision WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
</v:jsonset>
<v:jsonset var="existingEndNodeQuery" >
SELECT ?existingEndNode WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?existingEndNode .
?existingEndNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingEndDateQuery" >
SELECT ?existingEndDate WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?existingEndDate . }
</v:jsonset>
<v:jsonset var="existingEndPrecisionQuery" >
SELECT ?existingEndPrecision WHERE {
?positionUri <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
</v:jsonset>
<v:jsonset var="positionTypeAssertion">
?positionUri a ?positionType .
</v:jsonset>
<v:jsonset var="positionTypeQuery">
SELECT ?existingPositionType WHERE {
?positionUri a ?existingPositionType . }
</v:jsonset>
<c:set var="positionClass" value="${vivoCore}Position" />
<v:jsonset var="positionClassUriJson">${positionClass}</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/entity",
"subject" : ["organizationUri", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["positionUri", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForStmtToOrg}", "${titleAssertion}" , "${personUriAssertion}", "${positionTypeAssertion}"],
"n3optional" : [ "${n3ForStart}" , "${n3ForEnd}" ],
"newResources" : { "positionUri" : "${defaultNamespace}",
"intervalNode" : "${defaultNamespace}",
"startNode" : "${defaultNamespace}",
"endNode" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "personUri", "positionType" ],
"literalsOnForm" : [ "title" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"title" : "${titleExisting}",
"startField-value" : "${existingStartDateQuery}",
"endField-value" : "${existingEndDateQuery}"
},
"sparqlForExistingUris" : {
"personUri" : "${personUriExisting}",
"positionType" : "${positionTypeQuery}" ,
"intervalNode" : "${existingIntervalNodeQuery}",
"startNode" : "${existingStartNodeQuery}",
"endNode" : "${existingEndNodeQuery}",
"startField-precision": "${existingStartPrecisionQuery}",
"endField-precision" : "${existingEndPrecisionQuery}"
},
"fields" : {
"title" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${titleAssertion}" ]
},
"personUri" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "${personClassUri}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${personUriAssertion}" ]
},
"positionType" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "CHILD_VCLASSES_WITH_PARENT",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${positionClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${positionTypeAssertion}" ]
},
"startField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForStart}"]
},
"endField" : {
"newResource" : "false",
"validators" : [],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForEnd}"]
}
}
}
</c:set>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<%
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration(
(String) request
.getAttribute("editjson"));
EditConfiguration.putConfigInSession(editConfig,session);
//setup date time edit elements
Field startField = editConfig.getField("startField");
startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(),VitroVocabulary.Precision.NONE.uri()));
Field endField = editConfig.getField("endField");
endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(),VitroVocabulary.Precision.NONE.uri()));
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
}
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) {
editConfig.prepareForObjPropUpdate(model);
} else {
editConfig.prepareForNonUpdate(model);
}
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.CUSTOM_FORM.path()
));
request.setAttribute("customCss", customCss);
/* prepare the <title> and text for the submit button */
Individual subject = (Individual) request.getAttribute("subject");
String submitLabel = "";
if (objectUri != null) {
request.setAttribute("title","Edit position history entry for "+ subject.getName());
submitLabel = "Save Changes";
} else {
request.setAttribute("title","Create position history entry for " + subject.getName());
submitLabel = "Create Position History";
}
%>
<jsp:include page="${preForm}"/>
<h1>JSP form, must be removed for the 1.4!</h1>
<h2>${title}</h2>
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<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="Person" id="personUri" />
<v:input id="startField" label="Start Year ${yearHint}" />
<v:input id="endField" label="End Year ${yearHint}" />
<p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p>
</form>
<jsp:include page="${postForm}"/>

View file

@ -1,567 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding an educational attainment to an individual
Classes:
core:EducationalTraining - primary new individual being created
foaf:Person - existing individual
foaf:Organization - new or existing individual
core:AcademicDegree - existing individual
Data properties of EducationalTraining:
core:majorField
core:departmentOrSchool
core:supplementalInformation
Object properties (domain : range)
core:educationalTraining (Person : EducationalTraining) - inverse of core:educationalTrainingOf
core:educationalTrainingOf (EducationalTraining : Person) - inverse of core:educationalTraining
core:degreeEarned (EducationalTraining : AcademicDegree) - inverse of core:degreeOutcomeOf
core:degreeOutcomeOf (AcademicDegree : EducationalTraining) - inverse of core:degreeEarned
core:organizationGrantingDegree (EducationalTraining : Organization) - no inverse
Future version
--------------
Classes:
core:DateTimeValue
core:DateTimeValuePrecision
Object properties:
core:dateTimeValue (EducationalTraining : DateTimeValue)
core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision)
--%>
<%@ 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.dao.VitroVocabulary.Precision"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.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" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%>
<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%>
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%>
<%@ 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.personHasEducationalBackground.jsp");
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
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:trainingAtOrganization 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:trainingAtOrganization stmt. This should be similar to an add but the form should be expanded.
4. Really bad node. multiple core:trainingAtOrganization statements.
*/
EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#trainingAtOrganization");
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#" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
<c:set var="degreeClass" value="${vivoCore}AcademicDegree" />
<%-- Define predicates used in n3 assertions and sparql queries --%>
<c:set var="majorFieldPred" value="${vivoCore}majorField" />
<c:set var="deptPred" value="${vivoCore}departmentOrSchool" />
<c:set var="infoPred" value="${vivoCore}supplementalInformation" />
<c:set var="degreeEarned" value="${vivoCore}degreeEarned" />
<c:set var="degreeOutcomeOf" value="${vivoCore}degreeOutcomeOf" />
<c:set var="trainingAtOrg" value="${vivoCore}trainingAtOrganization" />
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="ToInterval" value="${vivoCore}dateTimeInterval"/>
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
<c:set var="intervalToStart" value="${vivoCore}start"/>
<c:set var="intervalToEnd" value="${vivoCore}end"/>
<%-- Assertions for adding a new educational training entry --%>
<v:jsonset var="orgTypeAssertion">
?org a ?orgType .
</v:jsonset>
<v:jsonset var="orgLabelAssertion">
?org <${label}> ?orgLabel .
</v:jsonset>
<v:jsonset var="degreeAssertion" >
?edTraining <${degreeEarned}> ?degree .
?degree <${degreeOutcomeOf}> ?edTraining .
</v:jsonset>
<v:jsonset var="majorFieldAssertion" >
?edTraining <${majorFieldPred}> ?majorField .
</v:jsonset>
<v:jsonset var="n3ForStart">
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?startField-value .
?startNode <${dateTimePrecision}> ?startField-precision .
</v:jsonset>
<v:jsonset var="n3ForEnd">
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?endField-value .
?endNode <${dateTimePrecision}> ?endField-precision .
</v:jsonset>
<v:jsonset var="deptAssertion" >
?edTraining <${deptPred}> ?dept .
</v:jsonset>
<v:jsonset var="infoAssertion" >
?edTraining <${infoPred}> ?info .
</v:jsonset>
<v:jsonset var="n3ForNewEdTraining">
@prefix core: <${vivoCore}> .
?person core:educationalTraining ?edTraining .
?edTraining a core:EducationalTraining ;
core:educationalTrainingOf ?person ;
<${trainingAtOrg}> ?org .
</v:jsonset>
<%-- This property has no inverse --%>
<v:jsonset var="n3ForEdTrainingToOrg" >
?edTraining <${trainingAtOrg}> ?org .
</v:jsonset>
<%-- Queries for editing an existing educational training entry --%>
<v:jsonset var="orgQuery" >
SELECT ?existingOrg WHERE {
?edTraining <${trainingAtOrg}> ?existingOrg . }
</v:jsonset>
<v:jsonset var="orgLabelQuery" >
SELECT ?existingOrgLabel WHERE {
?edTraining <${trainingAtOrg}> ?existingOrg .
?existingOrg <${label}> ?existingOrgLabel .
}
</v:jsonset>
<%-- Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another
type is returned and we don't get a match to the select element options. --%>
<v:jsonset var="orgTypeQuery" >
PREFIX rdfs: <${rdfs}>
SELECT ?existingOrgType WHERE {
?edTraining <${trainingAtOrg}> ?existingOrg .
?existingOrg a ?existingOrgType .
?existingOrgType rdfs:subClassOf <${orgClass}> .
}
</v:jsonset>
<v:jsonset var="degreeQuery" >
SELECT ?existingDegree WHERE {
?edTraining <${degreeEarned}> ?existingDegree . }
</v:jsonset>
<v:jsonset var="majorFieldQuery" >
SELECT ?existingMajorField WHERE {
?edTraining <${majorFieldPred}> ?existingMajorField . }
</v:jsonset>
<v:jsonset var="deptQuery" >
SELECT ?existingDept WHERE {
?edTraining <${deptPred}> ?existingDept . }
</v:jsonset>
<v:jsonset var="infoQuery" >
SELECT ?existingInfo WHERE {
?edTraining <${infoPred}> ?existingInfo . }
</v:jsonset>
<v:jsonset var="existingIntervalNodeQuery" >
SELECT ?existingIntervalNode WHERE {
?edTraining <${ToInterval}> ?existingIntervalNode .
?existingIntervalNode <${type}> <${intervalType}> . }
</v:jsonset>
<v:jsonset var="existingStartNodeQuery" >
SELECT ?existingStartNode WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?existingStartNode .
?existingStartNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingStartDateQuery" >
SELECT ?existingDateStart WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?existingDateStart . }
</v:jsonset>
<v:jsonset var="existingStartPrecisionQuery" >
SELECT ?existingStartPrecision WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
</v:jsonset>
<v:jsonset var="existingEndNodeQuery" >
SELECT ?existingEndNode WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?existingEndNode .
?existingEndNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingEndDateQuery" >
SELECT ?existingEndDate WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?existingEndDate . }
</v:jsonset>
<v:jsonset var="existingEndPrecisionQuery" >
SELECT ?existingEndPrecision WHERE {
?edTraining <${ToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
</v:jsonset>
<v:jsonset var="orgClassUriJson">${orgClass}</v:jsonset>
<v:jsonset var="degreeClassUriJson">${degreeClass}</v:jsonset>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/entity",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["edTraining", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewEdTraining}", "${orgLabelAssertion}", "${orgTypeAssertion}" ],
"n3optional" : [ "${n3ForEdTrainingToOrg}", "${majorFieldAssertion}",
"${degreeAssertion}", "${deptAssertion}", "${infoAssertion}" , "${n3ForStart}", "${n3ForEnd}"],
"newResources" : { "edTraining" : "${defaultNamespace}",
"org" : "${defaultNamespace}" ,
"intervalNode" : "${defaultNamespace}",
"startNode" : "${defaultNamespace}",
"endNode" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "org", "orgType", "degree" ],
"literalsOnForm" : [ "orgLabel", "majorField", "dept", "info" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"orgLabel" : "${orgLabelQuery}",
"majorField" : "${majorFieldQuery}",
"dept" : "${deptQuery}",
"info" : "${infoQuery}",
"startField-value" : "${existingStartDateQuery}",
"endField-value" : "${existingEndDateQuery}"
},
"sparqlForExistingUris" : {
"org" : "${orgQuery}",
"orgType" : "${orgTypeQuery}",
"degree" : "${degreeQuery}",
"intervalNode" : "${existingIntervalNodeQuery}",
"startNode" : "${existingStartNodeQuery}",
"endNode" : "${existingEndNodeQuery}",
"startField-precision": "${existingStartPrecisionQuery}",
"endField-precision" : "${existingEndPrecisionQuery}"
},
"fields" : {
"degree" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${degreeClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${degreeAssertion}" ]
},
"majorField" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${majorFieldAssertion}" ]
},
"startField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForStart}" ]
},
"endField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForEnd}" ]
},
"org" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${orgClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForEdTrainingToOrg}" ]
},
"orgLabel" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${orgLabelAssertion}" ]
},
"orgType" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "CHILD_VCLASSES",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${orgClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${orgTypeAssertion}" ]
},
"dept" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${deptAssertion}"]
},
"info" : {
"newResource" : "false",
"validators" : [ "datatype:${stringDatatypeUriJson}" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : ["${infoAssertion}"]
}
}
}
</c:set>
<%
log.debug(request.getAttribute("editjson"));
EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request);
if (editConfig == null) {
editConfig = new EditConfiguration((String) request.getAttribute("editjson"));
//setup date time edit elements
Field startField = editConfig.getField("startField");
// arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel])
startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri()));
Field endField = editConfig.getField("endField");
endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri()));
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
EditConfiguration.putConfigInSession(editConfig,session);
}
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) { // editing existing
editConfig.prepareForObjPropUpdate(model);
} else { // adding new
editConfig.prepareForNonUpdate(model);
}
editConfig.setTemplate("personHasEducationalTraining.ftl");
editConfig.setSubmitToUrl("/edit/processRdfForm2.jsp");
String subjectName = ((Individual) request.getAttribute("subject")).getName();
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/edit/forms/js/customFormWithAutocomplete.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/customFormWithAutocomplete.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="subjectName" value="<%= subjectName %>" />
<%-- Configure add vs. edit --%>
<c:choose>
<c:when test='${editMode == "add"}'>
<c:set var="titleVerb" value="Create" />
<c:set var="submitButtonText" value="Education and Training" />
<c:set var="disabledVal" value="" />
</c:when>
<c:otherwise>
<c:set var="titleVerb" value="Edit" />
<c:set var="submitButtonText" value="Edit Education and Training" />
<c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set>
</c:otherwise>
</c:choose>
<%--
This goes to an experimental FM based form:
<jsp:forward page="/N3EditForm"/>
--%>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<% 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} education and training entry for ${subjectName}</h2>
<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" >
<v:input type="select" label="Degree" id="degree" />
<v:input type="text" label="Major Field of Degree" id="majorField" size="30" />
<v:input id="startField" label="Start Year <span class='hint'>(YYYY)</span>" />
<v:input id="endField" label="End Year <span class='hint'>(YYYY)</span>" />
<p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p>
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
returning from a validation error, we retain the values. --%>
<c:if test="${editMode == 'edit'}">
<v:input type="hidden" id="orgType" />
<v:input type="hidden" id="orgLabel" />
</c:if>
<div class="acSelection">
<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>
<v:input type="text" label="Department or School Name within the ###" id="dept" size="50" />
<v:input type="text" label="Supplemental Information" id="info" size="50" />
<p>e.g., <em>Postdoctoral training</em> or <em>Transferred</em></p>
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<c:url var="acUrl" value="/autocomplete?tokenize=true" />
<script type="text/javascript">
var customFormData = {
acUrl: '${acUrl}',
editMode: '${editMode}',
submitButtonTextType: 'compound',
defaultTypeName: 'organization'
};
</script>
<% } %>
<jsp:include page="${postForm}"/>

View file

@ -1,481 +0,0 @@
<%-- $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.configuration.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="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %>
<%@ 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.configuration.Field"%>
<%@ 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" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%>
<%@ 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", ""); //empty string triggers default new URI behavior
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#" />
<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="positionClass" value="${vivoCore}Position" />
<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" />
<%-- Define predicates used in n3 assertions and sparql queries --%>
<c:set var="positionInOrgPred" value="${vivoCore}positionInOrganization" />
<c:set var="orgForPositionPred" value="${vivoCore}organizationForPosition" />
<c:set var="dateTimeValue" value="${vivoCore}dateTime"/>
<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/>
<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/>
<c:set var="edToDateTime" value="${vivoCore}dateTimeInterval"/>
<c:set var="positionToInterval" value="${vivoCore}dateTimeInterval"/>
<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/>
<c:set var="intervalToStart" value="${vivoCore}start"/>
<c:set var="intervalToEnd" value="${vivoCore}end"/>
<%-- Assertions for adding a new role --%>
<v:jsonset var="orgTypeAssertion">
?org a ?orgType .
</v:jsonset>
<v:jsonset var="orgLabelAssertion">
?org <${label}> ?orgLabel .
</v:jsonset>
<v:jsonset var="positionTitleAssertion" >
?position <${label}> ?positionTitle .
</v:jsonset>
<v:jsonset var="positionTypeAssertion">
?position a ?positionType .
</v:jsonset>
<v:jsonset var="n3ForNewPosition">
@prefix core: <${vivoCore}> .
?person core:personInPosition ?position .
?position a ?positionType ;
core:positionForPerson ?person ;
<${positionInOrgPred}> ?org .
?org <${orgForPositionPred}> ?position .
</v:jsonset>
<v:jsonset var="n3ForPositionToOrg" >
?position <${positionInOrgPred}> ?org .
?org <${orgForPositionPred}> ?position .
</v:jsonset>
<v:jsonset var="n3ForStart">
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?startField-value .
?startNode <${dateTimePrecision}> ?startField-precision .
</v:jsonset>
<v:jsonset var="n3ForEnd">
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?endField-value .
?endNode <${dateTimePrecision}> ?endField-precision .
</v:jsonset>
<%-- 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>
<%-- Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another
type is returned and we don't get a match to the select element options. --%>
<v:jsonset var="orgTypeQuery" >
PREFIX rdfs: <${rdfs}>
SELECT ?existingOrgType WHERE {
?position <${positionInOrgPred}> ?existingOrg .
?existingOrg a ?existingOrgType .
?existingOrgType rdfs:subClassOf <${orgClass}> .
}
</v:jsonset>
<v:jsonset var="positionTitleQuery" >
SELECT ?existingPositionTitle WHERE {
?position <${label}> ?existingPositionTitle . }
</v:jsonset>
<v:jsonset var="positionTypeQuery">
SELECT ?existingPositionType WHERE {
?position a ?existingPositionType . }
</v:jsonset>
<v:jsonset var="existingIntervalNodeQuery" >
SELECT ?existingIntervalNode WHERE {
?position <${positionToInterval}> ?existingIntervalNode .
?existingIntervalNode <${type}> <${intervalType}> . }
</v:jsonset>
<v:jsonset var="existingStartNodeQuery" >
SELECT ?existingStartNode WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?existingStartNode .
?existingStartNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingStartDateQuery" >
SELECT ?existingDateStart WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimeValue}> ?existingDateStart . }
</v:jsonset>
<v:jsonset var="existingStartPrecisionQuery" >
SELECT ?existingStartPrecision WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToStart}> ?startNode .
?startNode <${type}> <${dateTimeValueType}> .
?startNode <${dateTimePrecision}> ?existingStartPrecision . }
</v:jsonset>
<v:jsonset var="existingEndNodeQuery" >
SELECT ?existingEndNode WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?existingEndNode .
?existingEndNode <${type}> <${dateTimeValueType}> .}
</v:jsonset>
<v:jsonset var="existingEndDateQuery" >
SELECT ?existingEndDate WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimeValue}> ?existingEndDate . }
</v:jsonset>
<v:jsonset var="existingEndPrecisionQuery" >
SELECT ?existingEndPrecision WHERE {
?position <${positionToInterval}> ?intervalNode .
?intervalNode <${type}> <${intervalType}> .
?intervalNode <${intervalToEnd}> ?endNode .
?endNode <${type}> <${dateTimeValueType}> .
?endNode <${dateTimePrecision}> ?existingEndPrecision . }
</v:jsonset>
<v:jsonset var="positionClassUriJson">${positionClass}</v:jsonset>
<v:jsonset var="orgClassUriJson">${orgClass}</v:jsonset>
<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" />
<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" />
<%-- Configure add vs. edit --%>
<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" ? "" : "disabled" }</c:set>
</c:otherwise>
</c:choose>
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "/entity",
"subject" : ["person", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["position", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForNewPosition}", "${positionTitleAssertion}", "${positionTypeAssertion}",
"${orgLabelAssertion}", "${orgTypeAssertion}" ],
"n3optional" : [ "${n3ForStart}", "${n3ForEnd}" ],
"newResources" : { "position" : "${defaultNamespace}",
"org" : "${defaultNamespace}",
"intervalNode" : "${defaultNamespace}",
"startNode" : "${defaultNamespace}",
"endNode" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "org", "orgType", "positionType" ],
"literalsOnForm" : [ "positionTitle", "orgLabel" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : {
"orgLabel" : "${orgLabelQuery}",
"positionTitle" : "${positionTitleQuery}",
"startField-value" : "${existingStartDateQuery}",
"endField-value" : "${existingEndDateQuery}"
},
"sparqlForExistingUris" : {
"org" : "${orgQuery}",
"orgType" : "${orgTypeQuery}",
"positionType" : "${positionTypeQuery}" ,
"intervalNode" : "${existingIntervalNodeQuery}",
"startNode" : "${existingStartNodeQuery}",
"endNode" : "${existingEndNodeQuery}",
"startField-precision": "${existingStartPrecisionQuery}",
"endField-precision" : "${existingEndPrecisionQuery}"
},
"fields" : {
"positionTitle" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${positionTitleAssertion}" ]
},
"positionType" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "CHILD_VCLASSES_WITH_PARENT",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${positionClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${positionTypeAssertion}" ]
},
"org" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "INDIVIDUALS_VIA_VCLASS",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${orgClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForPositionToOrg}" ]
},
"orgLabel" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${orgLabelAssertion}" ]
},
"orgType" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "CHILD_VCLASSES",
"literalOptions" : [ "Select one" ],
"predicateUri" : "",
"objectClassUri" : "${orgClassUriJson}",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${orgTypeAssertion}" ]
},
"startField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForStart}"]
},
"endField" : {
"newResource" : "false",
"validators" : [ ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : ["${n3ForEnd}"]
}
}
}
</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);
//setup date time edit elements
Field startField = editConfig.getField("startField");
// arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel])
startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri()));
Field endField = editConfig.getField("endField");
endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri()));
editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") );
}
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
if (objectUri != null) { // editing existing
editConfig.prepareForObjPropUpdate(model);
} else { // adding new
editConfig.prepareForNonUpdate(model);
}
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/edit/forms/js/customFormWithAutocomplete.js"
));
request.setAttribute("customJs", customJs);
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/customFormWithAutocomplete.css"
));
request.setAttribute("customCss", customCss);
String subjectName = ((Individual) request.getAttribute("subject")).getName();
%>
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<% 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}&nbsp;position entry for <%= subjectName %></h2>
<form class="customForm" 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> needed to create wrapper for show/hide --%>
<p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p>
<%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when
returning from a validation error, we retain the values. --%>
<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>
<v:input type="text" label="Position Title ${requiredHint}" id="positionTitle" size="30" />
<v:input type="select" label="Position Type ${requiredHint}" id="positionType" />
<v:input id="startField" label="Start Year <span class='hint'>(YYYY)</span>" />
<v:input id="endField" label="End Year <span class='hint'>(YYYY)</span>" />
</div>
<p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p>
<p id="requiredLegend" class="requiredHint">* required fields</p>
</form>
<c:url var="acUrl" value="/autocomplete?tokenize=true" />
<script type="text/javascript">
var customFormData = {
acUrl: '${acUrl}',
editMode: '${editMode}',
submitButtonTextType: 'compound',
defaultTypeName: 'organization' // used in repair mode, to generate button text and org name field label
};
</script>
<% } %>
<jsp:include page="${postForm}"/>

View file

@ -1,300 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%-- Custom form for adding terminology annotation
--%>
<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Arrays" %>
<%@ page import="java.util.Collections" %>
<%@ page import="com.hp.hpl.jena.rdf.model.Model" %>
<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %>
<%@ page import="com.hp.hpl.jena.vocabulary.RDFS" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %>
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.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="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.lang.StringUtils" %>
<%@ page import="org.json.JSONObject" %>
<%@ 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.terminologyAnnotation.jsp");
%>
<%
VitroRequest vreq = new VitroRequest(request);
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior
vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString()));
%>
<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" />
<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" />
<c:set var="label" value="${rdfs}label" />
<c:set var="foaf" value="http://xmlns.com/foaf/0.1/" />
<c:set var="personClassUri" value="${foaf}Person" />
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
SPARQL queries for existing values. --%>
<v:jsonset var="n3ForTerminology">
@prefix core: <${vivoCore}> .
?subject ?predicate ?terminologyContextNode .
?terminologyContextNode core:referencedTerm ?referencedTerm .
?terminologyContextNode core:entryTerm ?entryTerm .
?terminologyContextNode core:termLabel ?termLabel .
?terminologyContextNode core:termType ?termType .
</v:jsonset>
<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" />
<c:url var="submitSearchUrl" value="/UMLSTermsRetrieval"/>
<c:url var="UMLSCUIURL" value="http://link.informatics.stonybrook.edu/umls/CUI/" />
<c:set var="editjson" scope="request">
{
"formUrl" : "${formUrl}",
"editKey" : "${editKey}",
"urlPatternToReturnTo" : "${returnPathAfterSubmit}",
"subject" : ["subject", "${subjectUriJson}" ],
"predicate" : ["predicate", "${predicateUriJson}" ],
"object" : ["terminologyContextNode", "${objectUriJson}", "URI" ],
"n3required" : [ "${n3ForTerminology}" ],
"n3optional" : [ ],
"newResources" : { "terminologyContextNode" : "${defaultNamespace}" },
"urisInScope" : { },
"literalsInScope": { },
"urisOnForm" : [ "referencedTerm" ],
"literalsOnForm" : [ "entryTerm", "termLabel", "termType" ],
"filesOnForm" : [ ],
"sparqlForLiterals" : { },
"sparqlForUris" : { },
"sparqlForExistingLiterals" : { },
"sparqlForExistingUris" : { },
"fields" : {
"referencedTerm" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED", //UNSURE WHAT TO KEEP HERE
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "",
"rangeLang" : "",
"assertions" : [ "${n3ForTerminology}" ]
},
"entryTerm" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${n3ForTerminology}" ]
},
"termLabel" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${n3ForTerminology}" ]
}
,"termType" : {
"newResource" : "false",
"validators" : [ "nonempty" ],
"optionsType" : "UNDEFINED",
"literalOptions" : [ ],
"predicateUri" : "",
"objectClassUri" : "",
"rangeDatatypeUri" : "${stringDatatypeUriJson}",
"rangeLang" : "",
"assertions" : [ "${n3ForTerminology}" ]
}
}
}
</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);
}
//Specific validators can be included here
Model model = (Model) application.getAttribute("jenaOntModel");
String objectUri = (String) request.getAttribute("objectUri");
//for some reason we are comming from the add new and that is working
//but we also come from the edit, and that is not working.
editConfig.setObject(""); //this will force the edit config to always be an add, never an update
editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing
String subjectUri = vreq.getParameter("subjectUri");
String predicateUri = vreq.getParameter("predicateUri");
String vivoCore = "http://vivoweb.org/ontology/core#";
//Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri);
Individual subject = ((Individual) request.getAttribute("subject"));
vreq.setAttribute("subjectName", subject.getName());
//Get existing terminology annotations
List<Individual> terminologyAnnotationNodes = subject.getRelatedIndividuals(predicateUri);
List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(),
JavaScript.CUSTOM_FORM_UTILS.path(),
"/js/browserUtils.js",
"/edit/forms/js/addTerminology.js"
));
request.setAttribute("customJs", customJs);
//no custom css we know of yet
List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/addTerminology.css"
));
request.setAttribute("customCss", customCss);
%>
<c:set var="title" value="<em>${subjectName}</em>"/>
<jsp:include page="${preForm}" />
<h1>JSP form, must be removed for the 1.4!</h1>
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
<h2>${title}</h2>
<%@ include file="unsupportedBrowserMessage.jsp" %>
<div class="noIE67">
<h3>Manage Terminology Annotations</h3>
<ul id="existingTerms" >
<%
int existingTermsCount = terminologyAnnotationNodes.size();
%>
<script type="text/javascript">
var existingTermsData = [];
</script>
<%
String termLabelUri = vivoCore + "termLabel";
String termTypeUri = vivoCore + "termType";
for ( Individual termNode : terminologyAnnotationNodes ) {
request.setAttribute("termNodeUri", termNode.getURI());
//Get label and type only as mirroring authorship where labels but no links for individuals incoldued
DataPropertyStatement termLabelStatement = termNode.getDataPropertyStatement(RDFS.label.getURI());
String termLabel = termLabelStatement.getData();
//request.setAttribute("termLabel", termLabel);
//DataPropertyStatement termTypeStatement = termNode.getDataPropertyStatement(termTypeUri);
//String termType = termTypeStatement.getData();
request.setAttribute("termType", "fake");
%>
<li class="existingTerm">
<%-- span.author will be used in the next phase, when we display a message that the author has been
removed. That text will replace the a.authorName, which will be removed. --%>
<span class="term">
<%-- This span is here to assign a width to. We can't assign directly to the a.authorName,
for the case when it's followed by an em tag - we want the width to apply to the whole thing. --%>
<span class="termWrapper">
<span class="termLabel">
${termLabel} (${termType})</span>
</span>
<c:url var="deleteTermHref" value="/edit/primitiveDelete" />
<a href="${deleteTermHref}" class="remove">Remove</a>
</span>
</li>
<script type="text/javascript">
existingTermsData.push({
"termNodeUri": "${termNodeUri}",
"termLabel": "${termLabel}"
});
</script>
<%
}
%>
</ul>
<% if (existingTermsCount == 0) { %>
<p>There are currently no terms specified.</p>
<% } %>
<div id="showAddForm">
<v:input type="submit" value="Add Term" id="showAddFormButton" name="showAddFormButton" cancel="true" cancelLabel="Return" cancelUrl="/individual" />
</div>
<form id="addTerminologyForm" class="customForm" action="<c:url value="/edit/processTerminologyAnnotation"/>" >
<p class="inline"><v:input type="text" id="searchTerm" label="Search UMLS Terms" cssClass="acSelector" size="35" />
<input type="button" id="searchButton" name="searchButton" value="Search"/>
</p>
<input type="hidden" id="entryTerm" name="entryTerm" value="" /> <!-- Field value populated by JavaScript -->
<input type="hidden" id="referencedTerm" name="referencedTerm" value=""/> <!-- Field value populated by JavaScript -->
<input type="hidden" id="termLabel" name="termLabel" value="" /> <!-- Field value populated by JavaScript -->
<input type="hidden" id="termType" name="termType" value="" /> <!-- Field value populated by JavaScript -->
<div id="selectedTerm" name="selectedTerm" class="acSelection">
<%-- RY maybe make this a label and input field. See what looks best. --%>
<p class="inline">
</p>
<!-- Field value populated by JavaScript -->
</div>
<div id="errors" name="errors"></div>
<p class="submit"><v:input type="submit" id="submit" name="submit" value="Add Term" cancel="true" /></p>
</form>
</div>
<script type="text/javascript">
var customFormData = {
dataServiceUrl: '${submitSearchUrl}',
UMLSCUIURL: '${UMLSCUIURL}'
};
</script>
<jsp:include page="${postForm}"/>

View file

@ -1,16 +0,0 @@
<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
<c:set var="portal" value="${requestScope.portalBean}"/>
<c:set var="contextPath"><c:out value="${pageContext.request.contextPath}" /></c:set>
<c:set var="themeDir" value="${contextPath}/${portal.themeDir}"/>
<div id="ie67DisableWrapper">
<h1>JSP form, must be removed for the 1.4!</h1>
<div id="ie67DisableContent">
<img src="${themeDir}site_icons/iconAlertBig.png" alt="Alert Icon"/>
<p>This form is not supported in versions of Internet Explorer below version 8. Please upgrade your browser, or
switch to another browser, such as FireFox.</p>
</div>
</div>

View file

@ -130,13 +130,13 @@
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/addConcept.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/addConcept.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/addConcept.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/addConcept.js"></script>')}

View file

@ -155,12 +155,12 @@ var customFormData = {
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />',
'<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />',
'<link rel="stylesheet" href="${urls.base}/edit/forms/css/autocomplete.css" />',
'<link rel="stylesheet" href="${urls.base}/edit/forms/css/addAuthorsToInformationResource.css" />')}
'<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />',
'<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/autocomplete.css" />',
'<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/addAuthorsToInformationResource.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/addAuthorsToInformationResource.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js"></script>')}

View file

@ -65,7 +65,7 @@
</p>
</form>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/userMenu/userMenuUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}

View file

@ -146,11 +146,11 @@ var customFormData = {
};
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}
</#if>

View file

@ -110,11 +110,11 @@
</#if>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -195,12 +195,12 @@
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}
</section>

View file

@ -57,11 +57,11 @@
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -124,11 +124,11 @@ Also multiple types parameter set to true only if more than one type returned-->
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -0,0 +1,33 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
.concepts .column {
float:left;
padding-right:3px;
}
.concepts .row {
clear:both;
float:left;
border-bottom: 1px solid #5F6464;
}
.conceptLabel {
width:220px;
}
.conceptType {
width: 40px;
}
.conceptDefinition{
width:400px;
}
form#addConceptForm {
display:none;
}
form#addConceptForm span#createOwnOne{
float:left;
margin-top:24px
}

View file

@ -0,0 +1,24 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
/* Styles for autocomplete and autocomplete selections using jQuery UI. This is separated out so that forms
that don't load customFormWithAutocomplete.css still have access to these styles. */
.acSelection {
display: none;
margin-top: 2em;
}
.acSelectionInfo {
background-color: #d9d9d9;
padding: .2em .35em;
}
ul.ui-autocomplete {
font-size: .95em;
}
li.ui-menu-item a.ui-corner-all {
text-align: left;
padding-left: .25em;
}
.acSelectorWithHelpText{
font-style: italic;
color: #555;
}

View file

@ -0,0 +1,124 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
form.customForm div {
clear: left;
}
form.customForm h6 {
font-size: 110%;
}
form.customForm div.addNewLink {
float: left;
clear: none;
margin-left: 5em;
margin-top: .9em;
width: 200px;
padding: .8em;
border: 1px solid #9c9c9c;
display: none; /* Hide if Javascript disabled. Javascript will show. */
}
form.customForm .existing span.requiredHint,
form.customForm .new span.requiredHint {
display: none; /* Hide if Javascript disabled. Javascript will show. */
}
form.customForm .existing {
float: left;
clear: none;
}
.existingOrNew {
font-style: italic;
margin-left: 1em;
}
.new {
padding: .6em 0 .6em 1.5em;
border: 1px solid #9c9c9c;
width: 300px;
}
form.customForm p.inline input,
form.customForm p.inline label {
float: left;
clear: left;
}
form.customForm p.inline.year input {
margin-top: -1.75em;
}
input,
select,
form.customForm p {
margin-top: 0;
padding-top: 0;
margin-bottom: 0;
padding-bottom: 0;
}
option {
padding: 0 2px;
}
form.customForm .hint {
color: #9c9c9c;
font-weight: normal;
}
form.customForm .requiredHint {
color: #c00;
font-weight: normal;
font-size: small;
}
form.customForm #requiredLegend {
font-style: italic;
margin-top: .5em;
}
form.customForm p.validationError {
clear: both;
margin-bottom: 1.8em;
margin-top: 0;
padding-top: 0;
padding-left: .4em;
font-size: .8em;
}
form.customForm a.close {
float: right;
margin-right: 1em;
font-size: 90%;
}
form.customForm a.close:link,
form.customForm a.close:visited {
border-color: #ff7700;
color: #ff7700;
}
form.customForm textarea {
width: 30%;
}
div.acSelection {
margin-bottom: 15px;
}
#ie67DisableWrapper {
display: none;
}
form.customForm input.concept-search {
float: right;
margin-right: 1em;
margin-bottom: 1em;
background-color: #317e95;
}
form.customForm h4.services {
margin-bottom: -5px;
margin-top: -12px;
}
form.customForm p.inline-search {
float: left;
clear: left;
}
form.customForm p.inline-search #searchTerm{
margin-top: 6px;
}
/* <------ DATE TIME*/
form.customForm label.dateTime {
display: inline;
}
form.customForm fieldset {
display: inline;
}
fieldset.dateTime label {
display: inline;
}
fieldset.dateTime select {
margin-top: 0;
}

View file

@ -0,0 +1,33 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
@import url("autocomplete.css");
/* Although Javascript hides these on page load, hide here as well to avoid the flash on page load.
This needs to be removed to support a non-JS version of the form. */
.fullViewOnly,
#submit,
.or,
#requiredLegend {
display: none;
}
form.customForm p.inline label {
display: inline;
clear: none;
float: none;
margin-right: 1em;
}
.verifyMatch {
margin-left: .5em;
}
form.customForm h4 {
margin-top: 1em;
margin-bottom: .75em;
}
.acSelector[disabled="disabled"]{
border-width: 0;
background: none;
color: #000;
}
.disabledSubmit {
cursor: default ! important;
}

View file

@ -0,0 +1,20 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
#localClassName {
margin-bottom: 0;
}
#createNewLocalClass p.note {
margin-top: 3px;
margin-bottom: 15px;
}
#noLocalOntologyExists {
padding: 1em;
background: #f4f4f4;
display: inline-block;
}
#noLocalOntologyExists blockquote {
margin: .4em 0 .4em 1em;
padding: .5em;
background: #ffc;
display: inline-block;
}

View file

@ -85,5 +85,5 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu
</form>
</section>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/institutionalInternalClass.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/institutionalInternalClass.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}

View file

@ -0,0 +1,534 @@
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
var customForm = {
/* *** Initial page setup *** */
onLoad: function() {
if (this.disableFormInUnsupportedBrowsers()) {
return;
}
this.mixIn();
this.initObjects();
this.initPage();
},
disableFormInUnsupportedBrowsers: function() {
var disableWrapper = $('#ie67DisableWrapper');
// Check for unsupported browsers only if the element exists on the page
if (disableWrapper.length) {
if (vitro.browserUtils.isIELessThan8()) {
disableWrapper.show();
$('.noIE67').hide();
return true;
}
}
return false;
},
mixIn: function() {
// Mix in the custom form utility methods
$.extend(this, vitro.customFormUtils);
// Get the custom form data from the page
$.extend(this, customFormData);
},
// On page load, create references for easy access to form elements.
// NB These must be assigned after the elements have been loaded onto the page.
initObjects: function(){
this.form = $('form.customForm');
this.fullViewOnly = $('.fullViewOnly');
this.button = $('#submit');
this.requiredLegend = $('#requiredLegend');
this.typeSelector = this.form.find('#typeSelector');
// These are classed rather than id'd in case we want more than one autocomplete on a form.
// At that point we'll use ids to match them up with one another.
this.acSelector = this.form.find('.acSelector');
this.acSelection = this.form.find('.acSelection');
this.acSelectionInfo = this.form.find('.acSelectionInfo');
this.acUriReceiver = this.form.find('.acUriReceiver');
//this.acLabelReceiver = this.form.find('.acLabelReceiver');
this.verifyMatch = this.form.find('.verifyMatch');
this.acSelectorWrapper = this.acSelector.parent();
this.or = $('span.or');
this.cancel = this.form.find('.cancel');
this.acHelpTextClass = 'acSelectorWithHelpText';
},
// Set up the form on page load
initPage: function() {
if (!this.editMode) {
this.editMode = 'add'; // edit vs add: default to add
}
if (!this.formSteps) { // Don't override formSteps specified in form data
if ( !this.fullViewOnly.length || this.editMode === 'edit' || this.editMode === 'repair' ) {
this.formSteps = 1;
// there may also be a 3-step form - look for this.subTypeSelector
}
else {
this.formSteps = 2;
}
}
//Handles special case such as autocomplete which allows for editing with autocomplete
//By default set to false
if(!this.supportEdit) {
this.supportEdit = false;
} else {
this.supportEdit = true;
}
this.bindEventListeners();
this.initAutocomplete();
this.initElementData();
this.initFormView();
},
initFormView: function() {
var typeVal = this.typeSelector.val();
// Put this case first, because in edit mode with
// validation errors we just want initFormFullView.
if ((!this.supportEdit) && (this.editMode == 'edit' || this.editMode == 'repair')) {
this.initFormFullView();
}
else if (this.findValidationErrors()) {
this.initFormWithValidationErrors();
} else if(this.supportEdit) {
this.initFormWithSupportEdit();
}
// If type is already selected when the page loads (Firefox retains value
// on a refresh), go directly to full view. Otherwise user has to reselect
// twice to get to full view.
else if ( this.formSteps == 1 || typeVal.length ) {
this.initFormFullView();
}
else {
this.initFormTypeView();
}
},
initFormTypeView: function() {
this.setType(); // empty any previous values (perhaps not needed)
this.hideFields(this.fullViewOnly);
this.button.hide();
this.requiredLegend.hide();
this.or.hide();
this.cancel.unbind('click');
},
initFormFullView: function() {
this.setType();
this.fullViewOnly.show();
this.or.show();
this.requiredLegend.show();
this.button.show();
this.setButtonText('new');
this.setLabels();
// Set the initial autocomplete help text in the acSelector field.
this.addAcHelpText();
this.cancel.unbind('click');
if (this.formSteps > 1) {
this.cancel.click(function() {
customForm.clearFormData(); // clear any input and validation errors
customForm.initFormTypeView();
return false;
});
// In one-step forms, if there is a type selection field, but no value is selected,
// hide the acSelector field. The type selection must be made first so that the
// autocomplete type can be determined. If a type selection has been made,
// unhide the acSelector field.
} else if (this.typeSelector.length) {
this.typeSelector.val() ? this.acSelectorWrapper.show() : this.hideFields(this.acSelectorWrapper);
}
},
initFormWithValidationErrors: function() {
var uri = this.acUriReceiver.val(),
label = this.acSelector.val();
// Call initFormFullView first, because showAutocompleteSelection needs
// acType, which is set in initFormFullView.
this.initFormFullView();
if (uri) {
this.showAutocompleteSelection(label, uri);
}
},
initFormWithSupportEdit: function() {
if(this.editMode == 'edit') {
this.initFormWithValidationErrors();
//Hide verify match when edit mode
this.verifyMatch.hide();
} else {
this.initFormFullView();
}
//Disable submit button until selection made
this.button.attr('disabled', 'disabled');
this.button.addClass('disabledSubmit'); // tlw
},
// Bind event listeners that persist over the life of the page. Event listeners
// that depend on the view should be initialized in the view setup method.
bindEventListeners: function() {
this.typeSelector.change(function() {
var typeVal = $(this).val();
// If an autocomplete selection has been made, undo it.
customForm.undoAutocompleteSelection();
// Reinitialize view. If no type selection in a two-step form, go back to type view;
// otherwise, reinitialize full view.
if (!typeVal.length && customForm.formSteps > 1) {
customForm.initFormTypeView();
}
else {
customForm.initFormFullView();
// TW Setting focus here was clearing autocomplete help text, so commented it out
// customForm.acSelector.focus();
}
});
this.verifyMatch.click(function() {
window.open($(this).attr('href'), 'verifyMatchWindow', 'width=640,height=640,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=no');
return false;
});
this.acSelector.focus(function() {
customForm.deleteAcHelpText();
});
this.acSelector.blur(function() {
customForm.addAcHelpText();
});
this.form.submit(function() {
customForm.deleteAcHelpText();
});
},
initAutocomplete: function() {
if (this.editMode === 'edit' && !this.supportEdit) {
return;
}
this.getAcFilter();
this.acCache = {};
this.acSelector.autocomplete({
minLength: 3,
source: function(request, response) {
if (request.term in customForm.acCache) {
// console.log('found term in cache');
response(customForm.acCache[request.term]);
return;
}
// console.log('not getting term from cache');
$.ajax({
url: customForm.acUrl,
dataType: 'json',
data: {
term: request.term,
type: customForm.acType,
multipleTypes:(customForm.acMultipleTypes == undefined || customForm.acMultipleTypes == null)? null: customForm.acMultipleTypes
},
complete: function(xhr, status) {
// Not sure why, but we need an explicit json parse here.
var results = $.parseJSON(xhr.responseText),
filteredResults = customForm.filterAcResults(results);
customForm.acCache[request.term] = filteredResults;
response(filteredResults);
}
});
},
select: function(event, ui) {
customForm.showAutocompleteSelection(ui.item.label, ui.item.uri);
}
});
},
// Store original or base text with elements that will have text substitutions.
// Generally the substitution cannot be made on the current value, since that value
// may have changed from the original. So we store the original text with the element to
// use as a base for substitutions.
initElementData: function() {
this.placeholderText = '###';
this.labelsWithPlaceholders = this.form.find('label, .label').filter(function() {
return $(this).html().match(customForm.placeholderText);
});
this.labelsWithPlaceholders.each(function(){
$(this).data('baseText', $(this).html());
});
this.button.data('baseText', this.button.val());
this.verifyMatch.data('baseHref', this.verifyMatch.attr('href'));
},
getAcFilter: function() {
if (!this.sparqlForAcFilter) {
//console.log('autocomplete filtering turned off');
this.acFilter = null;
return;
}
//console.log("sparql for autocomplete filter: " + this.sparqlForAcFilter);
// Define this.acFilter here, so in case the sparql query fails
// we don't get an error when referencing it later.
this.acFilter = [];
$.ajax({
url: customForm.sparqlQueryUrl,
dataType: "json",
data: {
query: customForm.sparqlForAcFilter
},
success: function(data, status, xhr) {
customForm.setAcFilter(data);
}
});
},
setAcFilter: function(data) {
var key = data.head.vars[0];
$.each(data.results.bindings, function() {
customForm.acFilter.push(this[key].value);
});
},
filterAcResults: function(results) {
var filteredResults;
if (!this.acFilter || !this.acFilter.length) {
//console.log('no autocomplete filtering applied');
return results;
}
filteredResults = [];
$.each(results, function() {
if ($.inArray(this.uri, customForm.acFilter) == -1) {
//console.log('adding ' + this.label + ' to filtered results');
filteredResults.push(this);
}
else {
//console.log('filtering out ' + this.label);
}
});
return filteredResults;
},
// Reset some autocomplete values after type is changed
resetAutocomplete: function(typeVal) {
// Append the type parameter to the base autocomplete url
var glue = this.baseAcUrl.indexOf('?') > -1 ? '&' : '?';
this.acUrl = this.baseAcUrl + glue + 'type=' + typeVal;
// Flush autocomplete cache when type is reset, since the cached values
// pertain only to the previous type.
this.acCache = {};
},
showAutocompleteSelection: function(label, uri) {
this.hideFields(this.acSelectorWrapper);
// If form has a type selector, add type name to label. If form has no type selector,
// type name is coded into the html.
if (this.typeSelector.length) {
this.acSelection.find('label').html('Selected ' + this.typeName + ':');
}
this.acSelection.show();
this.acUriReceiver.val(uri);
this.acSelector.val(label);
this.acSelectionInfo.html(label);
this.verifyMatch.attr('href', this.verifyMatch.data('baseHref') + uri);
//Verify match is hidden in edit mode and support edit so unhide it
if(this.editMode == 'edit' && this.supportEdit) {
this.verifyMatch.show();
}
if(this.supportEdit) {
//On initialization in this mode, submit button is disabled
this.button.removeAttr('disabled');
this.button.removeClass('disabledSubmit'); // tlw
}
this.setButtonText('existing');
this.cancel.unbind('click');
this.cancel.click(function() {
customForm.undoAutocompleteSelection();
customForm.initFormFullView();
return false;
});
},
// Cancel action after making an autocomplete selection: undo autocomplete
// selection (from showAutocomplete) before returning to full view.
undoAutocompleteSelection: function() {
// The test is not just for efficiency: undoAutocompleteSelection empties the acSelector value,
// which we don't want to do if user has manually entered a value, since he may intend to
// change the type but keep the value. If no new value has been selected, form initialization
// below will correctly empty the value anyway.
if (!this.acSelection.is(':hidden')) {
this.acSelectorWrapper.show();
this.hideFields(this.acSelection);
this.acSelector.val('');
this.acUriReceiver.val('');
this.acSelectionInfo.html('');
this.verifyMatch.attr('href', this.verifyMatch.data('baseHref'));
if (this.formSteps > 1) {
this.acSelection.find('label').html('Selected ');
}
//Resetting so disable submit button again for object property autocomplete
if(this.supportEdit) {
this.button.attr('disabled', 'disabled');
this.button.addClass('disabledSubmit');
}
}
},
// Set type uri for autocomplete, and type name for labels and button text.
// Note: we still need this in edit mode, to set the text values.
setType: function() {
var selectedType;
// If there's no type selector, these values have been specified in customFormData,
// and will not change over the life of the form.
if (!this.typeSelector.length) {
return;
}
selectedType = this.typeSelector.find(':selected');
if (selectedType.length) {
this.acType = selectedType.val();
this.typeName = selectedType.html();
}
// reset to empty values; may not need
else {
this.acType = '';
this.typeName = '';
}
},
// Set field labels based on type selection. Although these won't change in edit
// mode, it's easier to specify the text here than in the jsp.
setLabels: function() {
var typeName = this.getTypeNameForLabels();
this.labelsWithPlaceholders.each(function() {
var newLabel = $(this).data('baseText').replace(customForm.placeholderText, typeName);
$(this).html(newLabel);
});
},
// Set button text based on both type selection and whether it's an autocomplete selection
// or a new related individual. Called when setting up full view of form, and after
// an autocomplete selection.
setButtonText: function(newOrExisting) {
var typeText,
buttonText,
baseButtonText = this.button.data('baseText');
// Edit mode button doesn't change, so it's specified in the jsp
if (this.editMode === 'edit') {
return;
}
//if support select editing, keep button label same
if(this.supportEdit) {
return;
}
typeText = this.getTypeNameForLabels();
// Creating new related individual
if (newOrExisting === 'new') {
if (this.submitButtonTextType == 'compound') { // use == to tolerate nulls
// e.g., 'Create Grant & Principal Investigator'
buttonText = 'Create ' + typeText + ' & ' + baseButtonText;
} else {
// In repair mode, baseButtonText is "Edit X". Keep that for this case.
// In add mode, baseButtonText is "X", so we get, e.g., "Create Publication"
buttonText = this.editMode == 'repair' ? baseButtonText : 'Create ' + baseButtonText;
}
}
// Using existing related individual
else {
// In repair mode, baseButtonText is "Edit X". Keep that for this case.
buttonText = this.editMode == 'repair' ? baseButtonText : 'Add ' + baseButtonText;
}
this.button.val(buttonText);
},
getTypeNameForLabels: function() {
// If this.acType is empty, we are either in a one-step form with no type yet selected,
// or in repair mode in a two-step form with no type selected. Use the default type
// name specified in the form data.
return this.acType ? this.typeName : this.capitalize(this.defaultTypeName);
},
// Set the initial help text that appears in the autocomplete field and change the class name
addAcHelpText: function() {
var typeText;
// First case applies on page load; second case applies when the type gets changed.
if (!this.acSelector.val() || this.acSelector.hasClass(this.acHelpTextClass)) {
typeText = this.getTypeNameForLabels();
var helpText = "Select an existing " + typeText + " or create a new one.";
//Different for object property autocomplete
if(this.supportEdit) {
helpText = "Select an existing " + typeText;
}
this.acSelector.val(helpText)
.addClass(this.acHelpTextClass);
}
},
deleteAcHelpText: function() {
if (this.acSelector.hasClass(this.acHelpTextClass)) {
this.acSelector.val('')
.removeClass(this.acHelpTextClass);
}
}
};
$(document).ready(function() {
customForm.onLoad();
});

View file

@ -70,10 +70,10 @@ var customFormData = {
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />',
'<link rel="stylesheet" href="${urls.base}/edit/forms/css/manageWebpagesForIndividual.css" />',
'<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css" />',
'<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/manageWebpagesForIndividual.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageWebpagesForIndividual.js"></script>')}

View file

@ -76,4 +76,4 @@
</section>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}

View file

@ -149,8 +149,8 @@
</section>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
@ -158,4 +158,4 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -182,8 +182,8 @@ var customFormData = {
</section>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
@ -191,6 +191,6 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}

View file

@ -199,13 +199,13 @@ $(document).ready(function(){
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/mailingAddressUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/mailingAddressUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>')}

View file

@ -156,8 +156,8 @@ var customFormData = {
</script>
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')}
${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')}
${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>',
@ -165,4 +165,4 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/
'<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>',
'<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>',
'<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')}
'<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}