[VIVO-1115] Pass properties from the config to enable AltMetric badges

This commit is contained in:
grahamtriggs 2015-10-22 15:27:05 +01:00
parent d6c8d05018
commit 31898440f3

View file

@ -6,6 +6,7 @@ import java.io.IOException;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import com.hp.hpl.jena.rdf.model.RDFNode; import com.hp.hpl.jena.rdf.model.RDFNode;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
@ -74,6 +75,7 @@ class IndividualResponseBuilder {
this.eDataRetrieval = new ExecuteDataRetrieval(this.vreq, this.vreq.getDisplayModel(), this.individual); this.eDataRetrieval = new ExecuteDataRetrieval(this.vreq, this.vreq.getDisplayModel(), this.individual);
} }
ResponseValues assembleResponse() throws TemplateModelException { ResponseValues assembleResponse() throws TemplateModelException {
Map<String, Object> body = new HashMap<String, Object>(); Map<String, Object> body = new HashMap<String, Object>();
@ -84,6 +86,8 @@ class IndividualResponseBuilder {
body.put("profilePageTypesEnabled", getprofilePageTypesFlag()); body.put("profilePageTypesEnabled", getprofilePageTypesFlag());
body.put("verbosePropertySwitch", getVerbosePropertyValues()); body.put("verbosePropertySwitch", getVerbosePropertyValues());
addAltMetricOptions(body);
//Execute data getters that might apply to this individual, e.g. because of the class of the individual //Execute data getters that might apply to this individual, e.g. because of the class of the individual
try{ try{
this.eDataRetrieval.executeDataGetters(body); this.eDataRetrieval.executeDataGetters(body);
@ -172,6 +176,31 @@ class IndividualResponseBuilder {
return map; return map;
} }
private void addAltMetricOptions(Map<String, Object> body) {
ConfigurationProperties properties = ConfigurationProperties.getBean(vreq);
if (properties != null) {
String enabled = properties.getProperty("resource.altmetric"); //, "enabled"
String displayTo = properties.getProperty("resource.altmetric.displayto", "right");
String badgeType = properties.getProperty("resource.altmetric.badge-type", "donut");
String badgeHideEmpty = properties.getProperty("resource.altmetric.hide-no-mentions", "true");
String badgePopover = properties.getProperty("resource.altmetric.badge-popover", "right");
String badgeDetails = properties.getProperty("resource.altmetric.badge-details");
if ("enabled".equalsIgnoreCase(enabled)) {
body.put("altmetricEnabled", true);
body.put("altmetricDisplayTo", displayTo);
body.put("altmetricBadgeType", badgeType);
if ("true".equalsIgnoreCase(badgeHideEmpty)) {
body.put("altmetricHideEmpty", true);
}
body.put("altmetricPopover", badgePopover);
body.put("altmetricDetails", badgeDetails);
}
}
}
private boolean getTemporalVisualizationFlag() { private boolean getTemporalVisualizationFlag() {
String property = ConfigurationProperties.getBean(vreq).getProperty( String property = ConfigurationProperties.getBean(vreq).getProperty(
"visualization.temporal"); "visualization.temporal");