/** * Declares an association between this object and a IndicatorsSc object. * * @param IndicatorsSc $v * @return AsignacionSc The current object (for fluent API support) * @throws PropelException */ public function setIndicatorsSc(IndicatorsSc $v = null) { if ($v === null) { $this->setIndicadorId(NULL); } else { $this->setIndicadorId($v->getId()); } $this->aIndicatorsSc = $v; // Add binding for other direction of this n:n relationship. // If this object has already been added to the IndicatorsSc object, it will not be re-added. if ($v !== null) { $v->addAsignacionSc($this); } return $this; }
public function executeCreate_mirror_tree(sfWebRequest $request) { $tree_id = $request->getParameter('idTree'); $user = $this->getUser()->getAttribute(sfConfig::get('app_session_current_user'), null); if ($user != null) { $tree_current = TreeScPeer::retrieveByPK($tree_id); if (is_object($tree_current)) { try { $conn = Propel::getConnection(); $conn->beginTransaction(); $tree_bean = new TreeSc(); $tree_bean->setName($tree_current->getName()); $tree_bean->setUserId($tree_current->getUserId()); $tree_bean->setConfigureFlag($tree_current->getConfigureFlag()); $tree_bean->setConfigureDesign($tree_current->getConfigureDesign()); $tree_bean->setCreateAt(time()); $tree_bean->setUpdateAt(time()); $tree_bean->setFlag($tree_current->getFlag()); $tree_bean->setProduccion('not'); $tree_bean->setGrupoTrabajoId($tree_current->getGrupoTrabajoId()); $tree_bean->setPeriodoId($tree_current->getPeriodoId()); $tree_bean->save(); $tree_user_bean = new TreeUser(); $tree_user_bean->setUserId($tree_bean->getUserId()); $tree_user_bean->setTreeId($tree_bean->getId()); $tree_user_bean->save(); $criterio = new Criteria(); $criterio->add(IndicatorsScPeer::TREE_ID, $tree_current->getId()); $criterio->add(IndicatorsScPeer::FLAG, '%habilitado%', Criteria::LIKE); $criterio->addAscendingOrderByColumn(IndicatorsScPeer::ID); $list_indicadores = IndicatorsScPeer::doSelect($criterio); $list_relation = null; foreach ($list_indicadores as $row) { $indicator_bean = new IndicatorsSc(); $indicator_bean->setTitulo($row->getTitulo()); $indicator_bean->setDescripcion($row->getDescripcion()); $indicator_bean->setValorMinimo($row->getValorMinimo()); $indicator_bean->setValorDeseado($row->getValorDeseado()); $indicator_bean->setValorOptimo($row->getValorOptimo()); $indicator_bean->setResponsableId($row->getResponsableId()); $indicator_bean->setTreeId($tree_bean->getId()); $indicator_bean->setEmailResponsable($row->getEmailResponsable()); $indicator_bean->setUltimoNodo($row->getUltimoNodo()); $indicator_bean->setDetNetworkAttributeId($row->getDetNetworkAttributeId()); $indicator_bean->setUsernameInNetwork($row->getUsernameInNetwork()); $indicator_bean->setGaFecIni($row->getGaFecIni()); $indicator_bean->setGaFecFin($row->getGaFecFin()); if ($row->getPreviousId() == 0) { $indicator_bean->setPreviousId(0); } else { $id_relation = $this->return_relation_id($list_relation, $row->getPreviousId()); $indicator_bean->setPreviousId($id_relation); } if ($row->getParents() != "") { $parents = $this->return_parent_relation($list_relation, $row->getParents()); $indicator_bean->setParents($parents); } $indicator_bean->setFlag($row->getFlag()); $indicator_bean->setConectoresConfigure($row->getConectoresConfigure()); $indicator_bean->save(); $relation = array('array' => '' . $row->getId() . '-' . $indicator_bean->getId() . ''); $list_relation[] = $relation; } // $conn->rollBack(); $tree_current->setFlag(2); $tree_current->save(); $conn->commit(); $conn = Propel::close(); $this->list_relation = $list_relation; $this->redirect('@edit_strategy?id_tree=' . $tree_bean->getId()); } catch (Exception $e) { $conn->rollBack(); $this->message = $e->getMessage(); $conn = Propel::close(); return sfView::ERROR; } } else { $this->message = 'tree not definitive'; $conn = Propel::close(); return sfView::ERROR; } } else { $this->message = 'session expired'; $conn = Propel::close(); return sfView::ERROR; } }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param IndicatorsSc $value A IndicatorsSc object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(IndicatorsSc $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }