Controllers
[ class tree: Controllers ] [ index: Controllers ] [ all elements ]

Class: ExternallyLinkedORM

Source Location: /rvtwo/classes/DDMSClient/ExternallyLinkedORM.php

Class Overview

ORM
   |
   --ExternallyLinkedORM

Class: ExternallyLinkedORM


Author(s):

Variables

Methods



Class Details

[line 38]
Class: ExternallyLinkedORM

Description:




Tags:

todo:  possibly, include non-linked tables in the references table to indicate how these remotely linked cached data records relate to the local non-linked application data. Then upon deletion of records that are referenced by local tables the user should have a choice not to delete those records in order to avoid data corruption. These records can then also continue as purely local records even though stored in linked table. Alternatively, a separate table could be created for these purely local records.
todo:  possibly, as a step towards handling insertion of new records: allow for new records to be inserted but to remain purely local, recognisable by null value in remote key field. These records will be ignored during the refresh event, ie they will not be updated or deleted at any stage.
todo:  the update function can now run more than once for the same table during a refresh data event (eg during its regular update, but also in the case when a record is deleted in a table that is has foreign key references to). To maximise efficiency we could consider keeping an array with key values that have already been updated during the current refresh event, and before running another update check against this array. Alternatively, make the update function only ever execute once during any given refresh event, ie build up an array with key values and only if it is complete run the update event.
todo:  rename the different refresh functions to 'update' 'insert' 'delete', separate out delete and insert at start of refresh event retrieve set of remote keys as these are used in all three
todo:  for new records: go back to the server to check for foreign key references of other tables and optionally refresh these in the local cache
todo:  separate out the ALLDATA refresh alltogether


[ Top ]


Class Variables

$partOfDefaultRefreshEvent =

[line 49]



Tags:

access:  private

Type:   mixed


[ Top ]

$primaryKey =

[line 41]



Tags:

access:  private

Type:   mixed


[ Top ]

$primaryKeyIsString =  FALSE

[line 47]



Tags:

access:  private

Type:   mixed


[ Top ]

$references =

[line 44]



Tags:

access:  private

Type:   mixed


[ Top ]

$remoteKey =

[line 42]



Tags:

access:  private

Type:   mixed


[ Top ]

$remoteKeyIsString =  FALSE

[line 48]



Tags:

access:  private

Type:   mixed


[ Top ]

$remoteMap =

[line 43]



Tags:

access:  public

Type:   mixed


[ Top ]

$serverConnection =

[line 46]



Tags:

access:  private

Type:   mixed


[ Top ]

$tableName =

[line 45]



Tags:

access:  private

Type:   mixed


[ Top ]



Class Methods


constructor __construct [line 62]

$this __construct( Associative $tableDetails, Associative $references, &$serverConnection, ExternalDataServerConnection $serverConnection.)



Parameters:

ExternalDataServerConnection   $serverConnection.   Reference to the serverConnection object
Associative   $tableDetails   array $tableDetails. Expected array keys: table_name, primary_key, remote_key
Associative   $references   array $references, representing foreign key references of the linked table. Expected array keys: `column`, referenced_table, referenced_column, remote_referenced_column
   &$serverConnection  

[ Top ]

method addLocalKeysToLoadFile [line 827]

void addLocalKeysToLoadFile( &$fileString)



Parameters:

   &$fileString  

[ Top ]

method checkAndProcessStagedNewRecords [line 812]

void checkAndProcessStagedNewRecords( )



Tags:

todo:  Implement this method, and its counterpart on the server side as follows: This method checks log files on the server side that report the results of auditing previously submitted new records. To this end the server side should implement a system of making the relevant log files downloadable by clients who submitted new records. The result of auditing is either 'pass', in which cas the log file will contain the remote key value for the record, or 'fail' in which case the new record was refused for some reason. In the case of 'fail' there should probably be a system of codes that indicate the reason, eg 'duplicate record' or something.


[ Top ]

method convertForeignKeyValuesToLocalKeyValues [line 427]

rows_array convertForeignKeyValuesToLocalKeyValues( rows_array $foreignKeyValues, string $column, [ $isString = FALSE])

A utility function to retrieve a set of local_key values based on a set of foreign key values that might be referred to by records in this table



Tags:

return:  A set of remote_key values for records that have foreign key references to any of the values found in $foreignKeyValues.


Parameters:

rows_array   $foreignKeyValues  
string   $column   the column that is the foreign key
   $isString  

[ Top ]

