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

@ -167,10 +167,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 ) {
@ -213,17 +209,22 @@ public class PropertyEditLinks extends TagSupport{
if (stmts.hasNext()) { if (stmts.hasNext()) {
log.debug("not showing an \"add\" link for vitro namespace property " + propertyUri + " because it has a limit of 1"); log.debug("not showing an \"add\" link for vitro namespace property " + propertyUri + " because it has a limit of 1");
} 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");
String url = makeRelativeHref(contextPath + "edit/editDatapropStmtRequestDispatch.jsp", LinkStruct ls = null;
"subjectUri", subjectUri, if (propertyUri.equals(VitroVocabulary.IMAGETHUMB)) {
"predicateUri", propertyUri, ls = getImageLink(subjectUri, contextPath, "add");
"vitroNsProp", "true"); } else {
LinkStruct ls = new LinkStruct(); String url = makeRelativeHref(contextPath +"edit/editDatapropStmtRequestDispatch.jsp",
ls.setHref( url ); "subjectUri", subjectUri,
ls.setType("add"); "predicateUri", propertyUri,
ls.setMouseoverText("add a new entry"); "vitroNsProp", "true");
ls = new LinkStruct();
ls.setHref( url );
ls.setType("add");
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,38 +186,54 @@ RY Description not working - FIX
</c:if> </c:if>
<%-- Thumbnail (with citation) --%> <%-- Thumbnail (with citation) --%>
<c:if test="${!empty entity.imageThumb}"> <div id="dprop-vitro-image" class="propsItem ${editingClass}">
<div class="thumbnail"> <c:if test="${showEdits}">
<c:if test="${!empty entity.imageFile}"> <h3 class="propertyName">image</h3>
<c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" /> <edLnk:editLinks item="<%= VitroVocabulary.IMAGETHUMB %>" icons="false" />
<a class="image" href="${imageUrl}"> </c:if>
</c:if> <c:if test="${!empty entity.imageThumb}">
<c:url var="imageSrc" value='/${imageDir}/${entity.imageThumb}'/> <div class="datatypeProperties">
<img src="<c:out value="${imageSrc}"/>" title="click to view larger image in new window" alt="" width="150"/> <div class="datatypePropertyValue">
<c:if test="${!empty entity.imageFile}"></a></c:if> <div class="statementWrap thumbnail">
</div> <c:set var="imageTitle" value="${entity.name}" />
<c:if test="${!empty entity.imageFile}">
<%-- Citation --%> <c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" />
<div id="dprop-vitro-citation" class="propsItem ${editingClass}"> <a class="image" href="${imageUrl}">
<c:if test="${showEdits}"> <c:set var="imageTitle" value="click to view larger image in new window" />
<h3 class="propertyName">citation</h3> </c:if>
<edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" icons="false"/> <c:url var="imageSrc" value='/${imageDir}/${entity.imageThumb}'/>
</c:if> <img src="<c:out value="${imageSrc}"/>" title="${imageTitle}" alt="" width="150"/>
<c:if test="${!empty entity.citation}"> <c:if test="${!empty entity.imageFile}"></a></c:if>
<div class="datatypeProperties"> <c:if test="${showEdits}">
<div class="datatypePropertyValue"> <c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.IMAGETHUMB %>" data="${entity.imageThumb}" icons="false"/></c:set>
<div class="statementWrap"> <c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
${entity.citation} </c:if>
<c:if test="${showEdits}">
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" data="${entity.citation}" icons="false"/></c:set>
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
</c:if>
</div>
</div> </div>
</div> </div>
</c:if> </div>
</div>
</c:if> <%-- Citation --%>
<div id="dprop-vitro-citation" class="propsItem ${editingClass}">
<c:if test="${showEdits}">
<h3 class="propertyName">citation</h3>
<edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" icons="false"/>
</c:if>
<c:if test="${!empty entity.citation}">
<div class="datatypeProperties">
<div class="datatypePropertyValue">
<div class="statementWrap">
${entity.citation}
<c:if test="${showEdits}">
<c:set var="editLinks"><edLnk:editLinks item="<%= VitroVocabulary.CITATION %>" data="${entity.citation}" icons="false"/></c:set>
<c:if test="${!empty editLinks}"><span class="editLinks">${editLinks}</span></c:if>
</c:if>
</div>
</div>
</div>
</c:if>
</div>
</c:if>
</div>
<p:process> <p:process>