From 8c69cd43681521fd03c32d77b0fe9632348053c9 Mon Sep 17 00:00:00 2001 From: bdc34 Date: Tue, 13 Jul 2010 17:10:35 +0000 Subject: [PATCH] Working on clinical activity role form and view. NIHVIVO-629 NIHVIVO-630 --- .../user/vivo-core-1.1-annotations.rdf | 1 + .../edit/forms/addRoleToPersonTwoStage.jsp | 242 ++++++++++++++++++ .../entity/clinicalActivityRoleView.jsp | 8 + 3 files changed, 251 insertions(+) create mode 100644 productMods/edit/forms/addRoleToPersonTwoStage.jsp create mode 100644 productMods/templates/entity/clinicalActivityRoleView.jsp diff --git a/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf b/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf index b484f5f9..08d682c9 100644 --- a/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf +++ b/productMods/WEB-INF/ontologies/user/vivo-core-1.1-annotations.rdf @@ -1281,6 +1281,7 @@ display level -1 + clinicalActivityRoleView.jsp diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp new file mode 100644 index 00000000..fa6cd1d0 --- /dev/null +++ b/productMods/edit/forms/addRoleToPersonTwoStage.jsp @@ -0,0 +1,242 @@ +<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> + +<%-- + Custom two stage form for adding a Role to a Person. + + Stage one is selecting the type of the non-person thing + associated with the Role with the intention of reducing the + number of Individuals that the user has to select from. + Stage two is selecting the non-person Individual to associate + with the Role. + + This is intended to create a set of statements like: + + ?person core:hasResearchActivityRole ?newRole. + ?newRole rdf:type core:ResearchActivityRole ; + core:relatedRole ?someActivity . + ?someActivity rdf:type core:ResearchActivity . + ?someActivity rdfs:label "activity title" . +--%> + +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.Arrays" %> + +<%@ 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.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.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" %> + + +<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%> + + +<%-- + It may make sense to parameterize this jsp: + sparqlForAcFilter + role type + predicate inverse + role activity type label (should be singular) +--%> +<%-- Must be all one line for JavaScript. --%> + +PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri .?authorshipUri core:linkedInformationResource ?pubUri .} + +clinical activity +${vivoCore}ClinicalRole + +<% + VitroRequest vreq = new VitroRequest(request); + WebappDaoFactory wdf = vreq.getWebappDaoFactory(); + //vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior + + String subjectUri = vreq.getParameter("subjectUri"); + String predicateUri = vreq.getParameter("predicateUri"); + String subjectName = ((Individual) request.getAttribute("subject")).getName(); + vreq.setAttribute("subjectUriJson", MiscWebUtils.escape(subjectUri)); + + vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); + + String intDatatypeUri = XSD.xint.toString(); + vreq.setAttribute("intDatatypeUri", intDatatypeUri); + vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri)); + + ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri ); + if( op != null && op.getURIInverse() != null ){ + %> <%=op.getURIInverse()%> <% + }else{ + %> <% + } +%> + + + + + <%--blank triggers default URI generation behavior --%> + + + + + @prefix core: <${vivoCore}> . + + ?person ?rolePredicate ?role. + ?role a <${roleType}> . + ?role core:roleIn ?roleActivity . + ?roleActivity core:relatedRole ?role . + + + + ?roleActivity <${label}> ?title . + ?roleActivity a ?roleActivityType . + + + + ?role ?inverseRolePredicate ?person. + + + +${publicationsClassGroupUri} + + +{ + "formUrl" : "${formUrl}", + "editKey" : "${editKey}", + "urlPatternToReturnTo" : "/individual", + + "subject" : ["person", "${subjectUriJson}" ], + "predicate" : ["rolePredicate", "${predicateUriJson}" ], + "object" : ["role", "${objectUriJson}", "URI" ], + + "n3required" : [ "${n3ForNewRole}" ], + "n3optional" : [ "${n3ForNewActivity}", "${n3ForInverse}" ], + + "newResources" : { "role" : "${defaultNamespace}", + "roleActivity" : "${defaultNamespace}" }, + + "urisInScope" : { "inverseRolePredicate" : "${inversePredicate}" }, + "literalsInScope": { }, + "urisOnForm" : [ "roleActivity", "roleActivityType" ], + "literalsOnForm" : [ "title" ], + "filesOnForm" : [ ], + "sparqlForLiterals" : { }, + "sparqlForUris" : { }, + "sparqlForExistingLiterals" : { }, + "sparqlForExistingUris" : { }, + "fields" : { + "title" : { + "newResource" : "false", + "validators" : [ "datatype:${stringDatatypeUriJson}" ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", + "rangeLang" : "", + "assertions" : [ ] + }, + "roleActivityType" : { + "newResource" : "true", + "validators" : [ ], + "optionsType" : "VCLASSGROUP", + "literalOptions" : [ "Select one" ], + "predicateUri" : "", + "objectClassUri" : "${publicationsClassGroupUriJson}", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ ] + }, + "roleActivity" : { + "newResource" : "true", + "validators" : [ ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ ] + } + } +} + + +<% + EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); + if (editConfig == null) { + editConfig = new EditConfiguration((String) request.getAttribute("editjson")); + EditConfiguration.putConfigInSession(editConfig,session); + } + + //editConfig.addValidator(new PersonHasPublicationValidator()); + + //this will return the browser to the new activity entity after an edit. + editConfig.setEntityToReturnTo("?roleActivity"); + + Model model = (Model) application.getAttribute("jenaOntModel"); + String objectUri = (String) request.getAttribute("objectUri"); + editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing + + List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), + JavaScript.CUSTOM_FORM_UTILS.path(), + "/edit/forms/js/customFormWithAdvanceTypeSelection.js" + )); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), + Css.CUSTOM_FORM.path(), + "/edit/forms/css/autocomplete.css", + "/edit/forms/css/customFormWithAdvanceTypeSelection.css" + )); + request.setAttribute("customCss", customCss); +%> + + + + + +

Create a new ${roleActivityTypeLabel} entry for <%= subjectName %>

+ +
" > + +

+ +
+ +

+ +
+ <%-- RY maybe make this a label and input field. See what looks best. --%> +

(Verify this match)

+ +
+
+ +

+ +

* required fields

+
+ + + + + + \ No newline at end of file diff --git a/productMods/templates/entity/clinicalActivityRoleView.jsp b/productMods/templates/entity/clinicalActivityRoleView.jsp new file mode 100644 index 00000000..c4b24838 --- /dev/null +++ b/productMods/templates/entity/clinicalActivityRoleView.jsp @@ -0,0 +1,8 @@ +<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> + + + + + + +