eu.scape_project.watch.dao
Class AbstractDO<T extends thewebsemantic.binding.RdfBean<T>>

java.lang.Object
  extended by eu.scape_project.watch.dao.AbstractDO<T>
Type Parameters:
T - Type of the data object.
Direct Known Subclasses:
AsyncRequestDAO, EntityDAO, EntityTypeDAO, PropertyDAO, PropertyValueDAO, RequestDAO

public abstract class AbstractDO<T extends thewebsemantic.binding.RdfBean<T>>
extends Object

Abstract class to base Data Object classes creation.

Author:
Luis Faria

Constructor Summary
AbstractDO()
           
 
Method Summary
 void addDOListener(DOListener<T> listener)
          Add a listeners to data object events.
protected  int count(Class<T> typeClass, String bindings)
          Count the number of results that a query will produce.
 void delete(T... objects)
          Delete several objects at the same time, calling delete(RdfBean) on each.
 T delete(T object)
          Delete object (not cascading) and fire removed event.
protected  T findById(String id, Class<T> typeClass)
          Find a resource by its Id.
 void fireOnRemoved(T object)
          Fire an on remove event.
 void fireOnUpdated(T object)
          Fire an on create or update event.
protected  List<T> query(Class<T> typeClass, String bindings, int start, int max)
          Generic method to query the KB.
 void removeDOListener(DOListener<T> listener)
          Remove existing listener of data object events.
 void save(T... objects)
          Save several objects at the same time, calling save(RdfBean) on each.
 T save(T object)
          Save object (not deeply) and fire on update event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractDO

public AbstractDO()
Method Detail

findById

protected T findById(String id,
                     Class<T> typeClass)
Find a resource by its Id.

Parameters:
id - The id of the resource
typeClass - The class of the resource we want to find
Returns:
The resource or null if not found

query

protected List<T> query(Class<T> typeClass,
                        String bindings,
                        int start,
                        int max)
Generic method to query the KB.

Parameters:
typeClass - The class of the return type we want to bind width.
bindings - The bindings to use, to be injected into SELECT ?s WHERE {?s type-of \ . query}. Should use ?s for the binding. Can also use OPTIONAL{}, {{...} UNION {...}} and FILTER ... >= ... && ... \< ...
start - The index of the first item to return
max - The maximum number of item to return
Returns:
The list of the requested type filtered by the constraints above.

count

protected int count(Class<T> typeClass,
                    String bindings)
Count the number of results that a query will produce.

Parameters:
typeClass - The class of the return type we want to bind width.
bindings - The bindings to use, to be injected into SELECT ?s WHERE {?s type-of \ . query}. Should use ?s for the binding. Can also use OPTIONAL{}, {{...} UNION {...}} and FILTER ... >= ... && ... \< ...
Returns:
The number of results expected for this query.

addDOListener

public void addDOListener(DOListener<T> listener)
Add a listeners to data object events.

Parameters:
listener - The listener handler.

removeDOListener

public void removeDOListener(DOListener<T> listener)
Remove existing listener of data object events.

Parameters:
listener - The listener to remove

fireOnUpdated

public void fireOnUpdated(T object)
Fire an on create or update event.

Parameters:
object - The created or updated object.

fireOnRemoved

public void fireOnRemoved(T object)
Fire an on remove event.

Parameters:
object - The removed object.

save

public T save(T object)
Save object (not deeply) and fire on update event.

Parameters:
object - The object to create or update.
Returns:
The created or updated object, the same as the input.

save

public void save(T... objects)
Save several objects at the same time, calling save(RdfBean) on each.

Parameters:
objects - The objects to save

delete

public T delete(T object)
Delete object (not cascading) and fire removed event.

Parameters:
object - The deleted object.
Returns:
The deleted object, same as the input.

delete

public void delete(T... objects)
Delete several objects at the same time, calling delete(RdfBean) on each.

Parameters:
objects - The objects to delete


Copyright © 2012. All Rights Reserved.