diff --git a/productMods/edit/forms/addAttendeeRoleToPerson.jsp b/productMods/edit/forms/addAttendeeRoleToPerson.jsp deleted file mode 100644 index b52958c2..00000000 --- a/productMods/edit/forms/addAttendeeRoleToPerson.jsp +++ /dev/null @@ -1,26 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addAuthorsToInformationResource.jsp b/productMods/edit/forms/addAuthorsToInformationResource.jsp deleted file mode 100644 index a0f3a654..00000000 --- a/productMods/edit/forms/addAuthorsToInformationResource.jsp +++ /dev/null @@ -1,427 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding authors to information resources - -Classes: -core:InformationResource - the information resource being edited -core:Authorship - primary new individual being created -foaf:Person - new or existing individual being linked to - -Data properties of Authorship: -core:authorRank - -Object properties (domain : range): - -core:informationResourceInAuthorship (InformationResource : Authorship) -core:linkedInformationResource (Authorship : InformationResource) - inverse of informationResourceInAuthorship - -core:linkedAuthor (Authorship : Person) -core:authorInAuthorship (Person : Authorship) - inverse of linkedAuthor - ---%> - -<%@ page import="java.util.List" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.Collections" %> - -<%@ 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.beans.DataPropertyComparator" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PublicationHasAuthorValidatorOld" %> -<%@ 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.lang.StringUtils" %> -<%@ page import="org.json.JSONObject" %> -<%@ 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.addAuthorsToInformationResource.jsp"); -%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - - String intDatatypeUri = XSD.xint.toString(); - vreq.setAttribute("intDatatypeUri", intDatatypeUri); - vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri)); -%> - - - - - - - -<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no -SPARQL queries for existing values. --%> - -<%-- 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 applies to both a new and an existing person --%> - - @prefix core: <${vivoCore}> . - - ?authorshipUri a core:Authorship ; - core:linkedInformationResource ?infoResource ; - core:authorRank ?rank . - - ?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 ; - <${label}> ?label . - - ?authorshipUri core:linkedAuthor ?newPerson . - ?newPerson core:authorInAuthorship ?authorshipUri . - - -${personClassUri} - - - - -{ - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "${returnPathAfterSubmit}", - - "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" : [ "personUri" ], - "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" : [ "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" : [ "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}"] - }, - "personUri" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "${personClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForExistingPerson}"] - } - } -} - - -<% - 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); - } - - editConfig.addValidator(new PublicationHasAuthorValidatorOld()); - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - - //for some reason we are comming from the add new and that is working - //but we also come from the edit, and that is not working. - editConfig.setObject(""); //this will force the edit config to always be an add, never an update - - editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing - - String subjectUri = vreq.getParameter("subjectUri"); - String predicateUri = vreq.getParameter("predicateUri"); - - String vivoCore = "http://vivoweb.org/ontology/core#"; - - //Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri); - Individual infoResource = ((Individual) request.getAttribute("subject")); - vreq.setAttribute("infoResourceName", infoResource.getName()); - - List authorships = infoResource.getRelatedIndividuals(predicateUri); - - List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/js/browserUtils.js", - "/edit/forms/js/addAuthorsToInformationResource.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/addAuthorsToInformationResource.css" - )); - request.setAttribute("customCss", customCss); - - String ulClass = ""; - List ulClasses = new ArrayList(); - - if (authorships.size() > 1) { - // This class triggers application of dd styles. Don't wait for js to add - // the ui-sortable class, because then the page flashes as the styles are updated. - ulClasses.add("dd"); - } - - if (ulClasses.size() > 0) { - ulClass="class=\"" + StringUtils.join(ulClasses, " ") + "\""; - } -%> - - - - - - - -

JSP form, must be removed for the 1.4!

- -<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> -

${title}

- -<%@ include file="unsupportedBrowserMessage.jsp" %> - -
-

Manage Authors

- -
    > -<% - String rankPredicateUri = vivoCore + "authorRank"; - - DataPropertyComparator comp = new DataPropertyComparator(rankPredicateUri); - Collections.sort(authorships, comp); - - int maxRank = 0; - int authorshipCount = authorships.size(); - -%> - - -<% - for ( Individual authorship : authorships ) { - - request.setAttribute("authorshipUri", authorship.getURI()); - request.setAttribute("authorshipName", authorship.getName()); - - DataPropertyStatement rankStmt = authorship.getDataPropertyStatement(rankPredicateUri); - if (rankStmt != null) { - maxRank = Integer.parseInt(rankStmt.getData()); - } - - request.setAttribute("author", authorship.getRelatedIndividual(vivoCore + "linkedAuthor")); - -%> -
  • - <%-- span.author will be used in the next phase, when we display a message that the author has been - removed. That text will replace the a.authorName, which will be removed. --%> - - <%-- This span is here to assign a width to. We can't assign directly to the a.authorName, - for the case when it's followed by an em tag - we want the width to apply to the whole thing. --%> - - - - - - - - - ${authorName} - - - - - - - - - ${authorshipName} (no linked author) - - - - - Remove - <%-- Undo --%> - -
  • - - -<% - } - - // A new author will be ranked last when added. - // This value is now inserted by JavaScript, but leave it here as a safety net in case page - // load reordering returns an error. - request.setAttribute("newRank", maxRank + 1); - request.setAttribute("rankPredicate", rankPredicateUri); -%> - -
- -<% if (authorshipCount == 0) { %> -

This publication currently has no authors specified.

-<% } %> - -
- -
- -<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> -
" > - -

Add an Author

- -

-

-

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

- -
- - -

- -

* required fields

-
-
- - - - - - - - diff --git a/productMods/edit/forms/addClinicalRoleToPerson.jsp b/productMods/edit/forms/addClinicalRoleToPerson.jsp deleted file mode 100644 index 5eb41709..00000000 --- a/productMods/edit/forms/addClinicalRoleToPerson.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addEditWebpageForm.jsp b/productMods/edit/forms/addEditWebpageForm.jsp deleted file mode 100644 index a087ef07..00000000 --- a/productMods/edit/forms/addEditWebpageForm.jsp +++ /dev/null @@ -1,301 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding or editing a webpage associated with an individual. The primary page, -manageWebpagesForIndividual.jsp, forwards to this page if: (a) we are adding a new page, or -(b) an edit link in the Manage Webpages view has been clicked. - -Object properties: -core:webpage (range: core:URLLink) -core:webpageOf (domain: core:URLLink) (inverse of core:webpage) - -Class: -core:URLLink - the link to be added to the individual - -Data properties of core:URLLink: -core:linkURI -core:linkAnchorText -core:rank - ---%> - -<%@ 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="com.hp.hpl.jena.query.ResultSet" %> -<%@ page import="com.hp.hpl.jena.rdf.model.RDFNode" %> -<%@ page import="com.hp.hpl.jena.query.QuerySolution" %> -<%@ page import="com.hp.hpl.jena.query.Dataset" %> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils" %> - -<%@ 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.addEditWebpageForm.jsp"); - -%> - -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace()); - - String subjectUri = (String) request.getAttribute("subjectUri"); - String propertyUri = (String) request.getAttribute("predicateUri"); - String objectUri = (String) request.getAttribute("objectUri"); - - String stringDatatypeUriJson = MiscWebUtils.escape(XSD.xstring.toString()); - String uriDatatypeUriJson = MiscWebUtils.escape(XSD.anyURI.toString()); - String intDatatypeUriJson = MiscWebUtils.escape(XSD.xint.toString()); -%> - - - - - - - - - - - - - -<%-- Enter here any class names to be used for constructing INDIVIDUALS_VIA_VCLASS pick lists - These are then referenced in the field's ObjectClassUri but not elsewhere. - NOTE that this class may not exist in the model, in which the only choice of type - that will show up is "web page", which will insert no new statements and just create - links of type vitro:Link --%> - -<%-- 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 ?urlExisting - WHERE { ?link <${linkUrl}> ?urlExisting } - -<%-- 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) --%> - - ?link <${linkUrl}> ?url . - - - - SELECT ?anchorExisting - WHERE { ?link <${linkAnchor}> ?anchorExisting } - - - ?link <${linkAnchor}> ?anchor . - - - - SELECT ?rankExisting - WHERE { ?link <${rank}> ?rankExisting } - - - ?link <${rank}> ?rank . - - -<%-- When not retrieving a literal via a datatype property, put the SPARQL statement into - the SparqlForExistingUris --%> - - - ?subject <${webpageProperty}> ?link . - ?link <${inverseProperty}> ?subject . - - ?link a <${linkClass}> ; - <${linkUrl}> ?url . - - - - - - - { - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "${returnPathAfterSubmit}", - - "subject" : ["subject", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["link", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForEdit}" ], - "n3optional" : [ "${rankAssertion}", "${anchorAssertion}" ], - "newResources" : { "link" : "${defaultNamespace}" }, - "urisInScope" : { }, - "literalsInScope" : { }, - "urisOnForm" : [ ], - "literalsOnForm" : [ "url", "anchor", "rank" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "url" : "${urlQuery}", - "anchor" : "${anchorQuery}", - "rank" : "${rankQuery}" - }, - "sparqlForExistingUris" : { }, - "fields" : { - "url" : { - "newResource" : "false", - "validators" : [ "nonempty", "datatype:${uriDatatypeUriJson}" , "httpUrl" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${uriDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${urlAssertion}" ] - }, - "anchor" : { - "newResource" : "false", - "validators" : [ "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${anchorAssertion}" ] - }, - "rank" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${intDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${rankAssertion}" ] - } - } - } - -<% - 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"); - if( objectUri != null ){ - editConfig.prepareForObjPropUpdate(model); - } else { - editConfig.prepareForNonUpdate(model); - } - - List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path() - )); - request.setAttribute("customCss", customCss); - - String subjectName = ((Individual)request.getAttribute("subject")).getName(); - - // Get largest existing rank value to compute hidden rank field value - int newRank = getMaxRank(objectUri, subjectUri, vreq) + 1; - -%> - - - - - - - - - - - - - <%-- Cancel to where ever we came from: either directly from the profile page, or from - the Manage Web Pages screen. The latter has added a url param to signal itself. --%> - - - - - - - -

JSP form, must be removed for the 1.4!

- - -

${title} <%= subjectName %>

- -
" > - - -

If left blank, the URL will be used when displaying a link to this webpage.

- - - -

- -

