Nuxeo ECM Projects 5.4.3-SNAPSHOT

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:
Serializable, RelationManager, Adaptable, Component, Extensible

public class RelationService
extends DefaultComponent
implements RelationManager

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 add(String graphName, List<Statement> statements)
           
 void applicationStarted(ComponentContext context)
          Notify the component that Nuxeo Framework finished starting all Nuxeo bundles.
 void clear(String graphName)
           
<T> T
getAdapter(Class<T> adapter)
          Returns an object which is an instance of the given class associated with this object.
 Set<Resource> getAllResources(Serializable object, Map<String,Serializable> context)
          Computes all resources corresponding to the given object.
 Graph getGraphByName(String name)
          Gets a registered graph by name.
 Graph getGraphByType(String graphType)
          Gets a graph given a name.
 List<String> getGraphNames()
          Gets the list containing the graph names.
 List<String> getGraphTypes()
           
 List<Node> getObjects(String graphName, Node subject, Node predicate)
           
 List<Node> getPredicates(String graphName, Node subject, Node object)
           
 Resource getResource(String namespace, Serializable object, Map<String,Serializable> context)
          Gets a resource given a namespace and a serializable object.
 Serializable getResourceRepresentation(String namespace, Resource resource, Map<String,Serializable> context)
          Gets an object representing this resource given a namespace.
 List<Statement> getStatements(String graphName)
           
 List<Statement> getStatements(String graphName, Statement statement)
           
 List<Node> getSubjects(String graphName, Node predicate, Node object)
           
 Graph getTransientGraph(String type)
          Gets a transient graph.
 boolean hasResource(String graphName, Resource resource)
           
 boolean hasStatement(String graphName, Statement statement)
           
 QueryResult query(String graphName, String queryString, String language, String baseURI)
           
 boolean read(String graphName, InputStream in, String lang, String base)
           
 void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
           
 void remove(String graphName, List<Statement> statements)
           
 Long size(String graphName)
           
 void unregisterContribution(Object contribution, String extensionPoint, ComponentInstance contributor)
           
 boolean write(String graphName, OutputStream out, String lang, String base)
           
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, deactivate, 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(Object contribution,
                                 String extensionPoint,
                                 ComponentInstance contributor)
Overrides:
registerContribution in class DefaultComponent

unregisterContribution

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

getAdapter

public <T> T getAdapter(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(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 List<String> getGraphTypes()

getTransientGraph

public Graph getTransientGraph(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(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(String namespace,
                            Serializable object,
                            Map<String,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 Set<Resource> getAllResources(Serializable object,
                                     Map<String,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 Serializable getResourceRepresentation(String namespace,
                                              Resource resource,
                                              Map<String,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(String graphName,
                List<Statement> statements)
         throws ClientException
Specified by:
add in interface RelationManager
Throws:
ClientException
See Also:
Graph.add(java.util.List)

clear

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

getObjects

public List<Node> getObjects(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 List<Node> getPredicates(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 List<Statement> getStatements(String graphName,
                                     Statement statement)
                              throws ClientException
Specified by:
getStatements in interface RelationManager
Throws:
ClientException
See Also:
Graph.getStatements()

getStatements

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

getSubjects

public List<Node> getSubjects(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(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(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(String graphName,
                         String queryString,
                         String language,
                         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(String graphName,
                    InputStream in,
                    String 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(String graphName,
                   List<Statement> statements)
            throws ClientException
Specified by:
remove in interface RelationManager
Throws:
ClientException
See Also:
Graph.remove(java.util.List)

size

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

write

public boolean write(String graphName,
                     OutputStream out,
                     String 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 List<String> getGraphNames()
                           throws ClientException
Description copied from interface: RelationManager
Gets the list containing the graph names.

Specified by:
getGraphNames in interface RelationManager
Throws:
ClientException

applicationStarted

public void applicationStarted(ComponentContext context)
                        throws Exception
Description copied from interface: Component
Notify the component that Nuxeo Framework finished starting all Nuxeo bundles.

Specified by:
applicationStarted in interface Component
Overrides:
applicationStarted in class DefaultComponent
Throws:
Exception

Nuxeo ECM Projects 5.4.3-SNAPSHOT

Copyright © 2011 Nuxeo SAS. All Rights Reserved.