1: <?php
2:
3: namespace cli_db\propel\om;
4:
5: use \BaseObject;
6: use \BasePeer;
7: use \Criteria;
8: use \DateTime;
9: use \Exception;
10: use \PDO;
11: use \Persistent;
12: use \Propel;
13: use \PropelCollection;
14: use \PropelDateTime;
15: use \PropelException;
16: use \PropelObjectCollection;
17: use \PropelPDO;
18: use cli_db\propel\Acquisition;
19: use cli_db\propel\AcquisitionPeer;
20: use cli_db\propel\AcquisitionQuery;
21: use cli_db\propel\Assay;
22: use cli_db\propel\AssayQuery;
23: use cli_db\propel\Protocol;
24: use cli_db\propel\ProtocolQuery;
25: use cli_db\propel\Quantification;
26: use cli_db\propel\QuantificationQuery;
27:
28: /**
29: * Base class that represents a row from the 'acquisition' table.
30: *
31: *
32: *
33: * @package propel.generator.cli_db.om
34: */
35: abstract class BaseAcquisition extends BaseObject implements Persistent
36: {
37: /**
38: * Peer class name
39: */
40: const PEER = 'cli_db\\propel\\AcquisitionPeer';
41:
42: /**
43: * The Peer class.
44: * Instance provides a convenient way of calling static methods on a class
45: * that calling code may not be able to identify.
46: * @var AcquisitionPeer
47: */
48: protected static $peer;
49:
50: /**
51: * The flag var to prevent infinit loop in deep copy
52: * @var boolean
53: */
54: protected $startCopy = false;
55:
56: /**
57: * The value for the acquisition_id field.
58: * @var int
59: */
60: protected $acquisition_id;
61:
62: /**
63: * The value for the assay_id field.
64: * @var int
65: */
66: protected $assay_id;
67:
68: /**
69: * The value for the protocol_id field.
70: * @var int
71: */
72: protected $protocol_id;
73:
74: /**
75: * The value for the channel_id field.
76: * @var int
77: */
78: protected $channel_id;
79:
80: /**
81: * The value for the acquisitiondate field.
82: * Note: this column has a database default value of: (expression) now()
83: * @var string
84: */
85: protected $acquisitiondate;
86:
87: /**
88: * The value for the name field.
89: * @var string
90: */
91: protected $name;
92:
93: /**
94: * The value for the uri field.
95: * @var string
96: */
97: protected $uri;
98:
99: /**
100: * @var Assay
101: */
102: protected $aAssay;
103:
104: /**
105: * @var Protocol
106: */
107: protected $aProtocol;
108:
109: /**
110: * @var PropelObjectCollection|Quantification[] Collection to store aggregation of Quantification objects.
111: */
112: protected $collQuantifications;
113: protected $collQuantificationsPartial;
114:
115: /**
116: * Flag to prevent endless save loop, if this object is referenced
117: * by another object which falls in this transaction.
118: * @var boolean
119: */
120: protected $alreadyInSave = false;
121:
122: /**
123: * Flag to prevent endless validation loop, if this object is referenced
124: * by another object which falls in this transaction.
125: * @var boolean
126: */
127: protected $alreadyInValidation = false;
128:
129: /**
130: * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
131: * @var boolean
132: */
133: protected $alreadyInClearAllReferencesDeep = false;
134:
135: /**
136: * An array of objects scheduled for deletion.
137: * @var PropelObjectCollection
138: */
139: protected $quantificationsScheduledForDeletion = null;
140:
141: /**
142: * Applies default values to this object.
143: * This method should be called from the object's constructor (or
144: * equivalent initialization method).
145: * @see __construct()
146: */
147: public function applyDefaultValues()
148: {
149: }
150:
151: /**
152: * Initializes internal state of BaseAcquisition object.
153: * @see applyDefaults()
154: */
155: public function __construct()
156: {
157: parent::__construct();
158: $this->applyDefaultValues();
159: }
160:
161: /**
162: * Get the [acquisition_id] column value.
163: *
164: * @return int
165: */
166: public function getAcquisitionId()
167: {
168: return $this->acquisition_id;
169: }
170:
171: /**
172: * Get the [assay_id] column value.
173: *
174: * @return int
175: */
176: public function getAssayId()
177: {
178: return $this->assay_id;
179: }
180:
181: /**
182: * Get the [protocol_id] column value.
183: *
184: * @return int
185: */
186: public function getProtocolId()
187: {
188: return $this->protocol_id;
189: }
190:
191: /**
192: * Get the [channel_id] column value.
193: *
194: * @return int
195: */
196: public function getChannelId()
197: {
198: return $this->channel_id;
199: }
200:
201: /**
202: * Get the [optionally formatted] temporal [acquisitiondate] column value.
203: *
204: *
205: * @param string $format The date/time format string (either date()-style or strftime()-style).
206: * If format is null, then the raw DateTime object will be returned.
207: * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
208: * @throws PropelException - if unable to parse/validate the date/time value.
209: */
210: public function getAcquisitiondate($format = 'Y-m-d H:i:s')
211: {
212: if ($this->acquisitiondate === null) {
213: return null;
214: }
215:
216:
217: try {
218: $dt = new DateTime($this->acquisitiondate);
219: } catch (Exception $x) {
220: throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->acquisitiondate, true), $x);
221: }
222:
223: if ($format === null) {
224: // Because propel.useDateTimeClass is true, we return a DateTime object.
225: return $dt;
226: }
227:
228: if (strpos($format, '%') !== false) {
229: return strftime($format, $dt->format('U'));
230: }
231:
232: return $dt->format($format);
233:
234: }
235:
236: /**
237: * Get the [name] column value.
238: *
239: * @return string
240: */
241: public function getName()
242: {
243: return $this->name;
244: }
245:
246: /**
247: * Get the [uri] column value.
248: *
249: * @return string
250: */
251: public function getUri()
252: {
253: return $this->uri;
254: }
255:
256: /**
257: * Set the value of [acquisition_id] column.
258: *
259: * @param int $v new value
260: * @return Acquisition The current object (for fluent API support)
261: */
262: public function setAcquisitionId($v)
263: {
264: if ($v !== null && is_numeric($v)) {
265: $v = (int) $v;
266: }
267:
268: if ($this->acquisition_id !== $v) {
269: $this->acquisition_id = $v;
270: $this->modifiedColumns[] = AcquisitionPeer::ACQUISITION_ID;
271: }
272:
273:
274: return $this;
275: } // setAcquisitionId()
276:
277: /**
278: * Set the value of [assay_id] column.
279: *
280: * @param int $v new value
281: * @return Acquisition The current object (for fluent API support)
282: */
283: public function setAssayId($v)
284: {
285: if ($v !== null && is_numeric($v)) {
286: $v = (int) $v;
287: }
288:
289: if ($this->assay_id !== $v) {
290: $this->assay_id = $v;
291: $this->modifiedColumns[] = AcquisitionPeer::ASSAY_ID;
292: }
293:
294: if ($this->aAssay !== null && $this->aAssay->getAssayId() !== $v) {
295: $this->aAssay = null;
296: }
297:
298:
299: return $this;
300: } // setAssayId()
301:
302: /**
303: * Set the value of [protocol_id] column.
304: *
305: * @param int $v new value
306: * @return Acquisition The current object (for fluent API support)
307: */
308: public function setProtocolId($v)
309: {
310: if ($v !== null && is_numeric($v)) {
311: $v = (int) $v;
312: }
313:
314: if ($this->protocol_id !== $v) {
315: $this->protocol_id = $v;
316: $this->modifiedColumns[] = AcquisitionPeer::PROTOCOL_ID;
317: }
318:
319: if ($this->aProtocol !== null && $this->aProtocol->getProtocolId() !== $v) {
320: $this->aProtocol = null;
321: }
322:
323:
324: return $this;
325: } // setProtocolId()
326:
327: /**
328: * Set the value of [channel_id] column.
329: *
330: * @param int $v new value
331: * @return Acquisition The current object (for fluent API support)
332: */
333: public function setChannelId($v)
334: {
335: if ($v !== null && is_numeric($v)) {
336: $v = (int) $v;
337: }
338:
339: if ($this->channel_id !== $v) {
340: $this->channel_id = $v;
341: $this->modifiedColumns[] = AcquisitionPeer::CHANNEL_ID;
342: }
343:
344:
345: return $this;
346: } // setChannelId()
347:
348: /**
349: * Sets the value of [acquisitiondate] column to a normalized version of the date/time value specified.
350: *
351: * @param mixed $v string, integer (timestamp), or DateTime value.
352: * Empty strings are treated as null.
353: * @return Acquisition The current object (for fluent API support)
354: */
355: public function setAcquisitiondate($v)
356: {
357: $dt = PropelDateTime::newInstance($v, null, 'DateTime');
358: if ($this->acquisitiondate !== null || $dt !== null) {
359: $currentDateAsString = ($this->acquisitiondate !== null && $tmpDt = new DateTime($this->acquisitiondate)) ? $tmpDt->format('Y-m-d H:i:s') : null;
360: $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
361: if ($currentDateAsString !== $newDateAsString) {
362: $this->acquisitiondate = $newDateAsString;
363: $this->modifiedColumns[] = AcquisitionPeer::ACQUISITIONDATE;
364: }
365: } // if either are not null
366:
367:
368: return $this;
369: } // setAcquisitiondate()
370:
371: /**
372: * Set the value of [name] column.
373: *
374: * @param string $v new value
375: * @return Acquisition The current object (for fluent API support)
376: */
377: public function setName($v)
378: {
379: if ($v !== null && is_numeric($v)) {
380: $v = (string) $v;
381: }
382:
383: if ($this->name !== $v) {
384: $this->name = $v;
385: $this->modifiedColumns[] = AcquisitionPeer::NAME;
386: }
387:
388:
389: return $this;
390: } // setName()
391:
392: /**
393: * Set the value of [uri] column.
394: *
395: * @param string $v new value
396: * @return Acquisition The current object (for fluent API support)
397: */
398: public function setUri($v)
399: {
400: if ($v !== null && is_numeric($v)) {
401: $v = (string) $v;
402: }
403:
404: if ($this->uri !== $v) {
405: $this->uri = $v;
406: $this->modifiedColumns[] = AcquisitionPeer::URI;
407: }
408:
409:
410: return $this;
411: } // setUri()
412:
413: /**
414: * Indicates whether the columns in this object are only set to default values.
415: *
416: * This method can be used in conjunction with isModified() to indicate whether an object is both
417: * modified _and_ has some values set which are non-default.
418: *
419: * @return boolean Whether the columns in this object are only been set with default values.
420: */
421: public function hasOnlyDefaultValues()
422: {
423: // otherwise, everything was equal, so return true
424: return true;
425: } // hasOnlyDefaultValues()
426:
427: /**
428: * Hydrates (populates) the object variables with values from the database resultset.
429: *
430: * An offset (0-based "start column") is specified so that objects can be hydrated
431: * with a subset of the columns in the resultset rows. This is needed, for example,
432: * for results of JOIN queries where the resultset row includes columns from two or
433: * more tables.
434: *
435: * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
436: * @param int $startcol 0-based offset column which indicates which restultset column to start with.
437: * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
438: * @return int next starting column
439: * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
440: */
441: public function hydrate($row, $startcol = 0, $rehydrate = false)
442: {
443: try {
444:
445: $this->acquisition_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
446: $this->assay_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
447: $this->protocol_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
448: $this->channel_id = ($row[$startcol + 3] !== null) ? (int) $row[$startcol + 3] : null;
449: $this->acquisitiondate = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
450: $this->name = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
451: $this->uri = ($row[$startcol + 6] !== null) ? (string) $row[$startcol + 6] : null;
452: $this->resetModified();
453:
454: $this->setNew(false);
455:
456: if ($rehydrate) {
457: $this->ensureConsistency();
458: }
459: $this->postHydrate($row, $startcol, $rehydrate);
460: return $startcol + 7; // 7 = AcquisitionPeer::NUM_HYDRATE_COLUMNS.
461:
462: } catch (Exception $e) {
463: throw new PropelException("Error populating Acquisition object", $e);
464: }
465: }
466:
467: /**
468: * Checks and repairs the internal consistency of the object.
469: *
470: * This method is executed after an already-instantiated object is re-hydrated
471: * from the database. It exists to check any foreign keys to make sure that
472: * the objects related to the current object are correct based on foreign key.
473: *
474: * You can override this method in the stub class, but you should always invoke
475: * the base method from the overridden method (i.e. parent::ensureConsistency()),
476: * in case your model changes.
477: *
478: * @throws PropelException
479: */
480: public function ensureConsistency()
481: {
482:
483: if ($this->aAssay !== null && $this->assay_id !== $this->aAssay->getAssayId()) {
484: $this->aAssay = null;
485: }
486: if ($this->aProtocol !== null && $this->protocol_id !== $this->aProtocol->getProtocolId()) {
487: $this->aProtocol = null;
488: }
489: } // ensureConsistency
490:
491: /**
492: * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
493: *
494: * This will only work if the object has been saved and has a valid primary key set.
495: *
496: * @param boolean $deep (optional) Whether to also de-associated any related objects.
497: * @param PropelPDO $con (optional) The PropelPDO connection to use.
498: * @return void
499: * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
500: */
501: public function reload($deep = false, PropelPDO $con = null)
502: {
503: if ($this->isDeleted()) {
504: throw new PropelException("Cannot reload a deleted object.");
505: }
506:
507: if ($this->isNew()) {
508: throw new PropelException("Cannot reload an unsaved object.");
509: }
510:
511: if ($con === null) {
512: $con = Propel::getConnection(AcquisitionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
513: }
514:
515: // We don't need to alter the object instance pool; we're just modifying this instance
516: // already in the pool.
517:
518: $stmt = AcquisitionPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
519: $row = $stmt->fetch(PDO::FETCH_NUM);
520: $stmt->closeCursor();
521: if (!$row) {
522: throw new PropelException('Cannot find matching row in the database to reload object values.');
523: }
524: $this->hydrate($row, 0, true); // rehydrate
525:
526: if ($deep) { // also de-associate any related objects?
527:
528: $this->aAssay = null;
529: $this->aProtocol = null;
530: $this->collQuantifications = null;
531:
532: } // if (deep)
533: }
534:
535: /**
536: * Removes this object from datastore and sets delete attribute.
537: *
538: * @param PropelPDO $con
539: * @return void
540: * @throws PropelException
541: * @throws Exception
542: * @see BaseObject::setDeleted()
543: * @see BaseObject::isDeleted()
544: */
545: public function delete(PropelPDO $con = null)
546: {
547: if ($this->isDeleted()) {
548: throw new PropelException("This object has already been deleted.");
549: }
550:
551: if ($con === null) {
552: $con = Propel::getConnection(AcquisitionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
553: }
554:
555: $con->beginTransaction();
556: try {
557: $deleteQuery = AcquisitionQuery::create()
558: ->filterByPrimaryKey($this->getPrimaryKey());
559: $ret = $this->preDelete($con);
560: if ($ret) {
561: $deleteQuery->delete($con);
562: $this->postDelete($con);
563: $con->commit();
564: $this->setDeleted(true);
565: } else {
566: $con->commit();
567: }
568: } catch (Exception $e) {
569: $con->rollBack();
570: throw $e;
571: }
572: }
573:
574: /**
575: * Persists this object to the database.
576: *
577: * If the object is new, it inserts it; otherwise an update is performed.
578: * All modified related objects will also be persisted in the doSave()
579: * method. This method wraps all precipitate database operations in a
580: * single transaction.
581: *
582: * @param PropelPDO $con
583: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
584: * @throws PropelException
585: * @throws Exception
586: * @see doSave()
587: */
588: public function save(PropelPDO $con = null)
589: {
590: if ($this->isDeleted()) {
591: throw new PropelException("You cannot save an object that has been deleted.");
592: }
593:
594: if ($con === null) {
595: $con = Propel::getConnection(AcquisitionPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
596: }
597:
598: $con->beginTransaction();
599: $isInsert = $this->isNew();
600: try {
601: $ret = $this->preSave($con);
602: if ($isInsert) {
603: $ret = $ret && $this->preInsert($con);
604: } else {
605: $ret = $ret && $this->preUpdate($con);
606: }
607: if ($ret) {
608: $affectedRows = $this->doSave($con);
609: if ($isInsert) {
610: $this->postInsert($con);
611: } else {
612: $this->postUpdate($con);
613: }
614: $this->postSave($con);
615: AcquisitionPeer::addInstanceToPool($this);
616: } else {
617: $affectedRows = 0;
618: }
619: $con->commit();
620:
621: return $affectedRows;
622: } catch (Exception $e) {
623: $con->rollBack();
624: throw $e;
625: }
626: }
627:
628: /**
629: * Performs the work of inserting or updating the row in the database.
630: *
631: * If the object is new, it inserts it; otherwise an update is performed.
632: * All related objects are also updated in this method.
633: *
634: * @param PropelPDO $con
635: * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
636: * @throws PropelException
637: * @see save()
638: */
639: protected function doSave(PropelPDO $con)
640: {
641: $affectedRows = 0; // initialize var to track total num of affected rows
642: if (!$this->alreadyInSave) {
643: $this->alreadyInSave = true;
644:
645: // We call the save method on the following object(s) if they
646: // were passed to this object by their coresponding set
647: // method. This object relates to these object(s) by a
648: // foreign key reference.
649:
650: if ($this->aAssay !== null) {
651: if ($this->aAssay->isModified() || $this->aAssay->isNew()) {
652: $affectedRows += $this->aAssay->save($con);
653: }
654: $this->setAssay($this->aAssay);
655: }
656:
657: if ($this->aProtocol !== null) {
658: if ($this->aProtocol->isModified() || $this->aProtocol->isNew()) {
659: $affectedRows += $this->aProtocol->save($con);
660: }
661: $this->setProtocol($this->aProtocol);
662: }
663:
664: if ($this->isNew() || $this->isModified()) {
665: // persist changes
666: if ($this->isNew()) {
667: $this->doInsert($con);
668: } else {
669: $this->doUpdate($con);
670: }
671: $affectedRows += 1;
672: $this->resetModified();
673: }
674:
675: if ($this->quantificationsScheduledForDeletion !== null) {
676: if (!$this->quantificationsScheduledForDeletion->isEmpty()) {
677: QuantificationQuery::create()
678: ->filterByPrimaryKeys($this->quantificationsScheduledForDeletion->getPrimaryKeys(false))
679: ->delete($con);
680: $this->quantificationsScheduledForDeletion = null;
681: }
682: }
683:
684: if ($this->collQuantifications !== null) {
685: foreach ($this->collQuantifications as $referrerFK) {
686: if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
687: $affectedRows += $referrerFK->save($con);
688: }
689: }
690: }
691:
692: $this->alreadyInSave = false;
693:
694: }
695:
696: return $affectedRows;
697: } // doSave()
698:
699: /**
700: * Insert the row in the database.
701: *
702: * @param PropelPDO $con
703: *
704: * @throws PropelException
705: * @see doSave()
706: */
707: protected function doInsert(PropelPDO $con)
708: {
709: $modifiedColumns = array();
710: $index = 0;
711:
712: $this->modifiedColumns[] = AcquisitionPeer::ACQUISITION_ID;
713: if (null !== $this->acquisition_id) {
714: throw new PropelException('Cannot insert a value for auto-increment primary key (' . AcquisitionPeer::ACQUISITION_ID . ')');
715: }
716: if (null === $this->acquisition_id) {
717: try {
718: $stmt = $con->query("SELECT nextval('acquisition_acquisition_id_seq')");
719: $row = $stmt->fetch(PDO::FETCH_NUM);
720: $this->acquisition_id = $row[0];
721: } catch (Exception $e) {
722: throw new PropelException('Unable to get sequence id.', $e);
723: }
724: }
725:
726:
727: // check the columns in natural order for more readable SQL queries
728: if ($this->isColumnModified(AcquisitionPeer::ACQUISITION_ID)) {
729: $modifiedColumns[':p' . $index++] = '"acquisition_id"';
730: }
731: if ($this->isColumnModified(AcquisitionPeer::ASSAY_ID)) {
732: $modifiedColumns[':p' . $index++] = '"assay_id"';
733: }
734: if ($this->isColumnModified(AcquisitionPeer::PROTOCOL_ID)) {
735: $modifiedColumns[':p' . $index++] = '"protocol_id"';
736: }
737: if ($this->isColumnModified(AcquisitionPeer::CHANNEL_ID)) {
738: $modifiedColumns[':p' . $index++] = '"channel_id"';
739: }
740: if ($this->isColumnModified(AcquisitionPeer::ACQUISITIONDATE)) {
741: $modifiedColumns[':p' . $index++] = '"acquisitiondate"';
742: }
743: if ($this->isColumnModified(AcquisitionPeer::NAME)) {
744: $modifiedColumns[':p' . $index++] = '"name"';
745: }
746: if ($this->isColumnModified(AcquisitionPeer::URI)) {
747: $modifiedColumns[':p' . $index++] = '"uri"';
748: }
749:
750: $sql = sprintf(
751: 'INSERT INTO "acquisition" (%s) VALUES (%s)',
752: implode(', ', $modifiedColumns),
753: implode(', ', array_keys($modifiedColumns))
754: );
755:
756: try {
757: $stmt = $con->prepare($sql);
758: foreach ($modifiedColumns as $identifier => $columnName) {
759: switch ($columnName) {
760: case '"acquisition_id"':
761: $stmt->bindValue($identifier, $this->acquisition_id, PDO::PARAM_INT);
762: break;
763: case '"assay_id"':
764: $stmt->bindValue($identifier, $this->assay_id, PDO::PARAM_INT);
765: break;
766: case '"protocol_id"':
767: $stmt->bindValue($identifier, $this->protocol_id, PDO::PARAM_INT);
768: break;
769: case '"channel_id"':
770: $stmt->bindValue($identifier, $this->channel_id, PDO::PARAM_INT);
771: break;
772: case '"acquisitiondate"':
773: $stmt->bindValue($identifier, $this->acquisitiondate, PDO::PARAM_STR);
774: break;
775: case '"name"':
776: $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
777: break;
778: case '"uri"':
779: $stmt->bindValue($identifier, $this->uri, PDO::PARAM_STR);
780: break;
781: }
782: }
783: $stmt->execute();
784: } catch (Exception $e) {
785: Propel::log($e->getMessage(), Propel::LOG_ERR);
786: throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
787: }
788:
789: $this->setNew(false);
790: }
791:
792: /**
793: * Update the row in the database.
794: *
795: * @param PropelPDO $con
796: *
797: * @see doSave()
798: */
799: protected function doUpdate(PropelPDO $con)
800: {
801: $selectCriteria = $this->buildPkeyCriteria();
802: $valuesCriteria = $this->buildCriteria();
803: BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
804: }
805:
806: /**
807: * Array of ValidationFailed objects.
808: * @var array ValidationFailed[]
809: */
810: protected $validationFailures = array();
811:
812: /**
813: * Gets any ValidationFailed objects that resulted from last call to validate().
814: *
815: *
816: * @return array ValidationFailed[]
817: * @see validate()
818: */
819: public function getValidationFailures()
820: {
821: return $this->validationFailures;
822: }
823:
824: /**
825: * Validates the objects modified field values and all objects related to this table.
826: *
827: * If $columns is either a column name or an array of column names
828: * only those columns are validated.
829: *
830: * @param mixed $columns Column name or an array of column names.
831: * @return boolean Whether all columns pass validation.
832: * @see doValidate()
833: * @see getValidationFailures()
834: */
835: public function validate($columns = null)
836: {
837: $res = $this->doValidate($columns);
838: if ($res === true) {
839: $this->validationFailures = array();
840:
841: return true;
842: }
843:
844: $this->validationFailures = $res;
845:
846: return false;
847: }
848:
849: /**
850: * This function performs the validation work for complex object models.
851: *
852: * In addition to checking the current object, all related objects will
853: * also be validated. If all pass then <code>true</code> is returned; otherwise
854: * an aggreagated array of ValidationFailed objects will be returned.
855: *
856: * @param array $columns Array of column names to validate.
857: * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
858: */
859: protected function doValidate($columns = null)
860: {
861: if (!$this->alreadyInValidation) {
862: $this->alreadyInValidation = true;
863: $retval = null;
864:
865: $failureMap = array();
866:
867:
868: // We call the validate method on the following object(s) if they
869: // were passed to this object by their coresponding set
870: // method. This object relates to these object(s) by a
871: // foreign key reference.
872:
873: if ($this->aAssay !== null) {
874: if (!$this->aAssay->validate($columns)) {
875: $failureMap = array_merge($failureMap, $this->aAssay->getValidationFailures());
876: }
877: }
878:
879: if ($this->aProtocol !== null) {
880: if (!$this->aProtocol->validate($columns)) {
881: $failureMap = array_merge($failureMap, $this->aProtocol->getValidationFailures());
882: }
883: }
884:
885:
886: if (($retval = AcquisitionPeer::doValidate($this, $columns)) !== true) {
887: $failureMap = array_merge($failureMap, $retval);
888: }
889:
890:
891: if ($this->collQuantifications !== null) {
892: foreach ($this->collQuantifications as $referrerFK) {
893: if (!$referrerFK->validate($columns)) {
894: $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
895: }
896: }
897: }
898:
899:
900: $this->alreadyInValidation = false;
901: }
902:
903: return (!empty($failureMap) ? $failureMap : true);
904: }
905:
906: /**
907: * Retrieves a field from the object by name passed in as a string.
908: *
909: * @param string $name name
910: * @param string $type The type of fieldname the $name is of:
911: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
912: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
913: * Defaults to BasePeer::TYPE_PHPNAME
914: * @return mixed Value of field.
915: */
916: public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
917: {
918: $pos = AcquisitionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
919: $field = $this->getByPosition($pos);
920:
921: return $field;
922: }
923:
924: /**
925: * Retrieves a field from the object by Position as specified in the xml schema.
926: * Zero-based.
927: *
928: * @param int $pos position in xml schema
929: * @return mixed Value of field at $pos
930: */
931: public function getByPosition($pos)
932: {
933: switch ($pos) {
934: case 0:
935: return $this->getAcquisitionId();
936: break;
937: case 1:
938: return $this->getAssayId();
939: break;
940: case 2:
941: return $this->getProtocolId();
942: break;
943: case 3:
944: return $this->getChannelId();
945: break;
946: case 4:
947: return $this->getAcquisitiondate();
948: break;
949: case 5:
950: return $this->getName();
951: break;
952: case 6:
953: return $this->getUri();
954: break;
955: default:
956: return null;
957: break;
958: } // switch()
959: }
960:
961: /**
962: * Exports the object as an array.
963: *
964: * You can specify the key type of the array by passing one of the class
965: * type constants.
966: *
967: * @param string $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
968: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
969: * Defaults to BasePeer::TYPE_PHPNAME.
970: * @param boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
971: * @param array $alreadyDumpedObjects List of objects to skip to avoid recursion
972: * @param boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
973: *
974: * @return array an associative array containing the field names (as keys) and field values
975: */
976: public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
977: {
978: if (isset($alreadyDumpedObjects['Acquisition'][$this->getPrimaryKey()])) {
979: return '*RECURSION*';
980: }
981: $alreadyDumpedObjects['Acquisition'][$this->getPrimaryKey()] = true;
982: $keys = AcquisitionPeer::getFieldNames($keyType);
983: $result = array(
984: $keys[0] => $this->getAcquisitionId(),
985: $keys[1] => $this->getAssayId(),
986: $keys[2] => $this->getProtocolId(),
987: $keys[3] => $this->getChannelId(),
988: $keys[4] => $this->getAcquisitiondate(),
989: $keys[5] => $this->getName(),
990: $keys[6] => $this->getUri(),
991: );
992: if ($includeForeignObjects) {
993: if (null !== $this->aAssay) {
994: $result['Assay'] = $this->aAssay->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
995: }
996: if (null !== $this->aProtocol) {
997: $result['Protocol'] = $this->aProtocol->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
998: }
999: if (null !== $this->collQuantifications) {
1000: $result['Quantifications'] = $this->collQuantifications->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1001: }
1002: }
1003:
1004: return $result;
1005: }
1006:
1007: /**
1008: * Sets a field from the object by name passed in as a string.
1009: *
1010: * @param string $name peer name
1011: * @param mixed $value field value
1012: * @param string $type The type of fieldname the $name is of:
1013: * one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1014: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1015: * Defaults to BasePeer::TYPE_PHPNAME
1016: * @return void
1017: */
1018: public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1019: {
1020: $pos = AcquisitionPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1021:
1022: $this->setByPosition($pos, $value);
1023: }
1024:
1025: /**
1026: * Sets a field from the object by Position as specified in the xml schema.
1027: * Zero-based.
1028: *
1029: * @param int $pos position in xml schema
1030: * @param mixed $value field value
1031: * @return void
1032: */
1033: public function setByPosition($pos, $value)
1034: {
1035: switch ($pos) {
1036: case 0:
1037: $this->setAcquisitionId($value);
1038: break;
1039: case 1:
1040: $this->setAssayId($value);
1041: break;
1042: case 2:
1043: $this->setProtocolId($value);
1044: break;
1045: case 3:
1046: $this->setChannelId($value);
1047: break;
1048: case 4:
1049: $this->setAcquisitiondate($value);
1050: break;
1051: case 5:
1052: $this->setName($value);
1053: break;
1054: case 6:
1055: $this->setUri($value);
1056: break;
1057: } // switch()
1058: }
1059:
1060: /**
1061: * Populates the object using an array.
1062: *
1063: * This is particularly useful when populating an object from one of the
1064: * request arrays (e.g. $_POST). This method goes through the column
1065: * names, checking to see whether a matching key exists in populated
1066: * array. If so the setByName() method is called for that column.
1067: *
1068: * You can specify the key type of the array by additionally passing one
1069: * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1070: * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1071: * The default key type is the column's BasePeer::TYPE_PHPNAME
1072: *
1073: * @param array $arr An array to populate the object from.
1074: * @param string $keyType The type of keys the array uses.
1075: * @return void
1076: */
1077: public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1078: {
1079: $keys = AcquisitionPeer::getFieldNames($keyType);
1080:
1081: if (array_key_exists($keys[0], $arr)) $this->setAcquisitionId($arr[$keys[0]]);
1082: if (array_key_exists($keys[1], $arr)) $this->setAssayId($arr[$keys[1]]);
1083: if (array_key_exists($keys[2], $arr)) $this->setProtocolId($arr[$keys[2]]);
1084: if (array_key_exists($keys[3], $arr)) $this->setChannelId($arr[$keys[3]]);
1085: if (array_key_exists($keys[4], $arr)) $this->setAcquisitiondate($arr[$keys[4]]);
1086: if (array_key_exists($keys[5], $arr)) $this->setName($arr[$keys[5]]);
1087: if (array_key_exists($keys[6], $arr)) $this->setUri($arr[$keys[6]]);
1088: }
1089:
1090: /**
1091: * Build a Criteria object containing the values of all modified columns in this object.
1092: *
1093: * @return Criteria The Criteria object containing all modified values.
1094: */
1095: public function buildCriteria()
1096: {
1097: $criteria = new Criteria(AcquisitionPeer::DATABASE_NAME);
1098:
1099: if ($this->isColumnModified(AcquisitionPeer::ACQUISITION_ID)) $criteria->add(AcquisitionPeer::ACQUISITION_ID, $this->acquisition_id);
1100: if ($this->isColumnModified(AcquisitionPeer::ASSAY_ID)) $criteria->add(AcquisitionPeer::ASSAY_ID, $this->assay_id);
1101: if ($this->isColumnModified(AcquisitionPeer::PROTOCOL_ID)) $criteria->add(AcquisitionPeer::PROTOCOL_ID, $this->protocol_id);
1102: if ($this->isColumnModified(AcquisitionPeer::CHANNEL_ID)) $criteria->add(AcquisitionPeer::CHANNEL_ID, $this->channel_id);
1103: if ($this->isColumnModified(AcquisitionPeer::ACQUISITIONDATE)) $criteria->add(AcquisitionPeer::ACQUISITIONDATE, $this->acquisitiondate);
1104: if ($this->isColumnModified(AcquisitionPeer::NAME)) $criteria->add(AcquisitionPeer::NAME, $this->name);
1105: if ($this->isColumnModified(AcquisitionPeer::URI)) $criteria->add(AcquisitionPeer::URI, $this->uri);
1106:
1107: return $criteria;
1108: }
1109:
1110: /**
1111: * Builds a Criteria object containing the primary key for this object.
1112: *
1113: * Unlike buildCriteria() this method includes the primary key values regardless
1114: * of whether or not they have been modified.
1115: *
1116: * @return Criteria The Criteria object containing value(s) for primary key(s).
1117: */
1118: public function buildPkeyCriteria()
1119: {
1120: $criteria = new Criteria(AcquisitionPeer::DATABASE_NAME);
1121: $criteria->add(AcquisitionPeer::ACQUISITION_ID, $this->acquisition_id);
1122:
1123: return $criteria;
1124: }
1125:
1126: /**
1127: * Returns the primary key for this object (row).
1128: * @return int
1129: */
1130: public function getPrimaryKey()
1131: {
1132: return $this->getAcquisitionId();
1133: }
1134:
1135: /**
1136: * Generic method to set the primary key (acquisition_id column).
1137: *
1138: * @param int $key Primary key.
1139: * @return void
1140: */
1141: public function setPrimaryKey($key)
1142: {
1143: $this->setAcquisitionId($key);
1144: }
1145:
1146: /**
1147: * Returns true if the primary key for this object is null.
1148: * @return boolean
1149: */
1150: public function isPrimaryKeyNull()
1151: {
1152:
1153: return null === $this->getAcquisitionId();
1154: }
1155:
1156: /**
1157: * Sets contents of passed object to values from current object.
1158: *
1159: * If desired, this method can also make copies of all associated (fkey referrers)
1160: * objects.
1161: *
1162: * @param object $copyObj An object of Acquisition (or compatible) type.
1163: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1164: * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1165: * @throws PropelException
1166: */
1167: public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1168: {
1169: $copyObj->setAssayId($this->getAssayId());
1170: $copyObj->setProtocolId($this->getProtocolId());
1171: $copyObj->setChannelId($this->getChannelId());
1172: $copyObj->setAcquisitiondate($this->getAcquisitiondate());
1173: $copyObj->setName($this->getName());
1174: $copyObj->setUri($this->getUri());
1175:
1176: if ($deepCopy && !$this->startCopy) {
1177: // important: temporarily setNew(false) because this affects the behavior of
1178: // the getter/setter methods for fkey referrer objects.
1179: $copyObj->setNew(false);
1180: // store object hash to prevent cycle
1181: $this->startCopy = true;
1182:
1183: foreach ($this->getQuantifications() as $relObj) {
1184: if ($relObj !== $this) { // ensure that we don't try to copy a reference to ourselves
1185: $copyObj->addQuantification($relObj->copy($deepCopy));
1186: }
1187: }
1188:
1189: //unflag object copy
1190: $this->startCopy = false;
1191: } // if ($deepCopy)
1192:
1193: if ($makeNew) {
1194: $copyObj->setNew(true);
1195: $copyObj->setAcquisitionId(NULL); // this is a auto-increment column, so set to default value
1196: }
1197: }
1198:
1199: /**
1200: * Makes a copy of this object that will be inserted as a new row in table when saved.
1201: * It creates a new object filling in the simple attributes, but skipping any primary
1202: * keys that are defined for the table.
1203: *
1204: * If desired, this method can also make copies of all associated (fkey referrers)
1205: * objects.
1206: *
1207: * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1208: * @return Acquisition Clone of current object.
1209: * @throws PropelException
1210: */
1211: public function copy($deepCopy = false)
1212: {
1213: // we use get_class(), because this might be a subclass
1214: $clazz = get_class($this);
1215: $copyObj = new $clazz();
1216: $this->copyInto($copyObj, $deepCopy);
1217:
1218: return $copyObj;
1219: }
1220:
1221: /**
1222: * Returns a peer instance associated with this om.
1223: *
1224: * Since Peer classes are not to have any instance attributes, this method returns the
1225: * same instance for all member of this class. The method could therefore
1226: * be static, but this would prevent one from overriding the behavior.
1227: *
1228: * @return AcquisitionPeer
1229: */
1230: public function getPeer()
1231: {
1232: if (self::$peer === null) {
1233: self::$peer = new AcquisitionPeer();
1234: }
1235:
1236: return self::$peer;
1237: }
1238:
1239: /**
1240: * Declares an association between this object and a Assay object.
1241: *
1242: * @param Assay $v
1243: * @return Acquisition The current object (for fluent API support)
1244: * @throws PropelException
1245: */
1246: public function setAssay(Assay $v = null)
1247: {
1248: if ($v === null) {
1249: $this->setAssayId(NULL);
1250: } else {
1251: $this->setAssayId($v->getAssayId());
1252: }
1253:
1254: $this->aAssay = $v;
1255:
1256: // Add binding for other direction of this n:n relationship.
1257: // If this object has already been added to the Assay object, it will not be re-added.
1258: if ($v !== null) {
1259: $v->addAcquisition($this);
1260: }
1261:
1262:
1263: return $this;
1264: }
1265:
1266:
1267: /**
1268: * Get the associated Assay object
1269: *
1270: * @param PropelPDO $con Optional Connection object.
1271: * @param $doQuery Executes a query to get the object if required
1272: * @return Assay The associated Assay object.
1273: * @throws PropelException
1274: */
1275: public function getAssay(PropelPDO $con = null, $doQuery = true)
1276: {
1277: if ($this->aAssay === null && ($this->assay_id !== null) && $doQuery) {
1278: $this->aAssay = AssayQuery::create()->findPk($this->assay_id, $con);
1279: /* The following can be used additionally to
1280: guarantee the related object contains a reference
1281: to this object. This level of coupling may, however, be
1282: undesirable since it could result in an only partially populated collection
1283: in the referenced object.
1284: $this->aAssay->addAcquisitions($this);
1285: */
1286: }
1287:
1288: return $this->aAssay;
1289: }
1290:
1291: /**
1292: * Declares an association between this object and a Protocol object.
1293: *
1294: * @param Protocol $v
1295: * @return Acquisition The current object (for fluent API support)
1296: * @throws PropelException
1297: */
1298: public function setProtocol(Protocol $v = null)
1299: {
1300: if ($v === null) {
1301: $this->setProtocolId(NULL);
1302: } else {
1303: $this->setProtocolId($v->getProtocolId());
1304: }
1305:
1306: $this->aProtocol = $v;
1307:
1308: // Add binding for other direction of this n:n relationship.
1309: // If this object has already been added to the Protocol object, it will not be re-added.
1310: if ($v !== null) {
1311: $v->addAcquisition($this);
1312: }
1313:
1314:
1315: return $this;
1316: }
1317:
1318:
1319: /**
1320: * Get the associated Protocol object
1321: *
1322: * @param PropelPDO $con Optional Connection object.
1323: * @param $doQuery Executes a query to get the object if required
1324: * @return Protocol The associated Protocol object.
1325: * @throws PropelException
1326: */
1327: public function getProtocol(PropelPDO $con = null, $doQuery = true)
1328: {
1329: if ($this->aProtocol === null && ($this->protocol_id !== null) && $doQuery) {
1330: $this->aProtocol = ProtocolQuery::create()->findPk($this->protocol_id, $con);
1331: /* The following can be used additionally to
1332: guarantee the related object contains a reference
1333: to this object. This level of coupling may, however, be
1334: undesirable since it could result in an only partially populated collection
1335: in the referenced object.
1336: $this->aProtocol->addAcquisitions($this);
1337: */
1338: }
1339:
1340: return $this->aProtocol;
1341: }
1342:
1343:
1344: /**
1345: * Initializes a collection based on the name of a relation.
1346: * Avoids crafting an 'init[$relationName]s' method name
1347: * that wouldn't work when StandardEnglishPluralizer is used.
1348: *
1349: * @param string $relationName The name of the relation to initialize
1350: * @return void
1351: */
1352: public function initRelation($relationName)
1353: {
1354: if ('Quantification' == $relationName) {
1355: $this->initQuantifications();
1356: }
1357: }
1358:
1359: /**
1360: * Clears out the collQuantifications collection
1361: *
1362: * This does not modify the database; however, it will remove any associated objects, causing
1363: * them to be refetched by subsequent calls to accessor method.
1364: *
1365: * @return Acquisition The current object (for fluent API support)
1366: * @see addQuantifications()
1367: */
1368: public function clearQuantifications()
1369: {
1370: $this->collQuantifications = null; // important to set this to null since that means it is uninitialized
1371: $this->collQuantificationsPartial = null;
1372:
1373: return $this;
1374: }
1375:
1376: /**
1377: * reset is the collQuantifications collection loaded partially
1378: *
1379: * @return void
1380: */
1381: public function resetPartialQuantifications($v = true)
1382: {
1383: $this->collQuantificationsPartial = $v;
1384: }
1385:
1386: /**
1387: * Initializes the collQuantifications collection.
1388: *
1389: * By default this just sets the collQuantifications collection to an empty array (like clearcollQuantifications());
1390: * however, you may wish to override this method in your stub class to provide setting appropriate
1391: * to your application -- for example, setting the initial array to the values stored in database.
1392: *
1393: * @param boolean $overrideExisting If set to true, the method call initializes
1394: * the collection even if it is not empty
1395: *
1396: * @return void
1397: */
1398: public function initQuantifications($overrideExisting = true)
1399: {
1400: if (null !== $this->collQuantifications && !$overrideExisting) {
1401: return;
1402: }
1403: $this->collQuantifications = new PropelObjectCollection();
1404: $this->collQuantifications->setModel('Quantification');
1405: }
1406:
1407: /**
1408: * Gets an array of Quantification objects which contain a foreign key that references this object.
1409: *
1410: * If the $criteria is not null, it is used to always fetch the results from the database.
1411: * Otherwise the results are fetched from the database the first time, then cached.
1412: * Next time the same method is called without $criteria, the cached collection is returned.
1413: * If this Acquisition is new, it will return
1414: * an empty collection or the current collection; the criteria is ignored on a new object.
1415: *
1416: * @param Criteria $criteria optional Criteria object to narrow the query
1417: * @param PropelPDO $con optional connection object
1418: * @return PropelObjectCollection|Quantification[] List of Quantification objects
1419: * @throws PropelException
1420: */
1421: public function getQuantifications($criteria = null, PropelPDO $con = null)
1422: {
1423: $partial = $this->collQuantificationsPartial && !$this->isNew();
1424: if (null === $this->collQuantifications || null !== $criteria || $partial) {
1425: if ($this->isNew() && null === $this->collQuantifications) {
1426: // return empty collection
1427: $this->initQuantifications();
1428: } else {
1429: $collQuantifications = QuantificationQuery::create(null, $criteria)
1430: ->filterByAcquisition($this)
1431: ->find($con);
1432: if (null !== $criteria) {
1433: if (false !== $this->collQuantificationsPartial && count($collQuantifications)) {
1434: $this->initQuantifications(false);
1435:
1436: foreach($collQuantifications as $obj) {
1437: if (false == $this->collQuantifications->contains($obj)) {
1438: $this->collQuantifications->append($obj);
1439: }
1440: }
1441:
1442: $this->collQuantificationsPartial = true;
1443: }
1444:
1445: $collQuantifications->getInternalIterator()->rewind();
1446: return $collQuantifications;
1447: }
1448:
1449: if($partial && $this->collQuantifications) {
1450: foreach($this->collQuantifications as $obj) {
1451: if($obj->isNew()) {
1452: $collQuantifications[] = $obj;
1453: }
1454: }
1455: }
1456:
1457: $this->collQuantifications = $collQuantifications;
1458: $this->collQuantificationsPartial = false;
1459: }
1460: }
1461:
1462: return $this->collQuantifications;
1463: }
1464:
1465: /**
1466: * Sets a collection of Quantification objects related by a one-to-many relationship
1467: * to the current object.
1468: * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1469: * and new objects from the given Propel collection.
1470: *
1471: * @param PropelCollection $quantifications A Propel collection.
1472: * @param PropelPDO $con Optional connection object
1473: * @return Acquisition The current object (for fluent API support)
1474: */
1475: public function setQuantifications(PropelCollection $quantifications, PropelPDO $con = null)
1476: {
1477: $quantificationsToDelete = $this->getQuantifications(new Criteria(), $con)->diff($quantifications);
1478:
1479: $this->quantificationsScheduledForDeletion = unserialize(serialize($quantificationsToDelete));
1480:
1481: foreach ($quantificationsToDelete as $quantificationRemoved) {
1482: $quantificationRemoved->setAcquisition(null);
1483: }
1484:
1485: $this->collQuantifications = null;
1486: foreach ($quantifications as $quantification) {
1487: $this->addQuantification($quantification);
1488: }
1489:
1490: $this->collQuantifications = $quantifications;
1491: $this->collQuantificationsPartial = false;
1492:
1493: return $this;
1494: }
1495:
1496: /**
1497: * Returns the number of related Quantification objects.
1498: *
1499: * @param Criteria $criteria
1500: * @param boolean $distinct
1501: * @param PropelPDO $con
1502: * @return int Count of related Quantification objects.
1503: * @throws PropelException
1504: */
1505: public function countQuantifications(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1506: {
1507: $partial = $this->collQuantificationsPartial && !$this->isNew();
1508: if (null === $this->collQuantifications || null !== $criteria || $partial) {
1509: if ($this->isNew() && null === $this->collQuantifications) {
1510: return 0;
1511: }
1512:
1513: if($partial && !$criteria) {
1514: return count($this->getQuantifications());
1515: }
1516: $query = QuantificationQuery::create(null, $criteria);
1517: if ($distinct) {
1518: $query->distinct();
1519: }
1520:
1521: return $query
1522: ->filterByAcquisition($this)
1523: ->count($con);
1524: }
1525:
1526: return count($this->collQuantifications);
1527: }
1528:
1529: /**
1530: * Method called to associate a Quantification object to this object
1531: * through the Quantification foreign key attribute.
1532: *
1533: * @param Quantification $l Quantification
1534: * @return Acquisition The current object (for fluent API support)
1535: */
1536: public function addQuantification(Quantification $l)
1537: {
1538: if ($this->collQuantifications === null) {
1539: $this->initQuantifications();
1540: $this->collQuantificationsPartial = true;
1541: }
1542: if (!in_array($l, $this->collQuantifications->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1543: $this->doAddQuantification($l);
1544: }
1545:
1546: return $this;
1547: }
1548:
1549: /**
1550: * @param Quantification $quantification The quantification object to add.
1551: */
1552: protected function doAddQuantification($quantification)
1553: {
1554: $this->collQuantifications[]= $quantification;
1555: $quantification->setAcquisition($this);
1556: }
1557:
1558: /**
1559: * @param Quantification $quantification The quantification object to remove.
1560: * @return Acquisition The current object (for fluent API support)
1561: */
1562: public function removeQuantification($quantification)
1563: {
1564: if ($this->getQuantifications()->contains($quantification)) {
1565: $this->collQuantifications->remove($this->collQuantifications->search($quantification));
1566: if (null === $this->quantificationsScheduledForDeletion) {
1567: $this->quantificationsScheduledForDeletion = clone $this->collQuantifications;
1568: $this->quantificationsScheduledForDeletion->clear();
1569: }
1570: $this->quantificationsScheduledForDeletion[]= clone $quantification;
1571: $quantification->setAcquisition(null);
1572: }
1573:
1574: return $this;
1575: }
1576:
1577:
1578: /**
1579: * If this collection has already been initialized with
1580: * an identical criteria, it returns the collection.
1581: * Otherwise if this Acquisition is new, it will return
1582: * an empty collection; or if this Acquisition has previously
1583: * been saved, it will retrieve related Quantifications from storage.
1584: *
1585: * This method is protected by default in order to keep the public
1586: * api reasonable. You can provide public methods for those you
1587: * actually need in Acquisition.
1588: *
1589: * @param Criteria $criteria optional Criteria object to narrow the query
1590: * @param PropelPDO $con optional connection object
1591: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1592: * @return PropelObjectCollection|Quantification[] List of Quantification objects
1593: */
1594: public function getQuantificationsJoinAnalysis($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1595: {
1596: $query = QuantificationQuery::create(null, $criteria);
1597: $query->joinWith('Analysis', $join_behavior);
1598:
1599: return $this->getQuantifications($query, $con);
1600: }
1601:
1602:
1603: /**
1604: * If this collection has already been initialized with
1605: * an identical criteria, it returns the collection.
1606: * Otherwise if this Acquisition is new, it will return
1607: * an empty collection; or if this Acquisition has previously
1608: * been saved, it will retrieve related Quantifications from storage.
1609: *
1610: * This method is protected by default in order to keep the public
1611: * api reasonable. You can provide public methods for those you
1612: * actually need in Acquisition.
1613: *
1614: * @param Criteria $criteria optional Criteria object to narrow the query
1615: * @param PropelPDO $con optional connection object
1616: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1617: * @return PropelObjectCollection|Quantification[] List of Quantification objects
1618: */
1619: public function getQuantificationsJoinContact($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1620: {
1621: $query = QuantificationQuery::create(null, $criteria);
1622: $query->joinWith('Contact', $join_behavior);
1623:
1624: return $this->getQuantifications($query, $con);
1625: }
1626:
1627:
1628: /**
1629: * If this collection has already been initialized with
1630: * an identical criteria, it returns the collection.
1631: * Otherwise if this Acquisition is new, it will return
1632: * an empty collection; or if this Acquisition has previously
1633: * been saved, it will retrieve related Quantifications from storage.
1634: *
1635: * This method is protected by default in order to keep the public
1636: * api reasonable. You can provide public methods for those you
1637: * actually need in Acquisition.
1638: *
1639: * @param Criteria $criteria optional Criteria object to narrow the query
1640: * @param PropelPDO $con optional connection object
1641: * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1642: * @return PropelObjectCollection|Quantification[] List of Quantification objects
1643: */
1644: public function getQuantificationsJoinProtocol($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1645: {
1646: $query = QuantificationQuery::create(null, $criteria);
1647: $query->joinWith('Protocol', $join_behavior);
1648:
1649: return $this->getQuantifications($query, $con);
1650: }
1651:
1652: /**
1653: * Clears the current object and sets all attributes to their default values
1654: */
1655: public function clear()
1656: {
1657: $this->acquisition_id = null;
1658: $this->assay_id = null;
1659: $this->protocol_id = null;
1660: $this->channel_id = null;
1661: $this->acquisitiondate = null;
1662: $this->name = null;
1663: $this->uri = null;
1664: $this->alreadyInSave = false;
1665: $this->alreadyInValidation = false;
1666: $this->alreadyInClearAllReferencesDeep = false;
1667: $this->clearAllReferences();
1668: $this->applyDefaultValues();
1669: $this->resetModified();
1670: $this->setNew(true);
1671: $this->setDeleted(false);
1672: }
1673:
1674: /**
1675: * Resets all references to other model objects or collections of model objects.
1676: *
1677: * This method is a user-space workaround for PHP's inability to garbage collect
1678: * objects with circular references (even in PHP 5.3). This is currently necessary
1679: * when using Propel in certain daemon or large-volumne/high-memory operations.
1680: *
1681: * @param boolean $deep Whether to also clear the references on all referrer objects.
1682: */
1683: public function clearAllReferences($deep = false)
1684: {
1685: if ($deep && !$this->alreadyInClearAllReferencesDeep) {
1686: $this->alreadyInClearAllReferencesDeep = true;
1687: if ($this->collQuantifications) {
1688: foreach ($this->collQuantifications as $o) {
1689: $o->clearAllReferences($deep);
1690: }
1691: }
1692: if ($this->aAssay instanceof Persistent) {
1693: $this->aAssay->clearAllReferences($deep);
1694: }
1695: if ($this->aProtocol instanceof Persistent) {
1696: $this->aProtocol->clearAllReferences($deep);
1697: }
1698:
1699: $this->alreadyInClearAllReferencesDeep = false;
1700: } // if ($deep)
1701:
1702: if ($this->collQuantifications instanceof PropelCollection) {
1703: $this->collQuantifications->clearIterator();
1704: }
1705: $this->collQuantifications = null;
1706: $this->aAssay = null;
1707: $this->aProtocol = null;
1708: }
1709:
1710: /**
1711: * return the string representation of this object
1712: *
1713: * @return string
1714: */
1715: public function __toString()
1716: {
1717: return (string) $this->exportTo(AcquisitionPeer::DEFAULT_STRING_FORMAT);
1718: }
1719:
1720: /**
1721: * return true is the object is in saving state
1722: *
1723: * @return boolean
1724: */
1725: public function isAlreadyInSave()
1726: {
1727: return $this->alreadyInSave;
1728: }
1729:
1730: }
1731: