org.filteredpush.mapper.datapolicymapper
Interface DataPolicyMapper

All Superinterfaces:
Mapper
All Known Implementing Classes:
DataPolicyMapperImpl

public interface DataPolicyMapper
extends Mapper

The mapper based on data policy.

Author:
Lei Dou $Id:$

Method Summary
 java.lang.String add(java.lang.String objType, java.util.Map<java.lang.String,java.lang.String> data)
          Add the record of specified type in the local data source.
 void delete(java.lang.String objType, java.lang.String identifier)
          Delete the record in specified type with the specified identifier from the local data source.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> get(java.lang.String objType, java.util.Map<java.lang.String,java.lang.String> data)
          Find the records of the specified type and with the specified value.
 java.util.List<java.util.Map<java.lang.String,java.lang.String>> getByIdentifiers(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.List<java.util.Map<java.lang.String,java.lang.String>> getFillin(java.lang.String objType, java.util.Map<java.lang.String,java.lang.String> data)
          Get the possible fill-in from the local data source for the input proposed change.
 java.util.List<org.filteredpush.data.definition.BasicFieldDefinition> getObjectDef(java.lang.String objType)
          Get the list of field definition for the specified record.
 void update(java.lang.String objType, java.util.Map<java.lang.String,java.lang.String> data)
          Update the record in specified type with the specified type and value in the local data source.
 
Methods inherited from interface org.filteredpush.mapper.Mapper
setAdapterWithClass, setAdapterWithName, setContext
 

Method Detail

getByIdentifiers

java.util.List<java.util.Map<java.lang.String,java.lang.String>> getByIdentifiers(java.lang.String objType,
                                                                                  java.util.Map<java.lang.String,java.lang.String> identifiers)
                                                                                  throws UnAuthenticated,
                                                                                         InvalidParameter,
                                                                                         InternalException,
                                                                                         OAuthRedirectException,
                                                                                         ConverterException,
                                                                                         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 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.
ConverterException - If the data conversion fails.

get

java.util.List<java.util.Map<java.lang.String,java.lang.String>> get(java.lang.String objType,
                                                                     java.util.Map<java.lang.String,java.lang.String> data)
                                                                     throws UnAuthenticated,
                                                                            InvalidParameter,
                                                                            InternalException,
                                                                            OAuthRedirectException,
                                                                            ConverterException,
                                                                            LocalDataSourceAccessException
Find the records of the specified type and with the specified value. In the current annotation processor implementation, we don't have any use case to invoke this method. We leave it here for future possible use.

Parameters:
objType - The type of the target record.
data - The value to be matched.
Returns:
The list of 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.
ConverterException - If the data conversion fails.

getFillin

java.util.List<java.util.Map<java.lang.String,java.lang.String>> getFillin(java.lang.String objType,
                                                                           java.util.Map<java.lang.String,java.lang.String> data)
                                                                           throws UnAuthenticated,
                                                                                  InvalidParameter,
                                                                                  InternalException,
                                                                                  OAuthRedirectException,
                                                                                  ConverterException,
                                                                                  LocalDataSourceAccessException
Get the possible fill-in from the local data source for the input proposed change. The method navigates the record tree of the specified record according to the data policy. If any record is found to match the input kvp (only need to match the value of the fields of this record), and the parent of this record doesn't match if there's no parent record, then the information of this record and all its nested records would be used for fill-in. Find all such records, make a composition and finally return the list of map while each map represents one fill-in choices for the absent fields in the proposed change.

Parameters:
objType - The type of the target record.
data - The proposed change.
Returns:
The list of fill-in candidate.
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.
ConverterException - If the data conversion fails.

add

java.lang.String add(java.lang.String objType,
                     java.util.Map<java.lang.String,java.lang.String> data)
                     throws UnAuthenticated,
                            InvalidParameter,
                            MissingInformationException,
                            UniqueIdentificationException,
                            InternalException,
                            OAuthRedirectException,
                            ConverterException,
                            LocalDataSourceAccessException,
                            ObjectExistException
Add the record of specified type in the local data source. The new object will be created if it doesn't exist.

Parameters:
objType - The type of the target record.
data - The value of the target record to be created.
Returns:
The primary key of the 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.
ConverterException - If the data conversion fails.
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.
ObjectExistException - If the record of the specified type with the specified value already exists in the local data source.

update

void update(java.lang.String objType,
            java.util.Map<java.lang.String,java.lang.String> data)
            throws UnAuthenticated,
                   InvalidParameter,
                   MissingInformationException,
                   UniqueIdentificationException,
                   InternalException,
                   OAuthRedirectException,
                   ConverterException,
                   LocalDataSourceAccessException,
                   ObjectExistException
Update the record in specified type with the specified type and value in the local data source.

Parameters:
objType - The type of the target record.
data - The value of the target record to be updated.
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.
ConverterException - If the data conversion fails.
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.
ObjectExistException - If the record of the specified type with the specified value already exists in the

delete

void delete(java.lang.String objType,
            java.lang.String identifier)
            throws UnAuthenticated,
                   InvalidParameter,
                   InternalException,
                   OAuthRedirectException,
                   ConverterException,
                   LocalDataSourceAccessException
Delete the record in specified type with the specified identifier from the local data source.

Parameters:
objType - The type of the target record.
identifier - The primary key of the target 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.
ConverterException - If the data conversion fails.

getObjectDef

java.util.List<org.filteredpush.data.definition.BasicFieldDefinition> getObjectDef(java.lang.String objType)
Get the list of field definition for the specified record.

When the object has cross reference to another object, the mapper will go to the referenced object definition and grab the field definition. This process could be recursive.

The major usage of this method is to generate the table in the webUI to present the existing local dataset and the "new" data. It would also be useful in other cases to help interpret and validate the data.

Parameters:
objType - The type of the target record.
Returns:
The definition of the record.