Table of Contents
Gluing
The term "Gluing" refers to the manner in which PageParts are attached to a given URL. A "Glue" contains [Statements], made up of [Triples] written in either the [SPARQL] or N3 languages. When a URL is requested, you expect a page back, probably with content of some sort. With RAPPTOR, a Page is a class that gets instanciated. The Page is then Extended through its Extension Point. In this case, the Extension point is a Collection of PageParts.
This is really where the fruits of the "Gluing" process comes in. A PagePart qualifies for inclusion because the Glue written for it satisfies the contextual conditions of the URL and the users status by matching RDF Graphs. This Graph Matching is done in the AddInManager class, GetPossibleExtensions function.
Example: A Glue for the DeleteUserGroup PagePart.
<addin type-name="Rapptor.Web.PageParts.UserManagement.DeleteUserGroup">
<glue language="n3" priority="1" return-limit="1" search-pattern="session+instance">
<![CDATA[
@prefix core: <http://www.rapptor.org/core#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix um: <http://www.rapptor.org/usermanagement#> .
@prefix web: <http://www.rapptor.org/web#> .
core:instance web:path "/system/users"^^xsd:string ;
web:requested <view://maintenance> .
um:currentUser core:is ?user .
?user um:hasPermission um:editSystemConfig .
]]>
</glue>
</addin>
This is a glue used in the administration section. The first tag contains the name of the class to be glued. NOTE: The full .Net namespace including the Class name must be given.
The <glue> tag is where we specify the language. It can be set to either "sparql" or "n3". N3 is actually much faster in processing time than sparql.
Next comes the definition of prefixes for the different Namespaces. This is basically to avoiding writing out the complete URI every time. E.g. The "core:is" predicate translates to "<http://www.rapptor.org/core#is>". The namespaces: core, um and web are defined in the RapptorCore Project under the file Semantics.cs. A list of the available commands is included below. the XSD namespace is necessary to provide syntax for system types like string or int.
After defining the prefixes, one must define the statements allowing the PagePart will be shown. Each statement is made up of a Subject, Predicate and an Object.
This instance of the current Node must also have the path "/system/users" and the view query set to "?view=maintenance". The next block defines the variable "?user" to be an instance of the current user. The current user(Subject) must have the permission(Predicate) to edit system configuration settings(Object).
If the Glue statements match with statements generated by a URL like
http://localhost:8080/system/users/?view=maintenance
then this PagePart will be shown.
Creating a Glue Programmatically
A PagePart can be Glued programmatically, by placing a static function named Glue in the PagePart class. In n3/Sparql there is no way to express conditional statementents[citation needed] and is therefore rather inflexible. The form of the function is standard. Depending on ones requirements, the boolean values and their use in the final if statement are to be replaced.
public static IEnumerable<Entity> Glue(ICommonContext context)
{
StatementSet set = new StatementSet(new Entity(OCore.O_STR_INSTANCE));
set.Import(context.GetDeepCombination("instance"));
bool hasStream = set.MainSet.GetValue<bool>(new Entity(ORapptorWeb.P_STR_NODE_HAS_STREAM));
bool isView = Equals(set.MainSet.GetEntity(new Entity(ORapptorWeb.P_STR_REQUESTED)), new Entity("view://view"));
Entity node = set.MainSet.GetEntity(new Entity(ORapptorWeb.P_STR_NODE));
if((hasStream && !isView) || !hasStream)
{
yield return node;
}
}
In this example, we use two variables to test for the existance of a Stream(denotes a file) and if the requested view is "view". With these variables we can control whether a node is returned or not. This method is use full if we wanted a PagePart to be shown under two different "views", which, would not normally be possible.
Standard Gluing Vocabulary The standard glue namespaces are:
- core <http://www.rapptor.org/core#>
- um: <http://www.rapptor.org/usermanagement#>
- web: <http://www.rapptor.org/web#>
- xsd <http://www.w3.org/2001/XMLSchema#>
Subjects Usually, the Subject in a glue is an object whose properties you want to query. e.g. the current Node or the current User.
- core:instance - this one is used to reference the current Node. Usually to assign the current Node to a Variable E.g. core:instance web:node ?node .
- um:currentUser
Predicates
- core:is - one of the most frequently used and basic predicates.
- web:node
- web:path
- web:requested
- web:nodeExists
- web:storePersistable
- web:nodeHasStream - true/ false. used to identify Node as files/directories.
- um:hasPermission
Objects
The Object part of can contain strings,ints booleans and other system types as well as user defined URIs.
User Permissions
- um:viewContent
- um:editSystemConfig
- um:editContent
- um:editUser
- um:addNode
- um:addUser
- um:deleteUser
