From eaf0a0e2d33041def5c032a2ca9a8eff1098380e Mon Sep 17 00:00:00 2001 From: bdc34 Date: Thu, 22 Jul 2010 15:18:25 +0000 Subject: [PATCH] Merge to trunk. Changed the way a new individual is created on the siteAdmin NIHVIVO-881 --- productMods/edit/forms/newIndividualForm.jsp | 189 +++++++++++++++++++ 1 file changed, 189 insertions(+) create mode 100644 productMods/edit/forms/newIndividualForm.jsp diff --git a/productMods/edit/forms/newIndividualForm.jsp b/productMods/edit/forms/newIndividualForm.jsp new file mode 100644 index 00000000..eb9f78ae --- /dev/null +++ b/productMods/edit/forms/newIndividualForm.jsp @@ -0,0 +1,189 @@ +<%-- $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.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.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; + } + } + } +%> + +<%= 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); +%> + + + + + +

Create a new ${typeName} individual

+ +
" > + + + + + + + + + + +

+

* required fields

+ + +