diff --git a/productMods/edit/forms/css/customForm.css b/productMods/edit/forms/css/customForm.css new file mode 100644 index 00000000..2d0ce098 --- /dev/null +++ b/productMods/edit/forms/css/customForm.css @@ -0,0 +1,51 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +/* Some of these styles should most likely apply to all forms. */ + +#content form { + width: 50%; +} + +#content form div { + clear: left; +} + +#addNewLink { + float: right; + margin-right: 18em; + margin-top: .8em; + width: 30%; + padding: .6em 0 .6em 1.5em; + border: 1px solid #9c9c9c; + +} + +#content form #existing { + float: left; + clear: none; +/* width: 300px;*/ + display: inline-block; +} + +#new { + padding: .6em 0 .6em 1.5em; + border: 1px solid #9c9c9c; +} + +#content form p.inline input { + margin-right: 50em; + margin-top: -1.75em; + float: right; + clear: right; +} + +input, +select, +#content form p { + margin-bottom: 1em; +} + +/* This div starts off hidden in case Javascript is disabled. Javascript will show it. */ +.addNewLink { + display: none; +} \ No newline at end of file diff --git a/productMods/edit/forms/css/personHasPositionHistory.css b/productMods/edit/forms/css/personHasPositionHistory.css index eb1abcd7..0dc42bbe 100644 --- a/productMods/edit/forms/css/personHasPositionHistory.css +++ b/productMods/edit/forms/css/personHasPositionHistory.css @@ -1,22 +1,2 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -#content form div { - clear: left; -} - -#content form #existing { - float: left; - clear: none; -/* width: 300px;*/ - display: inline-block; -} - -#content form #notListed { - float: left; - clear: none; - width: 200px; - margin-left: 4em; - padding: 10px 0px 10px 16px; - border: 1px solid #9c9c9c; - -} \ No newline at end of file diff --git a/productMods/edit/forms/js/customForm.js b/productMods/edit/forms/js/customForm.js new file mode 100644 index 00000000..bef1a21b --- /dev/null +++ b/productMods/edit/forms/js/customForm.js @@ -0,0 +1,42 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var customForm = { + + onLoad: function() { + + var button = $('#submit'); + var addNewLink = $('#addNewLink'); + var existing = $('#existing'); + var addNew = $('#new'); + var entry = $('#entry'); + var editType = $("input[name='editType']").val(); + var entryType = $("input[name='entryType']").val(); + + if (editType == 'add') { + // Set up form for step 1 + addNewLink.show(); + addNew.hide(); + entry.hide(); + button.val('Continue'); + + // Add event listeners + button.bind('click', function() { + entry.show(); + addNewLink.hide(); + $(this).val('Create ' + entryType); + $(this).unbind('click'); + return false; + + }); + } else { // editing existing entry + + } + + + + } +}; + +$(document).ready(function(){ + customForm.onLoad(); +}); diff --git a/productMods/edit/forms/js/personHasPositionHistory.js b/productMods/edit/forms/js/personHasPositionHistory.js index 88326740..0dc42bbe 100644 --- a/productMods/edit/forms/js/personHasPositionHistory.js +++ b/productMods/edit/forms/js/personHasPositionHistory.js @@ -1,14 +1,2 @@ /* $This file is distributed under the terms of the license in /doc/license.txt$ */ -var personHasPositionHistory = { - - onLoad: function() { - $("#newOrg").hide(); - $("#position").hide(); - $("#submit").val("Continue"); - } -}; - -$(document).ready(function(){ - personHasPositionHistory.onLoad(); -}); diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp index 63ddda0e..08559bf5 100644 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ b/productMods/edit/forms/personHasPositionHistory.jsp @@ -15,9 +15,15 @@ <%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> <%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> +<%@ 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" %> +<%! + public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.personHasPositionHistory.jsp"); +%> <% VitroRequest vreq = new VitroRequest(request); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); @@ -37,14 +43,16 @@ - + + + <%-- 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 <${titlePred}> ?titleExisting } @@ -54,16 +62,7 @@ NOTE the pattern of punctuation (a period after the prefix URI and after the ?field) --%> ?positionUri <${titlePred}> ?title . - ?positionUri <${rdf}label> ?title. - - - - - SELECT ?existingOrgName WHERE { - ?positionUri <${involvedOrgNamePred}> ?existingOrgName } - - - ?positionUri <${involvedOrgNamePred}> ?organizationName . + ?positionUri <${label}> ?title. @@ -88,23 +87,41 @@ 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 <${positionInOrgPred}> ?existingOrgUri } ?positionUri <${positionInOrgPred}> ?organizationUri . - ?organizationUri <${vivo}organizationForPosition> ?positionUri . + ?organizationUri <${orgForPositionPred}> ?positionUri . - - @prefix rdf: <${rdf}>. - @prefix core: <${vivo}>. + + ?newOrg <${label}> ?newOrgName . + + + + ?newOrg <${type}> ?newOrgType . + + + + @prefix core: <${vivo}> . ?person core:personInPosition ?positionUri . ?positionUri core:positionForPerson ?person . - ?positionUri rdf:type core:Position . - ?positionUri rdf:type <${flagURI}> . + ?positionUri <${type}> core:Position . + ?positionUri <${type}> <${flagURI}> . + + + + @prefix rdf: <${rdf}> . + @prefix rdfs: <${rdfs}> . + + ?newOrg <${label}> ?newOrgName . + ?newOrg <${type}> ?newOrgType . + ?positionUri <${positionInOrgPred}> ?newOrg . + ?newOrg <${orgForPositionPred}> ?positionUri . http://vivoweb.org/ontology/core#Position @@ -122,13 +139,18 @@ "object" : ["positionUri", "${objectUriJson}", "URI" ], "n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ], - "n3optional" : [ "${organizationNameAssertion}","${organizationUriAssertion}", + + "n3optional" : [ "${organizationUriAssertion}", + "${n3ForNewOrg}", "${newOrgNameAsertion}", "${newOrgTypeAssertion}", "${endYearAssertion}"], - "newResources" : { "positionUri" : "${defaultNamespace}" }, + + "newResources" : { "positionUri" : "${defaultNamespace}", + "newOrg" : "${defaultNamespace}" }, + "urisInScope" : { }, "literalsInScope": { }, - "urisOnForm" : [ "organizationUri" ], - "literalsOnForm" : [ "title", "organizationName", + "urisOnForm" : [ "organizationUri", "newOrgType" ], + "literalsOnForm" : [ "title", "newOrgName", "startYear", "endYear" ], "filesOnForm" : [ ], "sparqlForLiterals" : { }, @@ -165,8 +187,8 @@ "rangeLang" : "", "assertions" : [ "${organizationUriAssertion}" ] }, - "organizationName" : { - "newResource" : "false", + "newOrgName" : { + "newResource" : "true", "validators" : [ ], "optionsType" : "UNDEFINED", "literalOptions" : [ ], @@ -174,8 +196,19 @@ "objectClassUri" : "", "rangeDatatypeUri" : "${stringDatatypeUriJson}", "rangeLang" : "", - "assertions" : [ "${organizationNameAssertion}" ] + "assertions" : [ "${newOrgNameAssertion}" ] }, + "newOrgType" : { + "newResource" : "false", + "validators" : [ ], + "optionsType" : "INDIVIDUALS_VIA_VCLASS", + "literalOptions" : [ "Select one" ], + "predicateUri" : "", + "objectClassUri" : "${organizationClass}", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ "${newOrgTypeAssertion}" ] + }, "startYear" : { "newResource" : "false", "validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ], @@ -202,38 +235,48 @@ } <% + log.debug(request.getAttribute("editjson")); EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); if (editConfig == null) { - editConfig = new EditConfiguration( - (String) request - .getAttribute("editjson")); + editConfig = new EditConfiguration((String) request.getAttribute("editjson")); EditConfiguration.putConfigInSession(editConfig,session); } Model model = (Model) application.getAttribute("jenaOntModel"); String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { + if (objectUri != null) { // editing existing editConfig.prepareForObjPropUpdate(model); - } else { + } else { // adding new editConfig.prepareForNonUpdate(model); } - /* 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 entry for "+ subjectName); - submitLabel = "Save changes"; - } else { - request.setAttribute("title","Create a new position entry for " + subjectName); - submitLabel = "Create new position history entry"; - } +%> + + +<% + if (objectUri != null) { // editing existing entry +%> + + + +<% + } else { // adding new entry +%> + + + +<% } - List customJs = new ArrayList(Arrays.asList("forms/js/personHasPositionHistory.js")); + List customJs = new ArrayList(Arrays.asList("forms/js/customForm.js" + //, "forms/js/personHasPositionHistory.js" + )); request.setAttribute("customJs", customJs); - List customCss = new ArrayList(Arrays.asList("forms/css/personHasPositionHistory.css")); + List customCss = new ArrayList(Arrays.asList("forms/css/customForm.css" + //, "forms/css/personHasPositionHistory.css" + )); request.setAttribute("customCss", customCss); %> @@ -241,28 +284,38 @@

