PageRenderTime 25ms CodeModel.GetById 34ms RepoModel.GetById 7ms app.codeStats 0ms

/lib/model/presupuesto/om/BaseCpdocaju.php

https://github.com/cidesa/roraima
PHP | 536 lines | 374 code | 162 blank | 0 comment | 47 complexity | 75e0f3fed0e71fc36a27a524ece2bd0b MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. abstract class BaseCpdocaju extends BaseObject implements Persistent {
  3. protected static $peer;
  4. protected $tipaju;
  5. protected $nomext;
  6. protected $nomabr;
  7. protected $refier;
  8. protected $id;
  9. protected $collCpajustes;
  10. protected $lastCpajusteCriteria = null;
  11. protected $alreadyInSave = false;
  12. protected $alreadyInValidation = false;
  13. public function getTipaju()
  14. {
  15. return trim($this->tipaju);
  16. }
  17. public function getNomext()
  18. {
  19. return trim($this->nomext);
  20. }
  21. public function getNomabr()
  22. {
  23. return trim($this->nomabr);
  24. }
  25. public function getRefier()
  26. {
  27. return trim($this->refier);
  28. }
  29. public function getId()
  30. {
  31. return $this->id;
  32. }
  33. public function setTipaju($v)
  34. {
  35. if ($this->tipaju !== $v) {
  36. $this->tipaju = $v;
  37. $this->modifiedColumns[] = CpdocajuPeer::TIPAJU;
  38. }
  39. }
  40. public function setNomext($v)
  41. {
  42. if ($this->nomext !== $v) {
  43. $this->nomext = $v;
  44. $this->modifiedColumns[] = CpdocajuPeer::NOMEXT;
  45. }
  46. }
  47. public function setNomabr($v)
  48. {
  49. if ($this->nomabr !== $v) {
  50. $this->nomabr = $v;
  51. $this->modifiedColumns[] = CpdocajuPeer::NOMABR;
  52. }
  53. }
  54. public function setRefier($v)
  55. {
  56. if ($this->refier !== $v) {
  57. $this->refier = $v;
  58. $this->modifiedColumns[] = CpdocajuPeer::REFIER;
  59. }
  60. }
  61. public function setId($v)
  62. {
  63. if ($this->id !== $v) {
  64. $this->id = $v;
  65. $this->modifiedColumns[] = CpdocajuPeer::ID;
  66. }
  67. }
  68. public function hydrate(ResultSet $rs, $startcol = 1)
  69. {
  70. try {
  71. $this->tipaju = $rs->getString($startcol + 0);
  72. $this->nomext = $rs->getString($startcol + 1);
  73. $this->nomabr = $rs->getString($startcol + 2);
  74. $this->refier = $rs->getString($startcol + 3);
  75. $this->id = $rs->getInt($startcol + 4);
  76. $this->resetModified();
  77. $this->setNew(false);
  78. $this->afterHydrate();
  79. return $startcol + 5;
  80. } catch (Exception $e) {
  81. throw new PropelException("Error populating Cpdocaju object", $e);
  82. }
  83. }
  84. protected function afterHydrate()
  85. {
  86. }
  87. public function __call($m, $a)
  88. {
  89. $prefijo = substr($m,0,3);
  90. $metodo = strtolower(substr($m,3));
  91. if($prefijo=='get'){
  92. if(isset($this->$metodo)) return $this->$metodo;
  93. else return '';
  94. }elseif($prefijo=='set'){
  95. if(isset($this->$metodo)) $this->$metodo = $a[0];
  96. }else call_user_func_array($m, $a);
  97. }
  98. public function delete($con = null)
  99. {
  100. if ($this->isDeleted()) {
  101. throw new PropelException("This object has already been deleted.");
  102. }
  103. if ($con === null) {
  104. $con = Propel::getConnection(CpdocajuPeer::DATABASE_NAME);
  105. }
  106. try {
  107. $con->begin();
  108. CpdocajuPeer::doDelete($this, $con);
  109. $this->setDeleted(true);
  110. $con->commit();
  111. } catch (PropelException $e) {
  112. $con->rollback();
  113. throw $e;
  114. }
  115. }
  116. public function save($con = null)
  117. {
  118. if ($this->isDeleted()) {
  119. throw new PropelException("You cannot save an object that has been deleted.");
  120. }
  121. if ($con === null) {
  122. $con = Propel::getConnection(CpdocajuPeer::DATABASE_NAME);
  123. }
  124. try {
  125. $con->begin();
  126. $affectedRows = $this->doSave($con);
  127. $con->commit();
  128. return $affectedRows;
  129. } catch (PropelException $e) {
  130. $con->rollback();
  131. throw $e;
  132. }
  133. }
  134. protected function doSave($con)
  135. {
  136. $affectedRows = 0; if (!$this->alreadyInSave) {
  137. $this->alreadyInSave = true;
  138. if ($this->isModified()) {
  139. if ($this->isNew()) {
  140. $pk = CpdocajuPeer::doInsert($this, $con);
  141. $affectedRows += 1;
  142. $this->setId($pk);
  143. $this->setNew(false);
  144. } else {
  145. $affectedRows += CpdocajuPeer::doUpdate($this, $con);
  146. }
  147. $this->resetModified(); }
  148. if ($this->collCpajustes !== null) {
  149. foreach($this->collCpajustes as $referrerFK) {
  150. if (!$referrerFK->isDeleted()) {
  151. $affectedRows += $referrerFK->save($con);
  152. }
  153. }
  154. }
  155. $this->alreadyInSave = false;
  156. }
  157. return $affectedRows;
  158. }
  159. protected $validationFailures = array();
  160. public function getValidationFailures()
  161. {
  162. return $this->validationFailures;
  163. }
  164. public function validate($columns = null)
  165. {
  166. $res = $this->doValidate($columns);
  167. if ($res === true) {
  168. $this->validationFailures = array();
  169. return true;
  170. } else {
  171. $this->validationFailures = $res;
  172. return false;
  173. }
  174. }
  175. protected function doValidate($columns = null)
  176. {
  177. if (!$this->alreadyInValidation) {
  178. $this->alreadyInValidation = true;
  179. $retval = null;
  180. $failureMap = array();
  181. if (($retval = CpdocajuPeer::doValidate($this, $columns)) !== true) {
  182. $failureMap = array_merge($failureMap, $retval);
  183. }
  184. if ($this->collCpajustes !== null) {
  185. foreach($this->collCpajustes as $referrerFK) {
  186. if (!$referrerFK->validate($columns)) {
  187. $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
  188. }
  189. }
  190. }
  191. $this->alreadyInValidation = false;
  192. }
  193. return (!empty($failureMap) ? $failureMap : true);
  194. }
  195. public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
  196. {
  197. $pos = CpdocajuPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  198. return $this->getByPosition($pos);
  199. }
  200. public function getByPosition($pos)
  201. {
  202. switch($pos) {
  203. case 0:
  204. return $this->getTipaju();
  205. break;
  206. case 1:
  207. return $this->getNomext();
  208. break;
  209. case 2:
  210. return $this->getNomabr();
  211. break;
  212. case 3:
  213. return $this->getRefier();
  214. break;
  215. case 4:
  216. return $this->getId();
  217. break;
  218. default:
  219. return null;
  220. break;
  221. } }
  222. public function toArray($keyType = BasePeer::TYPE_PHPNAME)
  223. {
  224. $keys = CpdocajuPeer::getFieldNames($keyType);
  225. $result = array(
  226. $keys[0] => $this->getTipaju(),
  227. $keys[1] => $this->getNomext(),
  228. $keys[2] => $this->getNomabr(),
  229. $keys[3] => $this->getRefier(),
  230. $keys[4] => $this->getId(),
  231. );
  232. return $result;
  233. }
  234. public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
  235. {
  236. $pos = CpdocajuPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
  237. return $this->setByPosition($pos, $value);
  238. }
  239. public function setByPosition($pos, $value)
  240. {
  241. switch($pos) {
  242. case 0:
  243. $this->setTipaju($value);
  244. break;
  245. case 1:
  246. $this->setNomext($value);
  247. break;
  248. case 2:
  249. $this->setNomabr($value);
  250. break;
  251. case 3:
  252. $this->setRefier($value);
  253. break;
  254. case 4:
  255. $this->setId($value);
  256. break;
  257. } }
  258. public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
  259. {
  260. $keys = CpdocajuPeer::getFieldNames($keyType);
  261. if (array_key_exists($keys[0], $arr)) $this->setTipaju($arr[$keys[0]]);
  262. if (array_key_exists($keys[1], $arr)) $this->setNomext($arr[$keys[1]]);
  263. if (array_key_exists($keys[2], $arr)) $this->setNomabr($arr[$keys[2]]);
  264. if (array_key_exists($keys[3], $arr)) $this->setRefier($arr[$keys[3]]);
  265. if (array_key_exists($keys[4], $arr)) $this->setId($arr[$keys[4]]);
  266. }
  267. public function buildCriteria()
  268. {
  269. $criteria = new Criteria(CpdocajuPeer::DATABASE_NAME);
  270. if ($this->isColumnModified(CpdocajuPeer::TIPAJU)) $criteria->add(CpdocajuPeer::TIPAJU, $this->tipaju);
  271. if ($this->isColumnModified(CpdocajuPeer::NOMEXT)) $criteria->add(CpdocajuPeer::NOMEXT, $this->nomext);
  272. if ($this->isColumnModified(CpdocajuPeer::NOMABR)) $criteria->add(CpdocajuPeer::NOMABR, $this->nomabr);
  273. if ($this->isColumnModified(CpdocajuPeer::REFIER)) $criteria->add(CpdocajuPeer::REFIER, $this->refier);
  274. if ($this->isColumnModified(CpdocajuPeer::ID)) $criteria->add(CpdocajuPeer::ID, $this->id);
  275. return $criteria;
  276. }
  277. public function buildPkeyCriteria()
  278. {
  279. $criteria = new Criteria(CpdocajuPeer::DATABASE_NAME);
  280. $criteria->add(CpdocajuPeer::ID, $this->id);
  281. return $criteria;
  282. }
  283. public function getPrimaryKey()
  284. {
  285. return $this->getId();
  286. }
  287. public function setPrimaryKey($key)
  288. {
  289. $this->setId($key);
  290. }
  291. public function copyInto($copyObj, $deepCopy = false)
  292. {
  293. $copyObj->setTipaju($this->tipaju);
  294. $copyObj->setNomext($this->nomext);
  295. $copyObj->setNomabr($this->nomabr);
  296. $copyObj->setRefier($this->refier);
  297. if ($deepCopy) {
  298. $copyObj->setNew(false);
  299. foreach($this->getCpajustes() as $relObj) {
  300. $copyObj->addCpajuste($relObj->copy($deepCopy));
  301. }
  302. }
  303. $copyObj->setNew(true);
  304. $copyObj->setId(NULL);
  305. }
  306. public function copy($deepCopy = false)
  307. {
  308. $clazz = get_class($this);
  309. $copyObj = new $clazz();
  310. $this->copyInto($copyObj, $deepCopy);
  311. return $copyObj;
  312. }
  313. public function getPeer()
  314. {
  315. if (self::$peer === null) {
  316. self::$peer = new CpdocajuPeer();
  317. }
  318. return self::$peer;
  319. }
  320. public function initCpajustes()
  321. {
  322. if ($this->collCpajustes === null) {
  323. $this->collCpajustes = array();
  324. }
  325. }
  326. public function getCpajustes($criteria = null, $con = null)
  327. {
  328. include_once 'lib/model/presupuesto/om/BaseCpajustePeer.php';
  329. if ($criteria === null) {
  330. $criteria = new Criteria();
  331. }
  332. elseif ($criteria instanceof Criteria)
  333. {
  334. $criteria = clone $criteria;
  335. }
  336. if ($this->collCpajustes === null) {
  337. if ($this->isNew()) {
  338. $this->collCpajustes = array();
  339. } else {
  340. $criteria->add(CpajustePeer::TIPAJU, $this->getTipaju());
  341. CpajustePeer::addSelectColumns($criteria);
  342. $this->collCpajustes = CpajustePeer::doSelect($criteria, $con);
  343. }
  344. } else {
  345. if (!$this->isNew()) {
  346. $criteria->add(CpajustePeer::TIPAJU, $this->getTipaju());
  347. CpajustePeer::addSelectColumns($criteria);
  348. if (!isset($this->lastCpajusteCriteria) || !$this->lastCpajusteCriteria->equals($criteria)) {
  349. $this->collCpajustes = CpajustePeer::doSelect($criteria, $con);
  350. }
  351. }
  352. }
  353. $this->lastCpajusteCriteria = $criteria;
  354. return $this->collCpajustes;
  355. }
  356. public function countCpajustes($criteria = null, $distinct = false, $con = null)
  357. {
  358. include_once 'lib/model/presupuesto/om/BaseCpajustePeer.php';
  359. if ($criteria === null) {
  360. $criteria = new Criteria();
  361. }
  362. elseif ($criteria instanceof Criteria)
  363. {
  364. $criteria = clone $criteria;
  365. }
  366. $criteria->add(CpajustePeer::TIPAJU, $this->getTipaju());
  367. return CpajustePeer::doCount($criteria, $distinct, $con);
  368. }
  369. public function addCpajuste(Cpajuste $l)
  370. {
  371. $this->collCpajustes[] = $l;
  372. $l->setCpdocaju($this);
  373. }
  374. }