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

Source for file UpdateLocalDataRule.php

Documentation is available at UpdateLocalDataRule.php

  1. <?php
  2. /**
  3.  * <b>Class Description</b>: Class representing the rules for refreshing linked data.
  4.  * (see {@link package.php} for documentation
  5.  * of the DDMS package.).
  6.  *@see package.php
  7.  * @since : 29/04/2009
  8.  * @author Jan van der Breggen
  9.  * @package DDMS
  10.  * @subpackage DDMSClient
  11.  ***/
  12.  
  13.  
  14. define('COUNTRY''country');
  15. define('ACTIVE_RETREATS''active_retreats');
  16.  
  17. class UpdateLocalDataRule extends ORM implements RuleObject
  18. {
  19.     private $defaultUpdateEvent;
  20.     private $externallyLinkedOrm;
  21.     function __construct($orm)
  22.     {
  23.         $this->database 'rigregversiontwo';    
  24.         //just for test purposes
  25.         $this->defaultUpdateEvent = COUNTRY;
  26.         $this->externallyLinkedOrm = $orm;
  27.     }
  28.  
  29.     public function applyRule()
  30.     {
  31.         $numargs func_num_args();
  32.         if (func_num_args(0)
  33.         {
  34.             $updateEvent func_get_arg(0);
  35.         else
  36.         {
  37.             $updateEvent $this->defaultUpdateEvent;
  38.         }
  39.         
  40.         switch ($this->externallyLinkedOrm->getTableName()) {
  41.             case "students":
  42.                 return $this->studentTable($updateEvent);
  43.                 break;
  44.             case "country":
  45.                 return
  46.                 break;
  47.             case "sanghas":
  48.                 //return $this->sanghaTable();
  49.  
  50.          }
  51.         
  52.      }
  53.     function sanghaTable()
  54.     {
  55.         return $this->externallyLinkedOrm->getKeySetForUpdate('ID''>''0');
  56.     }
  57.     
  58.     function studentTable ($updateEvent)
  59.     {
  60.         if ($updateEvent ==COUNTRY)
  61.         {
  62.             return $this->externallyLinkedOrm->getKeySetForUpdate('country''=''NP');//'country', '=', 'DE'
  63.         elseif ($updateEvent == ACTIVE_RETREATS)
  64.         {
  65.                       $this->query("SELECT distinct(studentID) FROM retreatreg r, retreat rt where r.retreatUID = rt.ID and rt.status = 1 limit 100");
  66.             return $this->externallyLinkedOrm->convertLocalKeyValuesToRemoteKeyValues($this->rows_array());
  67.         }
  68.         
  69.     }
  70.     
  71.    
  72. private function reduce($data)
  73.     {
  74.         $values array();
  75.         foreach ($data as $value)
  76.         {
  77.             array_push($valuesimplode(','$value));
  78.         }
  79.     
  80.         return implode(","$values);
  81.     }
  82.     
  83.     public function setORM($orm)
  84.     {
  85.         $this->externallyLinkedOrm = $orm;
  86.     }
  87.  
  88.  
  89. }
  90.  
  91. ?>

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