Skip to content

Commit

Permalink
created SPARQL_SELECT_QUERY_RESULTS_NOT_CONTAIN operator, renamed ope…
Browse files Browse the repository at this point in the history
…rator SPARQL_SELECT_QUERY_CONTAINS to SPARQL_SELECT_QUERY_RESULTS_CONTAIN
  • Loading branch information
litvinovg committed Dec 14, 2023
1 parent 6c5d21c commit 82e9463
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ private void adjustComputationCost(CheckType testType) {
case STARTS_WITH:
computationalCost += 1000;
return;
case SPARQL_SELECT_QUERY_CONTAINS:
case SPARQL_SELECT_QUERY_RESULTS_CONTAIN:
computationalCost += 10000;
return;
case SPARQL_SELECT_QUERY_RESULTS_NOT_CONTAIN:
computationalCost += 10000;
return;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ static boolean test(Check attr, AuthorizationRequest ar, String... values) {
return !contains(attr, values);
case STARTS_WITH:
return startsWith(attr, values);
case SPARQL_SELECT_QUERY_CONTAINS:
case SPARQL_SELECT_QUERY_RESULTS_CONTAIN:
return sparqlQueryContains(attr, ar, values);
case SPARQL_SELECT_QUERY_RESULTS_NOT_CONTAIN:
return !sparqlQueryContains(attr, ar, values);
default:
return false;
}
Expand Down Expand Up @@ -65,7 +67,7 @@ private static boolean sparqlQueryContains(Check attr, AuthorizationRequest ar,
List<String> resourceUris = Arrays.asList(ao.getResourceUris());
return ProximityChecker.isAnyRelated(m, resourceUris, personUris, queryTemplate);
}

private static boolean contains(Check attr, String... inputValues) {
AttributeValueSet values = attr.getValues();
for (String inputValue : inputValues) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ public enum CheckType {
ONE_OF,
NOT_ONE_OF,
STARTS_WITH,
SPARQL_SELECT_QUERY_CONTAINS
SPARQL_SELECT_QUERY_RESULTS_CONTAIN,
SPARQL_SELECT_QUERY_RESULTS_NOT_CONTAIN
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static edu.cornell.mannlib.vitro.webapp.auth.checks.CheckType.EQUALS;
import static edu.cornell.mannlib.vitro.webapp.auth.checks.CheckType.ONE_OF;
import static edu.cornell.mannlib.vitro.webapp.auth.checks.CheckType.SPARQL_SELECT_QUERY_CONTAINS;
import static edu.cornell.mannlib.vitro.webapp.auth.checks.CheckType.SPARQL_SELECT_QUERY_RESULTS_CONTAIN;
import static org.junit.Assert.assertEquals;

import java.util.List;
Expand All @@ -23,7 +23,7 @@ public void testAttributeOrderByComputationalCost() {
Check affordableAttribute = uriCheck("test:affordableAttributeUri", value("test:objectUri"));
cheapAttribute.setType(ONE_OF);
Check expensiveAttribute = uriCheck("test:expensiveAttributeUri", value("test:objectUri"));
cheapAttribute.setType(SPARQL_SELECT_QUERY_CONTAINS);
cheapAttribute.setType(SPARQL_SELECT_QUERY_RESULTS_CONTAIN);
rule.addCheck(affordableAttribute);
rule.addCheck(expensiveAttribute);
rule.addCheck(cheapAttribute);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,7 @@ access-individual:StartsWith a access:Operator;
access:id "STARTS_WITH" .

access-individual:SparqlSelectQueryContains a access:Operator;
access:id "SPARQL_SELECT_QUERY_CONTAINS" .
access:id "SPARQL_SELECT_QUERY_RESULTS_CONTAIN" .

access-individual:SparqlSelectQueryResultsNotContain a access:Operator;
access:id "SPARQL_SELECT_QUERY_RESULTS_NOT_CONTAIN" .

0 comments on commit 82e9463

Please sign in to comment.