From bfcd18096ab6ede5343a308339a5e982484ef9fa Mon Sep 17 00:00:00 2001 From: rjy7 Date: Mon, 14 Jun 2010 01:40:59 +0000 Subject: [PATCH] Revert changes to date field in personHasEducationalBackground just to get the form to submit (though the year isn't handled correctly). More work on addAuthorsToInformationResource form. --- .../forms/addAuthorsToInformationResource.jsp | 164 +++++++++++++++++- .../forms/personHasEducationalBackground.jsp | 17 +- 2 files changed, 176 insertions(+), 5 deletions(-) diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp index fbe81e6e..45643722 100644 --- a/productMods/edit/forms/addAuthorsToInformationResource.jsp +++ b/productMods/edit/forms/addAuthorsToInformationResource.jsp @@ -57,12 +57,172 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor vreq.setAttribute("flagUri",flagUri); vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); + vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(XSD.xint.toString())); +%> + + + + + +<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no +SPARQL queries for existing values. --%> +<%-- RY Is this claim correct, or do we need them to retrieve an existing individual? --%> +<%-- Data properties --%> + + + @prefix foaf: <${foaf}> . + + ?newPerson foaf:firstName ?firstName . + + + + @prefix core: <${vivoCore}> . + + ?newPerson core:middleName ?middleName . + + + + @prefix foaf: <${foaf}> . + + ?newPerson foaf:lastName ?lastName . + + + + @prefix core: <${vivoCore}> . + + ?authorshipUri core:authorRank ?rank + + +<%-- This much applies to both new and existing person --%> + + @prefix core: <${vivoCore}> . + + ?authorshipUri a core:Authorship , + <${flagURI}> ; + core:linkedInformationResource ?infoResource . + + ?infoResource core:informationResourceInAuthorship ?authorshipUri . + + + + @prefix core: <${vivoCore}> . + ?authorshipUri core:linkedAuthor ?personUri + ?personUri core:authorInAuthorship ?authorshipUri + + + + @prefix foaf: <${foaf}> . + @prefix core: <${vivoCore}> . + + ?newPerson a foaf:Person , + <${flagURI}> ; + core:firstName ?firstName ; + core:middleName ?middleName ; + core:lastName ?lastName . + + ?authorshipUri core:linkedAuthor ?newPerson + ?newPerson core:authorInAuthorship ?authorshipUri + + + +{ + "formUrl" : "${formUrl}", + "editKey" : "${editKey}", + "urlPatternToReturnTo" : "/entity", + + "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" : [ "authorshipUri", "personUri" ], + "literalsOnForm" : [ "firstName", "middleName", "lastName", "rank" ], + "filesOnForm" : [ ], + "sparqlForLiterals" : { }, + "sparqlForUris" : { }, + "sparqlForExistingLiterals" : { }, + "sparqlForExistingUris" : { }, + "fields" : { + "firstName" : { + "newResource" : "false", + "validators" : [ "nonempty", "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" : [ "nonempty", "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}"] + } + } +} + + +<% + + log.debug(request.getAttribute("editjson")); + + EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); + if (editConfig == null) { + editConfig = new EditConfiguration((String) request.getAttribute("editjson")); + EditConfiguration.putConfigInSession(editConfig,session); + } + + Model model = (Model) application.getAttribute("jenaOntModel"); + String objectUri = (String) request.getAttribute("objectUri"); + System.out.println("OBJECT URI: " + objectUri); + editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing + String subjectUri = vreq.getParameter("subjectUri"); String predicateUri = vreq.getParameter("predicateUri"); Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri); List authorships = infoResource.getRelatedIndividuals(predicateUri); vreq.setAttribute("infoResourceName", infoResource.getName()); + vreq.setAttribute("rank", authorships.size()+1); // new author ranked last when added String linkedAuthorProperty = "http://vivoweb.org/ontology/core#linkedAuthor"; @@ -97,7 +257,6 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor <% } } - %> @@ -110,7 +269,8 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor

${initialHint}

${initialHint}

- + +

diff --git a/productMods/edit/forms/personHasEducationalBackground.jsp b/productMods/edit/forms/personHasEducationalBackground.jsp index 523c7f1a..d5e499ec 100644 --- a/productMods/edit/forms/personHasEducationalBackground.jsp +++ b/productMods/edit/forms/personHasEducationalBackground.jsp @@ -95,6 +95,7 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) ?edAttainmentUri <${majorFieldPred}> ?majorField . +<%-- @@ -111,7 +112,17 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) core:dateTimeValuePrecision core:YearPrecision . ?edAttainmentUri core:dateTimeValue ?dateTime . - +--%> +<%-- + + + SELECT ?existingYear WHERE { + ?edBackgroundUri <${yearPred}> ?existingYear } + + + ?edBackgroundUri <${yearPred}> ?year . + + --%> SELECT ?existingDept WHERE { @@ -214,7 +225,7 @@ the org type still gets asserted. --%> "sparqlForUris" : { }, "sparqlForExistingLiterals" : { "majorField" : "${majorFieldExisting}", - "year" : "${yearExisting}", + /*"year" : "${yearExisting}",*/ "dept" : "${deptExisting}", "info" : "${infoExisting}" }, @@ -252,7 +263,7 @@ the org type still gets asserted. --%> "literalOptions" : [ ], "predicateUri" : "", "objectClassUri" : "", - "rangeDatatypeUri" : "http://www.w3.org/2001/XMLSchema#dateTime", + "rangeDatatypeUri" : "${gYearDatatypeUriJson}", "rangeLang" : "", "assertions" : ["${yearAssertion}"] },