PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 1ms

/oiclient/lib/model/om/BasePartition.php

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