eu.scape_project.watch.rest
Class WatchClient

java.lang.Object
  extended by eu.scape_project.watch.rest.WatchClient

public class WatchClient
extends Object

Client for Watch REST service.

Author:
Luis Faria

Nested Class Summary
static class WatchClient.Format
          The format of the output.
 
Constructor Summary
WatchClient(com.sun.jersey.api.client.WebResource resource, WatchClient.Format format)
          Create a new Watch client.
 
Method Summary
 AsyncRequest createAsyncRequest(AsyncRequest request)
          Create a new async request.
 Entity createEntity(String name, String type)
          Create a new Entity.
 EntityType createEntityType(String name, String description)
          Create a new entity type.
 Property createProperty(String type, String name, String description)
          Create a new Property.
 PropertyValue createPropertyValue(String entity, String property, String value)
          Create a new PropertyValue.
 Entity deleteEntity(String name)
          Delete an entity.
 EntityType deleteEntityType(String name)
          Delete an existing entity type.
 Property deleteProperty(String type, String name)
          Delete an existing property.
 PropertyValue deletePropertyValue(String entity, String property)
          Delete an existing property value.
 Entity getEntity(String name)
          Get entity from server.
 EntityType getEntityType(String name)
          Get an entity type.
 Property getProperty(String type, String name)
          Get an existing property.
 PropertyValue getPropertyValue(String entity, String property)
          Get an existing PropertyValue.
<T extends thewebsemantic.binding.RdfBean<T>>
List<T>
getRequest(Class<T> targetClass, String query, int start, int max)
          Make a synchronous request query.
 List<Entity> listEntity(int start, int max)
          List all entities in the knowledge base.
 List<Entity> listEntity(String type, int start, int max)
           
 List<EntityType> listEntityType()
          List all existing entity types.
 List<Property> listProperty()
          List all properties in the KB.
 List<PropertyValue> listPropertyValue()
          List all property values in the KB.
 Entity updateEntity(String name, Entity entity)
          Update the entity defined by the name.
 EntityType updateEntityType(String name, EntityType entity)
          Update an existing entity type.
 Property updateProperty(String type, String name, Property property)
          Update an existing property.
 PropertyValue updatePropertyValue(String entity, String property, String value)
          Update an existing PropertyValue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WatchClient

public WatchClient(com.sun.jersey.api.client.WebResource resource,
                   WatchClient.Format format)
Create a new Watch client.

Parameters:
resource - the jersey web resource to use
format - the output format to use
Method Detail

createEntity

public Entity createEntity(String name,
                           String type)
Create a new Entity.

Parameters:
name - the entity name
type - the name of the entity type
Returns:
the created entity

getEntity

public Entity getEntity(String name)
Get entity from server.

Parameters:
name - the entity name
Returns:
the entity with that name or null if not found

updateEntity

public Entity updateEntity(String name,
                           Entity entity)
Update the entity defined by the name.

Parameters:
name - the name of the entity to update
entity - the updated entity that will replace the previous one
Returns:
the updated entity after merged with the knowledge base

listEntity

public List<Entity> listEntity(int start,
                               int max)
List all entities in the knowledge base.

Returns:
the complete list of entities.

listEntity

public List<Entity> listEntity(String type,
                               int start,
                               int max)

deleteEntity

public Entity deleteEntity(String name)
Delete an entity.

Parameters:
name - the name of the entity to delete.
Returns:
the deleted entity.

createEntityType

public EntityType createEntityType(String name,
                                   String description)
Create a new entity type.

Parameters:
name - a unique name to identify this entity type
description - the entity type description
Returns:
the newly created entity type

getEntityType

public EntityType getEntityType(String name)
Get an entity type.

Parameters:
name - the entity type name
Returns:
the EntityType or null if not found

updateEntityType

public EntityType updateEntityType(String name,
                                   EntityType entity)
Update an existing entity type.

Parameters:
name - the existing entity type name
entity - the new entity type that should replace the old one
Returns:
the updated entity type

listEntityType

public List<EntityType> listEntityType()
List all existing entity types.

Returns:
A complete list of entity types in the KB.

deleteEntityType

public EntityType deleteEntityType(String name)
Delete an existing entity type.

Parameters:
name - the name of the entity type to delete
Returns:
the deleted entity type

createProperty

public Property createProperty(String type,
                               String name,
                               String description)
Create a new Property.

Parameters:
type - the EntityType related with this property
name - a unique name (within this entity type) to identity this property
description - the property description
Returns:
the newly created property

getProperty

public Property getProperty(String type,
                            String name)
Get an existing property.

Parameters:
type - the name of the EntityType related to this property
name - the name of this property within the EntityType
Returns:
the Property or null if not found.

updateProperty

public Property updateProperty(String type,
                               String name,
                               Property property)
Update an existing property.

Parameters:
type - the EntityType related to this property
name - the name of this property within the EntityType
property - the new update property
Returns:
the updated Property after merging with the KB.

listProperty

public List<Property> listProperty()
List all properties in the KB.

Returns:
A complete list of all properties in the KB

deleteProperty

public Property deleteProperty(String type,
                               String name)
Delete an existing property.

Parameters:
type - the EntityType related to this property
name - the name of this property within the EntityType
Returns:
The deleted property.

createPropertyValue

public PropertyValue createPropertyValue(String entity,
                                         String property,
                                         String value)
Create a new PropertyValue.

Parameters:
entity - The Entity related to this property value
property - the Property related to this property value
value - the value of the related property for the related entity.
Returns:
the newly created PropertyValue

getPropertyValue

public PropertyValue getPropertyValue(String entity,
                                      String property)
Get an existing PropertyValue.

Parameters:
entity - The Entity related to this property value
property - the Property related to this property value
Returns:
the PropertyValue or null if not found.

updatePropertyValue

public PropertyValue updatePropertyValue(String entity,
                                         String property,
                                         String value)
Update an existing PropertyValue.

Parameters:
entity - The Entity related to this property value
property - the Property related to this property value
value - The updated value of the related Property to the related Entity
Returns:
the updated PropertyValue

listPropertyValue

public List<PropertyValue> listPropertyValue()
List all property values in the KB.

Returns:
the complete list of property values in the KB

deletePropertyValue

public PropertyValue deletePropertyValue(String entity,
                                         String property)
Delete an existing property value.

Parameters:
entity - The Entity related to this property value
property - the Property related to this property value
Returns:
the deleted property value.

getRequest

public <T extends thewebsemantic.binding.RdfBean<T>> List<T> getRequest(Class<T> targetClass,
                                                                        String query,
                                                                        int start,
                                                                        int max)
Make a synchronous request query.

Type Parameters:
T - A class that must extends RdfBean and should be related to possible targets of a request.
Parameters:
targetClass - The query target class, that will define the resource type.
query - The SPARQL query bindings.
start - The index of the first item to retrieve.
max - The maximum number of items to retrieve.
Returns:
The list of resources of the type defined by target, filtered by the constraints above.

createAsyncRequest

public AsyncRequest createAsyncRequest(AsyncRequest request)
Create a new async request.

Parameters:
request - The new async request to insert into the KB.
Returns:
The created async request after merging with the KB


Copyright © 2012 SCAPE. All Rights Reserved.