- - - - -<%! - -/* Note on ordering by rank in sparql: if there is a non-integer value on a link, that will be returned, - * since it's ranked highest. Preventing that would require getting all the ranks and sorting in Java, - * throwing out non-int values. - */ -private static String RANK_QUERY = "" - + "PREFIX core: \n" - + "SELECT DISTINCT ?rank WHERE { \n" - + " ?subject core:webpage ?link . \n" - + " ?link core:rank ?rank .\n" - + "} ORDER BY DESC(?rank) LIMIT 1"; - -private int getMaxRank(String objectUri, String subjectUri, VitroRequest vreq) { - - int maxRank = 0; // default value - if (objectUri == null) { // adding new webpage - String queryStr = QueryUtils.subUriForQueryVar(RANK_QUERY, "subject", subjectUri); - log.debug("Query string is: " + queryStr); - try { - ResultSet results = QueryUtils.getQueryResults(queryStr, vreq); - if (results != null && results.hasNext()) { // there is at most one result - QuerySolution soln = results.next(); - RDFNode node = soln.get("rank"); - if (node != null && node.isLiteral()) { - // node.asLiteral().getInt() won't return an xsd:string that - // can be parsed as an int. - int rank = Integer.parseInt(node.asLiteral().getLexicalForm()); - if (rank > maxRank) { - log.debug("setting maxRank to " + rank); - maxRank = rank; - } - } - } - } catch (NumberFormatException e) { - log.error("Invalid rank returned from query: not an integer value."); - } catch (Exception e) { - log.error(e, e); - } - } - return maxRank; -} - -%> diff --git a/productMods/edit/forms/addEditorRoleToPerson.jsp b/productMods/edit/forms/addEditorRoleToPerson.jsp deleted file mode 100644 index c982d386..00000000 --- a/productMods/edit/forms/addEditorRoleToPerson.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addGrantRoleToPerson.jsp b/productMods/edit/forms/addGrantRoleToPerson.jsp deleted file mode 100644 index e52de8a1..00000000 --- a/productMods/edit/forms/addGrantRoleToPerson.jsp +++ /dev/null @@ -1,469 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding a grant to an person for the predicates hasCo-PrincipalInvestigatorRole - and hasPrincipalInvestigatorRole. - -This is intended to create a set of statements like: - -?person core:hasPrincipalInvestigatorRole ?newRole. -?newRole rdf:type core:PrincipalInvestigatorRole ; - core:relatedRole ?someGrant . ---%> - -<%@ 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.configuration.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="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> -<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> - -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - - String intDatatypeUri = XSD.xint.toString(); - vreq.setAttribute("intDatatypeUri", intDatatypeUri); - vreq.setAttribute("intDatatypeUriJson", MiscWebUtils.escape(intDatatypeUri)); - - vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); - - String predicateUri = (String)request.getAttribute("predicateUri"); - ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri ); - if( op != null && op.getURIInverse() != null ){ - %> -<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%> -<%@page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> -<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%><%=op.getURIInverse()%> <% - }else{ - %> <% - } - - /* - There are 4 modes that this form can be in: - 1. Add, there is a subject and a predicate but no role and nothing else. - - 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on - the other end of the object's core:roleIn stmt. - - 3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the - other end of the object's core:roleIn stmt. This should be similar to an add but the form should be expanded. - - 4. Really bad node. multiple core:roleIn statements. - */ - - EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#roleIn"); - - if( mode == EditMode.ADD ) { - %> <% - } else if(mode == EditMode.EDIT){ - %> <% - } else if(mode == EditMode.REPAIR){ - %> <% - } - %> - -<%@page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%> - - - - - - - - - - - - - - - - - - -<% // set role type based on predicate -String subjectName = ((Individual) request.getAttribute("subject")).getName(); -if ( ((String)request.getAttribute("predicateUri")).endsWith("hasPrincipalInvestigatorRole") ) { %> - http://vivoweb.org/ontology/core#PrincipalInvestigatorRole - Principal Investigator - principal investigator entry for <%= subjectName %> - <% }else if ( ((String)request.getAttribute("predicateUri")).endsWith("hasCo-PrincipalInvestigatorRole") ) { %> - http://vivoweb.org/ontology/core#CoPrincipalInvestigatorRole - Co-Principal Investigator - co-principal investigator entry for <%= subjectName %> - <% }else { %> - http://vivoweb.org/ontology/core#InvestigatorRole - Investigator - investigator entry for <%= subjectName %> - <% } %> - -<%-- Configure add vs. edit --%> - - - - - - - - - - - - - - - <%-- editMode == "repair" --%> - - - - - - - - - @prefix core: <${vivoCore}> . - @prefix rdf: <${rdf}> . - - ?person ?rolePredicate ?role. - - ?role a ?roleType ; - core:roleIn ?grant . - - ?grant a core:Grant ; - core:relatedRole ?role . - - - - - ?role ?inverseRolePredicate ?person. - - - - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?startField-value . - ?startNode <${dateTimePrecision}> ?startField-precision . - - - - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?endField-value . - ?endNode <${dateTimePrecision}> ?endField-precision . - - - - @prefix rdfs: <${rdfs}> . - ?grant rdfs:label ?grantLabel . - - - - PREFIX core: <${vivoCore}> - PREFIX rdfs: <${rdfs}> - SELECT ?existingGrantLabel WHERE { - ?role core:roleIn ?existingGrant . - ?existingGrant rdfs:label ?existingGrantLabel . } - - - - PREFIX core: <${vivoCore}> - SELECT ?existingGrant WHERE { ?role core:roleIn ?existingGrant . } - - -${vivoOnt}#Grant - - - SELECT ?existingIntervalNode WHERE { - ?role <${roleToInterval}> ?existingIntervalNode . - ?existingIntervalNode <${type}> <${intervalType}> . } - - - - SELECT ?existingStartNode WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?existingStartNode . - ?existingStartNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingDateStart WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?existingDateStart . } - - - - SELECT ?existingStartPrecision WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimePrecision}> ?existingStartPrecision . } - - - - SELECT ?existingEndNode WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?existingEndNode . - ?existingEndNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingEndDate WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?existingEndDate . } - - - - SELECT ?existingEndPrecision WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimePrecision}> ?existingEndPrecision . } - - - - -{ - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/individual", - - "subject" : ["person", "${subjectUriJson}" ], - "predicate" : ["rolePredicate", "${predicateUriJson}" ], - "object" : ["role", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForGrantRole}" ], - - "n3optional" : [ "${n3ForGrantLabel}", "${n3ForInverse}", "${n3ForStart}", "${n3ForEnd}" ], - - "newResources" : { "role" : "${defaultNamespace}", - "grant" : "${defaultNamespace}", - "intervalNode" : "${defaultNamespace}", - "startNode" : "${defaultNamespace}", - "endNode" : "${defaultNamespace}" }, - "urisInScope" : { "roleType" : "${roleType}", - "inverseRolePredicate" : "${inversePredicate}" }, - "literalsInScope": { }, - "urisOnForm" : [ "grant" ], - "literalsOnForm" : [ "grantLabel", "existingGrantLabel" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "grantLabel":"${grantLabelQuery}" , - "startField-value" : "${existingStartDateQuery}", - "endField-value" : "${existingEndDateQuery}" - }, - "sparqlForExistingUris" : { - "grant":"${grantQuery}", - "intervalNode" : "${existingIntervalNodeQuery}", - "startNode" : "${existingStartNodeQuery}", - "endNode" : "${existingEndNodeQuery}", - "startField-precision": "${existingStartPrecisionQuery}", - "endField-precision" : "${existingEndPrecisionQuery}" - }, - "fields" : { - "grant" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "${grantTypeUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForGrantRole}" ] - }, - "grantLabel" : { - "newResource" : "false", - "validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : ["${n3ForGrantLabel}", "${n3ForGrantRole}" ] - }, - "existingGrantLabel" : { /* Needed iff we return from an invalid submission */ - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ ] - }, - "startField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForStart}" ] - }, - "endField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForEnd}" ] - } - } -} - - -<% - - EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); - - if (editConfig == null) { - editConfig = new EditConfiguration((String) request.getAttribute("editjson")); - EditConfiguration.putConfigInSession(editConfig,session); - //setup date time edit elements - Field startField = editConfig.getField("startField"); - startField.setEditElement( - new DateTimeWithPrecision(startField, - VitroVocabulary.Precision.YEAR.uri(), - VitroVocabulary.Precision.NONE.uri())); - Field endField = editConfig.getField("endField"); - endField.setEditElement( - new DateTimeWithPrecision(endField, - VitroVocabulary.Precision.YEAR.uri(), - VitroVocabulary.Precision.NONE.uri())); - editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); - } - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { - editConfig.prepareForObjPropUpdate(model); - // Return browser to person individual after editing an existing role. - } else { - editConfig.prepareForNonUpdate(model); - // NIHVIVO-1014 Return browser to person individual after editing an existing role. - // Return the browser to the new activity entity after adding a new role. - // editConfig.setEntityToReturnTo("?grant"); - } - - String subjectUri = vreq.getParameter("subjectUri"); - - List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/js/browserUtils.js", - "/edit/forms/js/customFormWithAutocomplete.js" - )); - request.setAttribute("customJs", customJs); - - List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/customFormWithAutocomplete.css" - )); - request.setAttribute("customCss", customCss); -%> - - - - - -

JSP form, must be removed for the 1.4!

- - -<% if( mode == EditMode.ERROR ){ %> -
This form is unable to handle the editing of this position because it is associated with - multiple Position individuals.
-<% }else{ %> - -

${formHeading}

- -<%@ include file="unsupportedBrowserMessage.jsp" %> - -<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> -
" > - -

- - <%-- Store this value in a hidden field, because the displayed field is disabled and doesn't submit. This ensures that when - returning from a validation error, we retain the value. --%> - - - - -
-

(Verify this match)

- <%-- Field value populated by JavaScript --%> - <%-- Needed iff we return from an invalid submission --%> -
- -

Years of Participation in Grant

- - - -

- -

* required fields

- - - - - - -<%-- Must be all one line for JavaScript. --%> - -PREFIX core: <${vivoCore}> SELECT ?grantUri WHERE {<${subjectUri}> <${predicateUri}> ?grantRole . ?grantRole core:roleIn ?grantUri .} - - - - -<% } %> - - diff --git a/productMods/edit/forms/addHeadOfRoleToPerson.jsp b/productMods/edit/forms/addHeadOfRoleToPerson.jsp deleted file mode 100644 index db3cb930..00000000 --- a/productMods/edit/forms/addHeadOfRoleToPerson.jsp +++ /dev/null @@ -1,41 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addMemberRoleToPerson.jsp b/productMods/edit/forms/addMemberRoleToPerson.jsp deleted file mode 100644 index 7e678d72..00000000 --- a/productMods/edit/forms/addMemberRoleToPerson.jsp +++ /dev/null @@ -1,10 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addOrganizerRoleToPerson.jsp b/productMods/edit/forms/addOrganizerRoleToPerson.jsp deleted file mode 100644 index ab6b054a..00000000 --- a/productMods/edit/forms/addOrganizerRoleToPerson.jsp +++ /dev/null @@ -1,26 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addOutreachRoleToPerson.jsp b/productMods/edit/forms/addOutreachRoleToPerson.jsp deleted file mode 100644 index b027cba4..00000000 --- a/productMods/edit/forms/addOutreachRoleToPerson.jsp +++ /dev/null @@ -1,40 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addPresenterRoleToPerson.jsp b/productMods/edit/forms/addPresenterRoleToPerson.jsp deleted file mode 100644 index 818c4d2a..00000000 --- a/productMods/edit/forms/addPresenterRoleToPerson.jsp +++ /dev/null @@ -1,17 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addPublicationToPerson.jsp b/productMods/edit/forms/addPublicationToPerson.jsp deleted file mode 100644 index eb36fd33..00000000 --- a/productMods/edit/forms/addPublicationToPerson.jsp +++ /dev/null @@ -1,352 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding a publication to an author - -Classes: -foaf:Person - the individual being edited -core:Authorship - primary new individual being created - -Object properties (domain : range): - -core:authorInAuthorship (Person : Authorship) -core:linkedAuthor (Authorship : Person) - inverse of authorInAuthorship - -core:linkedInformationResource (Authorship : InformationResource) -core:informationResourceInAuthorship (InformationResource : Authorship) - inverse of linkedInformationResource - ---%> - -<%@ 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.ObjectPropertyStatement"%> -<%@ 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.configuration.EditConfiguration" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.PersonHasPublicationValidatorOld" %> -<%@ 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="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> - -<%@ 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.addAuthorsToInformationResource.jsp"); - public static String nodeToPubProp = "http://vivoweb.org/ontology/core#linkedInformationResource"; -%> -<% - - VitroRequest vreq = new VitroRequest(request); - - String subjectUri = vreq.getParameter("subjectUri"); - String predicateUri = vreq.getParameter("predicateUri"); - String objectUri = vreq.getParameter("objectUri"); - - Individual obj = (Individual) request.getAttribute("object"); - - EditMode mode = FrontEndEditingUtils.getEditMode(request, nodeToPubProp); - - /* - There are 3 modes that this form can be in: - 1. Add. There is a subject and a predicate but no position and nothing else. - - 2. Repair a bad role node. There is a subject, predicate and object but there is no individual on the - other end of the object's core:linkedInformationResource stmt. This should be similar to an add but the form should be expanded. - - 3. Really bad node. Multiple core:authorInAuthorship statements. - - This form does not currently support normal edit mode where there is a subject, an object, and an individual on - the other end of the object's core:linkedInformationResource statement. We redirect to the publication profile - to edit the publication. - */ - - if( mode == EditMode.ADD ) { - %> <% - } else if(mode == EditMode.EDIT){ - // Because it's edit mode, we already know there's one and only one statement - ObjectPropertyStatement ops = obj.getObjectPropertyStatements(nodeToPubProp).get(0); - String pubUri = ops.getObjectURI(); - String forwardToIndividual = pubUri != null ? pubUri : objectUri; - %> - - - - <% - } else if(mode == EditMode.REPAIR){ - %> <% - } - - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - Individual subject = (Individual) request.getAttribute("subject"); - String subjectName = 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)); - -%> - - - - - - - -<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no -SPARQL queries for existing values. --%> - - - ?pubUri a ?pubType . - - - - ?pubUri <${label}> ?title . - - -<%-- This applies to both a new and an existing publication --%> - - @prefix core: <${vivoCore}> . - - ?authorshipUri a core:Authorship ; - core:linkedAuthor ?person . - - ?person core:authorInAuthorship ?authorshipUri . - - - - @prefix core: <${vivoCore}> . - - ?authorshipUri core:linkedInformationResource ?pubUri . - ?pubUri core:informationResourceInAuthorship ?authorshipUri . - - - - @prefix core: <${vivoCore}> . - - ?pubUri a ?pubType ; - <${label}> ?title . - - ?authorshipUri core:linkedInformationResource ?pubUri . - ?pubUri core:informationResourceInAuthorship ?authorshipUri . - - - - ["", "Select one"], - ["http://purl.org/ontology/bibo/AcademicArticle", "Academic Article"], - ["http://purl.org/ontology/bibo/Article", "Article"], - ["http://purl.org/ontology/bibo/AudioDocument", "Audio Document"], - ["http://vivoweb.org/ontology/core#BlogPosting", "Blog Posting"], - ["http://purl.org/ontology/bibo/Book", "Book"], - ["http://vivoweb.org/ontology/core#CaseStudy", "Case Study"], - ["http://vivoweb.org/ontology/core#Catalog", "Catalog"], - ["http://purl.org/ontology/bibo/Chapter", "Chapter"], - ["http://vivoweb.org/ontology/core#ConferencePaper", "Conference Paper"], - ["http://vivoweb.org/ontology/core#ConferencePoster", "Conference Poster"], - ["http://vivoweb.org/ontology/core#Database", "Database"], - ["http://purl.org/ontology/bibo/EditedBook", "Edited Book"], - ["http://vivoweb.org/ontology/core#EditorialArticle", "Editorial Article"], - ["http://purl.org/ontology/bibo/Film", "Film"], - ["http://vivoweb.org/ontology/core#Newsletter", "Newsletter"], - ["http://vivoweb.org/ontology/core#NewsRelease", "News Release"], - ["http://purl.org/ontology/bibo/Patent", "Patent"], - ["http://purl.obolibrary.org/obo/OBI_0000272", "Protocol"], - ["http://purl.org/ontology/bibo/Report", "Report"], - ["http://vivoweb.org/ontology/core#ResearchProposal", "Research Proposal"], - ["http://vivoweb.org/ontology/core#Review", "Review"], - ["http://vivoweb.org/ontology/core#Software", "Software"], - ["http://vivoweb.org/ontology/core#Speech", "Speech"], - ["http://purl.org/ontology/bibo/Thesis", "Thesis"], - ["http://vivoweb.org/ontology/core#Video", "Video"], - ["http://purl.org/ontology/bibo/Webpage", "Webpage"], - ["http://purl.org/ontology/bibo/Website", "Website"], - ["http://vivoweb.org/ontology/core#WorkingPaper", "Working Paper"] - - - -{ - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/individual", - - "subject" : ["person", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["authorshipUri", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForNewAuthorship}" ], - - "n3optional" : [ "${n3ForExistingPub}", "${n3ForNewPub}", - "${newPubNameAssertion}", "${newPubTypeAssertion}" ], - - "newResources" : { "authorshipUri" : "${defaultNamespace}", - "pubUri" : "${defaultNamespace}" }, - - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ "pubUri", "pubType" ], - "literalsOnForm" : [ "title" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { }, - "sparqlForExistingUris" : { }, - "fields" : { - "title" : { - "newResource" : "false", - "validators" : [ "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${n3ForNewPub}" ] - }, - "pubType" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "HARDCODED_LITERALS", - "literalOptions" : [ ${publicationTypeLiteralOptions} ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${newPubTypeAssertion}" ] - }, - "pubUri" : { - "newResource" : "true", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "${personClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForExistingPub}"] - } - } -} - - -<% - 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); - } - - editConfig.addValidator(new PersonHasPublicationValidatorOld()); - - Model model = (Model) application.getAttribute("jenaOntModel"); - - if (objectUri != null) { // editing existing (in this case, only repair is currently provided by the form) - editConfig.prepareForObjPropUpdate(model); - } else { // adding new - editConfig.prepareForNonUpdate(model); - } - - // Return to person, not publication. See NIHVIVO-1464. - // editConfig.setEntityToReturnTo("?pubUri"); - - List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/js/browserUtils.js", - "/edit/forms/js/customFormWithAutocomplete.js" - )); - request.setAttribute("customJs", customJs); - - List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/customFormWithAutocomplete.css" - )); - request.setAttribute("customCss", customCss); -%> - -<%-- Configure add vs. edit --%> - - - - - - - - - - - - - - - -

JSP form, must be removed for the 1.4!

- -<% if( mode == EditMode.ERROR ){ %> -
This form is unable to handle the editing of this position because it is associated with - multiple Position individuals.
-<% }else{ %> - -

${titleVerb} publication entry for <%= subjectName %>

- -<%@ include file="unsupportedBrowserMessage.jsp" %> - -<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> -
" > - -

- -
- -

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

(Verify this match)

- -
-
- -

- -

* required fields

-
- - - - -<%-- Must be all one line for JavaScript. --%> - -PREFIX core: <${vivoCore}> SELECT ?pubUri WHERE {<${subjectUri}> core:authorInAuthorship ?authorshipUri . ?authorshipUri core:linkedInformationResource ?pubUri .} - - - - -<% } %> - - diff --git a/productMods/edit/forms/addResearcherRoleToPerson.jsp b/productMods/edit/forms/addResearcherRoleToPerson.jsp deleted file mode 100644 index 141b1805..00000000 --- a/productMods/edit/forms/addResearcherRoleToPerson.jsp +++ /dev/null @@ -1,13 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addReviewerRoleToPerson.jsp b/productMods/edit/forms/addReviewerRoleToPerson.jsp deleted file mode 100644 index d181e77a..00000000 --- a/productMods/edit/forms/addReviewerRoleToPerson.jsp +++ /dev/null @@ -1,14 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addRoleToPersonTwoStage.jsp b/productMods/edit/forms/addRoleToPersonTwoStage.jsp deleted file mode 100644 index 8a982512..00000000 --- a/productMods/edit/forms/addRoleToPersonTwoStage.jsp +++ /dev/null @@ -1,673 +0,0 @@ -<%-- $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 ; - roleToActivityPredicate ?someActivity . - ?someActivity rdf:type core:ResearchActivity . - ?someActivity rdfs:label "activity title" . - - Important: This form cannot be directly used as a custom form. It has parameters that must be set. - See addClinicalRoleToPerson.jsp for an example. - ---%> - -<%@ page import="java.util.List" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.Set" %> -<%@ page import="java.util.HashSet" %> -<%@ page import="java.util.Iterator" %> - -<%@ page import="com.hp.hpl.jena.rdf.model.Model" %> -<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %> - -<%@ page import="org.json.JSONObject" %> -<%@ page import="org.json.JSONException" %> -<%@ page import="org.json.JSONArray" %> - -<%@ 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.configuration.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="edu.cornell.mannlib.vitro.webapp.utils.TitleCase" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils"%> - -<%@ page import="org.apache.commons.lang.StringUtils" %> -<%@ 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.edit.n3editing.configuration.Field"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%> - -<%! -public static Log log = LogFactory.getLog("edu.cornell.mannlib.vitro.webapp.jsp.edit.forms.addRoleToPersonTwoStage.jsp"); -%> - - -<%-- REQUIRED PARAMETERS --%> - -${param.roleDescriptor} <%-- Used in textual references to the role --%> -${param.roleType} <%-- uri of role individual type --%> - -<%-- For creating the role activity type select list: --%> -${param.roleActivityType_optionsType} -${param.roleActivityType_objectClassUri} -${param.roleActivityType_literalOptions} - - -<%-- OPTIONAL PARAMETERS --%> - - <%-- label for type selector field --%> - ${! empty param.typeSelectorLabel ? param.typeSelectorLabel : param.roleDescriptor } - - - ${! empty param.buttonText ? param.buttonText : param.roleDescriptor } - - - ${! empty param.roleToActivityPredicate ? param.roleToActivityPredicate : "http://vivoweb.org/ontology/core#roleIn" } - - - ${! empty param.activityToRolePredicate ? param.activityToRolePredicate : "http://vivoweb.org/ontology/core#relatedRole" } - -${! empty param.numDateFields ? param.numDateFields : 2 } - - ${! empty param.showRoleLabelField ? param.showRoleLabelField : true } - - -<% - - 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)); - - vreq.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); - - vreq.setAttribute("typeSelectorLabelTitleCase", - TitleCase.toTitleCase( (String)vreq.getAttribute("typeSelectorLabel"), false)); - String buttonText = (String) vreq.getAttribute("buttonText"); - vreq.setAttribute("buttonText", TitleCase.toTitleCase(buttonText)); - - ObjectProperty op = wdf.getObjectPropertyDao().getObjectPropertyByURI( predicateUri ); - if( op != null && op.getURIInverse() != null ){ - %> <%=op.getURIInverse()%> <% - }else{ - %> <% - } - -/* - There are 4 modes that this form can be in: - 1. Add, there is a subject and a predicate but no role and nothing else. - - 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on - the other end of the object's roleToActivity stmt. - - 3. Repair a bad role node. There is a subject, predicate and object but there is no individual on the - other end of the object's roleToActivity stmt. This should be similar to an add but the form should be expanded. - - 4. Really bad node. multiple roleToActivity statements. -*/ - - String roleToActivityPredicate = (String) vreq.getAttribute("roleToActivityPredicate"); - log.debug("roleToActivityPredicate = " + roleToActivityPredicate); - EditMode mode = FrontEndEditingUtils.getEditMode(request, roleToActivityPredicate); - - if( mode == EditMode.ADD ) { - %> <% - } else if(mode == EditMode.EDIT){ - %> <% - } else if(mode == EditMode.REPAIR){ - %> <% - } -%> - - - - - - - <%--blank triggers default URI generation behavior --%> - - - - - - - - - - - - -<%-- label and type required if we are doing an add or a repair, but not an edit --%> -<%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"," : "" %> -<%= (mode == EditMode.ADD || mode == EditMode.REPAIR) ? "\"nonempty\"" : "" %> -${showRoleLabelField ? "\"nonempty\"," : "" } - - - ?role <${label}> ?roleLabel . - - - - @prefix core: <${vivoCore}> . - - ?person ?rolePredicate ?role. - ?role a <${roleType}> . - ?role <${roleToActivityPredicate}> ?roleActivity . - ?roleActivity <${activityToRolePredicate}> ?role . - - - - ?roleActivity a ?roleActivityType . - - - - @prefix core: <${vivoCore}> . - ?role <${roleToActivityPredicate}> ?roleActivity . - ?roleActivity <${activityToRolePredicate}> ?role . - - - - ?roleActivity <${label}> ?activityLabel . - - - - ?role ?inverseRolePredicate ?person. - - - - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?startField-value . - ?startNode <${dateTimePrecision}> ?startField-precision . - - - - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?endField-value . - ?endNode <${dateTimePrecision}> ?endField-precision . - - - - PREFIX core: <${vivoCore}> - PREFIX rdfs: <${rdfs}> - SELECT ?existingTitle WHERE { - ?role <${roleToActivityPredicate}> ?existingActivity . - ?existingActivity rdfs:label ?existingTitle . } - - - - PREFIX core: <${vivoCore}> - SELECT ?existingActivity WHERE { ?role <${roleToActivityPredicate}> ?existingActivity . } - - - - SELECT ?existingRoleLabel WHERE { ?role <${label}> ?existingRoleLabel . } - - -<% -request.setAttribute("typeQuery", getActivityTypeQuery(vreq)); -log.debug("TYPE QUERY: " + vreq.getAttribute("typeQuery")); -%> -${typeQuery} - -<%-- - - PREFIX core: <${vivoCore}> - PREFIX vitro: <${vitro}> - SELECT ?existingActivityType WHERE { - ?role <${roleToActivityPredicate}> ?existingActivity . - ?existingActivity vitro:mostSpecificType ?existingActivityType . - } - ---%> - - - SELECT ?existingIntervalNode WHERE { - ?role <${roleToInterval}> ?existingIntervalNode . - ?existingIntervalNode <${type}> <${intervalType}> . } - - - - SELECT ?existingStartNode WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?existingStartNode . - ?existingStartNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingDateStart WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?existingDateStart . } - - - - SELECT ?existingStartPrecision WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimePrecision}> ?existingStartPrecision . } - - - - SELECT ?existingEndNode WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?existingEndNode . - ?existingEndNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingEndDate WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?existingEndDate . } - - - - SELECT ?existingEndPrecision WHERE { - ?role <${roleToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimePrecision}> ?existingEndPrecision . } - - - -{ - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/individual", - - "subject" : ["person", "${subjectUriJson}" ], - "predicate" : ["rolePredicate", "${predicateUriJson}" ], - "object" : ["role", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForNewRole}" ], - "n3optional" : [ "${n3ForActivityLabel}", "${n3ForActivityType}", "${n3ForInverse}", - "${n3ForStart}", "${n3ForEnd}", "${roleLabelAssertion}" ], - - "newResources" : { "role" : "${defaultNamespace}", - "roleActivity" : "${defaultNamespace}", - "intervalNode" : "${defaultNamespace}", - "startNode" : "${defaultNamespace}", - "endNode" : "${defaultNamespace}" }, - - "urisInScope" : { "inverseRolePredicate" : "${inversePredicate}" }, - "literalsInScope": { }, - "urisOnForm" : [ "roleActivity", "roleActivityType" ], - "literalsOnForm" : [ "activityLabel", "roleLabel" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "activityLabel":"${activityLabelQuery}", - "roleLabel":"${roleLabelQuery}", - "startField-value" : "${existingStartDateQuery}", - "endField-value" : "${existingEndDateQuery}" - }, - "sparqlForExistingUris" : { - "roleActivity":"${activityQuery}" , - "roleActivityType":"${activityTypeQuery}" , - "intervalNode" : "${existingIntervalNodeQuery}", - "startNode" : "${existingStartNodeQuery}", - "endNode" : "${existingEndNodeQuery}", - "startField-precision": "${existingStartPrecisionQuery}", - "endField-precision" : "${existingEndPrecisionQuery}" - }, - "fields" : { - "activityLabel" : { - "newResource" : "false", - "validators" : [ ${labelRequired} "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : ["${n3ForActivityLabel}" ] - }, - "roleActivityType" : { - "newResource" : "true", - "validators" : [ ${typeRequired} ], - "optionsType" : "${roleActivityType_optionsType}", - "literalOptions" : [ ${roleActivityType_literalOptions } ], - "predicateUri" : "", - "objectClassUri" : "${roleActivityType_objectClassUri}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForActivityType}" ] - }, - "roleActivity" : { - "newResource" : "true", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForRoleToActivity}" ] - }, - "roleLabel" : { - "newResource" : "false", - "validators" : [ ${roleLabelRequired} "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : ["${roleLabelAssertion}" ] - }, - "startField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForStart}" ] - }, - "endField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForEnd}" ] - } - } -} - - -<% - EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); - if (editConfig == null) { - editConfig = new EditConfiguration((String) request.getAttribute("editjson")); - EditConfiguration.putConfigInSession(editConfig,session); - - //set up date time edit elements - Field startField = editConfig.getField("startField"); - startField.setEditElement( - new DateTimeWithPrecision(startField, - VitroVocabulary.Precision.YEAR.uri(), - VitroVocabulary.Precision.NONE.uri())); - Field endField = editConfig.getField("endField"); - endField.setEditElement( - new DateTimeWithPrecision(endField, - VitroVocabulary.Precision.YEAR.uri(), - VitroVocabulary.Precision.NONE.uri())); - } - - editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { - editConfig.prepareForObjPropUpdate(model); - // Return browser to person individual after editing an existing role. - } else { - editConfig.prepareForNonUpdate(model); - // NIHVIVO-1014 Return browser to person individual after editing an existing role. - // Return the browser to the new activity entity after adding a new role. - // editConfig.setEntityToReturnTo("?roleActivity"); - } - - List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/edit/forms/js/customFormWithAutocomplete.js" - )); - request.setAttribute("customJs", customJs); - - List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/customFormWithAutocomplete.css" - )); - request.setAttribute("customCss", customCss); -%> - - - - - - <%-- Includes edit AND repair mode --%> - "> - - - ${editMode == "repair" ? "" : "disabled" } - - - - - - - - - - - - - - - -

JSP form, must be removed for the 1.4!

- -<% if( mode == EditMode.ERROR ){ %> -
This form is unable to handle the editing of this role because it is associated with - multiple ${param.roleDescriptor} individuals.
-<% }else{ %> - -

${titleVerb} ${roleDescriptor} entry for <%= subjectName %>

- <%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE IN THIS FORM WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> - -
" > - -

- -
- -

- - <%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when - returning from a validation error, we retain the values. --%> - - - - - -
- <%-- RY maybe make this a label and input field. See what looks best. --%> -

(Verify this match)

- -
- - -

-
- - - - - - -

Years of Participation in ###

- - -
-
- -
- -

- -

* required fields

-
- - - - -<% } %> - - - -<%! - -private static final String VIVO_CORE = "http://vivoweb.org/ontology/core#"; - -private static final String DEFAULT_ACTIVITY_TYPE_QUERY = - "PREFIX core: <" + VIVO_CORE + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE { \n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + - "}"; - -private static final String SUBCLASS_ACTIVITY_TYPE_QUERY = - "PREFIX core: <" + VIVO_CORE + ">\n" + - "PREFIX rdfs: <" + VitroVocabulary.RDFS + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE {\n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + - " ?existingActivityType rdfs:subClassOf ?objectClassUri . \n" + - "}"; - -private static final String CLASSGROUP_ACTIVITY_TYPE_QUERY = - "PREFIX core: <" + VIVO_CORE + ">\n" + - "PREFIX vitro: <" + VitroVocabulary.vitroURI + "> \n" + - "SELECT ?existingActivityType WHERE { \n" + - " ?role ?predicate ?existingActivity . \n" + - " ?existingActivity vitro:mostSpecificType ?existingActivityType . \n" + - " ?existingActivityType vitro:inClassGroup ?classgroup . \n" + - "}"; - -/* - * The activity type query results must be limited to the values in the activity type select element. - * Sometimes the query returns a superclass such as owl:Thing instead. - * Make use of vitro:mostSpecificType so that, for example, an individual is both a - * core:InvitedTalk and a core:Presentation, core:InvitedTalk is selected. - * vitro:mostSpecificType alone may not suffice, since it does not guarantee that the value returned - * is in the select list. - * We could still have problems if the value from the select list is not a vitro:mostSpecificType, - * but that is unlikely. - */ -private String getActivityTypeQuery(VitroRequest vreq) { - - String activityTypeQuery = null; - - String optionsType = vreq.getParameter("roleActivityType_optionsType"); - - // Note that this value is overloaded to specify either object class uri or classgroup uri - String objectClassUri = vreq.getParameter("roleActivityType_objectClassUri"); - - if (StringUtils.isNotBlank(objectClassUri)) { - log.debug("objectClassUri = " + objectClassUri); - - if ("VCLASSGROUP".equals(optionsType)) { - activityTypeQuery = CLASSGROUP_ACTIVITY_TYPE_QUERY; - activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "classgroup", objectClassUri); - - } else if ("CHILD_VCLASSES".equals(optionsType)) { - activityTypeQuery = SUBCLASS_ACTIVITY_TYPE_QUERY; - activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "objectClassUri", objectClassUri); - - } else { - activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY; - } - - // Select options are hardcoded - } else if ("HARDCODED_LITERALS".equals(optionsType)) { - - String typeLiteralOptions = vreq.getParameter("roleActivityType_literalOptions"); - if (StringUtils.isNotBlank(typeLiteralOptions)) { - try { - JSONObject json = new JSONObject("{values: [" + typeLiteralOptions + "]}"); - Set typeUris = new HashSet(); - JSONArray values = json.getJSONArray("values"); - int valueCount = values.length(); - for (int i = 0; i < valueCount; i++) { - JSONArray option = values.getJSONArray(i); - String uri = option.getString(0); - if (StringUtils.isNotBlank(uri)) { - typeUris.add("(?existingActivityType = <" + uri + ">)"); - } - } - String typeFilters = "FILTER (" + StringUtils.join(typeUris, "||") + ")"; - activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY.replaceAll("}$", "") + typeFilters + "}"; - } catch (JSONException e) { - activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY; - } - - } else { - activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY; - } - - } else { - activityTypeQuery = DEFAULT_ACTIVITY_TYPE_QUERY; - } - - String roleToActivityPredicate = (String) vreq.getAttribute("roleToActivityPredicate"); - activityTypeQuery = QueryUtils.subUriForQueryVar(activityTypeQuery, "predicate", roleToActivityPredicate); - - log.debug("Activity type query: " + activityTypeQuery); - - return activityTypeQuery; -} -%> diff --git a/productMods/edit/forms/addServiceProviderRoleToPerson.jsp b/productMods/edit/forms/addServiceProviderRoleToPerson.jsp deleted file mode 100644 index f39a975a..00000000 --- a/productMods/edit/forms/addServiceProviderRoleToPerson.jsp +++ /dev/null @@ -1,41 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/addTeacherRoleToPerson.jsp b/productMods/edit/forms/addTeacherRoleToPerson.jsp deleted file mode 100644 index 09375b8e..00000000 --- a/productMods/edit/forms/addTeacherRoleToPerson.jsp +++ /dev/null @@ -1,15 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - - - - - - - - - - \ No newline at end of file diff --git a/productMods/edit/forms/images/sortable_icon.png b/productMods/edit/forms/images/sortable_icon.png deleted file mode 100644 index 8cae70f7..00000000 Binary files a/productMods/edit/forms/images/sortable_icon.png and /dev/null differ diff --git a/productMods/edit/forms/js/manageWebpagesForIndividual.js b/productMods/edit/forms/js/manageWebpagesForIndividual.js deleted file mode 100644 index 6c9479ab..00000000 --- a/productMods/edit/forms/js/manageWebpagesForIndividual.js +++ /dev/null @@ -1,226 +0,0 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var manageWebpages = { - - /* *** Initial page setup *** */ - - onLoad: function() { - - this.mixIn(); - this.initPage(); - }, - - mixIn: function() { - - // Get the custom form data from the page - $.extend(this, customFormData); - }, - - // Initial page setup. Called only at page load. - initPage: function() { - - this.initWebpageData(); - - this.bindEventListeners(); - - this.initDragAndDrop(); - - if ($('.webpage').length) { // make sure we have at least one webpage - // Reorder web pages on page load so that previously unranked items get a rank. Otherwise, - // when we add a new web page, it will get put ahead of any previously unranked web pages, instead - // of at the end of the list. (It is also helpful to normalize the data before we get started.) - this.reorder(); - } - }, - - // On page load, associate data with each list item. Then we don't - // have to keep retrieving data from or modifying the DOM as we manipulate the - // items. - initWebpageData: function() { - $('.webpage').each(function(index) { - $(this).data(webpageData[index]); - - // RY We might still need position to put back an element after reordering - // failure. Rank might already have been reset? Check. - $(this).data('position', index+1); - }); - }, - - bindEventListeners: function() { - - $('.remove').click(function() { - manageWebpages.removeWebpage(this); - return false; - }); - - }, - - /* *** Ajax initializations *** */ - - /* Drag-and-drop */ - initDragAndDrop: function() { - - var webpages = $('#webpageList'); - - // No DD if < 2 items - if (webpages.children('li') < 2) { - return; - } - - $('.webpageName').each(function() { - $(this).attr('title', 'Drag and drop to reorder web pages'); - }); - - webpages.sortable({ - cursor: 'move', - update: function(event, ui) { - manageWebpages.reorder(event, ui); - } - }); - }, - - // Reorder webpages. Called on page load and after drag-and-drop and remove. - // Event and ui parameters are defined only in the case of drag-and-drop. - reorder: function(event, ui) { - var webpages = $('li.webpage').map(function(index, el) { - return $(this).data('webpageUri'); - }).get(); - - $.ajax({ - url: manageWebpages.reorderUrl, - data: { - predicate: manageWebpages.rankPredicate, - individuals: webpages - }, - traditional: true, // serialize the array of individuals for the server - dataType: 'json', - type: 'POST', - success: function(data, status, request) { - var pos; - $('.webpage').each(function(index){ - pos = index + 1; - // Set the new position for this element. The only function of this value - // is so we can reset an element to its original position in case reordering fails. - manageWebpages.setPosition(this, pos); - }); - }, - error: function(request, status, error) { - // ui is undefined on page load and after a webpage removal. - if (ui) { - // Put the moved item back to its original position. - // Seems we need to do this by hand. Can't see any way to do it with jQuery UI. ?? - var pos = manageWebpages.getPosition(ui.item), - nextpos = pos + 1, - webpages = $('#webpageList'), - next = manageWebpages.findWebpage('position', nextpos); - - if (next.length) { - ui.item.insertBefore(next); - } - else { - ui.item.appendTo(webpages); - } - - alert('Reordering of web pages failed.'); - } - } - }); - }, - - getPosition: function(webpage) { - return $(webpage).data('position'); - }, - - setPosition: function(webpage, pos) { - $(webpage).data('position', pos); - }, - - findWebpage: function(key, value) { - var matchingWebpage = $(); // if we don't find one, return an empty jQuery set - - $('.webpage').each(function() { - var webpage = $(this); - if ( webpage.data(key) === value ) { - matchingWebpage = webpage; - return false; // stop the loop - } - }); - - return matchingWebpage; - }, - - removeWebpage: function(link) { - // RY Upgrade this to a modal window - var removeLast = false, - message = 'Are you sure you want to remove this web page?'; - - if (!confirm(message)) { - return false; - } - - if ($(link)[0] === $('.remove:last')[0]) { - removeLast = true; - } - - $.ajax({ - url: $(link).attr('href'), - type: 'POST', - data: { - deletion: $(link).parents('.webpage').data('webpageUri') - }, - dataType: 'json', - context: link, // context for callback - complete: function(request, status) { - var webpage; - - if (status === 'success') { - - webpage = $(this).parents('.webpage'); - - webpage.fadeOut(400, function() { - var numWebpages; - - // Remove from the DOM - $(this).remove(); - - // Actions that depend on the webpage having been removed from the DOM: - numWebpages = $('.webpage').length; // retrieve the new length after removing webpage from the DOM - - // If removed item not last, reorder to remove any gaps - if (numWebpages > 0 && ! removeLast) { - manageWebpages.reorder(); - } - - // If fewer than two webpages remaining, disable drag-drop - if (numWebpages < 2) { - manageWebpages.disableDD(); - } - }); - - } else { - alert('Error processing request: web page not removed'); - } - } - }); - }, - - // Disable DD and associated cues if only one item remains - disableDD: function() { - var webpages = $('#webpageList'); - - $('#webpageList').sortable({ disable: true } ) - /* Use class dd rather than jQuery UI's class ui-sortable, so that we can remove - * the class if there's fewer than one webpage. We don't want to remove the ui-sortable - * class, in case we want to re-enable DD without a page reload (e.g., if implementing - * adding a webpage via Ajax request). - */ - .removeClass('dd'); - - $('.webpageName').removeAttr('title'); - } - -}; - -$(document).ready(function() { - manageWebpages.onLoad(); -}); diff --git a/productMods/edit/forms/manageWebpagesForIndividual.jsp b/productMods/edit/forms/manageWebpagesForIndividual.jsp deleted file mode 100644 index ae39c5af..00000000 --- a/productMods/edit/forms/manageWebpagesForIndividual.jsp +++ /dev/null @@ -1,200 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Landing page for managing web pages associated with an individual. From here, we do one of three things: - -1. If arriving here by clicking add link on profile, go directly to add form. -2. If arriving here by edit link on the profile page, stay here for web page management (can add, edit, or delete). -3. If arriving here after an add/edit form submission, stay here for additional web page management. - ---%> - -<%@ page import="java.util.List" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.Map" %> - -<%@ page import="com.hp.hpl.jena.rdf.model.Literal" %> -<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %> -<%@ page import="com.hp.hpl.jena.query.ResultSet" %> -<%@ page import="com.hp.hpl.jena.rdf.model.RDFNode" %> -<%@ page import="com.hp.hpl.jena.query.QuerySolution" %> -<%@ page import="com.hp.hpl.jena.query.Dataset" %> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.VClass" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.EditConfiguration" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataProperty" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"%> -<%@ 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="edu.cornell.mannlib.vitro.webapp.dao.jena.QueryUtils" %> - -<%@ page import="org.apache.commons.lang.StringUtils" %> -<%@ 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.manageWebpagesForIndividual.jsp"); -%> - -<% - - String objectUri = (String) request.getAttribute("objectUri"); - String view = request.getParameter("view"); - - if ( "form".equals(view) || // the url specifies form view - ( view == null && objectUri == null ) ) { // add form always starts with form - - %> <% - - } // else stay here to manage webpages - - VitroRequest vreq = new VitroRequest(request); - //WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - //vreq.setAttribute("defaultNamespace", wdf.getDefaultNamespace()); - - String subjectName = ((Individual)request.getAttribute("subject")).getName(); - String subjectUri = (String) request.getAttribute("subjectUri"); - String predicateUri = (String) request.getAttribute("predicateUri"); - - List> webpages = getWebpages(subjectUri, vreq); - vreq.setAttribute("webpages", webpages); - - String ulClass = ""; - List ulClasses = new ArrayList(); - if (webpages.size() > 1) { - // This class triggers application of dd styles. Don't wait for js to add - // the ui-sortable class, because then the page flashes as the styles are updated. - ulClasses.add("dd"); - } - if (ulClasses.size() > 0) { - ulClass="class=\"" + StringUtils.join(ulClasses, " ") + "\""; - } - - List customJs = new ArrayList(Arrays.asList(JavaScript.JQUERY_UI.path(), - "/edit/forms/js/manageWebpagesForIndividual.js" - )); - request.setAttribute("customJs", customJs); - - List customCss = new ArrayList(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/manageWebpagesForIndividual.css" - )); - request.setAttribute("customCss", customCss); -%> - - - - - - - - - - - - - - - - - - - - -

JSP form, must be removed for the 1.4!

- -

<%= subjectName %>

- -

Manage Web Pages

- - - -
    > - - -

    This individual currently has no web pages specified. Add a new web page by clicking on the button below.

    -
    - - -
  • - ${ empty webpage.anchor ? webpage.url : webpage.anchor } - - ${anchor} - - - Edit | - Delete - -
  • - - -
    -
- - - - - - - - - -<%! - -private static String WEBPAGE_QUERY = "" - + "PREFIX core: \n" - + "SELECT DISTINCT ?link ?url ?anchor ?rank WHERE { \n" - + " ?subject core:webpage ?link . \n" - + " OPTIONAL { ?link core:linkURI ?url } \n" - + " OPTIONAL { ?link core:linkAnchorText ?anchor } \n" - + " OPTIONAL { ?link core:rank ?rank } \n" - + "} ORDER BY ?rank"; - - -private List> getWebpages(String subjectUri, VitroRequest vreq) { - - String queryStr = QueryUtils.subUriForQueryVar(WEBPAGE_QUERY, "subject", subjectUri); - log.debug("Query string is: " + queryStr); - List> webpages = new ArrayList>(); - try { - ResultSet results = QueryUtils.getQueryResults(queryStr, vreq); - while (results.hasNext()) { - QuerySolution soln = results.nextSolution(); - RDFNode node = soln.get("link"); - if (node.isURIResource()) { - webpages.add(QueryUtils.querySolutionToStringValueMap(soln)); - } - } - } catch (Exception e) { - log.error(e, e); - } - - return webpages; -} - -%> diff --git a/productMods/edit/forms/newIndividualForm.jsp b/productMods/edit/forms/newIndividualForm.jsp deleted file mode 100644 index ddc61220..00000000 --- a/productMods/edit/forms/newIndividualForm.jsp +++ /dev/null @@ -1,195 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding a new Individual from the siteAdmin page. - -This form is not associated with an object property, it is reached because the -html:form on dataInput.jsp has an input element like: - - -This form is intended to only do the addition of an individual. It is not configured with sparql -for existing so it cannot handle an update. It will not have a subject, predicate or object -parameter set up by editRequestDispatch. - ---%> - -<%@ 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.VClass"%> -<%@ 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.configuration.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.edit.n3editing.configuration.preprocessors.FoafNameToRdfsLabelPreprocessor"%> -<%@ 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.newIndividualForm"); - public static String FOAF_PERSON = "http://xmlns.com/foaf/0.1/Person"; -%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - - VClass type = wdf.getVClassDao().getVClassByURI(vreq.getParameter("typeOfNew")); - - Boolean isPersonType = Boolean.FALSE; - List superTypes = wdf.getVClassDao().getAllSuperClassURIs(vreq.getParameter("typeOfNew")); - if( superTypes != null ){ - for( String typeUri : superTypes){ - if( FOAF_PERSON.equals(typeUri)) { - isPersonType = Boolean.TRUE; - break; - } - } - } - - List customCss = new ArrayList(Arrays.asList("/edit/forms/css/customForm.css" - )); - request.setAttribute("customCss", customCss); -%> - -<%= type.getName() %> -<%= isPersonType %> - - - - - - - - - - - @prefix rdf: <${rdf}> . - ?newInd rdf:type <${param.typeOfNew}> . - - - - @prefix foaf: <${foaf}> . - ?newInd foaf:firstName ?firstName ; - foaf:lastName ?lastName . - - - - @prefix rdfs: <${rdfs}> . - ?newInd rdfs:label ?label . - - - - { - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/individual", - - "subject" : ["subjectNotUsed", "" ], - "predicate" : ["predicateNotUsed", "" ], - "object" : ["objectNotUsed", "", "URI" ], - - "n3required" : [ "${n3ForType}" ], - - "n3optional" : [ "${n3ForPersonNames}" , "${n3ForNonPersonRdfsLabel}" ], - - "newResources" : { "newInd" : "${defaultNamespace}" }, - - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ ], - "literalsOnForm" : [ "label", "firstName", "lastName" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { }, - "sparqlForExistingUris" : { }, - "fields" : { - "label" : { - "newResource" : "false", - "validators" : [ ${labelValidation} ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ ] - }, - "firstName" : { - "newResource" : "false", - "validators" : [ ${nameValidation} ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ ] - }, - "lastName" : { - "newResource" : "false", - "validators" : [ ${nameValidation} ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ ] - } - } -} - -<% - EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); - if (editConfig == null) { - editConfig = new EditConfiguration((String) request.getAttribute("editjson")); - EditConfiguration.putConfigInSession(editConfig,session); - } - editConfig.setEntityToReturnTo("?newInd"); - - //deal with rdfs:labe for firstname/lastname - editConfig.addModelChangePreprocessor(new FoafNameToRdfsLabelPreprocessor()); - - //this form always is always doing a non-update: - Model model = (Model) application.getAttribute("jenaOntModel"); - editConfig.prepareForNonUpdate(model); -%> - - - - - -

JSP form, must be removed for the 1.4!

- -

Create a new ${typeName}

- -
" > - - - - - - - - - - -

-

* required fields

- - - diff --git a/productMods/edit/forms/organizationHasPositionHistory.jsp b/productMods/edit/forms/organizationHasPositionHistory.jsp deleted file mode 100644 index a4a93a54..00000000 --- a/productMods/edit/forms/organizationHasPositionHistory.jsp +++ /dev/null @@ -1,336 +0,0 @@ -<%-- $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.configuration.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.beans.ObjectProperty"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> -<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> -<%@ taglib prefix="v" uri="http://vitro.mannlib.cornell.edu/vitro/tags" %> - -<%-- This form is for the object property between Organizations and Positions. --%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior -%> - -<%-- Define predicates used in n3 assertions and sparql queries --%> - - - - - - - - - - - - - - - - - - - - - -http://xmlns.com/foaf/0.1/Person - -<%-- 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 <${label}> ?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 <${label}> ?title. - - - -<%-- 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 ?existingPersonUri WHERE { - ?positionUri <${positionForPerson}> ?existingPersonUri } - - - - ?positionUri <${positionForPerson}> ?personUri . - ?personUri <${personInPosition}> ?positionUri . - - - - ?organizationUri <${orgForPositionPred}> ?positionUri . - ?positionUri <${positionInOrgPred}> ?organizationUri . - ?positionUri a ?positionType . - - - - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?startField-value . - ?startNode <${dateTimePrecision}> ?startField-precision . - - - - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?endField-value . - ?endNode <${dateTimePrecision}> ?endField-precision . - - - - SELECT ?existingIntervalNode WHERE { - ?positionUri <${positionToInterval}> ?existingIntervalNode . - ?existingIntervalNode <${type}> <${intervalType}> . } - - - - SELECT ?existingStartNode WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?existingStartNode . - ?existingStartNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingDateStart WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?existingDateStart . } - - - - SELECT ?existingStartPrecision WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimePrecision}> ?existingStartPrecision . } - - - - SELECT ?existingEndNode WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?existingEndNode . - ?existingEndNode <${type}> <${dateTimeValueType}> .} - - - - SELECT ?existingEndDate WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?existingEndDate . } - - - - SELECT ?existingEndPrecision WHERE { - ?positionUri <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimePrecision}> ?existingEndPrecision . } - - - - ?positionUri a ?positionType . - - - - SELECT ?existingPositionType WHERE { - ?positionUri a ?existingPositionType . } - - - -${positionClass} - - - { - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/entity", - - "subject" : ["organizationUri", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["positionUri", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForStmtToOrg}", "${titleAssertion}" , "${personUriAssertion}", "${positionTypeAssertion}"], - "n3optional" : [ "${n3ForStart}" , "${n3ForEnd}" ], - "newResources" : { "positionUri" : "${defaultNamespace}", - "intervalNode" : "${defaultNamespace}", - "startNode" : "${defaultNamespace}", - "endNode" : "${defaultNamespace}" }, - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ "personUri", "positionType" ], - "literalsOnForm" : [ "title" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "title" : "${titleExisting}", - "startField-value" : "${existingStartDateQuery}", - "endField-value" : "${existingEndDateQuery}" - }, - "sparqlForExistingUris" : { - "personUri" : "${personUriExisting}", - "positionType" : "${positionTypeQuery}" , - "intervalNode" : "${existingIntervalNodeQuery}", - "startNode" : "${existingStartNodeQuery}", - "endNode" : "${existingEndNodeQuery}", - "startField-precision": "${existingStartPrecisionQuery}", - "endField-precision" : "${existingEndPrecisionQuery}" - }, - "fields" : { - "title" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${titleAssertion}" ] - }, - "personUri" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "INDIVIDUALS_VIA_VCLASS", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "${personClassUri}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${personUriAssertion}" ] - }, - "positionType" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "CHILD_VCLASSES_WITH_PARENT", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${positionClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${positionTypeAssertion}" ] - }, - "startField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForStart}"] - }, - "endField" : { - "newResource" : "false", - "validators" : [], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForEnd}"] - } - } -} - - - -<% - - EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); - if (editConfig == null) { - editConfig = new EditConfiguration( - (String) request - .getAttribute("editjson")); - EditConfiguration.putConfigInSession(editConfig,session); - - //setup date time edit elements - Field startField = editConfig.getField("startField"); - startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(),VitroVocabulary.Precision.NONE.uri())); - Field endField = editConfig.getField("endField"); - endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(),VitroVocabulary.Precision.NONE.uri())); - - editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); - } - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { - editConfig.prepareForObjPropUpdate(model); - } else { - editConfig.prepareForNonUpdate(model); - } - - List customCss = new ArrayList(Arrays.asList(Css.CUSTOM_FORM.path() - )); - request.setAttribute("customCss", customCss); - - /* prepare the and text for the submit button */ - Individual subject = (Individual) request.getAttribute("subject"); - String submitLabel = ""; - if (objectUri != null) { - request.setAttribute("title","Edit position history entry for "+ subject.getName()); - submitLabel = "Save Changes"; - } else { - request.setAttribute("title","Create position history entry for " + subject.getName()); - submitLabel = "Create Position History"; - } -%> - -<jsp:include page="${preForm}"/> - -<h1>JSP form, must be removed for the 1.4!</h1> - -<h2>${title}</h2> -<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > - <v:input type="text" label="Position Title ${requiredHint}" id="title" size="30"/> - <v:input type="select" label="Position Type ${requiredHint}" id="positionType" /> - <v:input type="select" label="Person" id="personUri" /> - <v:input id="startField" label="Start Year ${yearHint}" /> - <v:input id="endField" label="End Year ${yearHint}" /> - <p class="submit"><v:input type="submit" id="submit" value="<%=submitLabel%>" cancel="true"/></p> -</form> - -<jsp:include page="${postForm}"/> - diff --git a/productMods/edit/forms/personHasEducationalTraining.jsp b/productMods/edit/forms/personHasEducationalTraining.jsp deleted file mode 100644 index 1951504d..00000000 --- a/productMods/edit/forms/personHasEducationalTraining.jsp +++ /dev/null @@ -1,567 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding an educational attainment to an individual - -Classes: -core:EducationalTraining - primary new individual being created -foaf:Person - existing individual -foaf:Organization - new or existing individual -core:AcademicDegree - existing individual - -Data properties of EducationalTraining: -core:majorField -core:departmentOrSchool -core:supplementalInformation - -Object properties (domain : range) - -core:educationalTraining (Person : EducationalTraining) - inverse of core:educationalTrainingOf -core:educationalTrainingOf (EducationalTraining : Person) - inverse of core:educationalTraining - -core:degreeEarned (EducationalTraining : AcademicDegree) - inverse of core:degreeOutcomeOf -core:degreeOutcomeOf (AcademicDegree : EducationalTraining) - inverse of core:degreeEarned - -core:organizationGrantingDegree (EducationalTraining : Organization) - no inverse - -Future version --------------- -Classes: -core:DateTimeValue -core:DateTimeValuePrecision -Object properties: -core:dateTimeValue (EducationalTraining : DateTimeValue) -core:dateTimePrecision (DateTimeValue : DateTimeValuePrecision) ---%> - -<%@ 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.dao.VitroVocabulary.Precision"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.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" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.JavaScript" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.Css" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> -<%@page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> - -<%@ 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.personHasEducationalBackground.jsp"); -%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); - - /* - There are 4 modes that this form can be in: - 1. Add, there is a subject and a predicate but no position and nothing else. - - 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on - the other end of the object's core:trainingAtOrganization stmt. - - 3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the - other end of the object's core:trainingAtOrganization stmt. This should be similar to an add but the form should be expanded. - - 4. Really bad node. multiple core:trainingAtOrganization statements. - */ - - EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#trainingAtOrganization"); - - if( mode == EditMode.ADD ) { - %> <c:set var="editMode" value="add"/><% - } else if(mode == EditMode.EDIT){ - %> <c:set var="editMode" value="edit"/><% - } else if(mode == EditMode.REPAIR){ - %> <c:set var="editMode" value="repair"/><% - } -%> - -<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" /> -<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" /> -<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" /> -<c:set var="label" value="${rdfs}label" /> -<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" /> -<c:set var="degreeClass" value="${vivoCore}AcademicDegree" /> - -<%-- Define predicates used in n3 assertions and sparql queries --%> -<c:set var="majorFieldPred" value="${vivoCore}majorField" /> -<c:set var="deptPred" value="${vivoCore}departmentOrSchool" /> -<c:set var="infoPred" value="${vivoCore}supplementalInformation" /> -<c:set var="degreeEarned" value="${vivoCore}degreeEarned" /> -<c:set var="degreeOutcomeOf" value="${vivoCore}degreeOutcomeOf" /> -<c:set var="trainingAtOrg" value="${vivoCore}trainingAtOrganization" /> - -<c:set var="dateTimeValue" value="${vivoCore}dateTime"/> -<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/> -<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/> - -<c:set var="ToInterval" value="${vivoCore}dateTimeInterval"/> -<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/> -<c:set var="intervalToStart" value="${vivoCore}start"/> -<c:set var="intervalToEnd" value="${vivoCore}end"/> - -<%-- Assertions for adding a new educational training entry --%> -<v:jsonset var="orgTypeAssertion"> - ?org a ?orgType . -</v:jsonset> - -<v:jsonset var="orgLabelAssertion"> - ?org <${label}> ?orgLabel . -</v:jsonset> - -<v:jsonset var="degreeAssertion" > - ?edTraining <${degreeEarned}> ?degree . - ?degree <${degreeOutcomeOf}> ?edTraining . -</v:jsonset> - -<v:jsonset var="majorFieldAssertion" > - ?edTraining <${majorFieldPred}> ?majorField . -</v:jsonset> - -<v:jsonset var="n3ForStart"> - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?startField-value . - ?startNode <${dateTimePrecision}> ?startField-precision . -</v:jsonset> - -<v:jsonset var="n3ForEnd"> - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?endField-value . - ?endNode <${dateTimePrecision}> ?endField-precision . -</v:jsonset> - -<v:jsonset var="deptAssertion" > - ?edTraining <${deptPred}> ?dept . -</v:jsonset> - -<v:jsonset var="infoAssertion" > - ?edTraining <${infoPred}> ?info . -</v:jsonset> - -<v:jsonset var="n3ForNewEdTraining"> - @prefix core: <${vivoCore}> . - - ?person core:educationalTraining ?edTraining . - - ?edTraining a core:EducationalTraining ; - core:educationalTrainingOf ?person ; - <${trainingAtOrg}> ?org . -</v:jsonset> - -<%-- This property has no inverse --%> -<v:jsonset var="n3ForEdTrainingToOrg" > - ?edTraining <${trainingAtOrg}> ?org . -</v:jsonset> - -<%-- Queries for editing an existing educational training entry --%> - -<v:jsonset var="orgQuery" > - SELECT ?existingOrg WHERE { - ?edTraining <${trainingAtOrg}> ?existingOrg . } -</v:jsonset> - -<v:jsonset var="orgLabelQuery" > - SELECT ?existingOrgLabel WHERE { - ?edTraining <${trainingAtOrg}> ?existingOrg . - ?existingOrg <${label}> ?existingOrgLabel . - } -</v:jsonset> - -<%-- Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another -type is returned and we don't get a match to the select element options. --%> -<v:jsonset var="orgTypeQuery" > - PREFIX rdfs: <${rdfs}> - SELECT ?existingOrgType WHERE { - ?edTraining <${trainingAtOrg}> ?existingOrg . - ?existingOrg a ?existingOrgType . - ?existingOrgType rdfs:subClassOf <${orgClass}> . - } -</v:jsonset> - -<v:jsonset var="degreeQuery" > - SELECT ?existingDegree WHERE { - ?edTraining <${degreeEarned}> ?existingDegree . } -</v:jsonset> - -<v:jsonset var="majorFieldQuery" > - SELECT ?existingMajorField WHERE { - ?edTraining <${majorFieldPred}> ?existingMajorField . } -</v:jsonset> - -<v:jsonset var="deptQuery" > - SELECT ?existingDept WHERE { - ?edTraining <${deptPred}> ?existingDept . } -</v:jsonset> - -<v:jsonset var="infoQuery" > - SELECT ?existingInfo WHERE { - ?edTraining <${infoPred}> ?existingInfo . } -</v:jsonset> - - - <v:jsonset var="existingIntervalNodeQuery" > - SELECT ?existingIntervalNode WHERE { - ?edTraining <${ToInterval}> ?existingIntervalNode . - ?existingIntervalNode <${type}> <${intervalType}> . } -</v:jsonset> - - <v:jsonset var="existingStartNodeQuery" > - SELECT ?existingStartNode WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?existingStartNode . - ?existingStartNode <${type}> <${dateTimeValueType}> .} -</v:jsonset> - -<v:jsonset var="existingStartDateQuery" > - SELECT ?existingDateStart WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?existingDateStart . } -</v:jsonset> - -<v:jsonset var="existingStartPrecisionQuery" > - SELECT ?existingStartPrecision WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimePrecision}> ?existingStartPrecision . } -</v:jsonset> - - - <v:jsonset var="existingEndNodeQuery" > - SELECT ?existingEndNode WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?existingEndNode . - ?existingEndNode <${type}> <${dateTimeValueType}> .} -</v:jsonset> - -<v:jsonset var="existingEndDateQuery" > - SELECT ?existingEndDate WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?existingEndDate . } -</v:jsonset> - -<v:jsonset var="existingEndPrecisionQuery" > - SELECT ?existingEndPrecision WHERE { - ?edTraining <${ToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimePrecision}> ?existingEndPrecision . } -</v:jsonset> - -<v:jsonset var="orgClassUriJson">${orgClass}</v:jsonset> -<v:jsonset var="degreeClassUriJson">${degreeClass}</v:jsonset> - -<c:set var="editjson" scope="request"> - { - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/entity", - - "subject" : ["person", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["edTraining", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForNewEdTraining}", "${orgLabelAssertion}", "${orgTypeAssertion}" ], - - "n3optional" : [ "${n3ForEdTrainingToOrg}", "${majorFieldAssertion}", - "${degreeAssertion}", "${deptAssertion}", "${infoAssertion}" , "${n3ForStart}", "${n3ForEnd}"], - - "newResources" : { "edTraining" : "${defaultNamespace}", - "org" : "${defaultNamespace}" , - "intervalNode" : "${defaultNamespace}", - "startNode" : "${defaultNamespace}", - "endNode" : "${defaultNamespace}" }, - - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ "org", "orgType", "degree" ], - "literalsOnForm" : [ "orgLabel", "majorField", "dept", "info" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "orgLabel" : "${orgLabelQuery}", - "majorField" : "${majorFieldQuery}", - "dept" : "${deptQuery}", - "info" : "${infoQuery}", - "startField-value" : "${existingStartDateQuery}", - "endField-value" : "${existingEndDateQuery}" - }, - "sparqlForExistingUris" : { - "org" : "${orgQuery}", - "orgType" : "${orgTypeQuery}", - "degree" : "${degreeQuery}", - "intervalNode" : "${existingIntervalNodeQuery}", - "startNode" : "${existingStartNodeQuery}", - "endNode" : "${existingEndNodeQuery}", - "startField-precision": "${existingStartPrecisionQuery}", - "endField-precision" : "${existingEndPrecisionQuery}" - }, - "fields" : { - "degree" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "INDIVIDUALS_VIA_VCLASS", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${degreeClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${degreeAssertion}" ] - }, - "majorField" : { - "newResource" : "false", - "validators" : [ "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${majorFieldAssertion}" ] - }, - "startField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForStart}" ] - }, - "endField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForEnd}" ] - }, - "org" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "INDIVIDUALS_VIA_VCLASS", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${orgClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForEdTrainingToOrg}" ] - }, - "orgLabel" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${orgLabelAssertion}" ] - }, - "orgType" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "CHILD_VCLASSES", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${orgClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${orgTypeAssertion}" ] - }, - "dept" : { - "newResource" : "false", - "validators" : [ "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : ["${deptAssertion}"] - }, - "info" : { - "newResource" : "false", - "validators" : [ "datatype:${stringDatatypeUriJson}" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : ["${infoAssertion}"] - } - } -} -</c:set> -<% - log.debug(request.getAttribute("editjson")); - - EditConfiguration editConfig = EditConfiguration.getConfigFromSession(session,request); - if (editConfig == null) { - editConfig = new EditConfiguration((String) request.getAttribute("editjson")); - - //setup date time edit elements - Field startField = editConfig.getField("startField"); - // arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel]) - startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri())); - Field endField = editConfig.getField("endField"); - endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri())); - - editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); - - EditConfiguration.putConfigInSession(editConfig,session); - } - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { // editing existing - editConfig.prepareForObjPropUpdate(model); - } else { // adding new - editConfig.prepareForNonUpdate(model); - } - - editConfig.setTemplate("personHasEducationalTraining.ftl"); - editConfig.setSubmitToUrl("/edit/processRdfForm2.jsp"); - - String subjectName = ((Individual) request.getAttribute("subject")).getName(); - - List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/edit/forms/js/customFormWithAutocomplete.js" - )); - request.setAttribute("customJs", customJs); - - List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/customFormWithAutocomplete.css" - )); - request.setAttribute("customCss", customCss); -%> - -<c:set var="subjectName" value="<%= subjectName %>" /> - -<%-- Configure add vs. edit --%> -<c:choose> - <c:when test='${editMode == "add"}'> - <c:set var="titleVerb" value="Create" /> - <c:set var="submitButtonText" value="Education and Training" /> - <c:set var="disabledVal" value="" /> - </c:when> - <c:otherwise> - <c:set var="titleVerb" value="Edit" /> - <c:set var="submitButtonText" value="Edit Education and Training" /> - <c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set> - </c:otherwise> -</c:choose> - -<%-- -This goes to an experimental FM based form: -<jsp:forward page="/N3EditForm"/> ---%> - -<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" /> -<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" /> - -<jsp:include page="${preForm}" /> -<h1>JSP form, must be removed for the 1.4!</h1> - -<% if( mode == EditMode.ERROR ){ %> - <div>This form is unable to handle the editing of this position because it is associated with - multiple Position individuals.</div> -<% }else{ %> - -<h2>${titleVerb} education and training entry for ${subjectName}</h2> - -<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > - - <v:input type="select" label="Degree" id="degree" /> - - <v:input type="text" label="Major Field of Degree" id="majorField" size="30" /> - - <v:input id="startField" label="Start Year <span class='hint'>(YYYY)</span>" /> - <v:input id="endField" label="End Year <span class='hint'>(YYYY)</span>" /> - - <p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p> - - <p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p> - - <%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when - returning from a validation error, we retain the values. --%> - <c:if test="${editMode == 'edit'}"> - <v:input type="hidden" id="orgType" /> - <v:input type="hidden" id="orgLabel" /> - </c:if> - - <div class="acSelection"> - - <p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p> - <v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript --> - </div> - - <v:input type="text" label="Department or School Name within the ###" id="dept" size="50" /> - - <v:input type="text" label="Supplemental Information" id="info" size="50" /> - <p>e.g., <em>Postdoctoral training</em> or <em>Transferred</em></p> - - <p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p> - - <p id="requiredLegend" class="requiredHint">* required fields</p> -</form> - -<c:url var="acUrl" value="/autocomplete?tokenize=true" /> - -<script type="text/javascript"> -var customFormData = { - acUrl: '${acUrl}', - editMode: '${editMode}', - submitButtonTextType: 'compound', - defaultTypeName: 'organization' -}; -</script> - -<% } %> - -<jsp:include page="${postForm}"/> diff --git a/productMods/edit/forms/personHasPositionHistory.jsp b/productMods/edit/forms/personHasPositionHistory.jsp deleted file mode 100644 index cab18dc5..00000000 --- a/productMods/edit/forms/personHasPositionHistory.jsp +++ /dev/null @@ -1,481 +0,0 @@ -<%-- $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.configuration.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="edu.cornell.mannlib.vitro.webapp.edit.elements.DateTimeWithPrecision"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.Field"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils"%> -<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils.EditMode"%> - -<%@ page import="org.apache.commons.logging.Log" %> -<%@ page import="org.apache.commons.logging.LogFactory" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.validators.DateTimeIntervalValidation"%> - -<%@ 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", ""); //empty string triggers default new URI behavior - - request.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - request.setAttribute("gYearDatatypeUriJson", MiscWebUtils.escape(XSD.gYear.toString())); - -/* - There are 4 modes that this form can be in: - 1. Add, there is a subject and a predicate but no position and nothing else. - - 2. normal edit where everything should already be filled out. There is a subject, a object and an individual on - the other end of the object's core:personInOrganization stmt. - - 3. Repair a bad role node. There is a subject, prediate and object but there is no individual on the - other end of the object's core:personInOrganization stmt. This should be similar to an add but the form should be expanded. - - 4. Really bad node. multiple core:personInOrganization statements. -*/ - - EditMode mode = FrontEndEditingUtils.getEditMode(request, "http://vivoweb.org/ontology/core#positionInOrganization"); - - if( mode == EditMode.ADD ) { - %> <c:set var="editMode" value="add"/><% - } else if(mode == EditMode.EDIT){ - %> <c:set var="editMode" value="edit"/><% - } else if(mode == EditMode.REPAIR){ - %> <c:set var="editMode" value="repair"/><% - } -%> - -<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" /> -<c:set var="type" value="<%= VitroVocabulary.RDF_TYPE %>" /> -<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" /> -<c:set var="label" value="${rdfs}label" /> -<c:set var="positionClass" value="${vivoCore}Position" /> -<c:set var="orgClass" value="http://xmlns.com/foaf/0.1/Organization" /> - -<%-- Define predicates used in n3 assertions and sparql queries --%> -<c:set var="positionInOrgPred" value="${vivoCore}positionInOrganization" /> -<c:set var="orgForPositionPred" value="${vivoCore}organizationForPosition" /> - -<c:set var="dateTimeValue" value="${vivoCore}dateTime"/> -<c:set var="dateTimeValueType" value="${vivoCore}DateTimeValue"/> -<c:set var="dateTimePrecision" value="${vivoCore}dateTimePrecision"/> -<c:set var="edToDateTime" value="${vivoCore}dateTimeInterval"/> - -<c:set var="positionToInterval" value="${vivoCore}dateTimeInterval"/> -<c:set var="intervalType" value="${vivoCore}DateTimeInterval"/> -<c:set var="intervalToStart" value="${vivoCore}start"/> -<c:set var="intervalToEnd" value="${vivoCore}end"/> - -<%-- Assertions for adding a new role --%> - -<v:jsonset var="orgTypeAssertion"> - ?org a ?orgType . -</v:jsonset> - -<v:jsonset var="orgLabelAssertion"> - ?org <${label}> ?orgLabel . -</v:jsonset> - -<v:jsonset var="positionTitleAssertion" > - ?position <${label}> ?positionTitle . -</v:jsonset> - -<v:jsonset var="positionTypeAssertion"> - ?position a ?positionType . -</v:jsonset> - -<v:jsonset var="n3ForNewPosition"> - @prefix core: <${vivoCore}> . - - ?person core:personInPosition ?position . - - ?position a ?positionType ; - core:positionForPerson ?person ; - <${positionInOrgPred}> ?org . - - ?org <${orgForPositionPred}> ?position . -</v:jsonset> - -<v:jsonset var="n3ForPositionToOrg" > - ?position <${positionInOrgPred}> ?org . - ?org <${orgForPositionPred}> ?position . -</v:jsonset> - -<v:jsonset var="n3ForStart"> - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?startField-value . - ?startNode <${dateTimePrecision}> ?startField-precision . -</v:jsonset> - -<v:jsonset var="n3ForEnd"> - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?endField-value . - ?endNode <${dateTimePrecision}> ?endField-precision . -</v:jsonset> - -<%-- Queries for editing an existing role --%> - -<v:jsonset var="orgQuery" > - SELECT ?existingOrg WHERE { - ?position <${positionInOrgPred}> ?existingOrg . } -</v:jsonset> - -<v:jsonset var="orgLabelQuery" > - SELECT ?existingOrgLabel WHERE { - ?position <${positionInOrgPred}> ?existingOrg . - ?existingOrg <${label}> ?existingOrgLabel . - } -</v:jsonset> - -<%-- Limit type to subclasses of foaf:Organization. Otherwise, sometimes owl:Thing or another -type is returned and we don't get a match to the select element options. --%> -<v:jsonset var="orgTypeQuery" > - PREFIX rdfs: <${rdfs}> - SELECT ?existingOrgType WHERE { - ?position <${positionInOrgPred}> ?existingOrg . - ?existingOrg a ?existingOrgType . - ?existingOrgType rdfs:subClassOf <${orgClass}> . - } -</v:jsonset> - -<v:jsonset var="positionTitleQuery" > - SELECT ?existingPositionTitle WHERE { - ?position <${label}> ?existingPositionTitle . } -</v:jsonset> - -<v:jsonset var="positionTypeQuery"> - SELECT ?existingPositionType WHERE { - ?position a ?existingPositionType . } -</v:jsonset> - - - <v:jsonset var="existingIntervalNodeQuery" > - SELECT ?existingIntervalNode WHERE { - ?position <${positionToInterval}> ?existingIntervalNode . - ?existingIntervalNode <${type}> <${intervalType}> . } -</v:jsonset> - - <v:jsonset var="existingStartNodeQuery" > - SELECT ?existingStartNode WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?existingStartNode . - ?existingStartNode <${type}> <${dateTimeValueType}> .} -</v:jsonset> - -<v:jsonset var="existingStartDateQuery" > - SELECT ?existingDateStart WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimeValue}> ?existingDateStart . } -</v:jsonset> - -<v:jsonset var="existingStartPrecisionQuery" > - SELECT ?existingStartPrecision WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToStart}> ?startNode . - ?startNode <${type}> <${dateTimeValueType}> . - ?startNode <${dateTimePrecision}> ?existingStartPrecision . } -</v:jsonset> - - - <v:jsonset var="existingEndNodeQuery" > - SELECT ?existingEndNode WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?existingEndNode . - ?existingEndNode <${type}> <${dateTimeValueType}> .} -</v:jsonset> - -<v:jsonset var="existingEndDateQuery" > - SELECT ?existingEndDate WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimeValue}> ?existingEndDate . } -</v:jsonset> - -<v:jsonset var="existingEndPrecisionQuery" > - SELECT ?existingEndPrecision WHERE { - ?position <${positionToInterval}> ?intervalNode . - ?intervalNode <${type}> <${intervalType}> . - ?intervalNode <${intervalToEnd}> ?endNode . - ?endNode <${type}> <${dateTimeValueType}> . - ?endNode <${dateTimePrecision}> ?existingEndPrecision . } -</v:jsonset> - -<v:jsonset var="positionClassUriJson">${positionClass}</v:jsonset> -<v:jsonset var="orgClassUriJson">${orgClass}</v:jsonset> - -<c:set var="requiredHint" value="<span class='requiredHint'> *</span>" /> -<c:set var="yearHint" value="<span class='hint'>(YYYY)</span>" /> - -<%-- Configure add vs. edit --%> -<c:choose> - <c:when test='${editMode == "add"}'> - <c:set var="titleVerb" value="Create" /> - <c:set var="submitButtonText" value="Position" /> - <c:set var="disabledVal" value="" /> - </c:when> - <c:otherwise> - <c:set var="titleVerb" value="Edit" /> - <c:set var="submitButtonText" value="Edit Position" /> - <c:set var="disabledVal">${editMode == "repair" ? "" : "disabled" }</c:set> - </c:otherwise> -</c:choose> - -<c:set var="editjson" scope="request"> - { - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "/entity", - - "subject" : ["person", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["position", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForNewPosition}", "${positionTitleAssertion}", "${positionTypeAssertion}", - "${orgLabelAssertion}", "${orgTypeAssertion}" ], - - "n3optional" : [ "${n3ForStart}", "${n3ForEnd}" ], - - "newResources" : { "position" : "${defaultNamespace}", - "org" : "${defaultNamespace}", - "intervalNode" : "${defaultNamespace}", - "startNode" : "${defaultNamespace}", - "endNode" : "${defaultNamespace}" }, - - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ "org", "orgType", "positionType" ], - "literalsOnForm" : [ "positionTitle", "orgLabel" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { - "orgLabel" : "${orgLabelQuery}", - "positionTitle" : "${positionTitleQuery}", - "startField-value" : "${existingStartDateQuery}", - "endField-value" : "${existingEndDateQuery}" - }, - "sparqlForExistingUris" : { - "org" : "${orgQuery}", - "orgType" : "${orgTypeQuery}", - "positionType" : "${positionTypeQuery}" , - "intervalNode" : "${existingIntervalNodeQuery}", - "startNode" : "${existingStartNodeQuery}", - "endNode" : "${existingEndNodeQuery}", - "startField-precision": "${existingStartPrecisionQuery}", - "endField-precision" : "${existingEndPrecisionQuery}" - }, - "fields" : { - "positionTitle" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${positionTitleAssertion}" ] - }, - "positionType" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "CHILD_VCLASSES_WITH_PARENT", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${positionClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${positionTypeAssertion}" ] - }, - "org" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "INDIVIDUALS_VIA_VCLASS", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${orgClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForPositionToOrg}" ] - }, - "orgLabel" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${orgLabelAssertion}" ] - }, - "orgType" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "CHILD_VCLASSES", - "literalOptions" : [ "Select one" ], - "predicateUri" : "", - "objectClassUri" : "${orgClassUriJson}", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${orgTypeAssertion}" ] - }, - "startField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForStart}"] - }, - "endField" : { - "newResource" : "false", - "validators" : [ ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : ["${n3ForEnd}"] - } - } -} -</c:set> - -<% - //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); - - //setup date time edit elements - Field startField = editConfig.getField("startField"); - // arguments for DateTimeWithPrecision are (fieldName, minimumPrecision, [requiredLevel]) - startField.setEditElement(new DateTimeWithPrecision(startField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri())); - Field endField = editConfig.getField("endField"); - endField.setEditElement(new DateTimeWithPrecision(endField, VitroVocabulary.Precision.YEAR.uri(), VitroVocabulary.Precision.NONE.uri())); - - editConfig.addValidator(new DateTimeIntervalValidation("startField","endField") ); - } - - Model model = (Model) application.getAttribute("jenaOntModel"); - - String objectUri = (String) request.getAttribute("objectUri"); - if (objectUri != null) { // editing existing - editConfig.prepareForObjPropUpdate(model); - } else { // adding new - editConfig.prepareForNonUpdate(model); - } - - List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/edit/forms/js/customFormWithAutocomplete.js" - )); - request.setAttribute("customJs", customJs); - - List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/customFormWithAutocomplete.css" - )); - request.setAttribute("customCss", customCss); - - String subjectName = ((Individual) request.getAttribute("subject")).getName(); -%> - -<jsp:include page="${preForm}" /> - -<h1>JSP form, must be removed for the 1.4!</h1> - -<% if( mode == EditMode.ERROR ){ %> - <div>This form is unable to handle the editing of this position because it is associated with - multiple Position individuals.</div> -<% }else{ %> - -<h2>${titleVerb} position entry for <%= subjectName %></h2> - -<form class="customForm" action="<c:url value="/edit/processRdfForm2.jsp"/>" > - - <p class="inline"><v:input type="select" label="Organization Type ${requiredHint}" name="orgType" disabled="${disabledVal}" id="typeSelector" /></p> - - <div class="fullViewOnly"> - - <%-- <p> needed to create wrapper for show/hide --%> - <p><v:input type="text" id="relatedIndLabel" name="orgLabel" label="### Name ${requiredHint}" cssClass="acSelector" disabled="${disabledVal}" size="50" /></p> - - <%-- Store these values in hidden fields, because the displayed fields are disabled and don't submit. This ensures that when - returning from a validation error, we retain the values. --%> - <c:if test="${editMode == 'edit'}"> - <v:input type="hidden" id="orgType" /> - <v:input type="hidden" id="orgLabel" /> - </c:if> - - <div class="acSelection"> - <%-- RY maybe make this a label and input field. See what looks best. --%> - <p class="inline"><label></label><span class="acSelectionInfo"></span> <a href="<c:url value="/individual?uri=" />" class="verifyMatch">(Verify this match)</a></p> - <v:input type="hidden" id="org" cssClass="acUriReceiver" /> <!-- Field value populated by JavaScript --> - </div> - - <v:input type="text" label="Position Title ${requiredHint}" id="positionTitle" size="30" /> - <v:input type="select" label="Position Type ${requiredHint}" id="positionType" /> - - <v:input id="startField" label="Start Year <span class='hint'>(YYYY)</span>" /> - <v:input id="endField" label="End Year <span class='hint'>(YYYY)</span>" /> - - </div> - - <p class="submit"><v:input type="submit" id="submit" value="${submitButtonText}" cancel="true"/></p> - - <p id="requiredLegend" class="requiredHint">* required fields</p> -</form> - -<c:url var="acUrl" value="/autocomplete?tokenize=true" /> - -<script type="text/javascript"> -var customFormData = { - acUrl: '${acUrl}', - editMode: '${editMode}', - submitButtonTextType: 'compound', - defaultTypeName: 'organization' // used in repair mode, to generate button text and org name field label -}; -</script> -<% } %> - -<jsp:include page="${postForm}"/> diff --git a/productMods/edit/forms/terminologyAnnotation.jsp b/productMods/edit/forms/terminologyAnnotation.jsp deleted file mode 100644 index b4104115..00000000 --- a/productMods/edit/forms/terminologyAnnotation.jsp +++ /dev/null @@ -1,300 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%-- Custom form for adding terminology annotation ---%> - -<%@ page import="java.util.List" %> -<%@ page import="java.util.ArrayList" %> -<%@ page import="java.util.Arrays" %> -<%@ page import="java.util.Collections" %> - -<%@ page import="com.hp.hpl.jena.rdf.model.Model" %> -<%@ page import="com.hp.hpl.jena.vocabulary.XSD" %> -<%@ page import="com.hp.hpl.jena.vocabulary.RDFS" %> - -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.Individual" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyComparator" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary" %> -<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.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.lang.StringUtils" %> -<%@ page import="org.json.JSONObject" %> -<%@ 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.terminologyAnnotation.jsp"); -%> -<% - VitroRequest vreq = new VitroRequest(request); - WebappDaoFactory wdf = vreq.getWebappDaoFactory(); - vreq.setAttribute("defaultNamespace", ""); //empty string triggers default new URI behavior - - vreq.setAttribute("stringDatatypeUriJson", MiscWebUtils.escape(XSD.xstring.toString())); - -%> - -<c:set var="vivoCore" value="http://vivoweb.org/ontology/core#" /> -<c:set var="rdfs" value="<%= VitroVocabulary.RDFS %>" /> -<c:set var="label" value="${rdfs}label" /> -<c:set var="foaf" value="http://xmlns.com/foaf/0.1/" /> -<c:set var="personClassUri" value="${foaf}Person" /> - -<%-- Unlike other custom forms, this form does not allow edits of existing authors, so there are no -SPARQL queries for existing values. --%> - - -<v:jsonset var="n3ForTerminology"> - @prefix core: <${vivoCore}> . - ?subject ?predicate ?terminologyContextNode . - ?terminologyContextNode core:referencedTerm ?referencedTerm . - ?terminologyContextNode core:entryTerm ?entryTerm . - ?terminologyContextNode core:termLabel ?termLabel . - ?terminologyContextNode core:termType ?termType . -</v:jsonset> - -<c:set var="returnPathAfterSubmit" value="/edit/editRequestDispatch.jsp?subjectUri=${subjectUri}&predicateUri=${predicateUri}" /> -<c:url var="submitSearchUrl" value="/UMLSTermsRetrieval"/> -<c:url var="UMLSCUIURL" value="http://link.informatics.stonybrook.edu/umls/CUI/" /> -<c:set var="editjson" scope="request"> -{ - "formUrl" : "${formUrl}", - "editKey" : "${editKey}", - "urlPatternToReturnTo" : "${returnPathAfterSubmit}", - - "subject" : ["subject", "${subjectUriJson}" ], - "predicate" : ["predicate", "${predicateUriJson}" ], - "object" : ["terminologyContextNode", "${objectUriJson}", "URI" ], - - "n3required" : [ "${n3ForTerminology}" ], - - "n3optional" : [ ], - - "newResources" : { "terminologyContextNode" : "${defaultNamespace}" }, - - "urisInScope" : { }, - "literalsInScope": { }, - "urisOnForm" : [ "referencedTerm" ], - "literalsOnForm" : [ "entryTerm", "termLabel", "termType" ], - "filesOnForm" : [ ], - "sparqlForLiterals" : { }, - "sparqlForUris" : { }, - "sparqlForExistingLiterals" : { }, - "sparqlForExistingUris" : { }, - "fields" : { - "referencedTerm" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", //UNSURE WHAT TO KEEP HERE - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "", - "rangeLang" : "", - "assertions" : [ "${n3ForTerminology}" ] - }, - "entryTerm" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${n3ForTerminology}" ] - }, - "termLabel" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${n3ForTerminology}" ] - } - ,"termType" : { - "newResource" : "false", - "validators" : [ "nonempty" ], - "optionsType" : "UNDEFINED", - "literalOptions" : [ ], - "predicateUri" : "", - "objectClassUri" : "", - "rangeDatatypeUri" : "${stringDatatypeUriJson}", - "rangeLang" : "", - "assertions" : [ "${n3ForTerminology}" ] - } - } -} -</c:set> - -<% - 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); - } - - //Specific validators can be included here - - Model model = (Model) application.getAttribute("jenaOntModel"); - String objectUri = (String) request.getAttribute("objectUri"); - - //for some reason we are comming from the add new and that is working - //but we also come from the edit, and that is not working. - editConfig.setObject(""); //this will force the edit config to always be an add, never an update - - editConfig.prepareForNonUpdate(model); // we're only adding new, not editing existing - - String subjectUri = vreq.getParameter("subjectUri"); - String predicateUri = vreq.getParameter("predicateUri"); - - String vivoCore = "http://vivoweb.org/ontology/core#"; - - //Individual infoResource = vreq.getWebappDaoFactory().getIndividualDao().getIndividualByURI(subjectUri); - Individual subject = ((Individual) request.getAttribute("subject")); - vreq.setAttribute("subjectName", subject.getName()); - //Get existing terminology annotations - List<Individual> terminologyAnnotationNodes = subject.getRelatedIndividuals(predicateUri); - - - - List<String> customJs = new ArrayList<String>(Arrays.asList(JavaScript.JQUERY_UI.path(), - JavaScript.CUSTOM_FORM_UTILS.path(), - "/js/browserUtils.js", - "/edit/forms/js/addTerminology.js" - )); - request.setAttribute("customJs", customJs); - - //no custom css we know of yet - - List<String> customCss = new ArrayList<String>(Arrays.asList(Css.JQUERY_UI.path(), - Css.CUSTOM_FORM.path(), - "/edit/forms/css/addTerminology.css" - )); - request.setAttribute("customCss", customCss); - - -%> - -<c:set var="title" value="<em>${subjectName}</em>"/> - -<jsp:include page="${preForm}" /> -<h1>JSP form, must be removed for the 1.4!</h1> - - -<%-- DO NOT CHANGE IDS, CLASSES, OR HTML STRUCTURE ON THIS PAGE WITHOUT UNDERSTANDING THE IMPACT ON THE JAVASCRIPT! --%> -<h2>${title}</h2> - -<%@ include file="unsupportedBrowserMessage.jsp" %> - -<div class="noIE67"> -<h3>Manage Terminology Annotations</h3> - -<ul id="existingTerms" > -<% - - int existingTermsCount = terminologyAnnotationNodes.size(); - -%> - <script type="text/javascript"> - var existingTermsData = []; - </script> - -<% - String termLabelUri = vivoCore + "termLabel"; - String termTypeUri = vivoCore + "termType"; - for ( Individual termNode : terminologyAnnotationNodes ) { - request.setAttribute("termNodeUri", termNode.getURI()); - //Get label and type only as mirroring authorship where labels but no links for individuals incoldued - DataPropertyStatement termLabelStatement = termNode.getDataPropertyStatement(RDFS.label.getURI()); - String termLabel = termLabelStatement.getData(); - //request.setAttribute("termLabel", termLabel); - //DataPropertyStatement termTypeStatement = termNode.getDataPropertyStatement(termTypeUri); - //String termType = termTypeStatement.getData(); - request.setAttribute("termType", "fake"); -%> - <li class="existingTerm"> - <%-- span.author will be used in the next phase, when we display a message that the author has been - removed. That text will replace the a.authorName, which will be removed. --%> - <span class="term"> - <%-- This span is here to assign a width to. We can't assign directly to the a.authorName, - for the case when it's followed by an em tag - we want the width to apply to the whole thing. --%> - <span class="termWrapper"> - <span class="termLabel"> - ${termLabel} (${termType})</span> - </span> - <c:url var="deleteTermHref" value="/edit/primitiveDelete" /> - <a href="${deleteTermHref}" class="remove">Remove</a> - </span> - </li> - - <script type="text/javascript"> - existingTermsData.push({ - "termNodeUri": "${termNodeUri}", - "termLabel": "${termLabel}" - }); - </script> -<% - } -%> - -</ul> - -<% if (existingTermsCount == 0) { %> - <p>There are currently no terms specified.</p> -<% } %> - -<div id="showAddForm"> - <v:input type="submit" value="Add Term" id="showAddFormButton" name="showAddFormButton" cancel="true" cancelLabel="Return" cancelUrl="/individual" /> -</div> - -<form id="addTerminologyForm" class="customForm" action="<c:url value="/edit/processTerminologyAnnotation"/>" > - <p class="inline"><v:input type="text" id="searchTerm" label="Search UMLS Terms" cssClass="acSelector" size="35" /> - <input type="button" id="searchButton" name="searchButton" value="Search"/> - </p> - <input type="hidden" id="entryTerm" name="entryTerm" value="" /> <!-- Field value populated by JavaScript --> - <input type="hidden" id="referencedTerm" name="referencedTerm" value=""/> <!-- Field value populated by JavaScript --> - <input type="hidden" id="termLabel" name="termLabel" value="" /> <!-- Field value populated by JavaScript --> - <input type="hidden" id="termType" name="termType" value="" /> <!-- Field value populated by JavaScript --> - - - - <div id="selectedTerm" name="selectedTerm" class="acSelection"> - <%-- RY maybe make this a label and input field. See what looks best. --%> - <p class="inline"> - - </p> - <!-- Field value populated by JavaScript --> - - </div> - <div id="errors" name="errors"></div> - - <p class="submit"><v:input type="submit" id="submit" name="submit" value="Add Term" cancel="true" /></p> - -</form> -</div> - - -<script type="text/javascript"> -var customFormData = { - dataServiceUrl: '${submitSearchUrl}', - UMLSCUIURL: '${UMLSCUIURL}' -}; -</script> - -<jsp:include page="${postForm}"/> - diff --git a/productMods/edit/forms/unsupportedBrowserMessage.jsp b/productMods/edit/forms/unsupportedBrowserMessage.jsp deleted file mode 100644 index fb3b38dd..00000000 --- a/productMods/edit/forms/unsupportedBrowserMessage.jsp +++ /dev/null @@ -1,16 +0,0 @@ -<%-- $This file is distributed under the terms of the license in /doc/license.txt$ --%> - -<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%> - -<c:set var="portal" value="${requestScope.portalBean}"/> -<c:set var="contextPath"><c:out value="${pageContext.request.contextPath}" /></c:set> -<c:set var="themeDir" value="${contextPath}/${portal.themeDir}"/> - -<div id="ie67DisableWrapper"> -<h1>JSP form, must be removed for the 1.4!</h1> - <div id="ie67DisableContent"> - <img src="${themeDir}site_icons/iconAlertBig.png" alt="Alert Icon"/> - <p>This form is not supported in versions of Internet Explorer below version 8. Please upgrade your browser, or - switch to another browser, such as FireFox.</p> - </div> -</div> diff --git a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl index 91d0ff18..19b14744 100644 --- a/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl +++ b/productMods/templates/freemarker/edit/forms/addAssociatedConcept.ftl @@ -130,13 +130,13 @@ </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/addConcept.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/addConcept.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')} -${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/addConcept.js"></script>')} +${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/addConcept.js"></script>')} diff --git a/productMods/templates/freemarker/edit/forms/addAuthorsToInformationResource.ftl b/productMods/templates/freemarker/edit/forms/addAuthorsToInformationResource.ftl index e03e8c29..f80a6e62 100644 --- a/productMods/templates/freemarker/edit/forms/addAuthorsToInformationResource.ftl +++ b/productMods/templates/freemarker/edit/forms/addAuthorsToInformationResource.ftl @@ -155,12 +155,12 @@ var customFormData = { </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />', - '<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />', - '<link rel="stylesheet" href="${urls.base}/edit/forms/css/autocomplete.css" />', - '<link rel="stylesheet" href="${urls.base}/edit/forms/css/addAuthorsToInformationResource.css" />')} + '<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />', + '<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/autocomplete.css" />', + '<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/addAuthorsToInformationResource.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')} -${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/addAuthorsToInformationResource.js"></script>')} \ No newline at end of file +${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js"></script>')} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addEditWebpageForm.ftl b/productMods/templates/freemarker/edit/forms/addEditWebpageForm.ftl index 95cc0b56..5cbbd7a0 100644 --- a/productMods/templates/freemarker/edit/forms/addEditWebpageForm.ftl +++ b/productMods/templates/freemarker/edit/forms/addEditWebpageForm.ftl @@ -65,7 +65,7 @@ </p> </form> -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/userMenu/userMenuUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl index ed37c80c..5587565c 100644 --- a/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addGrantRoleToPerson.ftl @@ -146,11 +146,11 @@ var customFormData = { }; </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')} -${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} +${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} </#if> \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl index 01c3daed..d02340e7 100644 --- a/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl +++ b/productMods/templates/freemarker/edit/forms/addPublicationToPerson.ftl @@ -110,11 +110,11 @@ </#if> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} diff --git a/productMods/templates/freemarker/edit/forms/addRoleToPersonTwoStage.ftl b/productMods/templates/freemarker/edit/forms/addRoleToPersonTwoStage.ftl index e6443405..ada5a3ba 100644 --- a/productMods/templates/freemarker/edit/forms/addRoleToPersonTwoStage.ftl +++ b/productMods/templates/freemarker/edit/forms/addRoleToPersonTwoStage.ftl @@ -195,12 +195,12 @@ </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>')} -${scripts.add('<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} +${scripts.add('<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} </section> \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl b/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl index 32824aaa..9324313f 100644 --- a/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl +++ b/productMods/templates/freemarker/edit/forms/addUserDefinedConcept.ftl @@ -57,11 +57,11 @@ </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} \ No newline at end of file + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl b/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl index a864e68d..48277cf4 100644 --- a/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl +++ b/productMods/templates/freemarker/edit/forms/autoCompleteObjectPropForm.ftl @@ -124,11 +124,11 @@ Also multiple types parameter set to true only if more than one type returned--> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} - ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} + ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} diff --git a/productMods/edit/forms/js/addAuthorsToInformationResource.js b/productMods/templates/freemarker/edit/forms/css/addAuthorsToInformationResource.css similarity index 100% rename from productMods/edit/forms/js/addAuthorsToInformationResource.js rename to productMods/templates/freemarker/edit/forms/css/addAuthorsToInformationResource.css diff --git a/productMods/templates/freemarker/edit/forms/css/addConcept.css b/productMods/templates/freemarker/edit/forms/css/addConcept.css new file mode 100644 index 00000000..fa2afdc9 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/addConcept.css @@ -0,0 +1,33 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +.concepts .column { + float:left; + padding-right:3px; + +} + +.concepts .row { + clear:both; + float:left; + border-bottom: 1px solid #5F6464; +} + +.conceptLabel { + width:220px; +} + +.conceptType { + width: 40px; +} +.conceptDefinition{ + width:400px; +} + +form#addConceptForm { + display:none; +} + +form#addConceptForm span#createOwnOne{ + float:left; + margin-top:24px +} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/css/autocomplete.css b/productMods/templates/freemarker/edit/forms/css/autocomplete.css new file mode 100644 index 00000000..d87f9aa3 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/autocomplete.css @@ -0,0 +1,24 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +/* Styles for autocomplete and autocomplete selections using jQuery UI. This is separated out so that forms +that don't load customFormWithAutocomplete.css still have access to these styles. */ + +.acSelection { + display: none; + margin-top: 2em; +} +.acSelectionInfo { + background-color: #d9d9d9; + padding: .2em .35em; +} +ul.ui-autocomplete { + font-size: .95em; +} +li.ui-menu-item a.ui-corner-all { + text-align: left; + padding-left: .25em; +} +.acSelectorWithHelpText{ + font-style: italic; + color: #555; +} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/css/customForm.css b/productMods/templates/freemarker/edit/forms/css/customForm.css new file mode 100644 index 00000000..19a63659 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/customForm.css @@ -0,0 +1,124 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +form.customForm div { + clear: left; +} +form.customForm h6 { + font-size: 110%; +} +form.customForm div.addNewLink { + float: left; + clear: none; + margin-left: 5em; + margin-top: .9em; + width: 200px; + padding: .8em; + border: 1px solid #9c9c9c; + display: none; /* Hide if Javascript disabled. Javascript will show. */ +} +form.customForm .existing span.requiredHint, +form.customForm .new span.requiredHint { + display: none; /* Hide if Javascript disabled. Javascript will show. */ +} +form.customForm .existing { + float: left; + clear: none; +} +.existingOrNew { + font-style: italic; + margin-left: 1em; +} +.new { + padding: .6em 0 .6em 1.5em; + border: 1px solid #9c9c9c; + width: 300px; +} +form.customForm p.inline input, +form.customForm p.inline label { + float: left; + clear: left; +} +form.customForm p.inline.year input { + margin-top: -1.75em; +} +input, +select, +form.customForm p { + margin-top: 0; + padding-top: 0; + margin-bottom: 0; + padding-bottom: 0; +} +option { + padding: 0 2px; +} +form.customForm .hint { + color: #9c9c9c; + font-weight: normal; +} +form.customForm .requiredHint { + color: #c00; + font-weight: normal; + font-size: small; +} +form.customForm #requiredLegend { + font-style: italic; + margin-top: .5em; +} +form.customForm p.validationError { + clear: both; + margin-bottom: 1.8em; + margin-top: 0; + padding-top: 0; + padding-left: .4em; + font-size: .8em; +} +form.customForm a.close { + float: right; + margin-right: 1em; + font-size: 90%; +} +form.customForm a.close:link, +form.customForm a.close:visited { + border-color: #ff7700; + color: #ff7700; +} +form.customForm textarea { + width: 30%; +} +div.acSelection { + margin-bottom: 15px; +} +#ie67DisableWrapper { + display: none; +} +form.customForm input.concept-search { + float: right; + margin-right: 1em; + margin-bottom: 1em; + background-color: #317e95; +} +form.customForm h4.services { + margin-bottom: -5px; + margin-top: -12px; +} +form.customForm p.inline-search { + float: left; + clear: left; +} +form.customForm p.inline-search #searchTerm{ + margin-top: 6px; +} +/* <------ DATE TIME*/ +form.customForm label.dateTime { + display: inline; +} +form.customForm fieldset { + display: inline; +} +fieldset.dateTime label { + display: inline; +} +fieldset.dateTime select { + margin-top: 0; +} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css b/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css new file mode 100644 index 00000000..7c66f21b --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css @@ -0,0 +1,33 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +@import url("autocomplete.css"); + +/* Although Javascript hides these on page load, hide here as well to avoid the flash on page load. + This needs to be removed to support a non-JS version of the form. */ +.fullViewOnly, +#submit, +.or, +#requiredLegend { + display: none; +} +form.customForm p.inline label { + display: inline; + clear: none; + float: none; + margin-right: 1em; +} +.verifyMatch { + margin-left: .5em; +} +form.customForm h4 { + margin-top: 1em; + margin-bottom: .75em; +} +.acSelector[disabled="disabled"]{ + border-width: 0; + background: none; + color: #000; +} +.disabledSubmit { + cursor: default ! important; +} diff --git a/productMods/templates/freemarker/edit/forms/css/institutionalInternalClass.css b/productMods/templates/freemarker/edit/forms/css/institutionalInternalClass.css new file mode 100644 index 00000000..8b68760d --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/css/institutionalInternalClass.css @@ -0,0 +1,20 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +#localClassName { + margin-bottom: 0; +} +#createNewLocalClass p.note { + margin-top: 3px; + margin-bottom: 15px; +} +#noLocalOntologyExists { + padding: 1em; + background: #f4f4f4; + display: inline-block; +} +#noLocalOntologyExists blockquote { + margin: .4em 0 .4em 1em; + padding: .5em; + background: #ffc; + display: inline-block; +} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl b/productMods/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl index dbeae288..0fe6e488 100644 --- a/productMods/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl +++ b/productMods/templates/freemarker/edit/forms/institutionalInternalClassForm.ftl @@ -85,5 +85,5 @@ edu.cornell.mannlib.vitro.webapp.edit.n3editing.configuration.generators.Institu </form> </section> -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/institutionalInternalClass.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} \ No newline at end of file +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/institutionalInternalClass.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js b/productMods/templates/freemarker/edit/forms/js/addAuthorsToInformationResource.js new file mode 100644 index 00000000..e69de29b diff --git a/productMods/edit/forms/js/addConcept.js b/productMods/templates/freemarker/edit/forms/js/addConcept.js similarity index 97% rename from productMods/edit/forms/js/addConcept.js rename to productMods/templates/freemarker/edit/forms/js/addConcept.js index f182c696..588a272c 100644 --- a/productMods/edit/forms/js/addConcept.js +++ b/productMods/templates/freemarker/edit/forms/js/addConcept.js @@ -1,326 +1,326 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var addConceptForm = { - - /* *** Initial page setup *** */ - - onLoad: function() { - - if (this.disableFormInUnsupportedBrowsers()) { - return; - } - this.mixIn(); - this.initObjects(); - this.initPage(); - }, - - disableFormInUnsupportedBrowsers: function() { - var disableWrapper = $('#ie67DisableWrapper'); - - // Check for unsupported browsers only if the element exists on the page - if (disableWrapper.length) { - if (vitro.browserUtils.isIELessThan8()) { - disableWrapper.show(); - $('.noIE67').hide(); - return true; - } - } - return false; - }, - - mixIn: function() { - // Mix in the custom form utility methods - $.extend(this, vitro.customFormUtils); - // Get the custom form data from the page - $.extend(this, customFormData); - }, - // On page load, create references for easy access to form elements. - initObjects: function() { - - this.form = $('#addConceptForm'); - this.showFormButtonWrapper = $('#showAddForm'); - this.submit = this.form.find(':submit'); - this.cancel = this.form.find('.cancel'); - //Add term - this.addConceptButton = $('#showAddFormButton'); - //section where results should be displayed - this.selectedConcept = $('#selectedConcept'); - //input for search term form - this.searchTerm = $('#searchTerm'); - this.searchSubmit = $('#searchButton'); - //Hidden inputs for eventual submission - this.externalConceptURI = $('#conceptNode'); - this.externalConceptLabel = $('#conceptLabel'); - this.externalConceptSource = $('#conceptSource'); - //remove links - this.removeConceptLinks = $('a.remove'); - this.errors = $('#errors'); - this.createOwn1 = $('#createOwnOne'); - this.createOwn2 = $('#createOwnTwo'); - this.orSpan = $('span.or') - }, - - initPage: function() { - this.initConceptData(); - this.bindEventListeners(); - - }, - bindEventListeners: function() { - this.searchSubmit.click(function() { - addConceptForm.clearErrors(); - addConceptForm.submitSearchTerm(); - return false; - }); - - this.form.submit(function() { - return addConceptForm.prepareSubmit(); - }); - - this.addConceptButton.click(function() { - addConceptForm.initForm(); - - }); - this.removeConceptLinks.click(function() { - addConceptForm.removeExistingConcept(this); - return false; - }); - }, - initForm: function() { - // Hide the button that shows the form - this.showFormButtonWrapper.hide(); - this.clearSearchResults(); - // Hide the create own link, add selected button and "or"" span - this.orSpan.hide(); - this.createOwn2.hide(); - this.submit.hide(); - //Also clear the search input - this.searchTerm.val(""); - this.cancel.unbind('click'); - - // Show the form - this.form.show(); - }, - // On page load, associate data with each existing term element. Then we don't - // have to keep retrieving data from or modifying the DOM as we manipulate the - // authorships. - initConceptData: function() { - $('.existingConcept').each(function(index) { - $(this).data(existingConceptsData[index]); - $(this).data('position', index+1); - }); - }, - clearSearchResults:function() { - $('#selectedConcept').empty(); - }, - clearErrors:function() { - addConceptForm.errors.empty(); - }, - showHiddenElements:function(results) { - this.createOwn1.hide(); - if ( results ) { - this.orSpan.show(); - this.createOwn2.show(); - this.submit.show(); - } - else { - this.orSpan.show(); - this.createOwn2.show(); - } - }, - showConceptListOnlyView: function() { - this.hideForm(); - this.showFormButtonWrapper.show(); - }, - submitSearchTerm: function() { - //Get value of search term - var searchValue = this.searchTerm.val(); - var checkedVocabSource = $('input:radio[name="source"]:checked'); - var hasResults = false; - if(!checkedVocabSource.length) { - addConceptForm.showUncheckedSourceError(); - return; - } - var vocabSourceValue = checkedVocabSource.val(); - var dataServiceUrl = addConceptForm.dataServiceUrl + "?searchTerm=" + encodeURIComponent(searchValue) + "&source=" + encodeURIComponent(vocabSourceValue); - //This should return an object including the concept list or any errors if there are any - $.getJSON(dataServiceUrl, function(results) { - var htmlAdd = ""; - var vocabUnavailable = "<p>The vocabulary service is unavailable. Please try again later.</p>"; - if ( results== null || results.semanticServicesError != null || results.conceptList == null) { - htmlAdd = vocabUnavailable; - } - else { - //array is an array of objects representing concept information - //loop through and find all the best matches - var bestMatchResults = addConceptForm.parseResults(results.conceptList); - var numberMatches = bestMatchResults.length; - var i; - //For each result, display - if(numberMatches > 0) { - htmlAdd = "<ul class='dd' id='concepts' name='concepts'>"; - htmlAdd+= addConceptForm.addResultsHeader(); - for(i = 0; i < numberMatches; i++) { - var conceptResult = bestMatchResults[i]; - var conceptId = conceptResult.conceptId; - var label = conceptResult.label; - var definition = conceptResult.definition; - var definedBy = conceptResult.definedBy; - var type = conceptResult.type; - var uri = conceptResult.uri; - htmlAdd+= addConceptForm.generateIndividualConceptDisplay(uri, label, definition, type, definedBy); - } - htmlAdd+= "</ul>"; - } else { - htmlAdd+= "<p>No search results were found.</p>"; - } - - } - if(htmlAdd.length) { - $('#selectedConcept').html(htmlAdd); - if (htmlAdd.indexOf("No search results") >= 0) { - addConceptForm.showHiddenElements(hasResults); - } - else { - hasResults = true; - addConceptForm.showHiddenElements(hasResults); - } - } - }); - return true; - }, - parseResults:function(resultsArray) { - //Loop through array and check if this is the best match - var arrayLen = resultsArray.length; - var bestMatchResults = new Array(); - var i; - for(i = 0; i < arrayLen; i++) { - var concept = resultsArray[i]; - if(concept.bestMatch != "false") { - bestMatchResults.push(concept); - } - } - return bestMatchResults; - }, - addResultsHeader:function() { - var htmlAdd = "<li class='concepts'><div class='row'><span class='column conceptLabel'>Label (Type) </span><span class='column conceptDefinition'>Definition</span></div></li>"; - return htmlAdd; - }, - hideSearchResults:function() { - this.selectedConcept.hide(); - }, - prepareSubmit:function() { - var checkedElements = $("input[name='CUI']:checked"); - if(!addConceptForm.validateConceptSelection(checkedElements)) { - return false; - } - var i; - var len = checkedElements.length; - var checkedConcept, checkedConceptElement, conceptLabel, conceptSource; - var conceptNodes = []; - var conceptLabels = []; - var conceptSources = []; - - checkedElements.each(function() { - checkedConceptElement = $(this); - checkedConcept = checkedConceptElement.val(); - conceptLabel = checkedConceptElement.attr("label"); - conceptSource = checkedConceptElement.attr("conceptDefinedBy"); - conceptNodes.push(checkedConcept); - conceptLabels.push(conceptLabel); - conceptSources.push(conceptSource); - }); - this.externalConceptURI.val(conceptNodes); - this.externalConceptLabel.val(conceptLabels); - this.externalConceptSource.val(conceptSources); - return true; - }, - generateIndividualConceptDisplay: function(cuiURI, label, definition, type, definedBy) { - var htmlAdd = "<li class='concepts'>" + - "<div class='row'>" + - "<span class='column conceptLabel'>" + - addConceptForm.generateIndividualCUIInput(cuiURI, label, type, definedBy) + - label + addConceptForm.generateIndividualTypeDisplay(type) + "</span>" + - addConceptForm.generateIndividualDefinitionDisplay(definition) + - "</div>" + - "</li>"; - return htmlAdd; - }, - generateIndividualCUIInput:function(cuiURI, label, type, definedBy) { - return "<input type='checkbox' name='CUI' value='" + cuiURI + "' label='" + label + "' conceptType='" + type + "' conceptDefinedBy='" + definedBy + "'/>"; - }, - generateIndividualTypeDisplay:function(type) { - if(type != null && type.length > 0) { - return " (" + type + ")"; - } - return ""; - }, - generateIndividualDefinitionDisplay:function(definition) { - return "<span class='column conceptDefinition'>" + definition + "</span>"; - }, - validateConceptSelection:function(checkedElements) { - var numberElements = checkedElements.length; - if(numberElements < 1) { - addConceptForm.errors.html("<p class='validationError'>Please select at least one term from the search search results.</p>"); - return false; - } - return true; - }, - showUncheckedSourceError:function() { - addConceptForm.errors.html("<p class='validationError'>Please select at least one external vocabulary source to search.</p>"); - }, - removeExistingConcept: function(link) { - var removeLast = false, - message = 'Are you sure you want to remove this term?'; - - if (!confirm(message)) { - return false; - } - - if ($(link)[0] === $('.remove:last')[0]) { - removeLast = true; - } - //Using primitive rdf edit which expects an n3 string for deletion - $.ajax({ - url: $(link).attr('href'), - type: 'POST', - data: { - additions: '', - retractions: addConceptForm.generateDeletionN3($(link).parents('.existingConcept').data('conceptNodeUri')) - }, - dataType: 'json', - context: link, // context for callback - complete: function(request, status) { - var existingConcept, - conceptNodeUri; - - if (status === 'success') { - - existingConcept = $(this).parents('.existingConcept'); - existingConcept.fadeOut(400, function() { - var numConcepts; - // For undo link: add to a deletedAuthorships array - // Remove from the DOM - $(this).remove(); - // Actions that depend on the author having been removed from the DOM: - numConcepts = $('.existingConcept').length; // retrieve the length after removing authorship from the DOM - }); - - } else { - alert('Error processing request: term not removed'); - } - } - }); - }, - generateDeletionN3: function(conceptNodeUri) { - var n3String = "<" + addConceptForm.subjectUri + "> <" + addConceptForm.predicateUri + "> <" + conceptNodeUri + "> ."; - //add inverse string to also be removed - if(addConceptForm.inversePredicateUri.length > 0) { - n3String += "<" + conceptNodeUri + "> <" + addConceptForm.inversePredicateUri + "> <" + addConceptForm.subjectUri + "> ."; - } - return n3String; - } -}; - -$(document).ready(function() { - addConceptForm.onLoad(); -}); +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var addConceptForm = { + + /* *** Initial page setup *** */ + + onLoad: function() { + + if (this.disableFormInUnsupportedBrowsers()) { + return; + } + this.mixIn(); + this.initObjects(); + this.initPage(); + }, + + disableFormInUnsupportedBrowsers: function() { + var disableWrapper = $('#ie67DisableWrapper'); + + // Check for unsupported browsers only if the element exists on the page + if (disableWrapper.length) { + if (vitro.browserUtils.isIELessThan8()) { + disableWrapper.show(); + $('.noIE67').hide(); + return true; + } + } + return false; + }, + + mixIn: function() { + // Mix in the custom form utility methods + $.extend(this, vitro.customFormUtils); + // Get the custom form data from the page + $.extend(this, customFormData); + }, + // On page load, create references for easy access to form elements. + initObjects: function() { + + this.form = $('#addConceptForm'); + this.showFormButtonWrapper = $('#showAddForm'); + this.submit = this.form.find(':submit'); + this.cancel = this.form.find('.cancel'); + //Add term + this.addConceptButton = $('#showAddFormButton'); + //section where results should be displayed + this.selectedConcept = $('#selectedConcept'); + //input for search term form + this.searchTerm = $('#searchTerm'); + this.searchSubmit = $('#searchButton'); + //Hidden inputs for eventual submission + this.externalConceptURI = $('#conceptNode'); + this.externalConceptLabel = $('#conceptLabel'); + this.externalConceptSource = $('#conceptSource'); + //remove links + this.removeConceptLinks = $('a.remove'); + this.errors = $('#errors'); + this.createOwn1 = $('#createOwnOne'); + this.createOwn2 = $('#createOwnTwo'); + this.orSpan = $('span.or') + }, + + initPage: function() { + this.initConceptData(); + this.bindEventListeners(); + + }, + bindEventListeners: function() { + this.searchSubmit.click(function() { + addConceptForm.clearErrors(); + addConceptForm.submitSearchTerm(); + return false; + }); + + this.form.submit(function() { + return addConceptForm.prepareSubmit(); + }); + + this.addConceptButton.click(function() { + addConceptForm.initForm(); + + }); + this.removeConceptLinks.click(function() { + addConceptForm.removeExistingConcept(this); + return false; + }); + }, + initForm: function() { + // Hide the button that shows the form + this.showFormButtonWrapper.hide(); + this.clearSearchResults(); + // Hide the create own link, add selected button and "or"" span + this.orSpan.hide(); + this.createOwn2.hide(); + this.submit.hide(); + //Also clear the search input + this.searchTerm.val(""); + this.cancel.unbind('click'); + + // Show the form + this.form.show(); + }, + // On page load, associate data with each existing term element. Then we don't + // have to keep retrieving data from or modifying the DOM as we manipulate the + // authorships. + initConceptData: function() { + $('.existingConcept').each(function(index) { + $(this).data(existingConceptsData[index]); + $(this).data('position', index+1); + }); + }, + clearSearchResults:function() { + $('#selectedConcept').empty(); + }, + clearErrors:function() { + addConceptForm.errors.empty(); + }, + showHiddenElements:function(results) { + this.createOwn1.hide(); + if ( results ) { + this.orSpan.show(); + this.createOwn2.show(); + this.submit.show(); + } + else { + this.orSpan.show(); + this.createOwn2.show(); + } + }, + showConceptListOnlyView: function() { + this.hideForm(); + this.showFormButtonWrapper.show(); + }, + submitSearchTerm: function() { + //Get value of search term + var searchValue = this.searchTerm.val(); + var checkedVocabSource = $('input:radio[name="source"]:checked'); + var hasResults = false; + if(!checkedVocabSource.length) { + addConceptForm.showUncheckedSourceError(); + return; + } + var vocabSourceValue = checkedVocabSource.val(); + var dataServiceUrl = addConceptForm.dataServiceUrl + "?searchTerm=" + encodeURIComponent(searchValue) + "&source=" + encodeURIComponent(vocabSourceValue); + //This should return an object including the concept list or any errors if there are any + $.getJSON(dataServiceUrl, function(results) { + var htmlAdd = ""; + var vocabUnavailable = "<p>The vocabulary service is unavailable. Please try again later.</p>"; + if ( results== null || results.semanticServicesError != null || results.conceptList == null) { + htmlAdd = vocabUnavailable; + } + else { + //array is an array of objects representing concept information + //loop through and find all the best matches + var bestMatchResults = addConceptForm.parseResults(results.conceptList); + var numberMatches = bestMatchResults.length; + var i; + //For each result, display + if(numberMatches > 0) { + htmlAdd = "<ul class='dd' id='concepts' name='concepts'>"; + htmlAdd+= addConceptForm.addResultsHeader(); + for(i = 0; i < numberMatches; i++) { + var conceptResult = bestMatchResults[i]; + var conceptId = conceptResult.conceptId; + var label = conceptResult.label; + var definition = conceptResult.definition; + var definedBy = conceptResult.definedBy; + var type = conceptResult.type; + var uri = conceptResult.uri; + htmlAdd+= addConceptForm.generateIndividualConceptDisplay(uri, label, definition, type, definedBy); + } + htmlAdd+= "</ul>"; + } else { + htmlAdd+= "<p>No search results were found.</p>"; + } + + } + if(htmlAdd.length) { + $('#selectedConcept').html(htmlAdd); + if (htmlAdd.indexOf("No search results") >= 0) { + addConceptForm.showHiddenElements(hasResults); + } + else { + hasResults = true; + addConceptForm.showHiddenElements(hasResults); + } + } + }); + return true; + }, + parseResults:function(resultsArray) { + //Loop through array and check if this is the best match + var arrayLen = resultsArray.length; + var bestMatchResults = new Array(); + var i; + for(i = 0; i < arrayLen; i++) { + var concept = resultsArray[i]; + if(concept.bestMatch != "false") { + bestMatchResults.push(concept); + } + } + return bestMatchResults; + }, + addResultsHeader:function() { + var htmlAdd = "<li class='concepts'><div class='row'><span class='column conceptLabel'>Label (Type) </span><span class='column conceptDefinition'>Definition</span></div></li>"; + return htmlAdd; + }, + hideSearchResults:function() { + this.selectedConcept.hide(); + }, + prepareSubmit:function() { + var checkedElements = $("input[name='CUI']:checked"); + if(!addConceptForm.validateConceptSelection(checkedElements)) { + return false; + } + var i; + var len = checkedElements.length; + var checkedConcept, checkedConceptElement, conceptLabel, conceptSource; + var conceptNodes = []; + var conceptLabels = []; + var conceptSources = []; + + checkedElements.each(function() { + checkedConceptElement = $(this); + checkedConcept = checkedConceptElement.val(); + conceptLabel = checkedConceptElement.attr("label"); + conceptSource = checkedConceptElement.attr("conceptDefinedBy"); + conceptNodes.push(checkedConcept); + conceptLabels.push(conceptLabel); + conceptSources.push(conceptSource); + }); + this.externalConceptURI.val(conceptNodes); + this.externalConceptLabel.val(conceptLabels); + this.externalConceptSource.val(conceptSources); + return true; + }, + generateIndividualConceptDisplay: function(cuiURI, label, definition, type, definedBy) { + var htmlAdd = "<li class='concepts'>" + + "<div class='row'>" + + "<span class='column conceptLabel'>" + + addConceptForm.generateIndividualCUIInput(cuiURI, label, type, definedBy) + + label + addConceptForm.generateIndividualTypeDisplay(type) + "</span>" + + addConceptForm.generateIndividualDefinitionDisplay(definition) + + "</div>" + + "</li>"; + return htmlAdd; + }, + generateIndividualCUIInput:function(cuiURI, label, type, definedBy) { + return "<input type='checkbox' name='CUI' value='" + cuiURI + "' label='" + label + "' conceptType='" + type + "' conceptDefinedBy='" + definedBy + "'/>"; + }, + generateIndividualTypeDisplay:function(type) { + if(type != null && type.length > 0) { + return " (" + type + ")"; + } + return ""; + }, + generateIndividualDefinitionDisplay:function(definition) { + return "<span class='column conceptDefinition'>" + definition + "</span>"; + }, + validateConceptSelection:function(checkedElements) { + var numberElements = checkedElements.length; + if(numberElements < 1) { + addConceptForm.errors.html("<p class='validationError'>Please select at least one term from the search search results.</p>"); + return false; + } + return true; + }, + showUncheckedSourceError:function() { + addConceptForm.errors.html("<p class='validationError'>Please select at least one external vocabulary source to search.</p>"); + }, + removeExistingConcept: function(link) { + var removeLast = false, + message = 'Are you sure you want to remove this term?'; + + if (!confirm(message)) { + return false; + } + + if ($(link)[0] === $('.remove:last')[0]) { + removeLast = true; + } + //Using primitive rdf edit which expects an n3 string for deletion + $.ajax({ + url: $(link).attr('href'), + type: 'POST', + data: { + additions: '', + retractions: addConceptForm.generateDeletionN3($(link).parents('.existingConcept').data('conceptNodeUri')) + }, + dataType: 'json', + context: link, // context for callback + complete: function(request, status) { + var existingConcept, + conceptNodeUri; + + if (status === 'success') { + + existingConcept = $(this).parents('.existingConcept'); + existingConcept.fadeOut(400, function() { + var numConcepts; + // For undo link: add to a deletedAuthorships array + // Remove from the DOM + $(this).remove(); + // Actions that depend on the author having been removed from the DOM: + numConcepts = $('.existingConcept').length; // retrieve the length after removing authorship from the DOM + }); + + } else { + alert('Error processing request: term not removed'); + } + } + }); + }, + generateDeletionN3: function(conceptNodeUri) { + var n3String = "<" + addConceptForm.subjectUri + "> <" + addConceptForm.predicateUri + "> <" + conceptNodeUri + "> ."; + //add inverse string to also be removed + if(addConceptForm.inversePredicateUri.length > 0) { + n3String += "<" + conceptNodeUri + "> <" + addConceptForm.inversePredicateUri + "> <" + addConceptForm.subjectUri + "> ."; + } + return n3String; + } +}; + +$(document).ready(function() { + addConceptForm.onLoad(); +}); diff --git a/productMods/edit/forms/js/addTerminology.js b/productMods/templates/freemarker/edit/forms/js/addTerminology.js similarity index 97% rename from productMods/edit/forms/js/addTerminology.js rename to productMods/templates/freemarker/edit/forms/js/addTerminology.js index 7f09fbc7..ff18a0ed 100644 --- a/productMods/edit/forms/js/addTerminology.js +++ b/productMods/templates/freemarker/edit/forms/js/addTerminology.js @@ -1,250 +1,250 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var addTerminologyForm = { - - /* *** Initial page setup *** */ - - onLoad: function() { - - if (this.disableFormInUnsupportedBrowsers()) { - return; - } - this.mixIn(); - this.initObjects(); - this.initPage(); - }, - - disableFormInUnsupportedBrowsers: function() { - var disableWrapper = $('#ie67DisableWrapper'); - - // Check for unsupported browsers only if the element exists on the page - if (disableWrapper.length) { - if (vitro.browserUtils.isIELessThan8()) { - disableWrapper.show(); - $('.noIE67').hide(); - return true; - } - } - return false; - }, - - mixIn: function() { - // Mix in the custom form utility methods - $.extend(this, vitro.customFormUtils); - // Get the custom form data from the page - $.extend(this, customFormData); - }, - // On page load, create references for easy access to form elements. - initObjects: function() { - - this.form = $('#addTerminologyForm'); - this.showFormButtonWrapper = $('#showAddForm'); - this.submit = this.form.find(':submit'); - this.cancel = this.form.find('.cancel'); - //Add term - this.addTermButton = $('#showAddFormButton'); - //section where results should be displayed - this.selectedTerm = $('#selectedTerm'); - //input for search term form - this.searchTerm = $('#searchTerm'); - this.searchSubmit = $('#searchButton'); - //Hidden inputs for eventual submission - this.referencedTerm = $('#referencedTerm'); - this.entryTerm = $('#entryTerm'); - this.termLabel = $('#termLabel'); - this.termType = $('#termType'); - this.removeTermLinks = $('a.remove'); - this.errors = $('#errors'); - }, - - initPage: function() { - this.initTermData(); - this.bindEventListeners(); - - }, - bindEventListeners: function() { - this.searchSubmit.click(function() { - addTerminologyForm.submitSearchTerm(); - addTerminologyForm.clearErrors(); - return false; - }); - - this.form.submit(function() { - return addTerminologyForm.prepareSubmit(); - }); - - this.addTermButton.click(function() { - addTerminologyForm.initForm(); - - }); - this.removeTermLinks.click(function() { - addTerminologyForm.removeExistingTerm(this); - return false; - }); - }, - initForm: function() { - // Hide the button that shows the form - this.showFormButtonWrapper.hide(); - this.clearSearchResults(); - - this.cancel.unbind('click'); - this.cancel.bind('click', function() { - //show only list of existing terms and hide adding term form - addTerminologyForm.showTermListOnlyView(); - return false; - }); - - // Show the form - this.form.show(); - }, - // On page load, associate data with each existing term element. Then we don't - // have to keep retrieving data from or modifying the DOM as we manipulate the - // authorships. - initTermData: function() { - $('.existingTerm').each(function(index) { - $(this).data(existingTermsData[index]); - $(this).data('position', index+1); - }); - }, - clearSearchResults:function() { - $('#selectedTerm').empty(); - }, - clearErrors:function() { - addTerminologyForm.errors.empty(); - }, - showTermListOnlyView: function() { - this.hideForm(); - this.showFormButtonWrapper.show(); - }, - submitSearchTerm: function() { - //Get value of search term - var searchValue = this.searchTerm.val(); - this.entryTerm.val(searchValue); - var dataServiceUrl = addTerminologyForm.dataServiceUrl + "?searchTerm=" + encodeURIComponent(searchValue); - $.getJSON(dataServiceUrl, function(results) { - if ( results.All.length == 0 ) { - } else { - //update existing content type with correct class group name and hide class group select again - var bestMatchResults = results["Best Match"]; - var numberMatches = bestMatchResults.length; - var i; - //For each result, display - var htmlAdd = ""; - if(numberMatches > 0) { - htmlAdd = "<ul class='dd' id='terms' name='terms'>"; - htmlAdd+= addTerminologyForm.addResultsHeader(); - for(i = 0; i < numberMatches; i++) { - var termResult = bestMatchResults[i]; - var CUI = termResult.CUI; - var label = termResult.label; - var definition = termResult.definition; - var type = termResult.type; - var cuiURI = addTerminologyForm.UMLSCUIURL + CUI; - htmlAdd+= addTerminologyForm.generateIndividualTermDisplay(cuiURI, label, definition, type); - } - htmlAdd+= "</ul>"; - } else { - htmlAdd+= "<p>No search results found.</p>"; - } - $('#selectedTerm').html(htmlAdd); - } - - }); - }, - addResultsHeader:function() { - var htmlAdd = "<li class='terminology'><div class='row'><span class='column termLabel'>Label (Type) </span><span class='column termDefinition'>Definition</span></div></li>"; - return htmlAdd; - }, - hideSearchResults:function() { - this.selectedTerm.hide(); - }, - prepareSubmit:function() { - var checkedElements = $("#CUI:checked"); - if(!addTerminologyForm.validateTermSelection(checkedElements)) { - return false; - } - var i; - var len = checkedElements.length; - var checkedTerm, checkedTermElement, termLabel, termType; - var referencedTerms = []; - var termLabels = []; - var termTypes = []; - - checkedElements.each(function() { - checkedTermElement = $(this); - checkedTerm = checkedTermElement.val(); - termType = checkedTermElement.attr("termType"); - termLabel = checkedTermElement.attr("label"); - referencedTerms.push(checkedTerm); - termLabels.push(termLabel); - termTypes.push(termType); - }); - this.referencedTerm.val(referencedTerms); - this.termLabel.val(termLabels); - this.termType.val(termTypes); - return true; - }, - generateIndividualTermDisplay: function(cuiURI, label, definition, type) { - var htmlAdd = "<li class='terminology'>" + - "<div class='row'>" + - "<span class='column termLabel'>" + - "<input type='checkbox' id='CUI' name='CUI' value='" + cuiURI + "' label='" + label + "' termType='" + type + "'/>" + - label + " (" + type + ")</span>" + - "<span class='column termDefinition'>" + definition + "</span>" + - "</div>" + - "</li>"; - return htmlAdd; - }, validateTermSelection:function(checkedElements) { - var numberElements = checkedElements.length; - if(numberElements < 1) { - addTerminologyForm.errors.html("<p class='validationError'>Please select at least one term from search results to add or click cancel.</p>"); - return false; - } - return true; - }, removeExistingTerm: function(link) { - var removeLast = false, - message = 'Are you sure you want to remove this term?'; - - if (!confirm(message)) { - return false; - } - - if ($(link)[0] === $('.remove:last')[0]) { - removeLast = true; - } - - $.ajax({ - url: $(link).attr('href'), - type: 'POST', - data: { - deletion: $(link).parents('.existingTerm').data('termNodeUri') - }, - dataType: 'json', - context: link, // context for callback - complete: function(request, status) { - var existingTerm, - termNodeUri; - - if (status === 'success') { - - existingTerm = $(this).parents('.existingTerm'); - existingTerm.fadeOut(400, function() { - var numTerms; - // For undo link: add to a deletedAuthorships array - // Remove from the DOM - $(this).remove(); - // Actions that depend on the author having been removed from the DOM: - numTerms = $('.existingTerm').length; // retrieve the length after removing authorship from the DOM - }); - - } else { - alert('Error processing request: term not removed'); - } - } - }); - } -}; - -$(document).ready(function() { - addTerminologyForm.onLoad(); -}); +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var addTerminologyForm = { + + /* *** Initial page setup *** */ + + onLoad: function() { + + if (this.disableFormInUnsupportedBrowsers()) { + return; + } + this.mixIn(); + this.initObjects(); + this.initPage(); + }, + + disableFormInUnsupportedBrowsers: function() { + var disableWrapper = $('#ie67DisableWrapper'); + + // Check for unsupported browsers only if the element exists on the page + if (disableWrapper.length) { + if (vitro.browserUtils.isIELessThan8()) { + disableWrapper.show(); + $('.noIE67').hide(); + return true; + } + } + return false; + }, + + mixIn: function() { + // Mix in the custom form utility methods + $.extend(this, vitro.customFormUtils); + // Get the custom form data from the page + $.extend(this, customFormData); + }, + // On page load, create references for easy access to form elements. + initObjects: function() { + + this.form = $('#addTerminologyForm'); + this.showFormButtonWrapper = $('#showAddForm'); + this.submit = this.form.find(':submit'); + this.cancel = this.form.find('.cancel'); + //Add term + this.addTermButton = $('#showAddFormButton'); + //section where results should be displayed + this.selectedTerm = $('#selectedTerm'); + //input for search term form + this.searchTerm = $('#searchTerm'); + this.searchSubmit = $('#searchButton'); + //Hidden inputs for eventual submission + this.referencedTerm = $('#referencedTerm'); + this.entryTerm = $('#entryTerm'); + this.termLabel = $('#termLabel'); + this.termType = $('#termType'); + this.removeTermLinks = $('a.remove'); + this.errors = $('#errors'); + }, + + initPage: function() { + this.initTermData(); + this.bindEventListeners(); + + }, + bindEventListeners: function() { + this.searchSubmit.click(function() { + addTerminologyForm.submitSearchTerm(); + addTerminologyForm.clearErrors(); + return false; + }); + + this.form.submit(function() { + return addTerminologyForm.prepareSubmit(); + }); + + this.addTermButton.click(function() { + addTerminologyForm.initForm(); + + }); + this.removeTermLinks.click(function() { + addTerminologyForm.removeExistingTerm(this); + return false; + }); + }, + initForm: function() { + // Hide the button that shows the form + this.showFormButtonWrapper.hide(); + this.clearSearchResults(); + + this.cancel.unbind('click'); + this.cancel.bind('click', function() { + //show only list of existing terms and hide adding term form + addTerminologyForm.showTermListOnlyView(); + return false; + }); + + // Show the form + this.form.show(); + }, + // On page load, associate data with each existing term element. Then we don't + // have to keep retrieving data from or modifying the DOM as we manipulate the + // authorships. + initTermData: function() { + $('.existingTerm').each(function(index) { + $(this).data(existingTermsData[index]); + $(this).data('position', index+1); + }); + }, + clearSearchResults:function() { + $('#selectedTerm').empty(); + }, + clearErrors:function() { + addTerminologyForm.errors.empty(); + }, + showTermListOnlyView: function() { + this.hideForm(); + this.showFormButtonWrapper.show(); + }, + submitSearchTerm: function() { + //Get value of search term + var searchValue = this.searchTerm.val(); + this.entryTerm.val(searchValue); + var dataServiceUrl = addTerminologyForm.dataServiceUrl + "?searchTerm=" + encodeURIComponent(searchValue); + $.getJSON(dataServiceUrl, function(results) { + if ( results.All.length == 0 ) { + } else { + //update existing content type with correct class group name and hide class group select again + var bestMatchResults = results["Best Match"]; + var numberMatches = bestMatchResults.length; + var i; + //For each result, display + var htmlAdd = ""; + if(numberMatches > 0) { + htmlAdd = "<ul class='dd' id='terms' name='terms'>"; + htmlAdd+= addTerminologyForm.addResultsHeader(); + for(i = 0; i < numberMatches; i++) { + var termResult = bestMatchResults[i]; + var CUI = termResult.CUI; + var label = termResult.label; + var definition = termResult.definition; + var type = termResult.type; + var cuiURI = addTerminologyForm.UMLSCUIURL + CUI; + htmlAdd+= addTerminologyForm.generateIndividualTermDisplay(cuiURI, label, definition, type); + } + htmlAdd+= "</ul>"; + } else { + htmlAdd+= "<p>No search results found.</p>"; + } + $('#selectedTerm').html(htmlAdd); + } + + }); + }, + addResultsHeader:function() { + var htmlAdd = "<li class='terminology'><div class='row'><span class='column termLabel'>Label (Type) </span><span class='column termDefinition'>Definition</span></div></li>"; + return htmlAdd; + }, + hideSearchResults:function() { + this.selectedTerm.hide(); + }, + prepareSubmit:function() { + var checkedElements = $("#CUI:checked"); + if(!addTerminologyForm.validateTermSelection(checkedElements)) { + return false; + } + var i; + var len = checkedElements.length; + var checkedTerm, checkedTermElement, termLabel, termType; + var referencedTerms = []; + var termLabels = []; + var termTypes = []; + + checkedElements.each(function() { + checkedTermElement = $(this); + checkedTerm = checkedTermElement.val(); + termType = checkedTermElement.attr("termType"); + termLabel = checkedTermElement.attr("label"); + referencedTerms.push(checkedTerm); + termLabels.push(termLabel); + termTypes.push(termType); + }); + this.referencedTerm.val(referencedTerms); + this.termLabel.val(termLabels); + this.termType.val(termTypes); + return true; + }, + generateIndividualTermDisplay: function(cuiURI, label, definition, type) { + var htmlAdd = "<li class='terminology'>" + + "<div class='row'>" + + "<span class='column termLabel'>" + + "<input type='checkbox' id='CUI' name='CUI' value='" + cuiURI + "' label='" + label + "' termType='" + type + "'/>" + + label + " (" + type + ")</span>" + + "<span class='column termDefinition'>" + definition + "</span>" + + "</div>" + + "</li>"; + return htmlAdd; + }, validateTermSelection:function(checkedElements) { + var numberElements = checkedElements.length; + if(numberElements < 1) { + addTerminologyForm.errors.html("<p class='validationError'>Please select at least one term from search results to add or click cancel.</p>"); + return false; + } + return true; + }, removeExistingTerm: function(link) { + var removeLast = false, + message = 'Are you sure you want to remove this term?'; + + if (!confirm(message)) { + return false; + } + + if ($(link)[0] === $('.remove:last')[0]) { + removeLast = true; + } + + $.ajax({ + url: $(link).attr('href'), + type: 'POST', + data: { + deletion: $(link).parents('.existingTerm').data('termNodeUri') + }, + dataType: 'json', + context: link, // context for callback + complete: function(request, status) { + var existingTerm, + termNodeUri; + + if (status === 'success') { + + existingTerm = $(this).parents('.existingTerm'); + existingTerm.fadeOut(400, function() { + var numTerms; + // For undo link: add to a deletedAuthorships array + // Remove from the DOM + $(this).remove(); + // Actions that depend on the author having been removed from the DOM: + numTerms = $('.existingTerm').length; // retrieve the length after removing authorship from the DOM + }); + + } else { + alert('Error processing request: term not removed'); + } + } + }); + } +}; + +$(document).ready(function() { + addTerminologyForm.onLoad(); +}); diff --git a/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js new file mode 100644 index 00000000..4b4d92f8 --- /dev/null +++ b/productMods/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js @@ -0,0 +1,534 @@ +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var customForm = { + + /* *** Initial page setup *** */ + + onLoad: function() { + + if (this.disableFormInUnsupportedBrowsers()) { + return; + } + this.mixIn(); + this.initObjects(); + this.initPage(); + }, + + disableFormInUnsupportedBrowsers: function() { + var disableWrapper = $('#ie67DisableWrapper'); + + // Check for unsupported browsers only if the element exists on the page + if (disableWrapper.length) { + if (vitro.browserUtils.isIELessThan8()) { + disableWrapper.show(); + $('.noIE67').hide(); + return true; + } + } + return false; + }, + + mixIn: function() { + // Mix in the custom form utility methods + $.extend(this, vitro.customFormUtils); + + // Get the custom form data from the page + $.extend(this, customFormData); + }, + + // On page load, create references for easy access to form elements. + // NB These must be assigned after the elements have been loaded onto the page. + initObjects: function(){ + + this.form = $('form.customForm'); + this.fullViewOnly = $('.fullViewOnly'); + this.button = $('#submit'); + this.requiredLegend = $('#requiredLegend'); + this.typeSelector = this.form.find('#typeSelector'); + + // These are classed rather than id'd in case we want more than one autocomplete on a form. + // At that point we'll use ids to match them up with one another. + this.acSelector = this.form.find('.acSelector'); + this.acSelection = this.form.find('.acSelection'); + this.acSelectionInfo = this.form.find('.acSelectionInfo'); + this.acUriReceiver = this.form.find('.acUriReceiver'); + //this.acLabelReceiver = this.form.find('.acLabelReceiver'); + this.verifyMatch = this.form.find('.verifyMatch'); + this.acSelectorWrapper = this.acSelector.parent(); + + this.or = $('span.or'); + this.cancel = this.form.find('.cancel'); + this.acHelpTextClass = 'acSelectorWithHelpText'; + }, + + // Set up the form on page load + initPage: function() { + + if (!this.editMode) { + this.editMode = 'add'; // edit vs add: default to add + } + + if (!this.formSteps) { // Don't override formSteps specified in form data + if ( !this.fullViewOnly.length || this.editMode === 'edit' || this.editMode === 'repair' ) { + this.formSteps = 1; + // there may also be a 3-step form - look for this.subTypeSelector + } + else { + this.formSteps = 2; + } + } + + //Handles special case such as autocomplete which allows for editing with autocomplete + //By default set to false + if(!this.supportEdit) { + this.supportEdit = false; + } else { + this.supportEdit = true; + } + + this.bindEventListeners(); + + this.initAutocomplete(); + + this.initElementData(); + + this.initFormView(); + + }, + + initFormView: function() { + + var typeVal = this.typeSelector.val(); + + // Put this case first, because in edit mode with + // validation errors we just want initFormFullView. + if ((!this.supportEdit) && (this.editMode == 'edit' || this.editMode == 'repair')) { + this.initFormFullView(); + } + else if (this.findValidationErrors()) { + this.initFormWithValidationErrors(); + } else if(this.supportEdit) { + this.initFormWithSupportEdit(); + } + // If type is already selected when the page loads (Firefox retains value + // on a refresh), go directly to full view. Otherwise user has to reselect + // twice to get to full view. + else if ( this.formSteps == 1 || typeVal.length ) { + this.initFormFullView(); + } + else { + this.initFormTypeView(); + } + }, + + initFormTypeView: function() { + + this.setType(); // empty any previous values (perhaps not needed) + this.hideFields(this.fullViewOnly); + this.button.hide(); + this.requiredLegend.hide(); + this.or.hide(); + + this.cancel.unbind('click'); + }, + + initFormFullView: function() { + + this.setType(); + this.fullViewOnly.show(); + this.or.show(); + this.requiredLegend.show(); + this.button.show(); + this.setButtonText('new'); + this.setLabels(); + + // Set the initial autocomplete help text in the acSelector field. + this.addAcHelpText(); + + this.cancel.unbind('click'); + if (this.formSteps > 1) { + this.cancel.click(function() { + customForm.clearFormData(); // clear any input and validation errors + customForm.initFormTypeView(); + return false; + }); + // In one-step forms, if there is a type selection field, but no value is selected, + // hide the acSelector field. The type selection must be made first so that the + // autocomplete type can be determined. If a type selection has been made, + // unhide the acSelector field. + } else if (this.typeSelector.length) { + this.typeSelector.val() ? this.acSelectorWrapper.show() : this.hideFields(this.acSelectorWrapper); + } + + }, + + initFormWithValidationErrors: function() { + var uri = this.acUriReceiver.val(), + label = this.acSelector.val(); + + // Call initFormFullView first, because showAutocompleteSelection needs + // acType, which is set in initFormFullView. + this.initFormFullView(); + + if (uri) { + this.showAutocompleteSelection(label, uri); + } + + }, + initFormWithSupportEdit: function() { + if(this.editMode == 'edit') { + this.initFormWithValidationErrors(); + //Hide verify match when edit mode + this.verifyMatch.hide(); + } else { + this.initFormFullView(); + } + //Disable submit button until selection made + this.button.attr('disabled', 'disabled'); + this.button.addClass('disabledSubmit'); // tlw + }, + + // Bind event listeners that persist over the life of the page. Event listeners + // that depend on the view should be initialized in the view setup method. + bindEventListeners: function() { + + this.typeSelector.change(function() { + var typeVal = $(this).val(); + + // If an autocomplete selection has been made, undo it. + customForm.undoAutocompleteSelection(); + + // Reinitialize view. If no type selection in a two-step form, go back to type view; + // otherwise, reinitialize full view. + if (!typeVal.length && customForm.formSteps > 1) { + customForm.initFormTypeView(); + } + else { + customForm.initFormFullView(); + // TW Setting focus here was clearing autocomplete help text, so commented it out + // customForm.acSelector.focus(); + } + }); + + this.verifyMatch.click(function() { + window.open($(this).attr('href'), 'verifyMatchWindow', 'width=640,height=640,scrollbars=yes,resizable=yes,status=yes,toolbar=no,menubar=no,location=no'); + return false; + }); + + this.acSelector.focus(function() { + customForm.deleteAcHelpText(); + }); + + this.acSelector.blur(function() { + customForm.addAcHelpText(); + }); + + this.form.submit(function() { + customForm.deleteAcHelpText(); + }); + + }, + + initAutocomplete: function() { + + if (this.editMode === 'edit' && !this.supportEdit) { + return; + } + + this.getAcFilter(); + this.acCache = {}; + + this.acSelector.autocomplete({ + minLength: 3, + source: function(request, response) { + if (request.term in customForm.acCache) { + // console.log('found term in cache'); + response(customForm.acCache[request.term]); + return; + } + // console.log('not getting term from cache'); + + $.ajax({ + url: customForm.acUrl, + dataType: 'json', + data: { + term: request.term, + type: customForm.acType, + multipleTypes:(customForm.acMultipleTypes == undefined || customForm.acMultipleTypes == null)? null: customForm.acMultipleTypes + }, + complete: function(xhr, status) { + // Not sure why, but we need an explicit json parse here. + var results = $.parseJSON(xhr.responseText), + filteredResults = customForm.filterAcResults(results); + customForm.acCache[request.term] = filteredResults; + response(filteredResults); + } + }); + }, + select: function(event, ui) { + customForm.showAutocompleteSelection(ui.item.label, ui.item.uri); + } + }); + }, + + // Store original or base text with elements that will have text substitutions. + // Generally the substitution cannot be made on the current value, since that value + // may have changed from the original. So we store the original text with the element to + // use as a base for substitutions. + initElementData: function() { + + this.placeholderText = '###'; + this.labelsWithPlaceholders = this.form.find('label, .label').filter(function() { + return $(this).html().match(customForm.placeholderText); + }); + this.labelsWithPlaceholders.each(function(){ + $(this).data('baseText', $(this).html()); + }); + + this.button.data('baseText', this.button.val()); + + this.verifyMatch.data('baseHref', this.verifyMatch.attr('href')); + }, + + getAcFilter: function() { + + if (!this.sparqlForAcFilter) { + //console.log('autocomplete filtering turned off'); + this.acFilter = null; + return; + } + + //console.log("sparql for autocomplete filter: " + this.sparqlForAcFilter); + + // Define this.acFilter here, so in case the sparql query fails + // we don't get an error when referencing it later. + this.acFilter = []; + $.ajax({ + url: customForm.sparqlQueryUrl, + dataType: "json", + data: { + query: customForm.sparqlForAcFilter + }, + success: function(data, status, xhr) { + customForm.setAcFilter(data); + } + }); + }, + + setAcFilter: function(data) { + + var key = data.head.vars[0]; + + $.each(data.results.bindings, function() { + customForm.acFilter.push(this[key].value); + }); + }, + + filterAcResults: function(results) { + var filteredResults; + + if (!this.acFilter || !this.acFilter.length) { + //console.log('no autocomplete filtering applied'); + return results; + } + + filteredResults = []; + $.each(results, function() { + if ($.inArray(this.uri, customForm.acFilter) == -1) { + //console.log('adding ' + this.label + ' to filtered results'); + filteredResults.push(this); + } + else { + //console.log('filtering out ' + this.label); + } + }); + return filteredResults; + }, + + // Reset some autocomplete values after type is changed + resetAutocomplete: function(typeVal) { + // Append the type parameter to the base autocomplete url + var glue = this.baseAcUrl.indexOf('?') > -1 ? '&' : '?'; + this.acUrl = this.baseAcUrl + glue + 'type=' + typeVal; + + // Flush autocomplete cache when type is reset, since the cached values + // pertain only to the previous type. + this.acCache = {}; + }, + + showAutocompleteSelection: function(label, uri) { + + this.hideFields(this.acSelectorWrapper); + + // If form has a type selector, add type name to label. If form has no type selector, + // type name is coded into the html. + if (this.typeSelector.length) { + this.acSelection.find('label').html('Selected ' + this.typeName + ':'); + } + + this.acSelection.show(); + + this.acUriReceiver.val(uri); + this.acSelector.val(label); + this.acSelectionInfo.html(label); + this.verifyMatch.attr('href', this.verifyMatch.data('baseHref') + uri); + //Verify match is hidden in edit mode and support edit so unhide it + if(this.editMode == 'edit' && this.supportEdit) { + this.verifyMatch.show(); + } + if(this.supportEdit) { + //On initialization in this mode, submit button is disabled + this.button.removeAttr('disabled'); + this.button.removeClass('disabledSubmit'); // tlw + } + this.setButtonText('existing'); + + this.cancel.unbind('click'); + this.cancel.click(function() { + customForm.undoAutocompleteSelection(); + customForm.initFormFullView(); + return false; + }); + }, + + // Cancel action after making an autocomplete selection: undo autocomplete + // selection (from showAutocomplete) before returning to full view. + undoAutocompleteSelection: function() { + + // The test is not just for efficiency: undoAutocompleteSelection empties the acSelector value, + // which we don't want to do if user has manually entered a value, since he may intend to + // change the type but keep the value. If no new value has been selected, form initialization + // below will correctly empty the value anyway. + if (!this.acSelection.is(':hidden')) { + this.acSelectorWrapper.show(); + this.hideFields(this.acSelection); + this.acSelector.val(''); + this.acUriReceiver.val(''); + this.acSelectionInfo.html(''); + this.verifyMatch.attr('href', this.verifyMatch.data('baseHref')); + + if (this.formSteps > 1) { + this.acSelection.find('label').html('Selected '); + } + + //Resetting so disable submit button again for object property autocomplete + if(this.supportEdit) { + this.button.attr('disabled', 'disabled'); + this.button.addClass('disabledSubmit'); + } + + } + }, + + // Set type uri for autocomplete, and type name for labels and button text. + // Note: we still need this in edit mode, to set the text values. + setType: function() { + + var selectedType; + + // If there's no type selector, these values have been specified in customFormData, + // and will not change over the life of the form. + if (!this.typeSelector.length) { + return; + } + + selectedType = this.typeSelector.find(':selected'); + if (selectedType.length) { + this.acType = selectedType.val(); + this.typeName = selectedType.html(); + } + // reset to empty values; may not need + else { + this.acType = ''; + this.typeName = ''; + } + }, + + // Set field labels based on type selection. Although these won't change in edit + // mode, it's easier to specify the text here than in the jsp. + setLabels: function() { + var typeName = this.getTypeNameForLabels(); + + this.labelsWithPlaceholders.each(function() { + var newLabel = $(this).data('baseText').replace(customForm.placeholderText, typeName); + $(this).html(newLabel); + }); + + }, + + // Set button text based on both type selection and whether it's an autocomplete selection + // or a new related individual. Called when setting up full view of form, and after + // an autocomplete selection. + setButtonText: function(newOrExisting) { + var typeText, + buttonText, + baseButtonText = this.button.data('baseText'); + + // Edit mode button doesn't change, so it's specified in the jsp + if (this.editMode === 'edit') { + return; + } + + //if support select editing, keep button label same + if(this.supportEdit) { + return; + } + + typeText = this.getTypeNameForLabels(); + + // Creating new related individual + if (newOrExisting === 'new') { + if (this.submitButtonTextType == 'compound') { // use == to tolerate nulls + // e.g., 'Create Grant & Principal Investigator' + buttonText = 'Create ' + typeText + ' & ' + baseButtonText; + } else { + // In repair mode, baseButtonText is "Edit X". Keep that for this case. + // In add mode, baseButtonText is "X", so we get, e.g., "Create Publication" + buttonText = this.editMode == 'repair' ? baseButtonText : 'Create ' + baseButtonText; + } + } + // Using existing related individual + else { + // In repair mode, baseButtonText is "Edit X". Keep that for this case. + buttonText = this.editMode == 'repair' ? baseButtonText : 'Add ' + baseButtonText; + } + + this.button.val(buttonText); + }, + + getTypeNameForLabels: function() { + // If this.acType is empty, we are either in a one-step form with no type yet selected, + // or in repair mode in a two-step form with no type selected. Use the default type + // name specified in the form data. + return this.acType ? this.typeName : this.capitalize(this.defaultTypeName); + }, + + // Set the initial help text that appears in the autocomplete field and change the class name + addAcHelpText: function() { + var typeText; + + // First case applies on page load; second case applies when the type gets changed. + if (!this.acSelector.val() || this.acSelector.hasClass(this.acHelpTextClass)) { + typeText = this.getTypeNameForLabels(); + var helpText = "Select an existing " + typeText + " or create a new one."; + //Different for object property autocomplete + if(this.supportEdit) { + helpText = "Select an existing " + typeText; + } + this.acSelector.val(helpText) + .addClass(this.acHelpTextClass); + } + }, + + deleteAcHelpText: function() { + if (this.acSelector.hasClass(this.acHelpTextClass)) { + this.acSelector.val('') + .removeClass(this.acHelpTextClass); + } + } + +}; + +$(document).ready(function() { + customForm.onLoad(); +}); diff --git a/productMods/edit/forms/js/mailingAddressUtils.js b/productMods/templates/freemarker/edit/forms/js/mailingAddressUtils.js similarity index 97% rename from productMods/edit/forms/js/mailingAddressUtils.js rename to productMods/templates/freemarker/edit/forms/js/mailingAddressUtils.js index 4b3c0a06..cb852024 100644 --- a/productMods/edit/forms/js/mailingAddressUtils.js +++ b/productMods/templates/freemarker/edit/forms/js/mailingAddressUtils.js @@ -1,140 +1,140 @@ -/* $This file is distributed under the terms of the license in /doc/license.txt$ */ - -var mailingAddressUtils = { - - onLoad: function(mode,country) { - this.initObjectReferences(); - this.bindEventListeners(); - this.sortCountrySelector(mode,country); - - if ( mode == "add" ) { - this.containerDiv.hide(); - this.submitButton.hide(); - } - else { - this.processCountryRelatedFields(); - } - }, - - initObjectReferences: function() { - this.form = $('#personHasMailingAddress'); - - // The external auth ID field and messages - this.countrySelector = $('#country'); - this.countrySelectorOptions = $('#country option'); - this.address1Field = $('#addrLineOne'); - this.cityField = $('#city'); - this.stateField = $('#state'); - this.stateSelector= $('#stateSelect'); - this.stateLabel = $('#stateLabel'); - this.postalCodeField = $('#postalCode'); - this.postalCodeLabel = $('#postalCodeLabel'); - this.subjectField = $('#subjectName'); - this.rdfsLabel = $('#addrLabel'); - this.addrTypeField = $('#addressType'); - this.submitButton = $('#submit'); - this.containerDiv = $('#addressDetails'); - this.orSpan = $('span.or'); - - }, - - bindEventListeners: function() { - this.idCache = {}; - - this.countrySelector.change(function() { - mailingAddressUtils.processCountryRelatedFields(); - mailingAddressUtils.showHiddenElements(); - }); - - this.form.submit(function() { - mailingAddressUtils.buildAddressLabel(); - }); - - this.stateSelector.change(function() { - mailingAddressUtils.setStateValue(); - }); - }, - - addressClassIsNonUS: function() { - var country = this.countrySelector.val(); - if ( country.search( 'United States' ) == -1 ) { - return true; - } - else { - return false; - } - }, - - buildAddressLabel: function() { - if ( mailingAddressUtils.addressClassIsNonUS() ) { - this.rdfsLabel.val(this.address1Field.val() + " " + this.cityField.val() + " " + this.countrySelector.val()); - } - else { - this.rdfsLabel.val(this.address1Field.val() + " " + this.cityField.val() + " " + this.stateField.val()); - } - }, - - processCountryRelatedFields: function() { - if ( mailingAddressUtils.addressClassIsNonUS() ) { - this.stateLabel.text("Province or Region"); - this.postalCodeField.attr('size', '40'); - this.stateSelector.hide(); - this.stateField.show(); - this.addrTypeField.val("http://vivoweb.org/ontology/core#Address"); - } - else { - this.stateLabel.text("State"); - this.postalCodeField.attr('size', '8'); - this.stateField.hide(); - this.stateSelector.show(); - this.addrTypeField.val("http://vivoweb.org/ontology/core#USPostalAddress"); - } - }, - - showHiddenElements: function() { - this.containerDiv.show(); - this.submitButton.show(); - this.orSpan.show(); - }, - - setStateValue: function() { - this.stateField.val(this.stateSelector.val()); - }, - - // in the ftl we remove the "the" that precedes some countries, so we need to - // re-sort them alphabetically - sortCountrySelector: function(mode,country) { - // Get options from select box - var the_options = this.countrySelectorOptions; - // sort alphabetically - the_options.sort(function(a,b) { - if (a.text > b.text) return 1; - else if (a.text < b.text) return -1; - else return 0 - }) - //replace with sorted the_options; - this.countrySelector.append( the_options ); - - // if it's add mode, add the "select one" option have it be selected; - // if it's edit mode, add the "Select one" option but have the correct country selected. - // if it's repair mode, add the "Select one" option but only select it if there's no country - if ( mode == "add" ) { - this.countrySelector.prepend($("<option selected></option>") - .attr("value","") - .text("Select one")); - } - else if ( mode == "edit" || country.length > 1 ) { - this.countrySelector.prepend($("<option></option>") - .attr("value","") - .text("Select one")); - this.countrySelector.val(country); - } - else if ( country.length == 0 ) { - this.countrySelector.prepend($("<option selected></option>") - .attr("value","") - .text("Select one")); - this.countrySelector.val(country); - } - } - +/* $This file is distributed under the terms of the license in /doc/license.txt$ */ + +var mailingAddressUtils = { + + onLoad: function(mode,country) { + this.initObjectReferences(); + this.bindEventListeners(); + this.sortCountrySelector(mode,country); + + if ( mode == "add" ) { + this.containerDiv.hide(); + this.submitButton.hide(); + } + else { + this.processCountryRelatedFields(); + } + }, + + initObjectReferences: function() { + this.form = $('#personHasMailingAddress'); + + // The external auth ID field and messages + this.countrySelector = $('#country'); + this.countrySelectorOptions = $('#country option'); + this.address1Field = $('#addrLineOne'); + this.cityField = $('#city'); + this.stateField = $('#state'); + this.stateSelector= $('#stateSelect'); + this.stateLabel = $('#stateLabel'); + this.postalCodeField = $('#postalCode'); + this.postalCodeLabel = $('#postalCodeLabel'); + this.subjectField = $('#subjectName'); + this.rdfsLabel = $('#addrLabel'); + this.addrTypeField = $('#addressType'); + this.submitButton = $('#submit'); + this.containerDiv = $('#addressDetails'); + this.orSpan = $('span.or'); + + }, + + bindEventListeners: function() { + this.idCache = {}; + + this.countrySelector.change(function() { + mailingAddressUtils.processCountryRelatedFields(); + mailingAddressUtils.showHiddenElements(); + }); + + this.form.submit(function() { + mailingAddressUtils.buildAddressLabel(); + }); + + this.stateSelector.change(function() { + mailingAddressUtils.setStateValue(); + }); + }, + + addressClassIsNonUS: function() { + var country = this.countrySelector.val(); + if ( country.search( 'United States' ) == -1 ) { + return true; + } + else { + return false; + } + }, + + buildAddressLabel: function() { + if ( mailingAddressUtils.addressClassIsNonUS() ) { + this.rdfsLabel.val(this.address1Field.val() + " " + this.cityField.val() + " " + this.countrySelector.val()); + } + else { + this.rdfsLabel.val(this.address1Field.val() + " " + this.cityField.val() + " " + this.stateField.val()); + } + }, + + processCountryRelatedFields: function() { + if ( mailingAddressUtils.addressClassIsNonUS() ) { + this.stateLabel.text("Province or Region"); + this.postalCodeField.attr('size', '40'); + this.stateSelector.hide(); + this.stateField.show(); + this.addrTypeField.val("http://vivoweb.org/ontology/core#Address"); + } + else { + this.stateLabel.text("State"); + this.postalCodeField.attr('size', '8'); + this.stateField.hide(); + this.stateSelector.show(); + this.addrTypeField.val("http://vivoweb.org/ontology/core#USPostalAddress"); + } + }, + + showHiddenElements: function() { + this.containerDiv.show(); + this.submitButton.show(); + this.orSpan.show(); + }, + + setStateValue: function() { + this.stateField.val(this.stateSelector.val()); + }, + + // in the ftl we remove the "the" that precedes some countries, so we need to + // re-sort them alphabetically + sortCountrySelector: function(mode,country) { + // Get options from select box + var the_options = this.countrySelectorOptions; + // sort alphabetically + the_options.sort(function(a,b) { + if (a.text > b.text) return 1; + else if (a.text < b.text) return -1; + else return 0 + }) + //replace with sorted the_options; + this.countrySelector.append( the_options ); + + // if it's add mode, add the "select one" option have it be selected; + // if it's edit mode, add the "Select one" option but have the correct country selected. + // if it's repair mode, add the "Select one" option but only select it if there's no country + if ( mode == "add" ) { + this.countrySelector.prepend($("<option selected></option>") + .attr("value","") + .text("Select one")); + } + else if ( mode == "edit" || country.length > 1 ) { + this.countrySelector.prepend($("<option></option>") + .attr("value","") + .text("Select one")); + this.countrySelector.val(country); + } + else if ( country.length == 0 ) { + this.countrySelector.prepend($("<option selected></option>") + .attr("value","") + .text("Select one")); + this.countrySelector.val(country); + } + } + } \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl b/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl index ad67b0f0..e1375ae9 100644 --- a/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl +++ b/productMods/templates/freemarker/edit/forms/manageWebpagesForIndividual.ftl @@ -70,10 +70,10 @@ var customFormData = { </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />', - '<link rel="stylesheet" href="${urls.base}/edit/forms/css/manageWebpagesForIndividual.css" />', + '<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/manageWebpagesForIndividual.css" />', '<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/utils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', '<script type="text/javascript" src="${urls.base}/js/customFormUtils.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/manageWebpagesForIndividual.js"></script>')} \ No newline at end of file + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/manageWebpagesForIndividual.js"></script>')} \ No newline at end of file diff --git a/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl b/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl index 1e4734d3..53c036c0 100644 --- a/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl +++ b/productMods/templates/freemarker/edit/forms/newIndividualForm.ftl @@ -76,4 +76,4 @@ </section> -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} diff --git a/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl b/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl index d6c7734f..161c67ae 100644 --- a/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl +++ b/productMods/templates/freemarker/edit/forms/organizationHasPositionHistory.ftl @@ -149,8 +149,8 @@ </section> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', @@ -158,4 +158,4 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/ '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} diff --git a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl index ccea6035..a2cdb017 100644 --- a/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasEducationalTraining.ftl @@ -182,8 +182,8 @@ var customFormData = { </section> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', @@ -191,6 +191,6 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/ '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')} diff --git a/productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl b/productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl index 05c2bd94..7d039001 100644 --- a/productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasMailingAddress.ftl @@ -199,13 +199,13 @@ $(document).ready(function(){ ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/mailingAddressUtils.js"></script>', + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/mailingAddressUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>')} diff --git a/productMods/templates/freemarker/edit/forms/personHasPositionHistory.ftl b/productMods/templates/freemarker/edit/forms/personHasPositionHistory.ftl index d79fad4e..cab88b0b 100644 --- a/productMods/templates/freemarker/edit/forms/personHasPositionHistory.ftl +++ b/productMods/templates/freemarker/edit/forms/personHasPositionHistory.ftl @@ -156,8 +156,8 @@ var customFormData = { </script> ${stylesheets.add('<link rel="stylesheet" href="${urls.base}/js/jquery-ui/css/smoothness/jquery-ui-1.8.9.custom.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customForm.css" />')} -${stylesheets.add('<link rel="stylesheet" href="${urls.base}/edit/forms/css/customFormWithAutocomplete.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customForm.css" />')} +${stylesheets.add('<link rel="stylesheet" href="${urls.base}/templates/freemarker/edit/forms/css/customFormWithAutocomplete.css" />')} ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/jquery-ui-1.8.9.custom.min.js"></script>', @@ -165,4 +165,4 @@ ${scripts.add('<script type="text/javascript" src="${urls.base}/js/jquery-ui/js/ '<script type="text/javascript" src="${urls.base}/js/extensions/String.js"></script>', '<script type="text/javascript" src="${urls.base}/js/browserUtils.js"></script>', '<script type="text/javascript" src="${urls.base}/js/jquery_plugins/jquery.bgiframe.pack.js"></script>', - '<script type="text/javascript" src="${urls.base}/edit/forms/js/customFormWithAutocomplete.js"></script>')} + '<script type="text/javascript" src="${urls.base}/templates/freemarker/edit/forms/js/customFormWithAutocomplete.js"></script>')}