%-- $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()));
%>
<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no
SPARQL queries for existing values. --%>
@prefix core: <${vivoCore}> .
?subject ?predicate ?terminologyContextNode .
?terminologyContextNode core:referencedTerm ?referencedTerm .
?terminologyContextNode core:entryTerm ?entryTerm .
?terminologyContextNode core:termLabel ?termLabel .
?terminologyContextNode core:termType ?termType .
{
"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}" ]
}
}
}
<%
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 terminologyAnnotationNodes = subject.getRelatedIndividuals(predicateUri);
List customJs = new ArrayList(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 customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(),
Css.CUSTOM_FORM.path(),
"/edit/forms/css/addTerminology.css"
));
request.setAttribute("customCss", customCss);
%>
JSP form, must be removed for the 1.4!
<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%>
${title}
<%@ include file="unsupportedBrowserMessage.jsp" %>
Manage Terminology Annotations
<%
int existingTermsCount = terminologyAnnotationNodes.size();
%>
<%
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");
%>
<%-- 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. --%>
<%-- 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. --%>
${termLabel} (${termType})Remove
<%
}
%>
<% if (existingTermsCount == 0) { %>
There are currently no terms specified.
<% } %>
" >
<%-- RY maybe make this a label and input field. See what looks best. --%>