From 8dc823f6630bdbd64a5fbd7619f0312fc9c5d514 Mon Sep 17 00:00:00 2001 From: jeb228 Date: Fri, 25 Jun 2010 21:19:39 +0000 Subject: [PATCH] NIHVIVO-161 Change how the Individual page shows images, editable or non-editable; for Persons or non-Persons, in accordance with the wireframes. --- .../webapp/web/jsptags/PropertyEditLinks.java | 105 ++++++++++++------ .../images/dummyImages/person.thumbnail.jpg | Bin 0 -> 2541 bytes webapp/web/templates/entity/entityBasic.jsp | 70 +++++++----- 3 files changed, 114 insertions(+), 61 deletions(-) create mode 100644 webapp/web/images/dummyImages/person.thumbnail.jpg diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java index 564713c0a..c29dd2fcc 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/jsptags/PropertyEditLinks.java @@ -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,18 +238,14 @@ 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, - "vitroNsProp", "true"); - ls = new LinkStruct(); - ls.setHref( url ); - ls.setType("add"); - ls.setMouseoverText("add a new entry"); - } + String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp", + "subjectUri", subjectUri, + "predicateUri", propertyUri, + "vitroNsProp", "true"); + ls = new LinkStruct(); + 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 links = new ArrayList(); + 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,15 +672,16 @@ public class PropertyEditLinks extends TagSupport{ private LinkStruct[] empty_array = {}; - private LinkStruct getImageLink(String subjectUri, String contextPath, String action) { - LinkStruct ls = new LinkStruct(); - String url = makeRelativeHref(contextPath + "uploadimages.jsp", - "entityUri", subjectUri); - ls.setHref(url); - ls.setType(action); - ls.setMouseoverText("upload a new image"); - return ls; - } + 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(mouseOverText); + return ls; + } private String getObjPropMouseoverLabel(String propertyUri) { String mouseoverText = "relationship"; // default diff --git a/webapp/web/images/dummyImages/person.thumbnail.jpg b/webapp/web/images/dummyImages/person.thumbnail.jpg new file mode 100644 index 0000000000000000000000000000000000000000..dea174dd9ee645d420620c5a163d866454290852 GIT binary patch literal 2541 zcmY*Z2|QG58-LG?84Xjn5$@GR*0N-12A9-?8*1D!)?}A!1~JKqvNm6f3MIQiME26k zjL}9}GZDru#!{9P63Uk)<~zCf>v#K~-+9jedEWE>p5=YsNAybc8f+w6?zaRG0svq5 z0ir2@+Z*<0U<81G7y!T)Hcf*KX1>8bG~inYTOg4ToB@dMK*9_u21}$EO6(g@Xw(|e zXmRm%;^JrwMnVFE!TtyciA18rP#82CvtAM-x&EgOFn;=J?Wcb}*uS+O_kGtybpW>x zgo02cgaZg1gv3Fj1`r7V0zyF$9OwTbhCrd$VI;(nKUmjRHv)h{LU6oD1PZlgf#57~ zD73ip4zoj2b|C~G>2?1pP}zhrSCwJP&LrQdx4))l`13Ege>+&)DCz@PBm@V7#DP6v zs4Kj9cLTz7ZRxv!q)#~Xo2sqpBg{NY?zTQ1x|oI+Z1<uo+Q z7&=kgoH8)lbk75K%Jt2IB7-CMDmUz;r3IbmF-S?KLgWFJJrnH8&556xQnLK{sNJ`+%qP7~Hr$)aW zue{vn*-@>CS&6%B@zh6qknX(;3JzzpJgC8-Ht#JIwwsTbh~^0D@Jwvt#jU=Dg!hCY zTLqOUX3HEu$4Zaa+gK8lubF_oI^bGURpJ>v5-Vi-7pf8>?vf`P_;pdNAKX)GCz(@u zZw$yPsoh_u2YKqx0(DwdMW75RFPMRIM`bJ?1-1F47m}K-SiIPnDWy;4 z2IMlk(lp;6m@aGInO00Ll-{T1eB^nN>5j9(`3$hVln2*-k+q#CU$?!Kzrb4LYU+^M z;)w)CfL(HMf!r?}3aWl{nEl}0EgxvqvhK=u%Gh3Rs9YR4{Lqun*TX!6pTO z`P=_)0k+rC12mt$-imO8;(Z!yoqCE?d^+Px+NZ-RQ~Ea&d0_Tzi^>O3G4vLqJ*2>e zZc+K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B^Kxzt)wHP_B+5Oke>|>wjgWlhAGPz!bwrsmKbh3HG+0S2sd7axh z2kuV3T?CY8i;qmDo%~~U&jPJlm~Udf+@Vxf4AOdgYjM@H8tt?u9}kEqJ@h<)cZd|(nQk$ literal 0 HcmV?d00001 diff --git a/webapp/web/templates/entity/entityBasic.jsp b/webapp/web/templates/entity/entityBasic.jsp index 862961093..94bd7d5c3 100644 --- a/webapp/web/templates/entity/entityBasic.jsp +++ b/webapp/web/templates/entity/entityBasic.jsp @@ -76,6 +76,7 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L +
@@ -186,38 +187,53 @@ if (VitroRequestPrep.isSelfEditing(request) || LoginFormBean.loggedIn(request, L <%-- Thumbnail (with citation) --%> - -
- - -

image

- -
- + " /> + + + + + +
+

image

+ ${imageLinks} +
+
+
+ +
-
- - - - - - - - - - ${editLinks} - +
+ + + ${imageLinks} +
- - <%-- Citation --%> - - - -
- +
+
+ <%-- hasImage --%> +
+
+
+
+ + + + + ${imageLinks} + +
+
+
+
+ +
+
<%-- Description --%>