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) {
Resource datatype = propName == TIMEKEY ? XSD.dateTime : XSD.xstring;

View file

@ -167,10 +167,6 @@ public class PropertyEditLinks extends TagSupport{
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) {
if( allowedAccessTypeArray == null || dprop == null || allowedAccessTypeArray.length == 0 ) {
@ -213,17 +209,22 @@ public class PropertyEditLinks extends TagSupport{
if (stmts.hasNext()) {
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 ) ){
log.debug("vitro namespace property "+propertyUri+" gets an \"add\" link");
String url = makeRelativeHref(contextPath + "edit/editDatapropStmtRequestDispatch.jsp",
"subjectUri", subjectUri,
"predicateUri", propertyUri,
"vitroNsProp", "true");
LinkStruct ls = new LinkStruct();
ls.setHref( url );
ls.setType("add");
ls.setMouseoverText("add a new entry");
LinkStruct ls = null;
if (propertyUri.equals(VitroVocabulary.IMAGETHUMB)) {
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");
}
links[0] = ls;
} else {
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 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();
Model model = (Model)pageContext.getServletContext().getAttribute("jenaOntModel");
String dpropHash = String.valueOf(RdfLiteralHash.makeVitroNsLiteralHash( subject, predicateUri, value, model ));
String dispatchUrl = contextPath + "edit/editDatapropStmtRequestDispatch.jsp";
LinkStruct[] links = new LinkStruct[2];
int index = 0;
boolean deleteAllowed = ( contains( allowedAccessTypeArray, EditLinkAccess.DELETE ) &&
@ -391,7 +405,7 @@ public class PropertyEditLinks extends TagSupport{
ls.setHref(url);
ls.setType("edit");
ls.setMouseoverText("edit this text");
ls.setMouseoverText(predicateUri.equals("label") ? "edit name" : "edit this text");
links[index] = ls;
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 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>
<%-- Thumbnail (with citation) --%>
<c:if test="${!empty entity.imageThumb}">
<div class="thumbnail">
<c:if test="${!empty entity.imageFile}">
<c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" />
<a class="image" href="${imageUrl}">
</c:if>
<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"/>
<c:if test="${!empty entity.imageFile}"></a></c:if>
</div>
<%-- 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 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}">
<div class="datatypeProperties">
<div class="datatypePropertyValue">
<div class="statementWrap thumbnail">
<c:set var="imageTitle" value="${entity.name}" />
<c:if test="${!empty entity.imageFile}">
<c:url var="imageUrl" value="/${imageDir}/${entity.imageFile}" />
<a class="image" href="${imageUrl}">
<c:set var="imageTitle" value="click to view larger image in new window" />
</c:if>
<c:url var="imageSrc" value='/${imageDir}/${entity.imageThumb}'/>
<img src="<c:out value="${imageSrc}"/>" title="${imageTitle}" alt="" width="150"/>
<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>
</c:if>
</div>
</c:if>
</div>
<%-- 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>