evt_sel_mode == SelectMode::SM_INCL) { // include query $query = "select cac.* from cur_alm_cond cac join alm_evt_dscr aed on cac.aed_id = aed.id join bal_evt_sel bes on bes.aed_id = aed.id join alm_bal_mon abm on abm.id = bes.abm_id where abm.id = :p1 order by amo_id"; } else { // exclude query $query = "select cac.* from cur_alm_cond cac join alm_evt_dscr aed on cac.aed_id = aed.id join bal_evt_sel bes on bes.aed_id <> aed.id join alm_bal_mon abm on abm.id = bes.abm_id where abm.id = :p1 order by amo_id"; } // execute query $stmt = $con->prepare($query); $stmt->bindValue(':p1', $this->id, PDO::PARAM_INT); $succ = $stmt->execute(); if (!$succ) throw new Exception("Statement execution not succeeded"); return CurrentAlarmConditionPeer::populateObjects($stmt); } /** * Returns a AlarmBalance recalculated from the * related alarms * * @param PropelPDO Optional Connection object. * @return AlarmBalance object * @throws PropelException */ public function getRecalculatedBalance(PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(AlarmBalanceMonitorPeer::DATABASE_NAME, Propel::CONNECTION_READ); } if ($this->evt_sel_mode == SelectMode::SM_INCL) { // include query $query = "select distinct cac.alm_stat from cur_alm_cond cac join alm_evt_dscr aed on cac.aed_id = aed.id join bal_evt_sel bes on bes.aed_id = aed.id join alm_bal_mon abm on abm.id = bes.abm_id where abm.id = :p1"; } else { // exclude query $query = "select distinct cac.alm_stat from cur_alm_cond cac join alm_evt_dscr aed on cac.aed_id = aed.id join bal_evt_sel bes on bes.aed_id <> aed.id join alm_bal_mon abm on abm.id = bes.abm_id where abm.id = :p1"; } // execute query $stmt = $con->prepare($query); $stmt->bindValue(':p1', $this->id, PDO::PARAM_INT); $succ = $stmt->execute(); if (!$succ) throw new Exception("Statement execution not succeeded"); $alm_bal = new AlarmBalance(); foreach ($stmt as $alm_stat_cac) { $alm_bal->accu(new AlarmStatus($alm_stat_cac["alm_stat"])); } return $alm_bal; } /** * Overrides parent methods to switch between db value and type class instance */ public function getUncfdAstaBal() { return new AlarmBalance($this->uncfd_asta_bal); } public function setUncfdAstaBal($alm_bal) { parent::setUncfdAstaBal($alm_bal->getValue()); } public function getCfdAstaBal() { return new AlarmBalance($this->cfd_asta_bal); } public function setCfdAstaBal($alm_bal) { parent::setCfdAstaBal($alm_bal->getValue()); } public function getEvtSelMode() { return new SelectMode($this->evt_sel_mode); } public function setEvtSelMode($sel_mode) { parent::setEvtSelMode($sel_mode->getValue()); } public function getBalEvtSel() { $bes_lst = $this->getBess(); $aed_ids = array (); foreach ($bes_lst as $bes) { if ("null" !== $bes->getAlarmEventDescriptor()->getName()) $aed_ids[] = $bes->getAlarmEventDescriptor()->getId(); } return $aed_ids; } public function setBalEvtSel($value) { $bes_lst = $this->getBess(); foreach ($bes_lst as $bes) { // if ("null" !== $bes->getAlarmEventDescriptor()->getName()) $bes->delete(); } $this->clearBess(); // this is necessary to erase the bes buffer if ( (count($value) == 0) && ($this->getEvtSelMode()->getValue() == SelectMode::SM_EXCL) ) { // create null bes $bes = new BalancingEventSelector(); $bes->setAbmId($this->getId()); $bes->setAedId(1); // id of NULL-AED $bes->save(); } else { foreach ($value as $aed_id) { $bes = new BalancingEventSelector(); $bes->setAbmId($this->getId()); $bes->setAedId($aed_id); $bes->save(); } } return; } public function getEscHostSel() { $ehs_lst = $this->getEhss(); $amh_ids = array (); foreach ($ehs_lst as $ehs) { $amh_ids[] = $ehs->getAlarmingManagementHost()->getId(); } return $amh_ids; } public function setEscHostSel($value) { $ehs_lst = $this->getEhss(); foreach ($ehs_lst as $ehs) { $ehs->delete(); } $this->clearEhss(); // this is necessary to erase the ehs buffer foreach ($value as $amh_id) { $ehs = new EscalationHostSelector(); $ehs->setAbmId($this->getId()); $ehs->setAmhId($amh_id); $ehs->save(); } return; } /** * Code to be run before deleting the object in database * @param PropelPDO $con * @return boolean */ public function preDelete(PropelPDO $con = null) { // delete escalation host selection $ehs_lst = $this->getEhss(); foreach ($ehs_lst as $ehs) { $ehs->delete(); } $this->clearEhss(); // delete balancing event selection $bes_lst = $this->getBess(); foreach ($bes_lst as $bes) { $bes->delete(); } $this->clearBess(); // this is necessary to erase the bes buffer return true; } /** * Overrides parent method to maintain modification counting */ public function save(PropelPDO $con = null) { if ($this->isNew() || $this->mod >= 999999) { $this->setMod(0); } else { $this->setMod($this->mod + 1); } return parent::save($con); } } // AlarmBalanceMonitor