/**
  * gets the previous change if the action is 'modified'
  *
  * @return ConceptPropertyHistory object
  * @param  string $historyTimestamp
  * @param  string $propertyId
  */
 function getPrevious()
 {
     $propertyId = $this->getSchemaPropertyElementId();
     $timestamp = $this->getCreatedAt();
     //build the query string
     $c = new Criteria();
     $crit0 = $c->getNewCriterion(SchemaPropertyElementHistoryPeer::SCHEMA_PROPERTY_ELEMENT_ID, $propertyId);
     $crit1 = $c->getNewCriterion(SchemaPropertyElementHistoryPeer::CREATED_AT, $timestamp, Criteria::LESS_THAN);
     // Perform AND at level 0 ($crit0 $crit1 )
     $crit0->addAnd($crit1);
     $c->add($crit0);
     //set order and limits
     $c->setLimit(1);
     $c->addDescendingOrderByColumn(SchemaPropertyElementHistoryPeer::CREATED_AT);
     $result = SchemaPropertyElementHistoryPeer::doSelect($c);
     //return the resulting object
     if (count($result)) {
         $result = $result[0];
     }
     return $result;
 }
Exemplo n.º 2
0
 /**
  * Gets the date of the last update of a domain or uri
  *
  * @return integer (unless a format string is supplied)
  */
 public function executeLastupdate()
 {
     $domain = $this->getRequestParameter('domain');
     $objects = $this->getRequestParameter('objects');
     $type = $this->getRequestParameter('type', "json");
     $lastUpdate = "";
     if (isset($domain)) {
         if ('schemas' == $objects) {
             $lastUpdate = SchemaPropertyElementHistoryPeer::getLastUpdateForDomain($domain, null);
         }
         if ('vocabs' == $objects) {
             $lastUpdate = ConceptPropertyHistoryPeer::getLastUpdateForDomain($domain, null);
         }
     }
     switch ($type) {
         case "json":
             echo json_encode($lastUpdate);
             break;
         default:
     }
     return sfView::NONE;
 }
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      Connection $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(SchemaPropertyElementHistoryPeer::ID, $pks, Criteria::IN);
         $objs = SchemaPropertyElementHistoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
  * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = SchemaPropertyElementHistoryPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setCreatedAt($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setCreatedUserId($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setAction($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setSchemaPropertyElementId($arr[$keys[4]]);
     }
     if (array_key_exists($keys[5], $arr)) {
         $this->setSchemaPropertyId($arr[$keys[5]]);
     }
     if (array_key_exists($keys[6], $arr)) {
         $this->setSchemaId($arr[$keys[6]]);
     }
     if (array_key_exists($keys[7], $arr)) {
         $this->setProfilePropertyId($arr[$keys[7]]);
     }
     if (array_key_exists($keys[8], $arr)) {
         $this->setObject($arr[$keys[8]]);
     }
     if (array_key_exists($keys[9], $arr)) {
         $this->setRelatedSchemaPropertyId($arr[$keys[9]]);
     }
     if (array_key_exists($keys[10], $arr)) {
         $this->setLanguage($arr[$keys[10]]);
     }
     if (array_key_exists($keys[11], $arr)) {
         $this->setStatusId($arr[$keys[11]]);
     }
     if (array_key_exists($keys[12], $arr)) {
         $this->setChangeNote($arr[$keys[12]]);
     }
     if (array_key_exists($keys[13], $arr)) {
         $this->setImportId($arr[$keys[13]]);
     }
 }
Exemplo n.º 5
0
             sfPropelParanoidBehavior::disable();
             $schema = $schema_property->getSchema();
         }
     }
     $tab = false;
     break;
 case 'schemahistorydetail':
     $showBc = true;
     $showSchemaBc = true;
     $showSchemaPropBc = true;
     $showSchemaPropelBc = true;
     $showSchemaHistoryBc = true;
     if (!isset($history)) {
         $id = $sf_params->get('id');
         if ($id) {
             $history = SchemaPropertyElementHistoryPeer::retrieveByPK($id);
         }
     }
     if (!isset($schema_property_element)) {
         if ($history) {
             sfPropelParanoidBehavior::disable();
             $schema_property_element = $history->getSchemaPropertyElement();
         }
     }
     if (!isset($schema_property)) {
         if ($schema_property_element) {
             sfPropelParanoidBehavior::disable();
             $schema_property = $schema_property_element->getSchemaPropertyRelatedBySchemaPropertyId();
         }
     }
     if (!isset($schema)) {
    /**
     * @param $args
     *
     * @throws \PropelException
     */
    public function perform($args)
    {
        list($environment, $importId) = $args;

        if ( ! defined('SF_ENVIRONMENT')) {
            //todo: this part really should be in a _bootstrapDbJob include
            // Set up environment for this job
            define('SF_ROOT_DIR', realpath(dirname(__file__) . '/../../../..'));
            define('SF_APP', 'frontend');
            define('SF_ENVIRONMENT', $environment);
            define('SF_DEBUG', false);

//initialize composer
            require_once(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php');
// initialize symfony
            require_once(SF_ROOT_DIR . DIRECTORY_SEPARATOR . 'apps' . DIRECTORY_SEPARATOR . SF_APP . DIRECTORY_SEPARATOR
                         . 'config' . DIRECTORY_SEPARATOR . 'config.php');
// initialize database manager
            $databaseManager = new \sfDatabaseManager();
            $databaseManager->initialize();
        }

        $connection = \Propel::getConnection();

        //todo: this should be setup to run on a cron

        //update the reciprocals and inverse
        if ($importId) {
            $c = new \Criteria();
            $c->add(\SchemaPropertyElementHistoryPeer::IMPORT_ID, $importId);
            $historyList = \SchemaPropertyElementHistoryPeer::doSelect($c);
            /** @var \SchemaPropertyElementHistory $history */
            foreach ($historyList as $history) {
                $element = $history->getSchemaPropertyElement();
                if ($element) {
                    //don't generate reciprocals for generated elements
                    if (!$element->getIsGenerated()) {
                        $element->importId = $importId;
                        $element->updateReciprocal($history->getAction(), $history->getCreatedUserId(),
                              $history->getSchemaId());
                    }
                }
            }
        }

        //update lexical aliases

        $query = <<<SQL
update reg_schema_property_element
set related_schema_property_id = schema_property_id
WHERE profile_property_id = 27
and related_schema_property_id is NULL
SQL;
        $statement = $connection->prepareStatement($query);
        $affectedRows = $statement->executeUpdate();
        echo $affectedRows;

        //update all of the related_schema_property_id

        $query = <<<SQL
update reg_schema_property_element as e, reg_schema_property as p
set e.related_schema_property_id = p.id
WHERE e.object = p.uri
and (e.related_schema_property_id <> p.id or e.related_schema_property_id is NULL)
SQL;
        $statement = $connection->prepareStatement($query);
        $affectedRows = $statement->executeUpdate();
        echo $affectedRows;

        //update all of the property parent_id

        $query = <<<SQL
UPDATE reg_schema_property as propa, reg_schema_property as propb
set propa.is_subproperty_of = propb.id
where propa.parent_uri is not NULL
and propa.is_subproperty_of is NULL
and propa.parent_uri = propb.uri;
SQL;
        $statement = $connection->prepareStatement($query);
        $affectedRows = $statement->executeUpdate();
        echo $affectedRows;
    }
Exemplo n.º 7
0
 /**
  *
  * gets the last update, either of the schema or the history
  *
  * @param int $id
  *
  * @throws PropelException
  * @return integer
  */
 public static function getLastUpdateDate($id)
 {
     $schema = self::retrieveByPK($id);
     if ($schema) {
         $lastSchemaUpdate = $schema->getUpdatedAt(null);
     }
     $lastHistoryUpdate = SchemaPropertyElementHistoryPeer::getLastUpdateForSchema($id, null);
     $result = max(array($lastHistoryUpdate, $lastSchemaUpdate));
     return $result;
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this SchemaProperty is new, it will return
  * an empty collection; or if this SchemaProperty has previously
  * been saved, it will retrieve related SchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in SchemaProperty.
  */
 public function getSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyIdJoinFileImportHistory($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'lib/model/om/BaseSchemaPropertyElementHistoryPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId === null) {
         if ($this->isNew()) {
             $this->collSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId = array();
         } else {
             $criteria->add(SchemaPropertyElementHistoryPeer::RELATED_SCHEMA_PROPERTY_ID, $this->getId());
             $this->collSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId = SchemaPropertyElementHistoryPeer::doSelectJoinFileImportHistory($criteria, $con);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(SchemaPropertyElementHistoryPeer::RELATED_SCHEMA_PROPERTY_ID, $this->getId());
         if (!isset($this->lastSchemaPropertyElementHistoryRelatedByRelatedSchemaPropertyIdCriteria) || !$this->lastSchemaPropertyElementHistoryRelatedByRelatedSchemaPropertyIdCriteria->equals($criteria)) {
             $this->collSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId = SchemaPropertyElementHistoryPeer::doSelectJoinFileImportHistory($criteria, $con);
         }
     }
     $this->lastSchemaPropertyElementHistoryRelatedByRelatedSchemaPropertyIdCriteria = $criteria;
     return $this->collSchemaPropertyElementHistorysRelatedByRelatedSchemaPropertyId;
 }
 /**
  * Selects a collection of SchemaPropertyElementHistory objects pre-filled with all related objects except SchemaPropertyRelatedByRelatedSchemaPropertyId.
  *
  * This is a corrected version of doSelectJoinAllExceptSchemaPropertyRelatedByRelatedSchemaPropertyId
  * that adds the schema property object onto the query
  * @return array Array of SchemaPropertyElementHistory objects.
  * @throws PropelException Any exceptions caught during processing will be
  *     rethrown wrapped into a PropelException.
  */
 public static function doSelectForList(Criteria $c, $con = null)
 {
     $c = clone $c;
     // Set the correct dbName if it has not been overridden
     // $c->getDbName() will return the same object if not set to another value
     // so == check is okay and faster
     if ($c->getDbName() == Propel::getDefaultDB()) {
         $c->setDbName(self::DATABASE_NAME);
     }
     SchemaPropertyElementHistoryPeer::addSelectColumns($c);
     $startcol2 = SchemaPropertyElementHistoryPeer::NUM_COLUMNS - SchemaPropertyElementHistoryPeer::NUM_LAZY_LOAD_COLUMNS + 1;
     UserPeer::addSelectColumns($c);
     $startcol3 = $startcol2 + UserPeer::NUM_COLUMNS;
     SchemaPropertyElementPeer::addSelectColumns($c);
     $startcol4 = $startcol3 + SchemaPropertyElementPeer::NUM_COLUMNS;
     SchemaPeer::addSelectColumns($c);
     $startcol5 = $startcol4 + SchemaPeer::NUM_COLUMNS;
     StatusPeer::addSelectColumns($c);
     $startcol6 = $startcol5 + StatusPeer::NUM_COLUMNS;
     SchemaPropertyPeer::addSelectColumns($c);
     $startcol7 = $startcol6 + SchemaPropertyPeer::NUM_COLUMNS;
     $c->addJoin(SchemaPropertyElementHistoryPeer::CREATED_USER_ID, UserPeer::ID);
     $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_PROPERTY_ELEMENT_ID, SchemaPropertyElementPeer::ID);
     $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_ID, SchemaPeer::ID);
     $c->addJoin(SchemaPropertyElementHistoryPeer::STATUS_ID, StatusPeer::ID);
     $c->addJoin(SchemaPropertyElementHistoryPeer::SCHEMA_PROPERTY_ID, SchemaPropertyPeer::ID);
     $rs = BasePeer::doSelect($c, $con);
     $results = array();
     while ($rs->next()) {
         $omClass = SchemaPropertyElementHistoryPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj1 = new $cls();
         $obj1->hydrate($rs);
         $omClass = UserPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj2 = new $cls();
         $obj2->hydrate($rs, $startcol2);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj2 = $temp_obj1->getUser();
             //CHECKME
             if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj2->addSchemaPropertyElementHistory($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj2->initSchemaPropertyElementHistorys();
             $obj2->addSchemaPropertyElementHistory($obj1);
         }
         $omClass = SchemaPropertyElementPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj3 = new $cls();
         $obj3->hydrate($rs, $startcol3);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj3 = $temp_obj1->getSchemaPropertyElement();
             //CHECKME
             if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj3->addSchemaPropertyElementHistory($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj3->initSchemaPropertyElementHistorys();
             $obj3->addSchemaPropertyElementHistory($obj1);
         }
         $omClass = SchemaPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj4 = new $cls();
         $obj4->hydrate($rs, $startcol4);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj4 = $temp_obj1->getSchema();
             //CHECKME
             if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj4->addSchemaPropertyElementHistory($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj4->initSchemaPropertyElementHistorys();
             $obj4->addSchemaPropertyElementHistory($obj1);
         }
         $omClass = StatusPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj5 = new $cls();
         $obj5->hydrate($rs, $startcol5);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj5 = $temp_obj1->getStatus();
             //CHECKME
             if ($temp_obj5->getPrimaryKey() === $obj5->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj5->addSchemaPropertyElementHistory($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj5->initSchemaPropertyElementHistorys();
             $obj5->addSchemaPropertyElementHistory($obj1);
         }
         $omClass = SchemaPropertyPeer::getOMClass();
         $cls = Propel::import($omClass);
         $obj6 = new $cls();
         $obj6->hydrate($rs, $startcol6);
         $newObject = true;
         for ($j = 0, $resCount = count($results); $j < $resCount; $j++) {
             $temp_obj1 = $results[$j];
             $temp_obj6 = $temp_obj1->getSchemaPropertyRelatedBySchemaPropertyId();
             //CHECKME
             if ($temp_obj6->getPrimaryKey() === $obj6->getPrimaryKey()) {
                 $newObject = false;
                 $temp_obj6->addSchemaPropertyElementHistoryRelatedBySchemaPropertyId($obj1);
                 break;
             }
         }
         if ($newObject) {
             $obj6->initSchemaPropertyElementHistorysRelatedBySchemaPropertyId();
             $obj6->addSchemaPropertyElementHistoryRelatedBySchemaPropertyId($obj1);
         }
         $results[] = $obj1;
     }
     return $results;
 }