Example #1
0
 protected function preHash(MeshingBaseObject $object, array $values)
 {
     // Get previous hash to add into the current hashing process
     $previousHash = $object->getHash($this->con);
     $values[] = $previousHash . $this->getValueTerminator($previousHash);
     return $values;
 }
Example #2
0
 /**
  * Clears cached hash providers
  * 
  * This is only really useful for testing - we wouldn't normally want to mix hash
  * providers on the one connection
  */
 public function clearHashProviders()
 {
     self::$hashProviders = array();
 }
Example #3
0
 /**
  * Gets value for row table
  * 
  * Swaps foreign creator_node_id values for their unique FQDN value. Note that the other
  * part(s) to a primary or foreign key is set by the creator and is the same in all nodes,
  * so may be hashed without causing difference problems between nodes.
  * 
  * @todo Better node table detection required (should use known prefix)
  * @todo Fix column name hardwiring
  * 
  * @param MeshingBaseObject $object
  * @param ColumnMap $columnMap
  * @return mixed 
  */
 protected function getRowValue(MeshingBaseObject $object, ColumnMap $columnMap)
 {
     // Get value for this column
     $columnName = $columnMap->getName();
     $value = $object->getByName($columnName, BasePeer::TYPE_RAW_COLNAME);
     // If the related table name ends with '_known_node' then we assume this is a
     // FK to a creator node ID.
     if ($columnMap->isForeignKey()) {
         $match = '_known_node';
         $isNodeTable = $match == substr($columnMap->getRelatedTableName(), -strlen($match));
         if ($isNodeTable && $columnMap->getRelatedColumnName() == 'ID') {
             $nodePeerName = $columnMap->getRelation()->getForeignTable()->getPeerClassname();
             $node = call_user_func(array($nodePeerName, 'retrieveByPK'), $value, $this->con);
             // If there is no related node, we really do have problems!
             if (!$node) {
                 $primaryKey = $object->getPrimaryKey();
                 if (is_array($primaryKey)) {
                     $primaryKey = '{' . implode(',', $primaryKey) . '}';
                 }
                 $type = get_class($object);
                 throw new Exception("Row {$primaryKey} in table '{$type}' points to a non-existent node row");
             }
             $value = $node->getFqdn();
         }
     }
     return $value;
 }
Example #4
0
 /**
  * Clears the static object variables used to cache a provider per connection
  */
 protected function clearProviderCache()
 {
     $o = new MeshingBaseObject();
     $o->clearHashProviders();
 }