# AccountResolution

## Program ID

MetraPipeline.AccountResolution.1

## Description

AccountResolution plug-in is used to get account information listed in outputs section, based on either the <AccountID> tag or the <Login> and <Namespace> tags. There are three sections in this file: Miscellaneous, Resolution, and Retrieval.

### Miscellaneous

Place the miscellaneous tags first. These tags require no property sets. Here are the permissible properties in the order that they are expected: <usebcpflag>, <FailIfNotResolved> (tag descriptions are below). Both of these tags are optional.

### Resolution

The next part of the configuration file is the resolution section. This section determines the criteria used to resolve the account. You should embed the properties needed in this section in <Resolution> property set tags. Inside this set, there can be three possible properties used in two possible combinations. The first combination will resolve accounts by Login/namespace: <Login> and <Namespace>. The second combination resolves by account ID:<AccountID>.

An optional fourth resolution property, <timestamp>, will reference the record of the account by a specific date/time.

Note: | <timestamp> resolves to _Timestamp, if no property is specified.

In most cases, one of the above combinations is sufficient to resolve the account. However, if you resolve by account ID only, some account adapters may need additional keys for their data. In these cases, additional keys must be configured in the resolution section. This can be done by adding an <AdditionalKeys> property set. This set is optional and contains one or more <Property> property sets. These sets are identical to the <Property> property sets used in the retrieval section and are discussed below.

### Retrieval

Retrieval is the last section in the configuration file. This section determines what properties are actually retrieved and sets them in session after an account has been resolved. For optimal performance, only the properties needed by the stage should be retrieved. This section is represented as property set named <Retrieval>. It contains one or more <Property> property sets, each one corresponding to a property which will be retrieved.

A <Property> property set can contain the following properties in the order specified: <Extension>, <AccountAdapter>, <Name>, <InSession>.

Not all properties that you might need to retrieve reside in account views and are accessible via account adapters. In order to address this problem, this plug-in has a notion of a virtual account adapter that brings all of these miscellaneous properties logically together. The virtual account adapter's name is "virtual" and it is said to reside in the "core" extension. This adapter contains the following properties:

## Virtual Adapter Properties

Property name | Value type | Description
AccountID | integer | A unique value generated for the created account. No two users in the MetraTech system will have the same account ID.
UsageCycleID | integer | The usage cycle ID indicating a usage cycle type. See the Usage Server Guide for more details.
AccountStartDate | date | The start date associated with the account.
AccountEndDate | date | The end date associated with the account.
AccountState | enum | The account's status. Can be one of the following: PA = Pending Active Approval AC = Active SU = Suspended PF = Pending Final Bill CL = Closed AR = Archived
PayingAccount | Integer | The ID of the account paying for the account's usage.

## Input Properties

The required input properties are determined by the properties chosen in the resolution property set in the configuration file.

## Output Properties

The required output properties are determined by the properties chosen in the retrieval property set in the configuration file.

## Configuration Tags

Here are the tags in the order expected by the system:

Tag name | Required | Value type | Description
The following are Miscellaneous (They need no property set tags and go first in the configuration file):
usebcpflag | No | String | Enables the Bulk Copy Program (BCP) interface for SQLServer. If Oracle is detected, the plug-in ignores the value enclosed and sets it to FALSE. If SQLServer is used, the recommended value is TRUE.
FailIfNotResolved | No | Boolean | If set to TRUE and the plugin is not able to resolve by the resolution criteria, then this plugin will fail the session. If set to FALSE, the retrieval properties are simply not set for that session and no failure is triggered.
The following properties are in the Resolution Properties set:
Login | No (see description) | Boolean | Reference to an account in the external system. (This tag is not required if the file resolves by the accountID property.)
Namespace | No (see description) | String | Namespace that uniquely identifies the username. Usually, it is the identifier associated with the customer, such as MT for MetraTech (This tag is not required if the file resolves by the accountID property).
AccountID | No (see description) | Long | A unique value generated for the created account. No two users in the MetraTech system will have the same account ID. (This tag is not required if the file resolves by the Login and Namespace properties.)
Timestamp | No | Date | The timestamp used as the effective date/time for this lookup. This property defaults to _Timestamp, if no property is specified.
The following are embedded in <retrieval> and <property> set tags:
Extension | No | String | The name of the extension that the account adapter can be found in. optional, defaults to the current extension except if <AccountAdapter> is also omitted in which case it defaults to "core".
AccountAdapter | No | String | The name of the account adapter where the property will come from. The name of the adapter should correspond to the account adapter's name as given by the given extension's \config\account\AccountAdapters.xml file. The account adapter chosen must use the MTAccount.MTSQLAdapter.1 implementation. (This property is optional if <Extension> was omitted. The default property is "virtual".)
Name | No | String | The name of the property to be retrieved according to the account view's definition.
InSession | No | String | The name of the session property in which the value of the retrieved account view property will be stored.

## Configuration Example

The following file resolves by Login/namespace:

<configdata>

<Resolution>

<Login>accountname</Login>

<Namespace>namespace</Namespace>

</Resolution>

<Retrieval>

<Property>

<Name>AccountID</Name>

<InSession>_accountID</InSession>

</Property>

<Property>

<Name>PayingAccount</Name>

<InSession>_PayingAccount</InSession>

</Property>

<Property>

<Name>UsageCycleID</Name>

<InSession>_usageCycleID</InSession>

</Property>

<Property>

<Extension>core</Extension>

<AccountAdapter>internal</AccountAdapter>

<Name>Pricelist</Name>

<InSession>_AccountPricelist</InSession>

</Property>

<Property>

<Extension>core</Extension>

<AccountAdapter>internal</AccountAdapter>

<Name>timezoneid</Name>

<InSession>timezoneid</InSession>

</Property>

</Retrieval>

</configdata>

The following file resolves by account ID:

<configdata>

<Resolution>

<AccountID>_accountID</AccountID>

</Resolution>

<Retrieval>

<Property>

<Name>UsageCycleID</Name>

<InSession>_usageCycleID</InSession>

</Property>

<Property>

<Extension>core</Extension>

<AccountAdapter>internal</AccountAdapter>

<Name>Pricelist</Name>

<InSession>_AccountPricelist</InSession>

</Property>

</Retrieval>

</configdata>