diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java index 8a960b0ff..d2c0b1259 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java @@ -156,7 +156,7 @@ public class PropertyEditLinks extends TagSupport{ // This is NOT the correct object property statement - we need the link individual uri in data, instead of the link URL // Then we can combine this with doObjPropStmt ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data); - links = doVitroNsObjPropStmt( subjectUri, predicateUri, data, policyToAccess(ids, policy, prop), contextPath ); + links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath ); } } else { @@ -426,24 +426,8 @@ public class PropertyEditLinks extends TagSupport{ String subjectUri = opropStmt.getSubjectURI(); String predicateUri = opropStmt.getPropertyURI(); String objectUri = opropStmt.getObjectURI(); - String mouseoverLabel = "relationship"; - return doObjPropStmt(subjectUri, predicateUri, objectUri, allowedAccessTypeArray, contextPath, mouseoverLabel); - } - - protected LinkStruct[] doVitroNsObjPropStmt(String subjectUri, String predicateUri, String objectUri, EditLinkAccess[] allowedAccessTypeArray, String contextPath) { - if( allowedAccessTypeArray == null || subjectUri == null || allowedAccessTypeArray.length == 0 ) { - log.info("null or empty access type array in doObjPropStmt for " + predicateUri); - return empty_array; - } - - Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel"); - String mouseoverLabel = getObjPropMouseoverLabel(predicateUri); - return doObjPropStmt(subjectUri, predicateUri, objectUri, allowedAccessTypeArray, contextPath, mouseoverLabel); - } - - protected LinkStruct[] doObjPropStmt(String subjectUri, String predicateUri, String objectUri, EditLinkAccess[] allowedAccessTypeArray, String contextPath, String mouseoverLabel) { LinkStruct[] links = new LinkStruct[2]; int index=0; diff --git a/webapp/web/edit/forms/defaultLinkForm.jsp b/webapp/web/edit/forms/defaultLinkForm.jsp index 7dbea1215..05c67e0f0 100644 --- a/webapp/web/edit/forms/defaultLinkForm.jsp +++ b/webapp/web/edit/forms/defaultLinkForm.jsp @@ -2,6 +2,8 @@ <%@ 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.beans.VClass" %> <%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %> @@ -10,6 +12,7 @@ <%@ 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="java.util.List" %> @@ -27,12 +30,20 @@ vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace()); String propertyUri = (String) request.getAttribute("predicateUri"); - String objectUri = (String) request.getAttribute("objectUri"); - + String objectUri = (String) request.getAttribute("objectUri"); + + String stringDatatypeUriJson = MiscWebUtils.escape(XSD.xstring.toString()); + String uriDatatypeUriJson = MiscWebUtils.escape(XSD.anyURI.toString()); %> - + + + + + + + <%-- 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. @@ -46,23 +57,30 @@ and in the literalsOnForm --%> SELECT ?urlExisting - WHERE { ?subject ?predicate ?urlExisting } + WHERE { ?link <${linkUrl}> ?urlExisting } <%-- 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) --%> - ?subject ?predicate ?url . + ?link <${linkUrl}> ?url . - PREFIX vitro: <${vitroUri}> . SELECT ?anchorExisting - WHERE { ?link vitro:linkAnchor ?anchorExisting } + WHERE { ?link <${linkAnchor}> ?anchorExisting } - @prefix vitro: <${vitroUri}> . - ?link vitro:linkAnchor ?anchor . + ?link <${linkAnchor}> ?anchor . + + +<%-- RY Currently display rank is always hard-coded to -1, but later we may want to enable sorting. --%> + + SELECT ?displayRankExisting + WHERE { ?link <${linkDisplayRank}> ?displayRankExisting } + + + ?link <${linkDisplayRank}> ?displayRank . <%-- When not retrieving a literal via a datatype property, put the SPARQL statement into @@ -77,16 +95,12 @@ ?link rdf:type vitro:Link . ?link - vitro:linkURL ?url ; - vitro:linkAnchor ?anchor . + <${linkUrl}> ?url ; + <${linkAnchor}> ?anchor ; + <${linkDisplayRank}> ?displayRank . - - @prefix rdf: <${rdfUri}> . - - ?link rdf:type ?type . - { @@ -99,48 +113,61 @@ "object" : ["link", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForEdit}" ], - "n3optional" : [ "${n3Optional}" ], + "n3optional" : [ ], "newResources" : { "link" : "${defaultNamespace}" }, "urisInScope" : { }, "literalsInScope" : { }, "urisOnForm" : [ ], - "literalsOnForm" : [ "url", "anchor" ], + "literalsOnForm" : [ "url", "anchor", "displayRank" ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, "sparqlForUris" : { }, "sparqlForExistingLiterals" : { "url" : "${urlExisting}", - "anchor" : "${anchorExisting}" + "anchor" : "${anchorExisting}", + "displayRank" : "${displayRankExisting}" }, "sparqlForExistingUris" : { }, "fields" : { "url" : { "newResource" : "false", - "validators" : [ "nonempty" ], + "validators" : [ "nonempty", "datatype:${uriDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "", + "rangeDatatypeUri" : "${uriDatatypeUriJson}", "rangeLang" : "", "assertions" : [ "${urlAssertion}" ] }, "anchor" : { "newResource" : "false", - "validators" : [ "nonempty" ], + "validators" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", "rangeLang" : "", "assertions" : [ "${anchorAssertion}" ] + }, + "displayRank" : { + "newResource" : "false", + "validators" : [ ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", + "rangeLang" : "", + "assertions" : [ "${displayRankAssertion}" ] } } } <% log.debug(request.getAttribute("editjson")); +System.out.println(request.getAttribute("editjson")); EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if( editConfig == null ){ @@ -156,16 +183,16 @@ } /* get some data to make the form more useful */ - Individual subject = (Individual)request.getAttribute("subject"); + String subjectName = ((Individual)request.getAttribute("subject")).getName(); String submitLabel=""; String title=""; - String linkType = propertyUri.equals(VitroVocabulary.PRIMARY_LINK) ? "primary" : "additional"; + String linkCategory = propertyUri.equals(VitroVocabulary.PRIMARY_LINK) ? "primary" : "additional"; if (objectUri != null) { - title = "Edit " + linkType + " link for " + subject.getName(); + title = "Edit " + linkCategory + " link for " + subjectName; submitLabel = "Save changes"; } else { - title = "Create a new " + linkType + " link for " + subject.getName(); + title = "Create a new " + linkCategory + " link for " + subjectName; submitLabel = "Create new link"; } @@ -177,6 +204,7 @@
" > +