eu.emi.dsr.db
Interface ServiceDatabase

All Known Implementing Classes:
MongoDBServiceDatabase

public interface ServiceDatabase

Author:
martoni, g.szigeti

Method Summary
 void deleteAll()
           
 void deleteByUrl(String url)
          Delete multiple items from the persistent store
 List<ServiceObject> findAll()
           
 void findAndDelete(String query)
          Query and delete the matching documents
 String getDBVersion()
          Get version of the database
 ServiceObject getServiceByUrl(String identifier)
          Get an item from the persistent store
 void insert(ServiceObject item)
          Insert service description to the persistent store.
 org.codehaus.jettison.json.JSONArray paginatedQuery(String query, Integer pageSize, String id)
           
 List<ServiceObject> query(String query)
          Query the persistent store
 List<ServiceObject> query(String query, Integer skip)
          Querying the collection
 List<ServiceObject> query(String query, Integer limit, Integer skip)
          Querying the collection
 org.codehaus.jettison.json.JSONArray queryDistinctJSON(String attributeName)
          Get distinct values for a given attribute
 org.codehaus.jettison.json.JSONArray queryJSON(String query)
           
 org.codehaus.jettison.json.JSONArray queryJSON(String query, Integer skip)
           
 org.codehaus.jettison.json.JSONArray queryJSON(String query, Integer limit, Integer skip)
           
 org.codehaus.jettison.json.JSONArray queryJSONWithLimit(String s, Integer limit)
           
 void update(ServiceObject sObj)
          Update an existing item in the persistent store
 

Method Detail

insert

void insert(ServiceObject item)
            throws ExistingResourceException,
                   PersistentStoreFailureException
Insert service description to the persistent store. If it throws an exception if the item already exists

Parameters:
item - an item to insert into the database
Throws:
ExistingResourceException - throws exception if the element already exists
PersistentStoreFailureException - throws exception if the persistent store is unavailable

getServiceByUrl

ServiceObject getServiceByUrl(String identifier)
                              throws MultipleResourceException,
                                     NonExistingResourceException,
                                     PersistentStoreFailureException
Get an item from the persistent store

Parameters:
identifier - unique identifier of an object in the persistent store (url)
Returns:
the stored content of the specified object
Throws:
MultipleResourceException - throws exception if the identifier specifies more than one item
NonExistingResourceException - throws exception if the item specified by identifier is not existing in the persistent store
PersistentStoreFailureException - throws exception if persistent store level error occurs

deleteByUrl

void deleteByUrl(String url)
                 throws MultipleResourceException,
                        NonExistingResourceException,
                        PersistentStoreFailureException
Delete multiple items from the persistent store

Parameters:
array - of service urls
Throws:
MultipleResourceException - throws exception if the identifier specifies more than one item
NonExistingResourceException - throws exception if the item specified by identifier is not existing in the persistent store
PersistentStoreFailureException - throws exception if persistent store level error occurs TODO: support list of urls

deleteAll

void deleteAll()

findAndDelete

void findAndDelete(String query)
Query and delete the matching documents


update

void update(ServiceObject sObj)
            throws MultipleResourceException,
                   NonExistingResourceException,
                   PersistentStoreFailureException
Update an existing item in the persistent store

Parameters:
identifier - unique identifier of an object in the persistent store
newItem - the new item to replace the former one in the persistent store
Throws:
MultipleResourceException - throws exception if the identifier specifies more than one item
NonExistingResourceException - throws exception if the item specified by identifier is not existing in the persistent store
PersistentStoreFailureException - throws exception if persistent store level error occurs

query

List<ServiceObject> query(String query)
                          throws QueryException,
                                 PersistentStoreFailureException
Query the persistent store

Parameters:
query - (a JSON String)
Returns:
a collection of matching entries from the persistent store if any or an empty collection
Throws:
PersistentStoreFailureException - throws exception if persistent store level error occurs
QueryException - throws exception if the query contains any query specific error

query

List<ServiceObject> query(String query,
                          Integer skip)
                          throws QueryException,
                                 PersistentStoreFailureException
Querying the collection

Parameters:
query - the json string containing the query
skip - skipping the query result
Returns:
the list containing total-skip number of matching ServiceObjects
Throws:
QueryException
PersistentStoreFailureException

query

List<ServiceObject> query(String query,
                          Integer limit,
                          Integer skip)
                          throws QueryException,
                                 PersistentStoreFailureException
Querying the collection

Parameters:
query - the json string containing the query
skip - skipping the query result
limit - total number of results to return
Returns:
returns a list with (limit-skip) number of records - within the same limit
Throws:
QueryException
PersistentStoreFailureException

findAll

List<ServiceObject> findAll()
                            throws org.codehaus.jettison.json.JSONException
Throws:
org.codehaus.jettison.json.JSONException

queryJSON

org.codehaus.jettison.json.JSONArray queryJSON(String query)
                                               throws QueryException,
                                                      PersistentStoreFailureException,
                                                      com.mongodb.MongoException,
                                                      org.codehaus.jettison.json.JSONException
Parameters:
query -
Returns:
Throws:
QueryException
PersistentStoreFailureException
org.codehaus.jettison.json.JSONException
com.mongodb.MongoException

queryJSON

org.codehaus.jettison.json.JSONArray queryJSON(String query,
                                               Integer limit,
                                               Integer skip)
                                               throws QueryException,
                                                      PersistentStoreFailureException
Parameters:
query -
limit -
skip -
Returns:
Throws:
QueryException
PersistentStoreFailureException

queryJSON

org.codehaus.jettison.json.JSONArray queryJSON(String query,
                                               Integer skip)
                                               throws QueryException,
                                                      PersistentStoreFailureException
Parameters:
query -
skip -
Returns:
Throws:
QueryException
PersistentStoreFailureException

queryJSONWithLimit

org.codehaus.jettison.json.JSONArray queryJSONWithLimit(String s,
                                                        Integer limit)
Parameters:
s -
limit -
Returns:

queryDistinctJSON

org.codehaus.jettison.json.JSONArray queryDistinctJSON(String attributeName)
Get distinct values for a given attribute

Parameters:
attributeName -
Returns:

paginatedQuery

org.codehaus.jettison.json.JSONArray paginatedQuery(String query,
                                                    Integer pageSize,
                                                    String id)

getDBVersion

String getDBVersion()
Get version of the database

Returns:
String, version of the database


Copyright © 2012. All Rights Reserved.