updates for page management security, labels

This commit is contained in:
hudajkhan 2013-10-02 14:58:01 -04:00
parent 8d520895ac
commit 3e5c770506
10 changed files with 60 additions and 17 deletions

View file

@ -111,6 +111,7 @@ class IndividualResponseBuilder {
*/
// body.put("individual", wrap(itm, BeansWrapper.EXPOSE_SAFE));
body.put("labelCount", getLabelCount(itm.getUri(), vreq));
body.put("languageCount", getLanguagesRepresentedCount(itm.getUri(), vreq));
//We also need to know the number of available locales
body.put("localesCount", SelectedLocale.getSelectableLocales(vreq).size());
body.put("profileType", getProfileType(itm.getUri(), vreq));
@ -279,6 +280,13 @@ class IndividualResponseBuilder {
+ " FILTER isLiteral(?label) \n"
+ "}" ;
private static String DISTINCT_LANGUAGE_QUERY = ""
+ "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n"
+ "SELECT ( str(COUNT(DISTINCT lang(?label))) AS ?languageCount ) WHERE { \n"
+ " ?subject rdfs:label ?label \n"
+ " FILTER isLiteral(?label) \n"
+ "}" ;
private static Integer getLabelCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(LABEL_COUNT_QUERY, "subject", subjectUri);
log.debug("queryStr = " + queryStr);
@ -297,6 +305,25 @@ class IndividualResponseBuilder {
}
return theCount;
}
//what is the number of languages represented across the labels
private static Integer getLanguagesRepresentedCount(String subjectUri, VitroRequest vreq) {
String queryStr = QueryUtils.subUriForQueryVar(DISTINCT_LANGUAGE_QUERY, "subject", subjectUri);
log.debug("queryStr = " + queryStr);
int theCount = 0;
try {
ResultSet results = QueryUtils.getLanguageNeutralQueryResults(queryStr, vreq);
if (results.hasNext()) {
QuerySolution soln = results.nextSolution();
String countStr = soln.get("languageCount").toString();
theCount = Integer.parseInt(countStr);
}
} catch (Exception e) {
log.error(e, e);
}
return theCount;
}
private static String PROFILE_TYPE_QUERY = ""
+ "PREFIX display: <http://vitro.mannlib.cornell.edu/ontologies/display/1.1#> \n"

View file

@ -48,7 +48,7 @@ public class DisplayVocabulary {
public static final String ITEM_TO_PAGE = NS + "toPage";
public static final String HAS_ELEMENT = NS + "hasElement";
public static final String USES_DATAGETTER_CLASS = NS + "usesDataGetterClass";
public static final String REQUIRED_ACTIONS = NS + "requiredAction";
public static final String REQUIRES_ACTIONS = NS + "requiresAction";
/**Data Getter object properties **/
public static final String HAS_DATA_GETTER = NS + "hasDataGetter";

View file

@ -83,7 +83,7 @@ public class PageDaoJena extends JenaBaseDao implements PageDao {
static final protected String requiredActionsQuery =
prefixes + "\n" +
"SELECT ?requiredAction WHERE{\n" +
" ?pageUri <" + DisplayVocabulary.REQUIRED_ACTIONS + "> ?requiredAction .\n"+
" ?pageUri <" + DisplayVocabulary.REQUIRES_ACTIONS + "> ?requiredAction .\n"+
"}";
//Get data getter URIs