method convertForeignKeyValuesToRemoteKeyValues [line 408]

rows_array convertForeignKeyValuesToRemoteKeyValues( rows_array $foreignKeyValues, string $column, [ $isString = FALSE])

A utility function to retrieve a set of remote_key values based on a set of foreign key values that might be referred to by records in this table



Tags:

return:  A set of remote_key values for records that have foreign key references to any of the values found in $foreignKeyValues.


Parameters:

rows_array   $foreignKeyValues  
string   $column   the column that is the foreign key
   $isString  

[ Top ]

method convertLocalKeyValuesToRemoteKeyValues [line 389]

void convertLocalKeyValuesToRemoteKeyValues( $localKeyValues)



Parameters:

   $localKeyValues  

[ Top ]

method convertRemoteKeyValuesToLocalKeyValues [line 382]

void convertRemoteKeyValuesToLocalKeyValues( $remoteKeyValues)



Parameters:

   $remoteKeyValues  

[ Top ]

method DeleteLocalRecords [line 546]

void DeleteLocalRecords( $dorKeySet)



Tags:

access:  private


Parameters:

   $dorKeySet  

[ Top ]

method extractColumnFromLoadFile [line 835]

void extractColumnFromLoadFile( $ColumnNumber, $fileString)



Parameters:

   $ColumnNumber  
   $fileString  

[ Top ]

method getColumnNumber [line 188]

void getColumnNumber( $fieldName)



Parameters:

   $fieldName  

[ Top ]

method getForeignKeyFieldName [line 291]

IF getForeignKeyFieldName( string $referredTable)

returns the name of the column the values of which have a foreign key relation with $referredTable



Tags:

return:  this table has foreign key reference to $referredTable: string representing the column name ELSE boolean FALSE


Parameters:

string   $referredTable  

[ Top ]

method getKeySetForUpdate [line 349]

void getKeySetForUpdate( $field, $operator, $value)



Tags:

access:  public


Parameters:

   $field  
   $operator  
   $value  

[ Top ]

method getLocalRemoteKeyPairs [line 360]

void getLocalRemoteKeyPairs( [ $returnHash = false], [ $field = ''], [ $operator = ''], [ $value = ''])



Parameters:

   $returnHash  
   $field  
   $operator  
   $value  

[ Top ]

method getReferencedObjects [line 267]

void getReferencedObjects( )



[ Top ]

method getReferences [line 257]

array getReferences( )



Tags:

return:  containing names of other linked tables this table has foreign key references to.


[ Top ]

method getReferringFieldForTable [line 327]

void getReferringFieldForTable( $tableName)



Parameters:

   $tableName  

[ Top ]

method getRemoteKey [line 183]

void getRemoteKey( )



[ Top ]

method getRemoteKeySet [line 342]

void getRemoteKeySet( )



[ Top ]

method getTableName [line 150]

void getTableName( )



[ Top ]

method hasForeignKeyReferenceTo [line 272]

void hasForeignKeyReferenceTo( $tableName)



Parameters:

   $tableName  

[ Top ]

method hasLocalKeyReferences [line 218]

if hasLocalKeyReferences( )



Tags:

return:  the linked table has references to local_key values of other linked tables: TRUE, else FALSE


[ Top ]

method hasReferences [line 204]

if hasReferences( )



Tags:

return:  the linked table has references to other linked tables: TRUE, else FALSE


[ Top ]

method InsertLocalRecords [line 604]

void InsertLocalRecords( $dorKeySet)



Tags:

todo:  split up the 'delete' and 'insert' events, which are currently both included in this function.
todo:  the get new records function should or could send a message to the server to get any records from table(s) that refer to this table and have a reference to the new record and the local cache for this referring table can then be updated accordingly
access:  private


Parameters:

   $dorKeySet  

[ Top ]

method isLocalKeyReference [line 242]

if isLocalKeyReference( array $reference)



Tags:

return:  'referenced_column' == 'local_key' TRUE else FALSE


Parameters:

array   $reference  

[ Top ]

method isSelectOnly [line 159]

TRUE isSelectOnly( )



Tags:

return:  if the linked table primary key field is the remote_key field FALSE if the linked table primary key field is not the remote_key field


[ Top ]

method localizeReferences [line 901]

void localizeReferences( $loadFile)



Parameters:

   $loadFile  

[ Top ]

method makeRemoteMap [line 137]

void makeRemoteMap( )



[ Top ]

method reduce [line 961]

