Commit a6e9500d authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[doc] Added documentation

parent f0b8d20207e6
...@@ -110,10 +110,45 @@ const MY_VIEW_DESCRIPTOR: definition.ViewDescriptor = { ...@@ -110,10 +110,45 @@ const MY_VIEW_DESCRIPTOR: definition.ViewDescriptor = {
### Priority evaluation ### Priority evaluation
The RDF dataset. When computing the priority of a view, the raw and complete RDF dataset is passed to the `priorityFor` method of the view implementation, along with the target of rendering, i.e. the primary entity to be rendered by this view.
It is the responsability of the view implementation to determine its priority regarding the dataset and the target entity.
For example, a view specific to books *should* try to detect the type of the target resource and *should* deactivate itself if it does not look like a book.
In the case the view desires to deactivate itself, the `VIEW_PRIORITY_INAPPROPRIATE` constant can be returned.
The target RDF resource. The strategy to be used to determine whether the view is appropriate and what is its priority is left to the view itself.
A common strategy is to look for the triples with the `rdf:type` predicate on triples with the target entity as subject.
For example:
priorityFor(store: $rdf.Formula, target: application.Resource): number {
// use an entity repository for easier manipulation of the RDF dataset
let repo = new rdfEntities.RdfEntityStore(store);
// get the entity identified as the target
let entity = repo.entityForUri(target.uri);
// determine whether the target is really is target, or a proxy of another entity with a focus predicate
// this step may not be applicable to all use cases
let focus = entity.getEntityForS("");
if (focus !== null) entity = focus;
// list all the types of the entity (using rdf:type)
let entityTypes = entity.getEntitiesForS("");
if (entityTypes.length > 0) {
// look for a specific entity type
let x = entityTypes.find(
(entity: rdfEntities.RdfEntity) =>
entity.uris.indexOf("") >= 0
if (x) {
// The entity is a Book
return 10;
// could not find the types, the view may not be appropriate
return implementation.VIEW_PRIORITY_INAPPROPRIATE;
### Rendering ### Rendering
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment