The DataSourceControl.xml file is used by the Adapter to control its access to the data source and ensure that whenever it executes, it always continues onwards from the last point to which it read.
The file Adapter retains the name of the last file read, the last read line, and the position in the file it reached. The next time the Adapter runs, it accesses the file from the location using the information found in the DataSourceControl.xml file. Using this mechanism, the Adapter can read only new records on each run.
The Adapter does not work directly on the source files, but first copies the current file to a work file. Hence, the same information is kept for the work file and for the source file. If the source file is appended, only new records are copied to the work file.
If the Adapter is configured to delete the source file once processed, by setting the parameter in the configuration file DeleteAfterProcessing to "yes", it does not save the information in the source file. When finished, it reads any new file that exists in the working folder that matches the file pattern defined in the configuration file.
Only when DeleteAfterProcessing is set to "no" does it check for new records in the last file. If there are none, it moves to the next file in a lexicographical order. Therefore, when naming source data files, to ensure they are read in the correct sequence, try and enforce an increasing sequential naming pattern. For example, append the files with a reverse date value (yyyymmdd-hhmmss) to support this. For example:
The following is an example of the DataSourceControl.xml for a file Adapter.
<AdapterControl Save="end" LastSaveTime="2005/05/20 13:06:39"> <Data><WorkData><LineNumber>0</LineNumber> <FilePattern>c:\adapters\callsadapter\*adapterpca.csv</FilePattern> [set the File Name variable]</FileName> <BasicPosition>0</BasicPosition> </WorkData> <NonDeletedFiles> <File NamePattern="c:\adapters\callsadapter\*adapterpca.csv"> [set the File Name variable]2005adapterpca.csv</FileName> <LastLine>25/04/2005,5925,NN4B,12,12,0,10,0,11</LastLine> <LastPosition>15427</LastPosition></File> </NonDeletedFiles> </Data> </AdapterControl>
A SQL Adapter retains the last value of the query key fields for each query executed. The key fields are unique identifiers for records in the destination database table. The Adapter uses these values when building the query for the next run. This allows the Adapter to read only new records.
For example, consider the following SQL statement used for fetching some Trouble ticket data.
Select ticket_id, status, organization, open_date, respond_date, resolved_date, record_modified_date from t_ticket_data;
In this example, to capture all the latest records from the data source, the query key field chosen to ensure obtaining the latest information is record_modified_date, since it generates new tickets raised since the last Adapter execution, as well as updates to existing tickets. By selecting this field as the query key field, the Adapter automatically appends the following section to the end of the query during execution:
where record_modified_date > :previous_value order by record_modified_date asc
Therefore, it only retrieves the newer records. Note that there are a number of considerations when choosing the query key field, and they always depend on the behavior of the data source and what you are trying to achieve with the retrieved data. Also note that the fields chosen in the previous example are not always the best choice for every situation.
An example of the DataSourceControl.xml file for a SQL Adapter is shown below.
<AdapterControl Save="end" LastSaveTime="2005/05/20 15:59:02"> <Data><QueryCollection> <Query QueryName="ChangeManagementOpenQuery"> <KeyField Name="Incident Ref"><LastValue>32357</LastValue></KeyField> <KeyField Name="Date Logged"><LastValue>18/04/2005 16:56:26</LastValue></KeyField> <LastFileName/> </Query> <Query QueryName="ChangeManagementPendingQuery"> <KeyField Name="Incident Ref"><LastValue>0</LastValue></KeyField> <KeyField Name="Date Resolved"><LastValue>1900-01-01</LastValue></KeyField><LastFileName/> </Query>
|
Copyright © 2012 CA.
All rights reserved.
|
|