${title}

-
" -
- -
- -
- If your organization is not listed, please add a new organization. -
- -
- -
- -
- - +" > + + + + + + +
+ +
+ +
+
Add a New Organization
+ + +
+ +
+ + - - -
- -

+

+

+
+ + + + + +

diff --git a/productMods/edit/forms/personHasPositionHistory.old.jsp b/productMods/edit/forms/personHasPositionHistory.old.jsp new file mode 100644 index 00000000..b700e4fb --- /dev/null +++ b/productMods/edit/forms/personHasPositionHistory.old.jsp @@ -0,0 +1,276 @@ +<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> + +<%@ page import="java.util.List" %> +<%@ page import="java.util.ArrayList" %> +<%@ page import="java.util.Arrays" %> + +<%@ 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.dao.WebappDaoFactory"%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%> +<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> + +<%@ 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" %> + +<%! + public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.personHasPositionHistory.jsp"); +%> +<% + VitroRequest vreq = new VitroRequest(request); + WebappDaoFactory wdf = vreq.getWebappDaoFactory(); + vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace()); + + String flagURI = null; + if (vreq.getAppBean().isFlag1Active()) { + flagURI = VitroVocabulary.vitroURI+"Flag1Value"+vreq.getPortal().getPortalId()+"Thing"; + } else { + 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())); +%> + + + + + +<%-- 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 <${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 <${titlePred}> ?title . + ?positionUri <${rdf}label> ?title. + + + + + SELECT ?existingOrgName WHERE { + ?positionUri <${involvedOrgNamePred}> ?existingOrgName } + + + ?positionUri <${involvedOrgNamePred}> ?organizationName . + + + + + SELECT ?startYearExisting WHERE { + ?positionUri <${startYearPred}> ?startYearExisting } + + + ?positionUri <${startYearPred}> ?startYear . + + + + + SELECT ?endYearExisting WHERE { + ?positionUri <${endYearPred}> ?endYearExisting } + + + ?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 <${positionInOrgPred}> ?existingOrgUri } + + + ?positionUri <${positionInOrgPred}> ?organizationUri . + ?organizationUri <${vivo}organizationForPosition> ?positionUri . + + + + @prefix rdf: <${rdf}>. + @prefix core: <${vivo}>. + + ?person core:personInPosition ?positionUri . + ?positionUri core:positionForPerson ?person . + ?positionUri rdf:type core:Position . + ?positionUri rdf:type <${flagURI}> . + + +http://vivoweb.org/ontology/core#Position +http://xmlns.com/foaf/0.1/Organization + + + + { + "formUrl" : "${formUrl}", + "editKey" : "${editKey}", + "urlPatternToReturnTo" : "/entity", + + "subject" : ["person", "${subjectUriJson}" ], + "predicate" : ["predicate", "${predicateUriJson}" ], + "object" : ["positionUri", "${objectUriJson}", "URI" ], + + "n3required" : [ "${n3ForStmtToPerson}", "${titleAssertion}", "${startYearAssertion}" ], + "n3optional" : [ "${organizationNameAssertion}","${organizationUriAssertion}", + "${endYearAssertion}"], + "newResources" : { "positionUri" : "${defaultNamespace}" }, + "urisInScope" : { }, + "literalsInScope": { }, + "urisOnForm" : [ "organizationUri" ], + "literalsOnForm" : [ "title", "organizationName", + "startYear", "endYear" ], + "filesOnForm" : [ ], + "sparqlForLiterals" : { }, + "sparqlForUris" : { }, + "sparqlForExistingLiterals" : { + "title" : "${titleExisting}", + "organizationName" : "${organizationNameExisting}", + "startYear" : "${startYearExisting}", + "endYear" : "${endYearExisting}" + }, + "sparqlForExistingUris" : { + "organizationUri" : "${organizationUriExisting}" + }, + "fields" : { + "title" : { + "newResource" : "false", + "validators" : [ "nonempty" ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ "${titleAssertion}" ] + }, + "organizationUri" : { + "newResource" : "false", + "validators" : [ ], + "optionsType" : "INDIVIDUALS_VIA_VCLASS", + "literalOptions" : [ "Select one" ], + "predicateUri" : "", + "objectClassUri" : "${organizationClass}", + "rangeDatatypeUri" : "", + "rangeLang" : "", + "assertions" : [ "${organizationUriAssertion}" ] + }, + "organizationName" : { + "newResource" : "false", + "validators" : [ ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "${stringDatatypeUriJson}", + "rangeLang" : "", + "assertions" : [ "${organizationNameAssertion}" ] + }, + "startYear" : { + "newResource" : "false", + "validators" : [ "nonempty", "datatype:${gYearDatatypeUriJson}" ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "${gYearDatatypeUriJson}", + "rangeLang" : "", + "assertions" : ["${startYearAssertion}"] + }, + "endYear" : { + "newResource" : "false", + "validators" : [ "datatype:${gYearDatatypeUriJson}" ], + "optionsType" : "UNDEFINED", + "literalOptions" : [ ], + "predicateUri" : "", + "objectClassUri" : "", + "rangeDatatypeUri" : "${gYearDatatypeUriJson}", + "rangeLang" : "", + "assertions" : ["${endYearAssertion}"] + } + } +} + +<% + 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"); + if (objectUri != null) { + editConfig.prepareForObjPropUpdate(model); + } else { + editConfig.prepareForNonUpdate(model); + } + + /* 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 entry for "+ subjectName); + submitLabel = "Save changes"; + } else { + request.setAttribute("title","Create a new position entry for " + subjectName); + submitLabel = "Create new position history entry"; + } + + List customJs = new ArrayList(Arrays.asList("forms/js/personHasPositionHistory.js")); + request.setAttribute("customJs", customJs); + + List customCss = new ArrayList(Arrays.asList("forms/css/personHasPositionHistory.css")); + request.setAttribute("customCss", customCss); +%> + + + +

${title}

+ +
" > +
+ If your organization is not listed, please add a new organization. +
+ +
+ +
+ +
+ +
+ +
+ + + + + +
+ +

+
+ + +