NIHVIVO-1332 Editing links for individual image
This commit is contained in:
parent
69e8180ae8
commit
91abe8e801
9 changed files with 75 additions and 43 deletions
|
@ -47,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
||||
import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo;
|
||||
|
@ -73,9 +74,15 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(IndividualController.class);
|
||||
|
||||
private static final Map<String, String> namespaces = new HashMap<String, String>() {{
|
||||
put("vitro", VitroVocabulary.vitroURI);
|
||||
put("vitroPublic", VitroVocabulary.VITRO_PUBLIC);
|
||||
}};
|
||||
|
||||
private static final String TEMPLATE_INDIVIDUAL_DEFAULT = "individual.ftl";
|
||||
private static final String TEMPLATE_HELP = "individual-help.ftl";
|
||||
|
||||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
try {
|
||||
|
@ -114,9 +121,9 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
|
||||
Map<String, Object> body = new HashMap<String, Object>();
|
||||
|
||||
body.put("title", individual.getName());
|
||||
|
||||
body.put("title", individual.getName());
|
||||
body.put("relatedSubject", getRelatedSubject(vreq));
|
||||
body.put("namespaces", namespaces);
|
||||
|
||||
IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual);
|
||||
/* We need to expose non-getters in displaying the individual's property list,
|
||||
|
@ -125,9 +132,7 @@ public class IndividualController extends FreemarkerHttpServlet {
|
|||
* into the data model: no real data can be modified.
|
||||
*/
|
||||
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(itm));
|
||||
|
||||
body.put("headContent", getRdfLinkTag(itm));
|
||||
|
||||
body.put("headContent", getRdfLinkTag(itm));
|
||||
body.put("localName", new IndividualLocalNameMethod());
|
||||
|
||||
String template = getIndividualTemplate(individual);
|
||||
|
|
|
@ -36,6 +36,7 @@ public class UrlBuilder {
|
|||
AUTHENTICATE("/authenticate"),
|
||||
BROWSE("/browse"),
|
||||
CONTACT("/contact"),
|
||||
IMAGE_UPLOAD("/uploadImages"),
|
||||
INDIVIDUAL("/individual"),
|
||||
INDIVIDUAL_EDIT("/entityEdit"),
|
||||
INDIVIDUAL_LIST("/individuallist"),
|
||||
|
@ -279,6 +280,13 @@ public class UrlBuilder {
|
|||
|
||||
return profileUrl;
|
||||
}
|
||||
|
||||
public static String getImageUploadUrl(String subjectUri, String action) {
|
||||
ParamMap params = new ParamMap(
|
||||
"entityUri", subjectUri,
|
||||
"action", action);
|
||||
return UrlBuilder.getUrl(Route.IMAGE_UPLOAD, params);
|
||||
}
|
||||
|
||||
public static String urlEncode(String url) {
|
||||
String encoding = "ISO-8859-1";
|
||||
|
|
|
@ -45,10 +45,11 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
|||
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
||||
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
||||
|
||||
@SuppressWarnings("serial")
|
||||
private static final List<String> VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList<String>() {{
|
||||
add(VitroVocabulary.PRIMARY_LINK);
|
||||
add(VitroVocabulary.ADDITIONAL_LINK);
|
||||
//add(VitroVocabulary.IND_MAIN_IMAGE);
|
||||
add(VitroVocabulary.IND_MAIN_IMAGE);
|
||||
}};
|
||||
|
||||
private Individual subject;
|
||||
|
|
|
@ -66,12 +66,15 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
return isPerson() ? getUrl(Route.VISUALIZATION_AJAX.path(), "uri", getUri()) : null;
|
||||
}
|
||||
|
||||
// ** Remove these when the new methods are written
|
||||
// This remains as a convenience method for getting the image url. We could instead use a custom list
|
||||
// view for mainImage which would provide this data in the query results.
|
||||
public String getImageUrl() {
|
||||
String imageUrl = individual.getImageUrl();
|
||||
return imageUrl == null ? null : getUrl(imageUrl);
|
||||
}
|
||||
|
||||
|
||||
// This remains as a convenience method for getting the thumbnail url. We could instead use a custom list
|
||||
// view for mainImage which would provide this data in the query results.
|
||||
public String getThumbUrl() {
|
||||
String thumbUrl = individual.getThumbUrl();
|
||||
return thumbUrl == null ? null : getUrl(thumbUrl);
|
||||
|
@ -106,33 +109,6 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
|||
return individual.isVClass("http://xmlns.com/foaf/0.1/Organization");
|
||||
}
|
||||
|
||||
public Link getPrimaryLink() {
|
||||
Link primaryLink = null;
|
||||
String anchor = individual.getAnchor();
|
||||
String url = individual.getUrl();
|
||||
if (anchor != null && url != null) {
|
||||
primaryLink = new Link();
|
||||
primaryLink.setAnchor(individual.getAnchor());
|
||||
primaryLink.setUrl(individual.getUrl());
|
||||
}
|
||||
return primaryLink;
|
||||
}
|
||||
|
||||
public List<Link> getAdditionalLinks() {
|
||||
return individual.getLinksList();
|
||||
}
|
||||
|
||||
public List<Link> getLinks() {
|
||||
List<Link> additionalLinks = getAdditionalLinks();
|
||||
List<Link> links = new ArrayList<Link>(additionalLinks.size()+1);
|
||||
Link primaryLink = getPrimaryLink();
|
||||
if (primaryLink != null) {
|
||||
links.add(primaryLink);
|
||||
}
|
||||
links.addAll(additionalLinks);
|
||||
return links;
|
||||
}
|
||||
|
||||
public GroupedPropertyList getPropertyList() {
|
||||
if (propertyList == null) {
|
||||
propertyList = new GroupedPropertyList(individual, vreq, policyHelper);
|
||||
|
|
|
@ -16,6 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
||||
public class ObjectPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||
|
||||
|
@ -82,6 +83,9 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
|||
public String getEditUrl() {
|
||||
String editUrl = "";
|
||||
if (isEditable()) {
|
||||
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||
return UrlBuilder.getImageUploadUrl(subjectUri, "edit");
|
||||
}
|
||||
ParamMap params = new ParamMap(
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri,
|
||||
|
@ -90,6 +94,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
|||
params.put("deleteProhibited", "prohibited");
|
||||
}
|
||||
editUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
|
||||
}
|
||||
|
||||
return editUrl;
|
||||
|
@ -98,12 +103,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
|||
public String getDeleteUrl() {
|
||||
String deleteUrl = "";
|
||||
if (isDeletable()) {
|
||||
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||
return UrlBuilder.getImageUploadUrl(subjectUri, "delete");
|
||||
}
|
||||
ParamMap params = new ParamMap(
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri,
|
||||
"objectUri", objectUri,
|
||||
"cmd", "delete");
|
||||
deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
|
||||
}
|
||||
return deleteUrl;
|
||||
}
|
||||
|
|
|
@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import freemarker.cache.TemplateLoader;
|
||||
import freemarker.template.Configuration;
|
||||
|
@ -353,10 +354,14 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
|||
public String getAddUrl() {
|
||||
String addUrl = "";
|
||||
if (addAccess) {
|
||||
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||
return UrlBuilder.getImageUploadUrl(subjectUri, "add");
|
||||
}
|
||||
ParamMap params = new ParamMap(
|
||||
"subjectUri", subjectUri,
|
||||
"predicateUri", propertyUri);
|
||||
addUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
"predicateUri", propertyUri);
|
||||
addUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||
|
||||
}
|
||||
return addUrl;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue