NIHVIVO-220 Add links to image upload on front end individual page

This commit is contained in:
rjy7 2010-03-23 22:05:25 +00:00
parent 3582d32ef3
commit 15e45f4474
3 changed files with 93 additions and 54 deletions

View file

@ -286,7 +286,7 @@ public class VitroVocabulary {
public static final List<String> VITRO_NS_PROPERTIES = Arrays.asList(BLURB, CITATION, DESCRIPTION, LABEL, LINK_ANCHOR, MONIKER, PRIMARY_LINK, RDF_TYPE, TIMEKEY); public static final List<String> VITRO_NS_PROPERTIES = Arrays.asList(BLURB, CITATION, DESCRIPTION, IMAGETHUMB, LABEL, LINK_ANCHOR, MONIKER, PRIMARY_LINK, RDF_TYPE, TIMEKEY);
public static String getVitroNsPropDatatypeUri(String propName) { public static String getVitroNsPropDatatypeUri(String propName) {
Resource datatype = propName == TIMEKEY ? XSD.dateTime : XSD.xstring; Resource datatype = propName == TIMEKEY ? XSD.dateTime : XSD.xstring;

View file

@ -168,10 +168,6 @@ public class PropertyEditLinks extends TagSupport{
return SKIP_BODY; return SKIP_BODY;
} }
private boolean isVitroNsProp(String predicateUri) {
return VitroVocabulary.VITRO_NS_PROPERTIES.contains(predicateUri);
}
protected LinkStruct[] doDataProp(DataProperty dprop, Individual entity, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) { protected LinkStruct[] doDataProp(DataProperty dprop, Individual entity, String themeDir, EditLinkAccess[] allowedAccessTypeArray, String contextPath) {
if( allowedAccessTypeArray == null || dprop == null || allowedAccessTypeArray.length == 0 ) { if( allowedAccessTypeArray == null || dprop == null || allowedAccessTypeArray.length == 0 ) {
log.debug("null or empty access type array in doDataProp for dprop "+dprop.getPublicName()+"; most likely just a property prohibited from editing"); log.debug("null or empty access type array in doDataProp for dprop "+dprop.getPublicName()+"; most likely just a property prohibited from editing");
@ -216,14 +212,19 @@ public class PropertyEditLinks extends TagSupport{
} else { } else {
if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){ if( contains( allowedAccessTypeArray, EditLinkAccess.ADDNEW ) ){
log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link"); log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link");
LinkStruct ls = null;
if (propertyUri.equals(VitroVocabulary.IMAGETHUMB)) {
ls = getImageLink(subjectUri, contextPath, "add");
} else {
String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp", String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp",
"subjectUri", subjectUri, "subjectUri", subjectUri,
"predicateUri", propertyUri, "predicateUri", propertyUri,
"vitroNsProp", "true"); "vitroNsProp", "true");
LinkStruct ls = new LinkStruct(); ls = new LinkStruct();
ls.setHref( url ); ls.setHref( url );
ls.setType("add"); ls.setType("add");
ls.setMouseoverText("add a new entry"); ls.setMouseoverText("add a new entry");
}
links[0] = ls; links[0] = ls;
} else { } else {
log.debug("no add link generated for vitro namespace property "+propertyUri); log.debug("no add link generated for vitro namespace property "+propertyUri);
@ -361,13 +362,26 @@ public class PropertyEditLinks extends TagSupport{
String subjectUri = subject.getURI(); String subjectUri = subject.getURI();
String predicateUri = dpropStmt.getDatapropURI(); String predicateUri = dpropStmt.getDatapropURI();
LinkStruct[] links = new LinkStruct[2];
if (predicateUri.equals(VitroVocabulary.IMAGETHUMB)) {
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(); String value = dpropStmt.getData();
Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel"); Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel");
String dpropHash = String.valueOf(RdfLiteralHash.makeVitroNsLiteralHash( subject, predicateUri, value, model )); String dpropHash = String.valueOf(RdfLiteralHash.makeVitroNsLiteralHash( subject, predicateUri, value, model ));
String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp"; String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp";
LinkStruct[] links = new LinkStruct[2];
int index = 0; int index = 0;
boolean deleteAllowed = ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) && boolean deleteAllowed = ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) &&
@ -391,7 +405,7 @@ public class PropertyEditLinks extends TagSupport{
ls.setHref(url); ls.setHref(url);
ls.setType("edit"); ls.setType("edit");
ls.setMouseoverText("edit this text"); ls.setMouseoverText(predicateUri.equals("label") ? "edit name" : "edit this text");
links[index] = ls; links[index] = ls;
index++; index++;
} }
@ -576,12 +590,21 @@ public class PropertyEditLinks extends TagSupport{
} }
// public interface CheckAccess{
// boolean access(ObjectProperty prop, EditLinkAccess access );
// boolean access(DataProperty prop, EditLinkAccess access );
// boolean access(ObjectPropertyStatement stmt, EditLinkAccess access );
// boolean access(DataPropertyStatement stmt, EditLinkAccess access );
// }
private LinkStruct[] empty_array = {}; 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 boolean isVitroNsProp(String predicateUri) {
return VitroVocabulary.VITRO_NS_PROPERTIES.contains(predicateUri);
}
} }

View file

@ -186,15 +186,30 @@ RY Description not working - FIX
</c:if> </c:if>
<%-- Thumbnail (with citation) --%> <%-- Thumbnail (with citation) --%>
<div id="dprop-vitro-image" class="propsItem ${editingClass}">
<c:if test="${showEdits}">
<h3 class="propertyName">image</h3>
<edLnk:editLinks item="<%= VitroVocabulary.IMAGETHUMB %>" icons="false" />
</c:if>
<c:if test="${!empty entity.imageThumb}"> <c:if test="${!empty entity.imageThumb}">
<div class="thumbnail"> <div class="datatypeProperties">
<div class="datatypePropertyValue">
<div class="statementWrap thumbnail">
<c:set var="imageTitle" value="${entity.name}" />
<c:if test="${!empty entity.imageFile}"> <c:if test="${!empty entity.imageFile}">
<c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" /> <c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" />
<a class="image" href="${imageUrl}"> <a class="image" href="${imageUrl}">
<c:set var="imageTitle" value="click to view larger image in new window" />
</c:if> </c:if>
<c:url var="imageSrc" value='/${imageDir}/${entity.imageThumb}'/> <c:url var="imageSrc" value='/${imageDir}/${entity.imageThumb}'/>
<img src="<c:out value="${imageSrc}"/>" title="click to view larger image in new window" alt="" width="150"/> <img src="<c:out value="${imageSrc}"/>" title="${imageTitle}" alt="" width="150"/>
<c:if test="${!empty entity.imageFile}"></a></c:if> <c:if test="${!empty entity.imageFile}"></a></c:if>
<c:if test="${showEdits}">
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.IMAGETHUMB %>" data="${entity.imageThumb}" icons="false"/></c:set>
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
</c:if>
</div>
</div>
</div> </div>
<%-- Citation --%> <%-- Citation --%>
@ -218,6 +233,7 @@ RY Description not working - FIX
</c:if> </c:if>
</div> </div>
</c:if> </c:if>
</div>
<p:process> <p:process>