NIHVIVO-161 Change how the Individual page shows images, editable or non-editable; for Persons or non-Persons, in accordance with the wireframes.

This commit is contained in:
jeb228 2010-06-25 21:19:39 +00:00
parent bf0d9bdb08
commit 8dc823f663
3 changed files with 114 additions and 61 deletions

View file

@ -6,6 +6,7 @@ import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.jsp.JspException;
@ -44,6 +45,7 @@ import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatementImpl;
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.RdfLiteralHash;
import edu.cornell.mannlib.vitro.webapp.filestorage.FileModelHelper;
import edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils;
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
@ -157,8 +159,10 @@ public class PropertyEditLinks extends TagSupport{
ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(subjectUri, predicateUri, data);
links = doObjPropStmt( prop, policyToAccess(ids, policy, prop), contextPath );
}
}
else {
} else if (VitroVocabulary.IND_MAIN_IMAGE.equals(predicateUri)) {
links = doImageLinks(entity, ids, policy, contextPath);
} else {
log.error("PropertyEditLinks cannot make links for an object of type " + predicateUri);
return SKIP_BODY;
}
@ -234,9 +238,6 @@ public class PropertyEditLinks extends TagSupport{
if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){
log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link");
LinkStruct ls = null;
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
ls = getImageLink(subjectUri, contextPath, "add");
} else {
String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp",
"subjectUri", subjectUri,
"predicateUri", propertyUri,
@ -245,7 +246,6 @@ public class PropertyEditLinks extends TagSupport{
ls.setHref( url );
ls.setType("add");
ls.setMouseoverText("add a new entry");
}
links[0] = ls;
} else {
log.debug("no add link generated for vitro namespace property "+propertyUri);
@ -345,17 +345,6 @@ public class PropertyEditLinks extends TagSupport{
LinkStruct[] links = new LinkStruct[2];
if (predicateUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
if( contains( allowedAccessTypeArray, EditLinkAccess.MODIFY ) ){
log.debug("permission found to UPDATE vitro namepsace property statement "+ predicateUri);
links[0] = getImageLink(subjectUri, contextPath, "edit");
return links;
}
else {
log.debug("NO permission found to DELETE vitro namespace property " + predicateUri);
}
}
String value = dpropStmt.getData();
Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel");
@ -479,6 +468,53 @@ public class PropertyEditLinks extends TagSupport{
return links;
}
protected LinkStruct[] doImageLinks(Individual entity,
IdentifierBundle ids, PolicyIface policy, String contextPath) {
Individual mainImage = FileModelHelper.getMainImage(entity);
String subjectUri = entity.getURI();
String predicateUri = VitroVocabulary.IND_MAIN_IMAGE;
if (mainImage == null) {
EditLinkAccess[] accesses = policyToAccess(ids, policy, subjectUri,
predicateUri);
if (contains(accesses, EditLinkAccess.ADDNEW)) {
log.debug("permission to ADD main image to " + subjectUri);
return new LinkStruct[] { getImageLink(subjectUri, contextPath,
"edit", "upload an image") };
} else {
log.debug("NO permission to ADD main image to " + subjectUri);
return empty_array;
}
} else {
ObjectPropertyStatement prop = new ObjectPropertyStatementImpl(
subjectUri, predicateUri, mainImage.getURI());
EditLinkAccess[] allowedAccessTypeArray = policyToAccess(ids,
policy, prop);
List<LinkStruct> links = new ArrayList<LinkStruct>();
if (contains(allowedAccessTypeArray, EditLinkAccess.MODIFY)) {
log.debug("permission to MODIFY main image to " + subjectUri);
links.add(getImageLink(subjectUri, contextPath, "edit",
"replace this image"));
} else {
log.debug("NO permission to MODIFY main image to "
+ subjectUri);
}
if (contains(allowedAccessTypeArray, EditLinkAccess.DELETE)) {
log.debug("permission to DELETE main image to " + subjectUri);
links.add(getImageLink(subjectUri, contextPath, "delete",
"delete this image"));
} else {
log.debug("NO permission to DELETE main image to "
+ subjectUri);
}
return links.toArray(new LinkStruct[links.size()]);
}
}
/* ********************* utility methods ********************************* */
protected static String makeRelativeHref( String baseUrl, String ... queries ) {
@ -636,13 +672,14 @@ public class PropertyEditLinks extends TagSupport{
private LinkStruct[] empty_array = {};
private LinkStruct getImageLink(String subjectUri, String contextPath, String action) {
private LinkStruct getImageLink(String subjectUri, String contextPath,
String action, String mouseOverText) {
LinkStruct ls = new LinkStruct();
String url = makeRelativeHref(contextPath + "uploadimages.jsp",
"entityUri", subjectUri);
ls.setHref(url);
ls.setType(action);
ls.setMouseoverText("upload a new image");
ls.setMouseoverText(mouseOverText);
return ls;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -76,6 +76,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
<c:set var='portal' value='${currentPortalId}'/>
<c:set var='portalBean' value='${currentPortal}'/>
<c:set var='themeDir'><c:out value='${portalBean.themeDir}' /></c:set>
<div id="content">
@ -186,38 +187,53 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L
</c:if>
<%-- Thumbnail (with citation) --%>
<c:if test="${showEdits || !empty entity.thumbUrl}">
<c:set var="isPerson" value="<%= entity.isVClass("http://xmlns.com/foaf/0.1/Person") %>" />
<c:set var="hasImage" value="${!empty entity.thumbUrl}" />
<c:set var="imageLinks"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" /></c:set>
<c:choose>
<c:when test="${!isPerson && !hasImage}">
<c:if test="${showEdits && !empty imageLinks}">
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
<c:set var="mayEditImage"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" /></c:set>
<c:if test="${showEdits and !empty mayEditImage}">
<h3 class="propertyName">image</h3>
<edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" icons="false" />
${imageLinks}
</div>
</c:if>
<c:if test="${!empty entity.thumbUrl}">
</c:when>
<c:when test="${isPerson && !hasImage}">
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
<div class="datatypeProperties">
<div class="datatypePropertyValue">
<div class="statementWrap thumbnail">
<c:set var="imageTitle" value="${entity.name}" />
<c:if test="${!empty entity.imageUrl}">
<a class="image" href="<c:url value='${entity.imageUrl}'/>">
<c:set var="imageTitle" value="click to view larger image in new window" />
</c:if>
<img src="<c:url value='${entity.thumbUrl}'/>" title="${imageTitle}" alt="" width="150"/>
<c:if test="${!empty entity.imageUrl}"></a></c:if>
<img src="<c:url value='/images/dummyImages/person.thumbnail.jpg'/>"
title="no image" alt="" width="150"/>
<c:if test="${showEdits}">
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.IND_MAIN_IMAGE %>" data="${entity.thumbUrl}" icons="false"/></c:set>
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
<span class="editLinks">${imageLinks}</span>
</c:if>
</div>
</div>
</div>
<%-- Citation --%>
</div>
</c:when>
<c:otherwise> <%-- hasImage --%>
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
<div class="datatypeProperties">
<div class="datatypePropertyValue">
<div class="statementWrap thumbnail">
<a class="image" href="<c:url value='${entity.imageUrl}'/>">
<img src="<c:url value='${entity.thumbUrl}'/>"
title="click to view larger image in new window"
alt="" width="150"/>
</a>
<c:if test="${showEdits}">
<span class="editLinks">${imageLinks}</span>
</c:if>
</div>
</div>
</div>
</div>
<jsp:include page="entityCitation.jsp" />
</c:if>
</div>
</c:if>
</c:otherwise>
</c:choose>
<%-- Description --%>
<c:if test="${ showEdits || !empty entity.description}">