Adding ability for user accounts to be associated with individuals. NIHVIVO-121

This commit is contained in:
bdc34 2010-03-16 16:51:18 +00:00
parent 5eb474a891
commit 1af92dc350
4 changed files with 91 additions and 20 deletions

View file

@ -104,16 +104,18 @@
<listener-class> edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup </listener-class>
</listener>
<!--
<listener>
<listener-class>
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
</listener-class>
</listener>
<listener>
<listener-class>
edu.cornell.mannlib.vitro.webapp.auth.policy.setup.SelfEditingPolicySetup
edu.cornell.mannlib.vitro.webapp.auth.identifier.UserToIndIdentifierFactorySetup
</listener-class>
</listener>
-->
<listener>
<listener-class> edu.cornell.mannlib.vitro.webapp.auth.policy.setup.EditorEditingPolicySetup
</listener-class>

View file

@ -0,0 +1,31 @@
package edu.cornell.mannlib.vitro.webapp.auth.identifier;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Setups context so that Identifiers for Individuals associated with Users are
* added to requests.
*
* This only adds identifiers. A self-editing policy is also needed.
*
* @author bdc34
*
*/
public class UserToIndIdentifierFactorySetup implements ServletContextListener{
private static final Log log = LogFactory.getLog(UserToIndIdentifierFactorySetup.class.getName());
public void contextInitialized(ServletContextEvent sce) {
ServletContext sc = sce.getServletContext();
ServletIdentifierBundleFactory
.addIdentifierBundleFactory(sc, new UserToIndIdentifierFactory());
log.info("Set up Identifier Factory UserToIndIdentifierFactory.");
}
public void contextDestroyed(ServletContextEvent arg0) {
}
}

View file

@ -58,8 +58,8 @@
/* the post parameters seem to get consumed by the parsing so
* we have to make a copy. */
Map <String,List<String>> queryParameters = null;
queryParameters = request.getParameterMap();
Map <String,String[]> queryParameters = null;
queryParameters = request.getParameterMap();
List<String> errorMessages = new ArrayList<String>();
@ -68,7 +68,7 @@
%><jsp:forward page="/edit/messages/noEditConfigFound.jsp"/><%
}
EditN3Generator n3Subber = editConfig.getN3Generator();
EditSubmission submission = new EditSubmission(queryParameters, editConfig);
EditSubmission submission = new EditSubmission(queryParameters, editConfig);
Map<String,String> errors = submission.getValidationErrors();
EditSubmission.putEditSubmissionInSession(session,submission);
@ -205,10 +205,12 @@
}
OntModel queryModel = editConfig.getQueryModelSelector().getModel(request,application);
Model emptyModel = ModelFactory.createDefaultModel();
if( editConfig.isUseDependentResourceDelete() ){
Model depResRetractions =
DependentResourceDeleteJena
.getDependentResourceDeleteForChange(null,allPossibleToDelete,queryModel);
.getDependentResourceDeleteForChange(emptyModel,allPossibleToDelete,queryModel);
allPossibleToDelete.add( depResRetractions );
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:edLnk="http://vitro.mannlib.cornell.edu/vitro/tags/PropertyEditLink" version="2.0">
<!-- $This file is distributed under the terms of the license in /doc/license.txt$ -->
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0">
<jsp:directive.page import="edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary"/>
<jsp:directive.page import="edu.cornell.mannlib.vitro.webapp.beans.User"/>
<div class="editingForm">
@ -10,10 +10,10 @@
<div align="center">
<table class="form-background" border="0" cellpadding="2" cellspacing="2">
<tr valign="bottom" align="center">
<td>
<tr align="center">
<td valign="bottom">
<form action="listUsers" method="get">
<input type="hidden" name="home" value="${portalBean.portalId}" />
<input type="hidden" name="home" value="${portalBean.portalId}" />
<input type="submit" class="form-button" value="See All User Accounts"/>
</form>
</td>
@ -22,7 +22,7 @@
<input name="home" type="hidden" value="${portalBean.portalId}" />
<input name="uri" type = "hidden" value="${user.URI}" />
<input type="submit" class="form-button" value="Edit User Account"/>
<input type="hidden" name="controller" value="User"/>
<input type="hidden" name="controller" value="User"/>
</form>
<form action="editForm" method="get">
<input name="home" type="hidden" value="${portalBean.portalId}" />
@ -36,14 +36,50 @@
<td valign="bottom">
<form action="editForm" method="get">
<input name="home" type="hidden" value="${portalBean.portalId}" />
<input type="hidden" name="controller" value="User"/>
<input type="hidden" name="controller" value="User"/>
<input type="submit" class="form-button" value="Add New User Account"/>
</form>
</td>
</td>
</tr>
</table>
</div>
</div>
<c:if test="true"> <!-- test="${requestScope.user.roleURI == 1 }"> -->
<table class="form-background" border="0" cellpadding="2" cellspacing="2">
<tr align="center">
<td>
Add new individual that user may edit as
<c:url var="addUrl" value="/edit/editRequestDispatch.jsp">
<c:param name="subjectUri">${user.URI}</c:param>
<c:param name="editform">admin/mayEditAs.jsp</c:param>
</c:url>
<a href="${addUrl}">add</a>
</td>
</tr>
<c:if test="${requestScope.mayEditAsStmts != null }">
<tr><td>User may edit as the following Individuals:</td></tr>
<c:forEach items="${requestScope.mayEditAsStmts }" var="stmt">
<tr>
<td>${stmt.objectURI}</td>
<c:url var="deleteUrl" value="/edit/editRequestDispatch.jsp">
<c:param name="subjectUri">${user.URI}</c:param>
<c:param name="predicateUri">${requestScope.predicateUri}</c:param>
<c:param name="objectUri">${stmt.objectURI}</c:param>
<c:param name="editform">admin/mayEditAs.jsp</c:param>
</c:url>
<td><a href="${deleteUrl}">delete</a></td>
</tr>
</c:forEach>
</c:if>
<c:if test="${requestScope.mayEditAsStmts == null }">
<tr><td>There are no Individuals in the system that the user may edit as.</td></tr>
</c:if>
</table>
</c:if>
</div>
</div>
</jsp:root>