org.filteredpush.mapper.datapolicymapper
Interface DataPolicyAdapter

All Superinterfaces:
DataSourceAdapter
All Known Implementing Classes:
SpecifyAdapter

public interface DataPolicyAdapter
extends DataSourceAdapter

The interface for the adapter which is implemented based on the data policy.

Author:
Lei Dou $Id$

Method Summary
 java.lang.String add(java.lang.String objType, java.util.Map<java.lang.String,java.lang.Object> obj)
          Insert a record into the data source with the specified type and value.
 void delete(java.lang.String objType, java.lang.String identifier)
          Delete a record in the data source with the specified type and primary key.
 java.util.List<java.lang.String> find(java.lang.String objType, java.util.Map<java.lang.String,java.lang.Object> obj)
          Find the record that is in the specified type and has the specified value and return their primary keys.
 java.util.List<java.lang.String> findByIdentifiers(java.lang.String objType, java.util.Map<java.lang.String,java.lang.String> identifiers)
          Find the record in the local data source with the specified type and identified by the specific identifiers.
 java.util.Map<java.lang.String,java.lang.String> get(java.lang.String objType, java.lang.String identifier)
          Return the object with the specified type and the primary key.
 DataPolicy getDataPolicy()
          Return the data policy used by this adapter.
 void update(java.lang.String objType, java.util.Map<java.lang.String,java.lang.Object> obj)
          Update a record in the data source with the specified type and value.
 
Methods inherited from interface org.filteredpush.mapper.DataSourceAdapter
setContext
 

Method Detail

getDataPolicy

DataPolicy getDataPolicy()
Return the data policy used by this adapter.

Returns:
The data policy used by this adapter.

findByIdentifiers

java.util.List<java.lang.String> findByIdentifiers(java.lang.String objType,
                                                   java.util.Map<java.lang.String,java.lang.String> identifiers)
                                                   throws UnAuthenticated,
                                                          InvalidParameter,
                                                          InternalException,
                                                          OAuthRedirectException,
                                                          LocalDataSourceAccessException
Find the record in the local data source with the specified type and identified by the specific identifiers. The identifiers are not necessary the primary keys or any identifiers defined in the data policy for this type of record. For example, while mapping the "insert identification", to find all the identifications for the occurrence object, the identifiers used is actually the identifiers for the occurrence object, like collection code, catalog number etc. The reason why we design such method here is because only the local data source knows how to find the identifications for an occurrence object with the specified identifiers.

Parameters:
objType - The type of the target record.
identifiers - The list of identifiers identifying the target record.
Returns:
The list of primary key of the found record.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.

find

java.util.List<java.lang.String> find(java.lang.String objType,
                                      java.util.Map<java.lang.String,java.lang.Object> obj)
                                      throws UnAuthenticated,
                                             InvalidParameter,
                                             InternalException,
                                             OAuthRedirectException,
                                             LocalDataSourceAccessException
Find the record that is in the specified type and has the specified value and return their primary keys.

Parameters:
objType - The type of record to be find.
obj - The value that the target record should have.
Returns:
List of primary keys of the found records.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.

get

java.util.Map<java.lang.String,java.lang.String> get(java.lang.String objType,
                                                     java.lang.String identifier)
                                                     throws UnAuthenticated,
                                                            InvalidParameter,
                                                            InternalException,
                                                            OAuthRedirectException,
                                                            LocalDataSourceAccessException
Return the object with the specified type and the primary key.

Parameters:
objType - The type of record to be find.
identifier - The primary key.
Returns:
The value in key-value pairs of the matched record.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.

add

java.lang.String add(java.lang.String objType,
                     java.util.Map<java.lang.String,java.lang.Object> obj)
                     throws UnAuthenticated,
                            InvalidParameter,
                            MissingInformationException,
                            UniqueIdentificationException,
                            InternalException,
                            OAuthRedirectException,
                            LocalDataSourceAccessException
Insert a record into the data source with the specified type and value.

Parameters:
objType - The type of record to be inserted.
obj - The value of the object to be inserted.
Returns:
The primary key of the inserted object.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
MissingInformationException - If the information provided to create the record is not enough. E.g. the information to create higher taxon is needed when a taxon is inserted and its higher taxon doesn't exist.
UniqueIdentificationException - If more than one records (could be the referenced record) are matched according to the input value while only one is expected. E.g. when insert an identification record, a gci_botanist (representing the identifier) record will be found and its id will be used to create the identification record. But if only the identifier's name is provided and more than one gci_botanist records are matched, then the system won't be able to know which record should be used. In this case, this exception will be thrown out.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.

update

void update(java.lang.String objType,
            java.util.Map<java.lang.String,java.lang.Object> obj)
            throws UnAuthenticated,
                   InvalidParameter,
                   MissingInformationException,
                   UniqueIdentificationException,
                   InternalException,
                   OAuthRedirectException,
                   LocalDataSourceAccessException
Update a record in the data source with the specified type and value. It's required to provide the primary key in the input value.

Parameters:
objType - The type of record to be updated.
obj - The value that the object to be updated to. The primary key of the object must be contained so that the to be updated object could be identified.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
MissingInformationException - If the information provided to create the record is not enough. E.g. the information to create higher taxon is needed when a taxon is updated and its higher taxon doesn't exist.
UniqueIdentificationException - If more than one records (could be the referenced record) are matched according to the input value while only one is expected. E.g. when insert an identification record, a gci_botanist (representing the identifier) record will be found and its id will be used to create the identification record. But if only the identifier's name is provided and more than one gci_botanist records are matched, then the system won't be able to know which record should be used. In this case, this exception will be thrown out.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.

delete

void delete(java.lang.String objType,
            java.lang.String identifier)
            throws UnAuthenticated,
                   InvalidParameter,
                   InternalException,
                   OAuthRedirectException,
                   LocalDataSourceAccessException
Delete a record in the data source with the specified type and primary key.

Parameters:
objType - The type of record to be deleted.
identifier - The primary key of the object to be deleted.
Throws:
UnAuthenticated - If the adapter can't be authenticated to access the local data source.
InvalidParameter - If the input value is not valid.
InternalException - Indicates internal error happening in the local data source to answer this query.
OAuthRedirectException - If redirection to the OAuth authentication page is needed.
LocalDataSourceAccessException - If the local data source can't be accessed for some reason.