From 4a9a81fc15d021e4e3a02ce3a00d20b1b42842b2 Mon Sep 17 00:00:00 2001 From: rjy7 Date: Fri, 26 Mar 2010 20:19:17 +0000 Subject: [PATCH] NIHVIVO-193 Preliminary code cleanup before making functional modifications. --- .../edit/forms/personHasPositionHistory.jsp | 69 +++++++++++-------- 1 file changed, 40 insertions(+), 29 deletions(-) diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 880719a7..5f3e8524 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -2,13 +2,14 @@ <%@ page import="com.hp.hpl.jena.rdf.model.Literal"%> <%@ page import="com.hp.hpl.jena.rdf.model.Model"%> +<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %> + <%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%> -<%@ page - import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory"%> -<%@ page - import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> <%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> @@ -25,66 +26,76 @@ flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering } vreq.setAttribute("flagURI",flagURI); + + request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); + request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); %> -<%-- RY *** SET VARIABLES for uris & namespaces --%> + + + <%-- 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 --%> - + + SELECT ?titleExisting WHERE { - ?positionUri ?titleExisting } + ?positionUri <${titlePred}> ?titleExisting } <%-- 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) --%> - ?positionUri ?title . - ?positionUri ?title. + ?positionUri <${titlePred}> ?title . + ?positionUri <${rdf}label> ?title. + SELECT ?existingOrgName WHERE { - ?positionUri ?existingOrgName } + ?positionUri <${involvedOrgNamePred}> ?existingOrgName } - ?positionUri ?organizationName . + ?positionUri <${involvedOrgNamePred}> ?organizationName . + SELECT ?startYearExisting WHERE { - ?positionUri ?startYearExisting } + ?positionUri <${startYearPred}> ?startYearExisting } - ?positionUri ?startYear . + ?positionUri <${startYearPred}> ?startYear . + SELECT ?endYearExisting WHERE { - ?positionUri ?endYearExisting } + ?positionUri <${endYearPred}> ?endYearExisting } - ?positionUri ?endYear . + ?positionUri <${endYearPred}> ?endYear . <%-- 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 --%> + SELECT ?existingOrgUri WHERE { - ?positionUri ?existingOrgUri } + ?positionUri <${positionInOrgPred}> ?existingOrgUri } - ?positionUri ?organizationUri . - ?organizationUri ?positionUri . + ?positionUri <${positionInOrgPred}> ?organizationUri . + ?organizationUri <${vivo}organizationForPosition> ?positionUri . - @prefix rdf: . - @prefix core: . + @prefix rdf: <${rdf}>. + @prefix core: <${vivo}>. ?person core:personInPosition ?positionUri . ?positionUri core:positionForPerson ?person . @@ -157,29 +168,29 @@ "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#string", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", "rangeLang" : "", "assertions" : [ "${organizationNameAssertion}" ] }, "startYear" : { "newResource" : "false", - "validators" : [ "nonempty", "datatype:http://www.w3.org/2001/XMLSchema#gYear" ], + "validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#gYear", + "rangeDatatypeUri" : "${gYearDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${startYearAssertion}"] }, "endYear" : { "newResource" : "false", - "validators" : [ "datatype:http://www.w3.org/2001/XMLSchema#gYear" ], + "validators" : [ "datatype:${gYearDatatypeUriJson}" ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#gYear", + "rangeDatatypeUri" : "${gYearDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${endYearAssertion}"] } @@ -204,14 +215,14 @@ editConfig.prepareForNonUpdate(model); } - /* prepare the and text for the submit button */ - Individual subject = (Individual) request.getAttribute("subject"); + /* prepare the page title and text for the submit button */ + String subjectName = ((Individual) request.getAttribute("subject")).getName(); String submitLabel = ""; if (objectUri != null) { - request.setAttribute("title","Edit position history entry for "+ subject.getName()); + request.setAttribute("title","Edit position entry for "+ subjectName); submitLabel = "Save changes"; } else { - request.setAttribute("title","Create a new position history entry for " + subject.getName()); + request.setAttribute("title","Create a new position entry for " + subjectName); submitLabel = "Create new position history entry"; } %>