org.pelds.rules
Class RuleQuery

java.lang.Object
  extended by org.pelds.rules.RuleQuery

public class RuleQuery
extends java.lang.Object

RuleQuery takes a SPARQL query, a ruleset, and some data and returns only triples permitted by the given rules.

Author:
Hannes Muehleisen (hannes@muehleisen.org)

Field Summary
static java.lang.String PELDS_NS
           
static java.lang.String PELDS_ONT_FILE
           
static java.lang.String PELDS_ONT_LOC
           
static java.lang.String PELDS_PREFIX
           
static java.lang.String QUERY_ACTION
           
static java.lang.String UPDATE_ACTION
           
 
Constructor Summary
RuleQuery(java.lang.String type, com.hp.hpl.jena.rdf.model.Model data, java.util.Collection<java.lang.String> identities, java.util.Collection<java.lang.String> rules, com.hp.hpl.jena.shared.PrefixMapping pm)
          Constructor
 
Method Summary
 RuleQuery addRule(java.lang.String ruleStr)
           
 boolean checkUpdates(com.hp.hpl.jena.rdf.model.Model updates)
          Returns true if the changes to the model are allowed by the rules
static java.lang.String createRandomizedUri(java.lang.String subNs)
          Create a random URI for variables and actions
 com.hp.hpl.jena.rdf.model.Model getCheckedModel()
          Returns a model containing only the triples authorized by the rules
 com.hp.hpl.jena.ontology.OntModel getModel()
           
 com.hp.hpl.jena.shared.PrefixMapping getPrefixMapping()
           
 RuleQuery setData(com.hp.hpl.jena.rdf.model.Model data)
           
 RuleQuery setIdentities(java.util.Collection<java.lang.String> verifiedIds)
           
 RuleQuery setRules(java.util.Collection<java.lang.String> rules)
           
 RuleQuery setVerbose(boolean set)
           
static java.lang.String slurp(java.io.InputStream in)
          Reads a whole InputStream into a String
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PELDS_PREFIX

public static final java.lang.String PELDS_PREFIX
See Also:
Constant Field Values

PELDS_NS

public static final java.lang.String PELDS_NS
See Also:
Constant Field Values

PELDS_ONT_LOC

public static final java.lang.String PELDS_ONT_LOC
See Also:
Constant Field Values

PELDS_ONT_FILE

public static final java.lang.String PELDS_ONT_FILE
See Also:
Constant Field Values

QUERY_ACTION

public static final java.lang.String QUERY_ACTION
See Also:
Constant Field Values

UPDATE_ACTION

public static final java.lang.String UPDATE_ACTION
See Also:
Constant Field Values
Constructor Detail

RuleQuery

public RuleQuery(java.lang.String type,
                 com.hp.hpl.jena.rdf.model.Model data,
                 java.util.Collection<java.lang.String> identities,
                 java.util.Collection<java.lang.String> rules,
                 com.hp.hpl.jena.shared.PrefixMapping pm)
Constructor

Parameters:
type - Query type, either QueryAction or UpdateAction
data - RDF Model containing the data to be checked
identities - querying users authenticated Web IDs
rules - rules in string representation
pm - prefix mapping from configuration
Method Detail

getCheckedModel

public com.hp.hpl.jena.rdf.model.Model getCheckedModel()
Returns a model containing only the triples authorized by the rules

Returns:
checked RDF model

checkUpdates

public boolean checkUpdates(com.hp.hpl.jena.rdf.model.Model updates)
Returns true if the changes to the model are allowed by the rules

Parameters:
updates - changes as RDF model
Returns:
true if changes are allowed

createRandomizedUri

public static java.lang.String createRandomizedUri(java.lang.String subNs)
Create a random URI for variables and actions

Parameters:
subNs - namespace separator
Returns:
randomized URI

slurp

public static java.lang.String slurp(java.io.InputStream in)
                              throws java.io.IOException
Reads a whole InputStream into a String

Parameters:
in - Stream
Returns:
String with the data from the stream
Throws:
java.io.IOException

setIdentities

public RuleQuery setIdentities(java.util.Collection<java.lang.String> verifiedIds)

setVerbose

public RuleQuery setVerbose(boolean set)

setRules

public RuleQuery setRules(java.util.Collection<java.lang.String> rules)

addRule

public RuleQuery addRule(java.lang.String ruleStr)

setData

public RuleQuery setData(com.hp.hpl.jena.rdf.model.Model data)

getPrefixMapping

public com.hp.hpl.jena.shared.PrefixMapping getPrefixMapping()

getModel

public com.hp.hpl.jena.ontology.OntModel getModel()