/**
  * Get the associated ChildComparison object
  *
  * @param  ConnectionInterface $con Optional Connection object.
  * @return ChildComparison The associated ChildComparison object.
  * @throws PropelException
  */
 public function getcomparisonObj(ConnectionInterface $con = null)
 {
     if ($this->acomparisonObj === null && $this->comparison !== null) {
         $this->acomparisonObj = ChildComparisonQuery::create()->findPk($this->comparison, $con);
         /* The following can be used additionally to
               guarantee the related object contains a reference
               to this object.  This level of coupling may, however, be
               undesirable since it could result in an only partially populated collection
               in the referenced object.
               $this->acomparisonObj->addItemFilterRulesRelatedByComparison($this);
            */
     }
     return $this->acomparisonObj;
 }
 /**
  * Returns a new query object pre configured with filters from current object and given arguments to query the database.
  * 
  * @param int $id
  * @param Criteria $criteria
  *
  * @return ChildComparisonQuery
  */
 public function createComparisonsQuery($id = null, Criteria $criteria = null)
 {
     $criteria = ChildComparisonQuery::create($criteria)->filterByType($this);
     $typeComparisonQuery = $criteria->useTypeComparisonQuery();
     if (null !== $id) {
         $typeComparisonQuery->filterById($id);
     }
     $typeComparisonQuery->endUse();
     return $criteria;
 }
 /**
  * Performs an INSERT on the database, given a Comparison or Criteria object.
  *
  * @param mixed               $criteria Criteria or Comparison object containing data that is used to create the INSERT statement.
  * @param ConnectionInterface $con the ConnectionInterface connection to use
  * @return mixed           The new primary key.
  * @throws PropelException Any exceptions caught during processing will be
  *                         rethrown wrapped into a PropelException.
  */
 public static function doInsert($criteria, ConnectionInterface $con = null)
 {
     if (null === $con) {
         $con = Propel::getServiceContainer()->getWriteConnection(ComparisonTableMap::DATABASE_NAME);
     }
     if ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
         // rename for clarity
     } else {
         $criteria = $criteria->buildCriteria();
         // build Criteria from Comparison object
     }
     if ($criteria->containsKey(ComparisonTableMap::COL_ID) && $criteria->keyContainsValue(ComparisonTableMap::COL_ID)) {
         throw new PropelException('Cannot insert a value for auto-increment primary key (' . ComparisonTableMap::COL_ID . ')');
     }
     // Set the correct dbName
     $query = ComparisonQuery::create()->mergeWith($criteria);
     // use transaction because $criteria could contain info
     // for more than one table (I guess, conceivably)
     return $con->transaction(function () use($con, $query) {
         return $query->doInsert($con);
     });
 }
 /**
  * Builds a Criteria object containing the primary key for this object.
  *
  * Unlike buildCriteria() this method includes the primary key values regardless
  * of whether or not they have been modified.
  *
  * @throws LogicException if no primary key is defined
  *
  * @return Criteria The Criteria object containing value(s) for primary key(s).
  */
 public function buildPkeyCriteria()
 {
     $criteria = ChildComparisonQuery::create();
     $criteria->add(ComparisonTableMap::COL_ID, $this->id);
     return $criteria;
 }
 /**
  * Returns a new ChildComparisonQuery object.
  *
  * @param     string $modelAlias The alias of a model in the query
  * @param     Criteria $criteria Optional Criteria to build the query from
  *
  * @return ChildComparisonQuery
  */
 public static function create($modelAlias = null, Criteria $criteria = null)
 {
     if ($criteria instanceof ChildComparisonQuery) {
         return $criteria;
     }
     $query = new ChildComparisonQuery();
     if (null !== $modelAlias) {
         $query->setModelAlias($modelAlias);
     }
     if ($criteria instanceof Criteria) {
         $query->mergeWith($criteria);
     }
     return $query;
 }
 public function calculateNewItemFilterTypes()
 {
     $comparisonDict = $this->getDictById(ECP\ComparisonQuery::create()->find());
     $typeContext = $this->invTypeService->getTypeContext();
     while (true) {
         $entityContext = $this->getFittingRuleEntityContextForItemFilterTypeCalculations();
         $fittingRuleRowsWithTypeDict = $entityContext['fittingRuleRowsWithTypes'];
         $connection = $this->getPropelConnection();
         foreach ($entityContext['entities'] as $entity) {
             try {
                 $connection->beginTransaction();
                 foreach ($entity->getFittingRuleRows() as $fittingRuleRow) {
                     $typeArray = $this->calculateItemFilterTypesFrom($comparisonDict, $typeContext, $fittingRuleRow);
                     $fittingRuleRowId = $fittingRuleRow->getId();
                     if (!array_key_exists($fittingRuleRowId, $fittingRuleRowsWithTypeDict)) {
                         echo '... so this row has already been deleted between those two fetches ... interesting ... skiping it ...\\n';
                         continue;
                     }
                     $this->updateItemFilterTypes($connection, $typeArray, $fittingRuleRowsWithTypeDict[$fittingRuleRowId]);
                 }
                 $this->setFittingRuleEntityUpToDate($connection, $entity);
                 $connection->commit();
             } catch (Exception $e) {
                 $connection->rollBack();
                 throw $e;
             }
         }
         sleep(30);
     }
 }