From 8570254efb94a4283dd78c15fe08a2e662b84f9b Mon Sep 17 00:00:00 2001 From: rjy7 Date: Tue, 15 Jun 2010 19:35:38 +0000 Subject: [PATCH] NIHVIVO-646 More work on addAuthorsToInformationResource custom form. Create edit submission preprocessing mechanism to make automated modifications to the form submission (e.g., creating a label from first, last, and middle name entries). --- .../forms/addAuthorsToInformationResource.jsp | 69 ++++++++++++------- .../css/addAuthorsToInformationResource.css | 8 +++ .../forms/personHasEducationalBackground.jsp | 12 ++-- .../edit/forms/personHasPositionHistory.jsp | 12 ++-- 4 files changed, 64 insertions(+), 37 deletions(-) diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp index 020a303f..ea39ce06 100644 --- a/productMods/edit/forms/addAuthorsToInformationResource.jsp +++ b/productMods/edit/forms/addAuthorsToInformationResource.jsp @@ -30,6 +30,7 @@ core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor <%@ 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.CreateLabelFromNameFields"%> <%@ 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"%> @@ -71,26 +72,22 @@ SPARQL queries for existing values. --%> <%-- Data properties --%> - @prefix foaf: <${foaf}> . - + @prefix foaf: <${foaf}> . ?newPerson foaf:firstName ?firstName . - @prefix core: <${vivoCore}> . - + @prefix core: <${vivoCore}> . ?newPerson core:middleName ?middleName . - @prefix foaf: <${foaf}> . - + @prefix foaf: <${foaf}> . ?newPerson foaf:lastName ?lastName . - @prefix core: <${vivoCore}> . - + @prefix core: <${vivoCore}> . ?authorshipUri core:authorRank ?rank . @@ -99,16 +96,17 @@ SPARQL queries for existing values. --%> @prefix core: <${vivoCore}> . ?authorshipUri a core:Authorship , - <${flagURI}> ; - core:linkedInformationResource ?infoResource . + <${flagUri}> ; + core:linkedInformationResource ?infoResource ; + core:authorRank ?rank . ?infoResource core:informationResourceInAuthorship ?authorshipUri . @prefix core: <${vivoCore}> . - ?authorshipUri core:linkedAuthor ?personUri - ?personUri core:authorInAuthorship ?authorshipUri + ?authorshipUri core:linkedAuthor ?personUri . + ?personUri core:authorInAuthorship ?authorshipUri . @@ -116,13 +114,11 @@ SPARQL queries for existing values. --%> @prefix core: <${vivoCore}> . ?newPerson a foaf:Person , - <${flagURI}> ; - core:firstName ?firstName ; - core:middleName ?middleName ; - core:lastName ?lastName . + <${flagUri}> ; + <${label}> ?label . - ?authorshipUri core:linkedAuthor ?newPerson - ?newPerson core:authorInAuthorship ?authorshipUri + ?authorshipUri core:linkedAuthor ?newPerson . + ?newPerson core:authorInAuthorship ?authorshipUri . @@ -147,13 +143,24 @@ SPARQL queries for existing values. --%> "urisInScope" : { }, "literalsInScope": { }, "urisOnForm" : [ "authorshipUri", "personUri" ], - "literalsOnForm" : [ "firstName", "middleName", "lastName", "rank" ], + "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" : [ "nonempty", "datatype:${stringDatatypeUriJson}" ], @@ -203,7 +210,6 @@ SPARQL queries for existing values. --%> <% - log.debug(request.getAttribute("editjson")); EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); @@ -212,6 +218,11 @@ SPARQL queries for existing values. --%> EditConfiguration.putConfigInSession(editConfig,session); } + // For now the field names in CreateLabelFromFieldNames.processEditSubmission() are + // hard-coded. If we want the flexibility in naming them, we can pass in a map of + // the field names when creating the preprocessor. + editConfig.addEditSubmissionPreprocessor(new CreateLabelFromNameFields(editConfig)); + Model model = (Model) application.getAttribute("jenaOntModel"); String objectUri = (String) request.getAttribute("objectUri"); editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing @@ -220,6 +231,7 @@ SPARQL queries for existing values. --%> 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 @@ -252,11 +264,11 @@ SPARQL queries for existing values. --%> if ( author != null ) { request.setAttribute("author", author); %> - <%-- RY Should use author short view here? --%> + <%-- RY Should use author short view here instead? --%> -
  • <%= getAuthorName(author) %>Remove
  • +
  • ${author.name}Remove
  • <% } @@ -266,7 +278,7 @@ SPARQL queries for existing values. --%>
    - +
    @@ -276,7 +288,10 @@ SPARQL queries for existing values. --%>

    ${initialHint}

    ${initialHint}

    - + <%-- These fields will have values populated/modified by JavaScript --%> + <%--

    ${initialHint}

    --%> + +

    @@ -287,6 +302,10 @@ SPARQL queries for existing values. --%> <%! +// We'll just rely on rdfs:label for now. In future, the label will be created by the app from +// last name, first name, and middle name fields, so we don't have to worry about inconsistent +// ordering. +/* public String getAuthorName(Individual author) { String name; @@ -305,5 +324,5 @@ public String getAuthorName(Individual author) { } return name; } - +*/ %> diff --git a/productMods/edit/forms/css/addAuthorsToInformationResource.css b/productMods/edit/forms/css/addAuthorsToInformationResource.css index 7802f1c4..f8bb783e 100644 --- a/productMods/edit/forms/css/addAuthorsToInformationResource.css +++ b/productMods/edit/forms/css/addAuthorsToInformationResource.css @@ -20,6 +20,14 @@ a.remove { display: none; } +#showAddForm span.or { + display: none; +} + +#showAddForm a.cancel { + margin-left: 2em; +} + form a:link.cancel, form a:visited.cancel, #authors a:link.remove, #authors a:visited.remove, #showAddForm a:link.cancel, #showAddForm a:visited.cancel { diff --git a/productMods/edit/forms/personHasEducationalBackground.jsp b/productMods/edit/forms/personHasEducationalBackground.jsp index 5be43e1b..b69ae887 100644 --- a/productMods/edit/forms/personHasEducationalBackground.jsp +++ b/productMods/edit/forms/personHasEducationalBackground.jsp @@ -58,13 +58,13 @@ core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) WebappDaoFactory wdf = vreq.getWebappDaoFactory(); vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - String flagURI = null; + String flagUri = null; if (wdf.getApplicationDao().isFlag1Active()) { - flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing"; + flagUri = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing"; } else { - flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering + flagUri = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering } - vreq.setAttribute("flagURI",flagURI); + vreq.setAttribute("flagUri",flagUri); request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); @@ -182,13 +182,13 @@ the org type still gets asserted. --%> ?edAttainmentUri core:educationalBackgroundOf ?person ; a core:EducationalAttainment , - <${flagURI}> . + <${flagUri}> . ?newOrg <${label}> ?newOrgName ; a ?newOrgType , - <${flagURI}> . + <${flagUri}> . ?edAttainmentUri <${orgGrantingDegree}> ?newOrg . diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 54f709ba..d90243a5 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -31,13 +31,13 @@ WebappDaoFactory wdf = vreq.getWebappDaoFactory(); vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - String flagURI = null; + String flagUri = null; if (vreq.getAppBean().isFlag1Active()) { - flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing"; + flagUri = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing"; } else { - flagURI = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering + flagUri = wdf.getVClassDao().getTopConcept().getURI(); // fall back to owl:Thing if not portal filtering } - vreq.setAttribute("flagURI",flagURI); + vreq.setAttribute("flagUri",flagUri); request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); @@ -121,7 +121,7 @@ ?positionUri core:positionForPerson ?person ; a ?positionType , - <${flagURI}> . + <${flagUri}> . @@ -129,7 +129,7 @@ ?newOrg <${label}> ?newOrgName ; a ?newOrgType , - <${flagURI}> ; + <${flagUri}> ; <${orgForPositionPred}> ?positionUri .