/**
  * Filter the query by a related \ECP\RulesetShip object
  *
  * @param \ECP\RulesetShip|ObjectCollection $rulesetShip the related object to use as filter
  * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return ChildRulesetEntityQuery The current query, for fluid interface
  */
 public function filterByRulesetShip($rulesetShip, $comparison = null)
 {
     if ($rulesetShip instanceof \ECP\RulesetShip) {
         return $this->addUsingAlias(RulesetEntityTableMap::COL_ID, $rulesetShip->getRulesetentityid(), $comparison);
     } elseif ($rulesetShip instanceof ObjectCollection) {
         return $this->useRulesetShipQuery()->filterByPrimaryKeys($rulesetShip->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByRulesetShip() only accepts arguments of type \\ECP\\RulesetShip or Collection');
     }
 }
 /**
  * Exclude object from result
  *
  * @param   ChildRulesetShip $rulesetShip Object to remove from the list of results
  *
  * @return $this|ChildRulesetShipQuery The current query, for fluid interface
  */
 public function prune($rulesetShip = null)
 {
     if ($rulesetShip) {
         $this->addUsingAlias(RulesetShipTableMap::COL_ID, $rulesetShip->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
 protected function performSave($data, $fork)
 {
     $entity = $this->getLocalyMappedEntityToSave($data, $fork);
     $entity->setMinPilots($data->minPilots);
     $entity->setMaxPilots($data->maxPilots);
     $entity->setMaxPoints($data->maxPoints);
     $connection = $this->getPropelConnection();
     try {
         $connection->beginTransaction();
         $shipDict = array();
         foreach ($entity->getRulesetShips() as $ship) {
             $shipDict[$ship->getShipId()] = $ship;
         }
         $shipDict = $shipDict;
         foreach ($data->ships as $dataShipId => $dataShipPoints) {
             $iShipId = intval($dataShipId);
             $shipExists = array_key_exists($iShipId, $shipDict);
             $ship = null;
             if ($shipExists) {
                 $ship = $shipDict[$iShipId];
             } else {
                 $ship = new ECP\RulesetShip();
                 $ship->setShipId($iShipId);
             }
             $ship->setPoints($dataShipPoints);
             $this->prepareSubentitySave2($connection, $entity, 'RulesetShip', $ship, !$shipExists);
         }
         $ruleRowIndex = 0;
         foreach ($data->rules as $dataRuleRow) {
             $ruleRow = $this->getSubentity($entity, 'RulesetRuleRow', $dataRuleRow);
             $ruleRow->setInd3x($ruleRowIndex++);
             $ruleRow->setMessage($dataRuleRow->message);
             $filterRuleIndex = 0;
             foreach ($dataRuleRow->fittingRules as $dataFilterRule) {
                 $filterRule = $this->getSubentity($ruleRow, 'RulesetFilterRule', $dataFilterRule);
                 $filterRule->setInd3x($filterRuleIndex);
                 if ($filterRuleIndex == 0) {
                     $filterRule->setConcatenation(0);
                 } else {
                     if (property_exists($dataFilterRule, 'concatenation')) {
                         $filterRule->setConcatenation($dataFilterRule->concatenation->id);
                     }
                 }
                 $filterRule->setFittingRuleEntityId($dataFilterRule->tag->id);
                 $filterRule->setComparison($dataFilterRule->comparison->id);
                 $filterRule->setValue($dataFilterRule->value);
                 $this->prepareSubentitySave($connection, $ruleRow, 'RulesetFilterRule', $filterRule, $dataFilterRule);
                 $filterRuleIndex++;
             }
             $this->cleanupOldEnties($ruleRow, 'RulesetFilterRule', $dataRuleRow->fittingRules);
             $this->prepareSubentitySave($connection, $entity, 'RulesetRuleRow', $ruleRow, $dataRuleRow);
         }
         $this->cleanupOldEnties($entity, 'RulesetRuleRow', $data->rules);
         $this->saveGroupAccess($connection, $entity, $data);
         $entity->save($connection);
         $connection->commit();
         return $this->createIdObj($entity->getId());
     } catch (Exception $e) {
         $connection->rollBack();
         throw $e;
     }
 }