The Integration Repository consists of a set of item descriptors. Each item is queryable through a RepositoryView
using a QueryBuilder
. Each item descriptor is associated with a particular Command
or set of Commands
. One of these Commands
returns results that are converted to repository items of the given item descriptor. Other Commands
are used for updating or deleting values in the remote system.
The Integration Repository includes extensions to, or implementations of, the following repository classes. Each of these classes is in the atg.adapter.integrations
package.
IntegrationRepository extends atg.repository.RepositoryImpl
IntegrationRepositoryItemDescriptor extends
atg.repository.ItemDescriptorImpl
IntegrationRepositoryItem implements atg.repository.RepositoryItem,
atg.repository.MutableRepositoryItem
ChangedPropertyBean implements atg.repository.RepositoryItem,
atg.repository.MutableRepositoryItem
atg.repository.databinding.MappingRepositoryItem implements
atg.repository.RepositoryItem, atg.repository.MutableRepositoryItem
IntegrationRepositoryView extends atg.repository.RepositoryViewImpl
In addition, each IntegrationRepositoryItemDescriptor
refers to one or more commands, which implement the atg.integrations.Command
interface. The RPC call in a Command
returns an object of the atg.integrations.CommandResult
class. Command
and CommandResult
are discussed in the Remote Procedure Calls chapter.
IntegrationRepository
extends RepositoryImpl
The IntegrationRepository
references another repository, which is referred to as the local repository and which is a SQL repository. The IntegrationRepository
is defined by a Nucleus properties file and an XML definition file. Each method call functions as described in the following table, forwarding the request either to the local repository or to the IntegrationRepositoryItemDescriptor
, which then executes a Command
against the remote system.
Element | Description |
---|---|
properties | localRepository
definitionFile integrationRepositoryTools persistentCacheManager mappingManager mappingTools defaultTimeoutResponse ROLLBACK - Rollback the current transaction. sendScenarioEvents |
methods | Most methods in the getItem Calls Calls Calls Both the local repository’s query cache and the For a more detailed description, see getItem in the Command Operations section. getView getItemDescriptor getItemForUpdate createItem addItem updateItem removeItem Each of the |
IntegrationRepositoryItemDescriptor
extends ItemDescriptorImpl
This class references an item descriptor from the local repository. Most operations will be pass-through to the local repository item descriptor. The following operations (described in the Command Operations section) execute a Command
if one is defined for the item descriptor; otherwise they do nothing.
executeQuery
getItem
updateItem
addItem
removeItem
In addition, this class is responsible for converting the results of queries obtained from the remote system into repository items.
IntegrationRepositoryItem
implements RepositoryItem
, MutableRepositoryItem
This class references a repository item in the local repository. Most operations will be passed through to it.
ChangedPropertyBean
implements RepositoryItem
, MutableRepositoryItem
This class includes only the external ID property plus the list of properties in a RepositoryItem
that have been changed. When, for example, updateItem
is invoked on an IntegrationRepositoryItem
, this wrapper can be passed to the update Command
instead of the RepositoryItem
. This allows us to send only the changed properties to be saved to the remote system, instead of trying to update all the properties of a repository item.
For example, if you change the middleName
property of the user profile, and the user profile is configured with an external id property called remoteId
, the ChangedPropertyBean
will only expose two properties: middleName
and remoteId
. If you call ChangedPropertyBean.getPropertyDescriptors
, the result will only contain these two properties. A ChangedPropertyBean
is read-only.
atg.repository.databinding.MappingRepositoryItem
implements RepositoryItem
, MutableRepositoryItem
A MappingRepositoryItem
wraps a repository item and exposes properties as they are configured in a mapping file. The Integration Repository creates MappingRepositoryItems
automatically if it is configured with a mapping file. The property names that are exposed are the target names as defined in the mapping file. If a property’s include
attribute is false
in the mapping file, then that property is not a legal property of the MappingRepositoryItem
. For example, if the following mapping exists:
<item-descriptor repository-path="/atg/userprofiling/ProfileAdapterRepository" name="user" default-include="false"> <property name="firstName" include="true"/> <property name="lastName" include="true"/> <property name="id" target-name="dynamoId" include="true"/> </item-descriptor>
then the corresponding MappingRepositoryItem
would contain three properties: firstName
, lastName
, and dynamoId
.
IntegrationRepositoryView
extends RepositoryViewImpl
IntegrationRepositoryView
is an abstract class that provides some standard operations like applyOptions
and getRange
. For each type of remote system that you want to integrate with, you need to create an implementation of IntegrationRepositoryView
specific for your remote system in order to provide the translation between the Oracle ATG Web Commerce Query
format, and the format expected by the remote system. When a query is executed, the executeUncachedQuery
method is called. That method looks like this:
public RepositoryItem[] executeUncachedQuery(Query pQuery, QueryOptions pOptions) { // Step 1 Object input = createQueryCommandInput(pQuery, pOptions); // Step 2 RepositoryItem[] items = executeQueryCommand(input); // Step 3 return applyOptions(items, pOptions); }
The inputs to this method are a standard Query
object and a standard QueryOptions
object. The executeUncachedQuery
method goes through the following steps:
Step 1
The first thing the view needs to do is translate the Query
object into an object that is understandable by the remote system. This is the responsibility of your subclass of IntegrationRepositoryView
and the only method that you must implement.
Step 2
This step is a call to the method defined in IntegrationRepositoryView
that gets the correct Command
according to your configuration and calls Command.execute
with the provided query input.
Step 3
This step may not be necessary. If your remote system supports sorting and ranging (returning a subset of the items) then it will be more efficient for that information to be included in the command input. In that case this step can be skipped in the executeUncachedQuery
and you should override the applyOptions
method to do nothing.
The only thing required for querying to work is to subclass IntegrationRepositoryView
and implement createQueryCommandInput
. The implementation of this method will introspect the Query
class and create an input object. The type and contents of the input object depend on the requirements of your application and the remote system you are querying. You then need to create a Command
that knows what to do with this input.
In addition, you will typically need to implement a processResults
method in your IntegrationRepositoryView
subclass. This method is responsible for translating between the remote data format and the repository items in the local repository.
The default implementation of IntegrationRepositoryView.processResults
calls IntegrationRepositoryTools.createRepositoryItems
. It passes in the results from pCommandResult.getResults()
as the first argument. The createRepositoryItems
method uses DynamicBeans
to look at the given command results. For each object in the result it uses the IntegrationRepositoryItemDescriptor
to find the external ID. It uses this external ID to look for an existing item in the local repository with the same external ID. If one is found, this method iterates across the properties in the result object (using DynamicBeans
) and updates the properties. If one is not found, a new item is first created, then the properties are updated.