one reduce( two $data, [ $AddQuotes = FALSE])

utility function to reduce an array of arrays to a 'simple' array

that is: each value in the returned $values array is not an array but one string value if the second dimension array contains multiple values these will be imploded to a comma delimited string




Tags:

return:  dimensional array $values
access:  private


Parameters:

two   $data   dimensional array $data
   $AddQuotes  

[ Top ]

method referenceIsCascadingDelete [line 315]

void referenceIsCascadingDelete( $tableName)



Parameters:

   $tableName  

[ Top ]

method referenceIsCascadingInsert [line 303]

void referenceIsCascadingInsert( $tableName)



Parameters:

   $tableName  

[ Top ]

method refreshAllData [line 503]

void refreshAllData( )

Does a blanket replacement of all local data with data from the DoR

In future can be made more sophisticated for logging and 'undo' purposes




Tags:

access:  private


[ Top ]

method refreshDataFragment [line 522]

void refreshDataFragment( [ $updateEventType = ''])



Tags:

access:  private


Parameters:

   $updateEventType  

[ Top ]

method refreshLocalData [line 465]

void refreshLocalData( [String $updateEventType = ''])



Tags:

todo:  implement the refresh thing as follows: distinguish between the 'refreshType' and the 'updateType'. Of 'refreshType' there are two: the 'regular' refresh event including only those tables that need refresh regularly; and the'all tables' refresh event. Of updateTypes there can be any number, one of which is the default update type. The dataset to be updated for each of these types is defined in the updatLocalDataRule object.
todo:  the delete and get new events can be combined into one event as the full set of keys is returned to the application by the remote server for the delete event. based on this it is easy to determine which records are not in the local cache and request them from the server.
todo:  think about the implications of deleting records that might be referenced by other tables. Deleting records in referenced tables should probably result in some kind of update event in table(s) that reference that table as foreign key values in the records that refer to records that are now deleted should have been updated in the DoR. In case of an ALLDATA update this would be taken care of as a matter of course, but not necessarily in update events that work with subsets of the data.
access:  public


Parameters:

String   $updateEventType   - a valid update event type as specified in ...... if this argument is not provided the default update event is executed

[ Top ]

method surroundValues [line 974]

void surroundValues( &$item1, $key, $char)



Parameters:

   &$item1  
   $key  
   $char  

[ Top ]

method updateLocalRecords [line 673]

void updateLocalRecords( [unknown_type $updateEventType = ''], [ $keySet = array()])

Enter description here...



Tags:

todo:  the 'keystring' that is used for the update event has the side effect that records that have been deleted from the DoR will be permanently deleted from the cache during the update event. So the update event does more than just update. As records that are to be deleted are treated differently this should be changed. One way to do this is to get the keyset from the server and to trim the 'keystring' down to include only what's actually on the server. A current workaround is to do the 'delete' event before the 'update' event.
todo:  possibly make it optional to include the update rules of referenced tables currently this happens without choice. Can be done with a boolean flag in the references table.
access:  protected


Parameters:

unknown_type   $updateEventType  
   $keySet  

[ Top ]

method writeNewRecords [line 817]

void writeNewRecords( )



[ Top ]

method _createAndLoadFile [line 920]

void _createAndLoadFile( $fileString)



Parameters:

   $fileString  

[ Top ]

method _getLoadFile [line 932]

void _getLoadFile( [ $keySet = ''])



Parameters:

   $keySet  

[ Top ]

method _localTablesEmpty [line 171]

void _localTablesEmpty( )



Tags:

access:  private


[ Top ]

method _populateLocalTables [line 785]

void _populateLocalTables( )



Tags:

access:  private


[ Top ]

method _replaceValuesInLoadFileString [line 869]

the _replaceValuesInLoadFileString( $fileString, Assoc $replaceValues, $lookupColumn, integer $replaceColumn, string $fileString:, integer $lookupColumn:)



Tags:

return:  with the $replaceColum updated with the replace value as found in the $replaceValues array.


Parameters:

string   $fileString:   representing the loadfile, tab delimited field values, newline delimited records
integer   $lookupColumn:   column number that's the reference in the record to find the replace value
integer   $replaceColumn   column number in the record the value of which should be replaced
Assoc   $replaceValues   Array $replaceValues: key is lookup value, value is replace value
   $fileString  
   $lookupColumn  

[ Top ]


Documentation generated on Mon, 18 May 2009 11:22:01 +0200 by phpDocumentor 1.4.1