NIHVIVO-2343 Allow configuration of what types of Individual are eligible to have proxies.
This commit is contained in:
parent
89ea62af47
commit
2203b09fed
6 changed files with 49 additions and 4 deletions
|
@ -125,3 +125,9 @@ selfEditing.idMatchingProperty = http://vitro.mydomain.edu/ns#networkId
|
|||
#
|
||||
#externalAuth.buttonText = Log in using BearCat Shibboleth
|
||||
#externalAuth.netIdHeaderName = remote_userID
|
||||
|
||||
#
|
||||
# Types of individual for which we can create proxy editors.
|
||||
# If this is omitted, defaults to http://www.w3.org/2002/07/owl#Thing
|
||||
proxy.eligibleTypeList = http://www.w3.org/2002/07/owl#Thing
|
||||
|
||||
|
|
|
@ -35,6 +35,8 @@ public class ManageProxiesListPage extends AbstractPageHandler {
|
|||
|
||||
private static final String TEMPLATE_NAME = "manageProxies-list.ftl";
|
||||
|
||||
private static final String PROPERTY_PROFILE_TYPES = "proxy.eligibleTypeList";
|
||||
|
||||
private static final String DEFAULT_IMAGE_URL = UrlBuilder
|
||||
.getUrl("/images/placeholders/person.thumbnail.jpg");
|
||||
|
||||
|
@ -94,6 +96,7 @@ public class ManageProxiesListPage extends AbstractPageHandler {
|
|||
body.put("page", buildPageMap(selection));
|
||||
|
||||
body.put("matchingProperty", getMatchingProperty());
|
||||
body.put("profileTypes", buildProfileTypesString());
|
||||
|
||||
body.put("formUrls", buildUrlsMap());
|
||||
|
||||
|
@ -103,6 +106,11 @@ public class ManageProxiesListPage extends AbstractPageHandler {
|
|||
return body;
|
||||
}
|
||||
|
||||
private String buildProfileTypesString() {
|
||||
return ConfigurationProperties.getBean(vreq).getProperty(
|
||||
PROPERTY_PROFILE_TYPES, "http://www.w3.org/2002/07/owl#Thing");
|
||||
}
|
||||
|
||||
private List<ProxyRelationship> wrapProxyRelationships(
|
||||
ProxyRelationshipSelection selection) {
|
||||
List<ProxyRelationship> wrapped = new ArrayList<ProxyRelationship>();
|
||||
|
|
|
@ -18,6 +18,7 @@ import edu.cornell.mannlib.vitro.webapp.auth.requestedAction.usepages.ManageOwnP
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.SelfEditingConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||
import edu.cornell.mannlib.vitro.webapp.config.ConfigurationProperties;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.accounts.UserAccountsPage;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.accounts.admin.UserAccountsEditPage;
|
||||
|
@ -47,6 +48,8 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
|||
|
||||
private static final String TEMPLATE_NAME = "userAccounts-myAccount.ftl";
|
||||
|
||||
private static final String PROPERTY_PROFILE_TYPES = "proxy.eligibleTypeList";
|
||||
|
||||
private final UserAccountsMyAccountPageStrategy strategy;
|
||||
|
||||
private final UserAccount userAccount;
|
||||
|
@ -148,6 +151,7 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
|||
}
|
||||
body.put("formUrls", buildUrlsMap());
|
||||
body.put("myAccountUri", userAccount.getUri());
|
||||
body.put("profileTypes", buildProfileTypesString());
|
||||
|
||||
// Could I do this without exposing this mechanism? But how to search
|
||||
// for an associated profile in AJAX?
|
||||
|
@ -172,6 +176,11 @@ public class UserAccountsMyAccountPage extends UserAccountsPage {
|
|||
return new TemplateResponseValues(TEMPLATE_NAME, body);
|
||||
}
|
||||
|
||||
private String buildProfileTypesString() {
|
||||
return ConfigurationProperties.getBean(vreq).getProperty(
|
||||
PROPERTY_PROFILE_TYPES, "http://www.w3.org/2002/07/owl#Thing");
|
||||
}
|
||||
|
||||
public void updateAccount() {
|
||||
userAccount.setEmailAddress(emailAddress);
|
||||
userAccount.setFirstName(firstName);
|
||||
|
|
|
@ -128,6 +128,7 @@ function statusFieldUpdater(element, minLength) {
|
|||
|
||||
var profileQuery = ""
|
||||
+ "PREFIX fn: <http://www.w3.org/2005/xpath-functions#> \n"
|
||||
+ "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> \n"
|
||||
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
|
||||
+ "PREFIX foaf: <http://xmlns.com/foaf/0.1/> \n"
|
||||
+ "PREFIX vitro: <http://vitro.mannlib.cornell.edu/ns/vitro/0.7#> \n"
|
||||
|
@ -136,8 +137,8 @@ var profileQuery = ""
|
|||
+ "\n"
|
||||
+ "SELECT DISTINCT ?uri ?label ?classLabel ?imageUrl \n"
|
||||
+ "WHERE { \n"
|
||||
+ " ?uri a foaf:Person ; \n"
|
||||
+ " rdfs:label ?label ; \n"
|
||||
+ " %typesUnion% \n"
|
||||
+ " ?uri rdfs:label ?label ; \n"
|
||||
+ " OPTIONAL { \n"
|
||||
+ " ?uri vitro:mostSpecificType ?type. \n"
|
||||
+ " ?type rdfs:label ?classLabel \n"
|
||||
|
@ -220,6 +221,23 @@ var getAdditionalProxyInfo = function(parent, info, externalAuthId) {
|
|||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* The profileTypes context string must have one or more type URIs, separated by commas.
|
||||
*/
|
||||
var applyProfileTypes = function(rawQuery) {
|
||||
var typeClause = '';
|
||||
var types = proxyContextInfo.profileTypes.split(',');
|
||||
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
typeClause += '{ ?uri rdf:type <' + types[i].trim() + '> }';
|
||||
if (i + 1 < types.length) {
|
||||
typeClause += ' UNION ';
|
||||
} else {
|
||||
typeClause += ' .';
|
||||
}
|
||||
}
|
||||
return rawQuery.replace("%typesUnion%", typeClause);
|
||||
}
|
||||
|
||||
/*
|
||||
* Execute this when the page loads.
|
||||
|
@ -245,16 +263,18 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
/*
|
||||
* For each proxyProfilesPanel, create a plain vanilla panel using the
|
||||
* For each proxyProfilesPanel, modify the profile query to restrict it
|
||||
* to the permitted types, then create a plain vanilla panel using the
|
||||
* profile query against the main model.
|
||||
*/
|
||||
$("div[name='proxyProfilesPanel']").each(function(i) {
|
||||
var query = applyProfileTypes(profileQuery);
|
||||
var context = {
|
||||
excludedUris: [],
|
||||
baseUrl: proxyContextInfo.baseUrl,
|
||||
sparqlQueryUrl: proxyContextInfo.sparqlQueryUrl,
|
||||
defaultImageUrl: proxyContextInfo.defaultImageUrl,
|
||||
query: profileQuery,
|
||||
query: query,
|
||||
model: ''
|
||||
}
|
||||
this["proxyItemsPanel"] = new proxyItemsPanel(this, context);
|
||||
|
|
|
@ -54,6 +54,7 @@ var proxyContextInfo = {
|
|||
sparqlQueryUrl: '${formUrls.sparqlQueryAjax}',
|
||||
defaultImageUrl: '${formUrls.defaultImageUrl}',
|
||||
matchingProperty: '${matchingProperty}',
|
||||
profileTypes: '${profileTypes}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -212,6 +212,7 @@ var proxyContextInfo = {
|
|||
sparqlQueryUrl: '${formUrls.sparqlQueryAjax}',
|
||||
defaultImageUrl: '${formUrls.defaultImageUrl}',
|
||||
matchingProperty: '${matchingProperty}',
|
||||
profileTypes: '${profileTypes}'
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue