Nuxeo Enterprise Platform 5.4

org.nuxeo.ecm.platform.relations.services
Class RelationService

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.platform.relations.services.RelationService
All Implemented Interfaces:
java.io.Serializable, java.util.EventListener, RelationManager, Adaptable, Component, Extensible, org.osgi.framework.FrameworkListener

public class RelationService
extends DefaultComponent
implements RelationManager, org.osgi.framework.FrameworkListener

Relation service.

It handles a registry of graph instances through extension points.

Author:
Anahide Tchertchian
See Also:
Serialized Form

Field Summary
static ComponentName NAME
           
 
Constructor Summary
RelationService()
           
 
Method Summary
 void activate(ComponentContext context)
          Activates the component.
 void add(java.lang.String graphName, java.util.List<Statement> statements)
           
 void clear(java.lang.String graphName)
           
 void deactivate(ComponentContext context)
          Deactivates the component.
 void frameworkEvent(org.osgi.framework.FrameworkEvent event)
           
<T> T
getAdapter(java.lang.Class<T> adapter)
          Returns an object which is an instance of the given class associated with this object.
 java.util.Set<Resource> getAllResources(java.io.Serializable object, java.util.Map<java.lang.String,java.io.Serializable> context)
          Computes all resources corresponding to the given object.
 Graph getGraphByName(java.lang.String name)
          Gets a registered graph by name.
 Graph getGraphByType(java.lang.String graphType)
          Gets a graph given a name.
 java.util.List<java.lang.String> getGraphNames()
          Gets the list containing the graph names.
 java.util.List<java.lang.String> getGraphTypes()
           
 java.util.List<Node> getObjects(java.lang.String graphName, Node subject, Node predicate)
           
 java.util.List<Node> getPredicates(java.lang.String graphName, Node subject, Node object)
           
 Resource getResource(java.lang.String namespace, java.io.Serializable object, java.util.Map<java.lang.String,java.io.Serializable> context)
          Gets a resource given a namespace and a serializable object.
 java.io.Serializable getResourceRepresentation(java.lang.String namespace, Resource resource, java.util.Map<java.lang.String,java.io.Serializable> context)
          Gets an object representing this resource given a namespace.
 java.util.List<Statement> getStatements(java.lang.String graphName)
           
 java.util.List<Statement> getStatements(java.lang.String graphName, Statement statement)
           
 java.util.List<Node> getSubjects(java.lang.String graphName, Node predicate, Node object)
           
 Graph getTransientGraph(java.lang.String type)
          Gets a transient graph.
 boolean hasResource(java.lang.String graphName, Resource resource)
           
 boolean hasStatement(java.lang.String graphName, Statement statement)
           
 QueryResult query(java.lang.String graphName, java.lang.String queryString, java.lang.String language, java.lang.String baseURI)
           
 boolean read(java.lang.String graphName, java.io.InputStream in, java.lang.String lang, java.lang.String base)
           
 void registerContribution(java.lang.Object contribution, java.lang.String extensionPoint, ComponentInstance contributor)
           
 void remove(java.lang.String graphName, java.util.List<Statement> statements)
           
 java.lang.Long size(java.lang.String graphName)
           
 void unregisterContribution(java.lang.Object contribution, java.lang.String extensionPoint, ComponentInstance contributor)
           
 boolean write(java.lang.String graphName, java.io.OutputStream out, java.lang.String lang, java.lang.String base)
           
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
registerExtension, unregisterExtension
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

public static final ComponentName NAME
Constructor Detail

RelationService

public RelationService()
Method Detail

registerContribution

public void registerContribution(java.lang.Object contribution,
                                 java.lang.String extensionPoint,
                                 ComponentInstance contributor)
Overrides:
registerContribution in class DefaultComponent

unregisterContribution

public void unregisterContribution(java.lang.Object contribution,
                                   java.lang.String extensionPoint,
                                   ComponentInstance contributor)
Overrides:
unregisterContribution in class DefaultComponent

getAdapter

public <T> T getAdapter(java.lang.Class<T> adapter)
Description copied from interface: Adaptable
Returns an object which is an instance of the given class associated with this object. Returns null if no such object can be found.

Specified by:
getAdapter in interface Adaptable
Overrides:
getAdapter in class DefaultComponent
Parameters:
adapter - the adapter class to look up
Returns:
a object castable to the given class, or null if this object does not have an adapter for the given class

getGraphByType

public Graph getGraphByType(java.lang.String graphType)
Gets a graph given a name.

This is used to instantiate graphs with a given name

Parameters:
graphType -
Returns:
the prefixed resource instance initialized with no value or null if prefix is not found

getGraphTypes

public java.util.List<java.lang.String> getGraphTypes()

getTransientGraph

public Graph getTransientGraph(java.lang.String type)
                        throws ClientException
Description copied from interface: RelationManager
Gets a transient graph.

Specified by:
getTransientGraph in interface RelationManager
Parameters:
type - The graph type.
Returns:
the graph.
Throws:
ClientException

getGraphByName

public Graph getGraphByName(java.lang.String name)
                     throws ClientException
Description copied from interface: RelationManager
Gets a registered graph by name.

Specified by:
getGraphByName in interface RelationManager
Parameters:
name - string name of the graph used at registration
Returns:
the graph
Throws:
ClientException

getResource

public Resource getResource(java.lang.String namespace,
                            java.io.Serializable object,
                            java.util.Map<java.lang.String,java.io.Serializable> context)
                     throws ClientException
Description copied from interface: RelationManager
Gets a resource given a namespace and a serializable object.

There can be several resources with different namespaces associated to an incoming object. A document can for instance be used to refer to itself as a precise version as well as to the set of all versions.

Context can hold any object useful for the adapters, like a CoreSession.

Specified by:
getResource in interface RelationManager
Throws:
ClientException

getAllResources

public java.util.Set<Resource> getAllResources(java.io.Serializable object,
                                               java.util.Map<java.lang.String,java.io.Serializable> context)
                                        throws ClientException
Description copied from interface: RelationManager
Computes all resources corresponding to the given object.

Context can hold any object useful for the adapters, like a CoreSession.

Specified by:
getAllResources in interface RelationManager
Returns:
the resources as a set
Throws:
ClientException

getResourceRepresentation

public java.io.Serializable getResourceRepresentation(java.lang.String namespace,
                                                      Resource resource,
                                                      java.util.Map<java.lang.String,java.io.Serializable> context)
                                               throws ClientException
Description copied from interface: RelationManager
Gets an object representing this resource given a namespace.

Context can hold any object useful for the adapters, like a CoreSession.

Specified by:
getResourceRepresentation in interface RelationManager
Throws:
ClientException

add

public void add(java.lang.String graphName,
                java.util.List<Statement> statements)
         throws ClientException
Specified by:
add in interface RelationManager
Throws:
ClientException
See Also:
Graph.add(java.util.List)

clear

public void clear(java.lang.String graphName)
           throws ClientException
Specified by:
clear in interface RelationManager
Throws:
ClientException
See Also:
Graph.clear()

getObjects

public java.util.List<Node> getObjects(java.lang.String graphName,
                                       Node subject,
                                       Node predicate)
                                throws ClientException
Specified by:
getObjects in interface RelationManager
Throws:
ClientException
See Also:
Graph.getObjects(org.nuxeo.ecm.platform.relations.api.Node, org.nuxeo.ecm.platform.relations.api.Node)

getPredicates

public java.util.List<Node> getPredicates(java.lang.String graphName,
                                          Node subject,
                                          Node object)
                                   throws ClientException
Specified by:
getPredicates in interface RelationManager
Throws:
ClientException
See Also:
Graph.getPredicates(org.nuxeo.ecm.platform.relations.api.Node, org.nuxeo.ecm.platform.relations.api.Node)

getStatements

public java.util.List<Statement> getStatements(java.lang.String graphName,
                                               Statement statement)
                                        throws ClientException
Specified by:
getStatements in interface RelationManager
Throws:
ClientException
See Also:
Graph.getStatements()

getStatements

public java.util.List<Statement> getStatements(java.lang.String graphName)
                                        throws ClientException
Specified by:
getStatements in interface RelationManager
Throws:
ClientException
See Also:
Graph.getStatements()

getSubjects

public java.util.List<Node> getSubjects(java.lang.String graphName,
                                        Node predicate,
                                        Node object)
                                 throws ClientException
Specified by:
getSubjects in interface RelationManager
Throws:
ClientException
See Also:
Graph.getSubjects(org.nuxeo.ecm.platform.relations.api.Node, org.nuxeo.ecm.platform.relations.api.Node)

hasResource

public boolean hasResource(java.lang.String graphName,
                           Resource resource)
                    throws ClientException
Specified by:
hasResource in interface RelationManager
Throws:
ClientException
See Also:
Graph.hasResource(org.nuxeo.ecm.platform.relations.api.Resource)

hasStatement

public boolean hasStatement(java.lang.String graphName,
                            Statement statement)
                     throws ClientException
Specified by:
hasStatement in interface RelationManager
Throws:
ClientException
See Also:
Graph.hasStatement(org.nuxeo.ecm.platform.relations.api.Statement)

query

public QueryResult query(java.lang.String graphName,
                         java.lang.String queryString,
                         java.lang.String language,
                         java.lang.String baseURI)
                  throws ClientException
Specified by:
query in interface RelationManager
Throws:
ClientException
See Also:
Graph.query(java.lang.String, java.lang.String, java.lang.String)

read

public boolean read(java.lang.String graphName,
                    java.io.InputStream in,
                    java.lang.String lang,
                    java.lang.String base)
             throws ClientException
Specified by:
read in interface RelationManager
Throws:
ClientException
See Also:
Graph.read(java.lang.String, java.lang.String, java.lang.String)

remove

public void remove(java.lang.String graphName,
                   java.util.List<Statement> statements)
            throws ClientException
Specified by:
remove in interface RelationManager
Throws:
ClientException
See Also:
Graph.remove(java.util.List)

size

public java.lang.Long size(java.lang.String graphName)
                    throws ClientException
Specified by:
size in interface RelationManager
Throws:
ClientException
See Also:
Graph.size()

write

public boolean write(java.lang.String graphName,
                     java.io.OutputStream out,
                     java.lang.String lang,
                     java.lang.String base)
              throws ClientException
Specified by:
write in interface RelationManager
Throws:
ClientException
See Also:
Graph.write(java.lang.String, java.lang.String, java.lang.String)

getGraphNames

public java.util.List<java.lang.String> getGraphNames()
                                               throws ClientException
Description copied from interface: RelationManager
Gets the list containing the graph names.

Specified by:
getGraphNames in interface RelationManager
Throws:
ClientException

frameworkEvent

public void frameworkEvent(org.osgi.framework.FrameworkEvent event)
Specified by:
frameworkEvent in interface org.osgi.framework.FrameworkListener

activate

public void activate(ComponentContext context)
              throws java.lang.Exception
Description copied from interface: Component
Activates the component.

This method is called by the runtime when a component is activated.

Specified by:
activate in interface Component
Overrides:
activate in class DefaultComponent
Parameters:
context - the runtime context
Throws:
java.lang.Exception - if an error occurs during activation

deactivate

public void deactivate(ComponentContext context)
                throws java.lang.Exception
Description copied from interface: Component
Deactivates the component.

This method is called by the runtime when a component is deactivated.

Specified by:
deactivate in interface Component
Overrides:
deactivate in class DefaultComponent
Parameters:
context - the runtime context
Throws:
java.lang.Exception - if an error occurs during activation

Nuxeo Enterprise Platform 5.4

Copyright © 2010 Nuxeo SAS. All Rights Reserved.