Nuxeo ECM Projects 5.6-RC1

org.nuxeo.ecm.platform.semanticentities.service
Class RemoteEntityServiceImpl

java.lang.Object
  extended by org.nuxeo.runtime.model.DefaultComponent
      extended by org.nuxeo.ecm.platform.semanticentities.service.RemoteEntityServiceImpl
All Implemented Interfaces:
RemoteEntityService, RemoteEntitySource, Adaptable, Component, Extensible, TimestampedService

public class RemoteEntityServiceImpl
extends DefaultComponent
implements RemoteEntityService

Default implementation for the RemoteEntityService component. Can be used to register remote entity sources for linked data dereferencing.


Field Summary
static String REMOTESOURCES_XP_NAME
           
 
Constructor Summary
RemoteEntityServiceImpl()
           
 
Method Summary
 boolean canDereference(URI remoteEntity)
           
 boolean canSuggestRemoteEntity()
           
 boolean dereferenceInto(DocumentModel localEntity, URI remoteEntity, boolean override, boolean lazyResourceFetch)
          Dereference a remote entity into an existing document model.
 boolean dereferenceIntoFromModel(DocumentModel localEntity, URI remoteEntity, com.hp.hpl.jena.rdf.model.Model rdfModel, boolean override, boolean lazyResourceFetch)
          Dereference a remote entity into an existing document model from a pre-fetched RDF description of the entity.
 Set<String> getAdmissibleTypes(URI remoteEntity)
          Introspect the referenced entity to suggest which Nuxeo types can be used to dereference this entity.
 void registerExtension(Extension extension)
          Registers the given extension.
 void removeSameAsLink(DocumentModel doc, URI uriToRemove)
          Helper API to unlink a local entity from a remote entity identified by it's URI.
 List<EntitySuggestion> suggestRemoteEntity(String keywords, String type, int maxSuggestions)
          Perform query on registered remote entity sources to suggests entity definitions that match the name given as keywords and the requested entity type.
 void unregisterExtension(Extension extension)
          Unregisters the given extension.
 
Methods inherited from class org.nuxeo.runtime.model.DefaultComponent
activate, applicationStarted, deactivate, getAdapter, getApplicationStartedOrder, getLastModified, registerContribution, setLastModified, unregisterContribution
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

REMOTESOURCES_XP_NAME

public static final String REMOTESOURCES_XP_NAME
See Also:
Constant Field Values
Constructor Detail

RemoteEntityServiceImpl

public RemoteEntityServiceImpl()
Method Detail

registerExtension

public void registerExtension(Extension extension)
                       throws Exception
Description copied from interface: Extensible
Registers the given extension.

Specified by:
registerExtension in interface Extensible
Overrides:
registerExtension in class DefaultComponent
Parameters:
extension - the extension to register
Throws:
Exception - if any error occurs

unregisterExtension

public void unregisterExtension(Extension extension)
                         throws Exception
Description copied from interface: Extensible
Unregisters the given extension.

Specified by:
unregisterExtension in interface Extensible
Overrides:
unregisterExtension in class DefaultComponent
Parameters:
extension - the extension to unregister
Throws:
Exception - if any error occurs

canSuggestRemoteEntity

public boolean canSuggestRemoteEntity()
Specified by:
canSuggestRemoteEntity in interface RemoteEntitySource
Returns:
true if the features suggestions by name (a.k.a. entity label)

canDereference

public boolean canDereference(URI remoteEntity)
Specified by:
canDereference in interface RemoteEntitySource
Returns:
true if one of the registered remote sources can handle the provided URI

dereferenceInto

public boolean dereferenceInto(DocumentModel localEntity,
                               URI remoteEntity,
                               boolean override,
                               boolean lazyResourceFetch)
                        throws DereferencingException
Description copied from interface: RemoteEntitySource
Dereference a remote entity into an existing document model. Only non empty local fields are updated, unless override is set to true. It is the responsibility of the method caller to save the updated document model back to the repository.

Specified by:
dereferenceInto in interface RemoteEntitySource
Parameters:
localEntity - local document model to store a copy of the entity attribute
remoteEntity - the URI of the entity to dereference
override - replace non-empty local fields with values from the remote entity
lazyResourceFetch - if true, delay the fetch of the content of referenced resources (e.g. JPEG images) to first access.
Returns:
true if a suitable remote entity description was found in the source, false otherwise.
Throws:
DereferencingException

dereferenceIntoFromModel

public boolean dereferenceIntoFromModel(DocumentModel localEntity,
                                        URI remoteEntity,
                                        com.hp.hpl.jena.rdf.model.Model rdfModel,
                                        boolean override,
                                        boolean lazyResourceFetch)
                                 throws DereferencingException
Description copied from interface: RemoteEntitySource
Dereference a remote entity into an existing document model from a pre-fetched RDF description of the entity. Only non empty local fields are updated, unless override is set to true. This is typically useful for the SemanticAnalysisService that might receive pre-fetched entity link suggestion and description from the enhancement engines. It is the responsibility of the method caller to save the updated document model back to the repository.

Specified by:
dereferenceIntoFromModel in interface RemoteEntitySource
Parameters:
localEntity - local document model to store a copy of the entity attribute
remoteEntity - the URI of the entity to dereference
override - replace non-empty local fields with values from the remote entity
lazyResourceFetch - if true, delay the fetch of the content of referenced resources (e.g. JPEG images) to first access.
Returns:
true if a suitable remote entity description was found in the source, false otherwise.
Throws:
DereferencingException

suggestRemoteEntity

public List<EntitySuggestion> suggestRemoteEntity(String keywords,
                                                  String type,
                                                  int maxSuggestions)
                                           throws IOException
Perform query on registered remote entity sources to suggests entity definitions that match the name given as keywords and the requested entity type. The caller will then typically ask the user to select one of the suggestions and then dereference of the remote entity into a local copy for easy off-line reuse and indexing in the local repository. The suggestion backend should order the results by a mix of keyword relevance and popularity. This implementation aggregates all the suggestions of the sources that can perform suggestions. Hence the number of aggregate suggestions might be larger than maxSuggestions

Specified by:
suggestRemoteEntity in interface RemoteEntitySource
Throws:
IOException

getAdmissibleTypes

public Set<String> getAdmissibleTypes(URI remoteEntity)
                               throws DereferencingException
Description copied from interface: RemoteEntitySource
Introspect the referenced entity to suggest which Nuxeo types can be used to dereference this entity. The first element of the list should be the type the user should expect in front facing label (e.g. the most specific). Hence the set implementation should imply unicity as all set but also preserver ordering (e.g. a LinkedHashSet for instance).

Specified by:
getAdmissibleTypes in interface RemoteEntitySource
Parameters:
remoteEntity - the URI of the entity to dereference
Returns:
an ordered set of Nuxeo Core type names that can be used to dereference the entity into a local copy
Throws:
DereferencingException

removeSameAsLink

public void removeSameAsLink(DocumentModel doc,
                             URI uriToRemove)
                      throws ClientException
Description copied from interface: RemoteEntityService
Helper API to unlink a local entity from a remote entity identified by it's URI. It is the responsability of the caller to save the change in back to the repository if persistence is required.

Specified by:
removeSameAsLink in interface RemoteEntityService
Throws:
ClientException

Nuxeo ECM Projects 5.6-RC1

Copyright © 2012 Nuxeo SA. All Rights Reserved.