Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

  • BaseAcquisition
  • BaseAcquisitionPeer
  • BaseAcquisitionQuery
  • BaseAnalysis
  • BaseAnalysisPeer
  • BaseAnalysisQuery
  • BaseAssay
  • BaseAssayBiomaterial
  • BaseAssayBiomaterialPeer
  • BaseAssayBiomaterialQuery
  • BaseAssayPeer
  • BaseAssayQuery
  • BaseBiomaterial
  • BaseBiomaterialPeer
  • BaseBiomaterialprop
  • BaseBiomaterialpropPeer
  • BaseBiomaterialpropQuery
  • BaseBiomaterialQuery
  • BaseBiomaterialRelationship
  • BaseBiomaterialRelationshipPeer
  • BaseBiomaterialRelationshipQuery
  • BaseContact
  • BaseContactPeer
  • BaseContactQuery
  • BaseCv
  • BaseCvPeer
  • BaseCvQuery
  • BaseCvterm
  • BaseCvtermPeer
  • BaseCvtermQuery
  • BaseDb
  • BaseDbPeer
  • BaseDbQuery
  • BaseDbxref
  • BaseDbxrefPeer
  • BaseDbxrefQuery
  • BaseFeature
  • BaseFeatureCvterm
  • BaseFeatureCvtermDbxref
  • BaseFeatureCvtermDbxrefPeer
  • BaseFeatureCvtermDbxrefQuery
  • BaseFeatureCvtermPeer
  • BaseFeatureCvtermprop
  • BaseFeatureCvtermpropPeer
  • BaseFeatureCvtermpropQuery
  • BaseFeatureCvtermPub
  • BaseFeatureCvtermPubPeer
  • BaseFeatureCvtermPubQuery
  • BaseFeatureCvtermQuery
  • BaseFeatureDbxref
  • BaseFeatureDbxrefPeer
  • BaseFeatureDbxrefQuery
  • BaseFeaturePeer
  • BaseFeaturePub
  • BaseFeaturePubPeer
  • BaseFeaturePubQuery
  • BaseFeatureQuery
  • BaseFeatureSynonym
  • BaseFeatureSynonymPeer
  • BaseFeatureSynonymQuery
  • BaseOrganism
  • BaseOrganismPeer
  • BaseOrganismQuery
  • BaseProtocol
  • BaseProtocolPeer
  • BaseProtocolQuery
  • BasePub
  • BasePubauthor
  • BasePubauthorPeer
  • BasePubauthorQuery
  • BasePubDbxref
  • BasePubDbxrefPeer
  • BasePubDbxrefQuery
  • BasePubPeer
  • BasePubprop
  • BasePubpropPeer
  • BasePubpropQuery
  • BasePubQuery
  • BasePubRelationship
  • BasePubRelationshipPeer
  • BasePubRelationshipQuery
  • BaseQuantification
  • BaseQuantificationPeer
  • BaseQuantificationQuery
  • BaseSynonym
  • BaseSynonymPeer
  • BaseSynonymQuery
  • Overview
  • Namespace
  • Class
  • Tree
   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\AcquisitionQuery;
  20: use cli_db\propel\Assay;
  21: use cli_db\propel\AssayBiomaterial;
  22: use cli_db\propel\AssayBiomaterialQuery;
  23: use cli_db\propel\AssayPeer;
  24: use cli_db\propel\AssayQuery;
  25: use cli_db\propel\Contact;
  26: use cli_db\propel\ContactQuery;
  27: use cli_db\propel\Protocol;
  28: use cli_db\propel\ProtocolQuery;
  29: 
  30: /**
  31:  * Base class that represents a row from the 'assay' table.
  32:  *
  33:  *
  34:  *
  35:  * @package    propel.generator.cli_db.om
  36:  */
  37: abstract class BaseAssay extends BaseObject implements Persistent
  38: {
  39:     /**
  40:      * Peer class name
  41:      */
  42:     const PEER = 'cli_db\\propel\\AssayPeer';
  43: 
  44:     /**
  45:      * The Peer class.
  46:      * Instance provides a convenient way of calling static methods on a class
  47:      * that calling code may not be able to identify.
  48:      * @var        AssayPeer
  49:      */
  50:     protected static $peer;
  51: 
  52:     /**
  53:      * The flag var to prevent infinit loop in deep copy
  54:      * @var       boolean
  55:      */
  56:     protected $startCopy = false;
  57: 
  58:     /**
  59:      * The value for the assay_id field.
  60:      * @var        int
  61:      */
  62:     protected $assay_id;
  63: 
  64:     /**
  65:      * The value for the arraydesign_id field.
  66:      * @var        int
  67:      */
  68:     protected $arraydesign_id;
  69: 
  70:     /**
  71:      * The value for the protocol_id field.
  72:      * @var        int
  73:      */
  74:     protected $protocol_id;
  75: 
  76:     /**
  77:      * The value for the assaydate field.
  78:      * Note: this column has a database default value of: (expression) now()
  79:      * @var        string
  80:      */
  81:     protected $assaydate;
  82: 
  83:     /**
  84:      * The value for the arrayidentifier field.
  85:      * @var        string
  86:      */
  87:     protected $arrayidentifier;
  88: 
  89:     /**
  90:      * The value for the arraybatchidentifier field.
  91:      * @var        string
  92:      */
  93:     protected $arraybatchidentifier;
  94: 
  95:     /**
  96:      * The value for the operator_id field.
  97:      * @var        int
  98:      */
  99:     protected $operator_id;
 100: 
 101:     /**
 102:      * The value for the dbxref_id field.
 103:      * @var        int
 104:      */
 105:     protected $dbxref_id;
 106: 
 107:     /**
 108:      * The value for the name field.
 109:      * @var        string
 110:      */
 111:     protected $name;
 112: 
 113:     /**
 114:      * The value for the description field.
 115:      * @var        string
 116:      */
 117:     protected $description;
 118: 
 119:     /**
 120:      * @var        Contact
 121:      */
 122:     protected $aContact;
 123: 
 124:     /**
 125:      * @var        Protocol
 126:      */
 127:     protected $aProtocol;
 128: 
 129:     /**
 130:      * @var        PropelObjectCollection|Acquisition[] Collection to store aggregation of Acquisition objects.
 131:      */
 132:     protected $collAcquisitions;
 133:     protected $collAcquisitionsPartial;
 134: 
 135:     /**
 136:      * @var        PropelObjectCollection|AssayBiomaterial[] Collection to store aggregation of AssayBiomaterial objects.
 137:      */
 138:     protected $collAssayBiomaterials;
 139:     protected $collAssayBiomaterialsPartial;
 140: 
 141:     /**
 142:      * Flag to prevent endless save loop, if this object is referenced
 143:      * by another object which falls in this transaction.
 144:      * @var        boolean
 145:      */
 146:     protected $alreadyInSave = false;
 147: 
 148:     /**
 149:      * Flag to prevent endless validation loop, if this object is referenced
 150:      * by another object which falls in this transaction.
 151:      * @var        boolean
 152:      */
 153:     protected $alreadyInValidation = false;
 154: 
 155:     /**
 156:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 157:      * @var        boolean
 158:      */
 159:     protected $alreadyInClearAllReferencesDeep = false;
 160: 
 161:     /**
 162:      * An array of objects scheduled for deletion.
 163:      * @var     PropelObjectCollection
 164:      */
 165:     protected $acquisitionsScheduledForDeletion = null;
 166: 
 167:     /**
 168:      * An array of objects scheduled for deletion.
 169:      * @var     PropelObjectCollection
 170:      */
 171:     protected $assayBiomaterialsScheduledForDeletion = null;
 172: 
 173:     /**
 174:      * Applies default values to this object.
 175:      * This method should be called from the object's constructor (or
 176:      * equivalent initialization method).
 177:      * @see        __construct()
 178:      */
 179:     public function applyDefaultValues()
 180:     {
 181:     }
 182: 
 183:     /**
 184:      * Initializes internal state of BaseAssay object.
 185:      * @see        applyDefaults()
 186:      */
 187:     public function __construct()
 188:     {
 189:         parent::__construct();
 190:         $this->applyDefaultValues();
 191:     }
 192: 
 193:     /**
 194:      * Get the [assay_id] column value.
 195:      *
 196:      * @return int
 197:      */
 198:     public function getAssayId()
 199:     {
 200:         return $this->assay_id;
 201:     }
 202: 
 203:     /**
 204:      * Get the [arraydesign_id] column value.
 205:      *
 206:      * @return int
 207:      */
 208:     public function getArraydesignId()
 209:     {
 210:         return $this->arraydesign_id;
 211:     }
 212: 
 213:     /**
 214:      * Get the [protocol_id] column value.
 215:      *
 216:      * @return int
 217:      */
 218:     public function getProtocolId()
 219:     {
 220:         return $this->protocol_id;
 221:     }
 222: 
 223:     /**
 224:      * Get the [optionally formatted] temporal [assaydate] column value.
 225:      *
 226:      *
 227:      * @param string $format The date/time format string (either date()-style or strftime()-style).
 228:      *               If format is null, then the raw DateTime object will be returned.
 229:      * @return mixed Formatted date/time value as string or DateTime object (if format is null), null if column is null
 230:      * @throws PropelException - if unable to parse/validate the date/time value.
 231:      */
 232:     public function getAssaydate($format = 'Y-m-d H:i:s')
 233:     {
 234:         if ($this->assaydate === null) {
 235:             return null;
 236:         }
 237: 
 238: 
 239:         try {
 240:             $dt = new DateTime($this->assaydate);
 241:         } catch (Exception $x) {
 242:             throw new PropelException("Internally stored date/time/timestamp value could not be converted to DateTime: " . var_export($this->assaydate, true), $x);
 243:         }
 244: 
 245:         if ($format === null) {
 246:             // Because propel.useDateTimeClass is true, we return a DateTime object.
 247:             return $dt;
 248:         }
 249: 
 250:         if (strpos($format, '%') !== false) {
 251:             return strftime($format, $dt->format('U'));
 252:         }
 253: 
 254:         return $dt->format($format);
 255: 
 256:     }
 257: 
 258:     /**
 259:      * Get the [arrayidentifier] column value.
 260:      *
 261:      * @return string
 262:      */
 263:     public function getArrayidentifier()
 264:     {
 265:         return $this->arrayidentifier;
 266:     }
 267: 
 268:     /**
 269:      * Get the [arraybatchidentifier] column value.
 270:      *
 271:      * @return string
 272:      */
 273:     public function getArraybatchidentifier()
 274:     {
 275:         return $this->arraybatchidentifier;
 276:     }
 277: 
 278:     /**
 279:      * Get the [operator_id] column value.
 280:      *
 281:      * @return int
 282:      */
 283:     public function getOperatorId()
 284:     {
 285:         return $this->operator_id;
 286:     }
 287: 
 288:     /**
 289:      * Get the [dbxref_id] column value.
 290:      *
 291:      * @return int
 292:      */
 293:     public function getDbxrefId()
 294:     {
 295:         return $this->dbxref_id;
 296:     }
 297: 
 298:     /**
 299:      * Get the [name] column value.
 300:      *
 301:      * @return string
 302:      */
 303:     public function getName()
 304:     {
 305:         return $this->name;
 306:     }
 307: 
 308:     /**
 309:      * Get the [description] column value.
 310:      *
 311:      * @return string
 312:      */
 313:     public function getDescription()
 314:     {
 315:         return $this->description;
 316:     }
 317: 
 318:     /**
 319:      * Set the value of [assay_id] column.
 320:      *
 321:      * @param int $v new value
 322:      * @return Assay The current object (for fluent API support)
 323:      */
 324:     public function setAssayId($v)
 325:     {
 326:         if ($v !== null && is_numeric($v)) {
 327:             $v = (int) $v;
 328:         }
 329: 
 330:         if ($this->assay_id !== $v) {
 331:             $this->assay_id = $v;
 332:             $this->modifiedColumns[] = AssayPeer::ASSAY_ID;
 333:         }
 334: 
 335: 
 336:         return $this;
 337:     } // setAssayId()
 338: 
 339:     /**
 340:      * Set the value of [arraydesign_id] column.
 341:      *
 342:      * @param int $v new value
 343:      * @return Assay The current object (for fluent API support)
 344:      */
 345:     public function setArraydesignId($v)
 346:     {
 347:         if ($v !== null && is_numeric($v)) {
 348:             $v = (int) $v;
 349:         }
 350: 
 351:         if ($this->arraydesign_id !== $v) {
 352:             $this->arraydesign_id = $v;
 353:             $this->modifiedColumns[] = AssayPeer::ARRAYDESIGN_ID;
 354:         }
 355: 
 356: 
 357:         return $this;
 358:     } // setArraydesignId()
 359: 
 360:     /**
 361:      * Set the value of [protocol_id] column.
 362:      *
 363:      * @param int $v new value
 364:      * @return Assay The current object (for fluent API support)
 365:      */
 366:     public function setProtocolId($v)
 367:     {
 368:         if ($v !== null && is_numeric($v)) {
 369:             $v = (int) $v;
 370:         }
 371: 
 372:         if ($this->protocol_id !== $v) {
 373:             $this->protocol_id = $v;
 374:             $this->modifiedColumns[] = AssayPeer::PROTOCOL_ID;
 375:         }
 376: 
 377:         if ($this->aProtocol !== null && $this->aProtocol->getProtocolId() !== $v) {
 378:             $this->aProtocol = null;
 379:         }
 380: 
 381: 
 382:         return $this;
 383:     } // setProtocolId()
 384: 
 385:     /**
 386:      * Sets the value of [assaydate] column to a normalized version of the date/time value specified.
 387:      *
 388:      * @param mixed $v string, integer (timestamp), or DateTime value.
 389:      *               Empty strings are treated as null.
 390:      * @return Assay The current object (for fluent API support)
 391:      */
 392:     public function setAssaydate($v)
 393:     {
 394:         $dt = PropelDateTime::newInstance($v, null, 'DateTime');
 395:         if ($this->assaydate !== null || $dt !== null) {
 396:             $currentDateAsString = ($this->assaydate !== null && $tmpDt = new DateTime($this->assaydate)) ? $tmpDt->format('Y-m-d H:i:s') : null;
 397:             $newDateAsString = $dt ? $dt->format('Y-m-d H:i:s') : null;
 398:             if ($currentDateAsString !== $newDateAsString) {
 399:                 $this->assaydate = $newDateAsString;
 400:                 $this->modifiedColumns[] = AssayPeer::ASSAYDATE;
 401:             }
 402:         } // if either are not null
 403: 
 404: 
 405:         return $this;
 406:     } // setAssaydate()
 407: 
 408:     /**
 409:      * Set the value of [arrayidentifier] column.
 410:      *
 411:      * @param string $v new value
 412:      * @return Assay The current object (for fluent API support)
 413:      */
 414:     public function setArrayidentifier($v)
 415:     {
 416:         if ($v !== null && is_numeric($v)) {
 417:             $v = (string) $v;
 418:         }
 419: 
 420:         if ($this->arrayidentifier !== $v) {
 421:             $this->arrayidentifier = $v;
 422:             $this->modifiedColumns[] = AssayPeer::ARRAYIDENTIFIER;
 423:         }
 424: 
 425: 
 426:         return $this;
 427:     } // setArrayidentifier()
 428: 
 429:     /**
 430:      * Set the value of [arraybatchidentifier] column.
 431:      *
 432:      * @param string $v new value
 433:      * @return Assay The current object (for fluent API support)
 434:      */
 435:     public function setArraybatchidentifier($v)
 436:     {
 437:         if ($v !== null && is_numeric($v)) {
 438:             $v = (string) $v;
 439:         }
 440: 
 441:         if ($this->arraybatchidentifier !== $v) {
 442:             $this->arraybatchidentifier = $v;
 443:             $this->modifiedColumns[] = AssayPeer::ARRAYBATCHIDENTIFIER;
 444:         }
 445: 
 446: 
 447:         return $this;
 448:     } // setArraybatchidentifier()
 449: 
 450:     /**
 451:      * Set the value of [operator_id] column.
 452:      *
 453:      * @param int $v new value
 454:      * @return Assay The current object (for fluent API support)
 455:      */
 456:     public function setOperatorId($v)
 457:     {
 458:         if ($v !== null && is_numeric($v)) {
 459:             $v = (int) $v;
 460:         }
 461: 
 462:         if ($this->operator_id !== $v) {
 463:             $this->operator_id = $v;
 464:             $this->modifiedColumns[] = AssayPeer::OPERATOR_ID;
 465:         }
 466: 
 467:         if ($this->aContact !== null && $this->aContact->getContactId() !== $v) {
 468:             $this->aContact = null;
 469:         }
 470: 
 471: 
 472:         return $this;
 473:     } // setOperatorId()
 474: 
 475:     /**
 476:      * Set the value of [dbxref_id] column.
 477:      *
 478:      * @param int $v new value
 479:      * @return Assay The current object (for fluent API support)
 480:      */
 481:     public function setDbxrefId($v)
 482:     {
 483:         if ($v !== null && is_numeric($v)) {
 484:             $v = (int) $v;
 485:         }
 486: 
 487:         if ($this->dbxref_id !== $v) {
 488:             $this->dbxref_id = $v;
 489:             $this->modifiedColumns[] = AssayPeer::DBXREF_ID;
 490:         }
 491: 
 492: 
 493:         return $this;
 494:     } // setDbxrefId()
 495: 
 496:     /**
 497:      * Set the value of [name] column.
 498:      *
 499:      * @param string $v new value
 500:      * @return Assay The current object (for fluent API support)
 501:      */
 502:     public function setName($v)
 503:     {
 504:         if ($v !== null && is_numeric($v)) {
 505:             $v = (string) $v;
 506:         }
 507: 
 508:         if ($this->name !== $v) {
 509:             $this->name = $v;
 510:             $this->modifiedColumns[] = AssayPeer::NAME;
 511:         }
 512: 
 513: 
 514:         return $this;
 515:     } // setName()
 516: 
 517:     /**
 518:      * Set the value of [description] column.
 519:      *
 520:      * @param string $v new value
 521:      * @return Assay The current object (for fluent API support)
 522:      */
 523:     public function setDescription($v)
 524:     {
 525:         if ($v !== null && is_numeric($v)) {
 526:             $v = (string) $v;
 527:         }
 528: 
 529:         if ($this->description !== $v) {
 530:             $this->description = $v;
 531:             $this->modifiedColumns[] = AssayPeer::DESCRIPTION;
 532:         }
 533: 
 534: 
 535:         return $this;
 536:     } // setDescription()
 537: 
 538:     /**
 539:      * Indicates whether the columns in this object are only set to default values.
 540:      *
 541:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 542:      * modified _and_ has some values set which are non-default.
 543:      *
 544:      * @return boolean Whether the columns in this object are only been set with default values.
 545:      */
 546:     public function hasOnlyDefaultValues()
 547:     {
 548:         // otherwise, everything was equal, so return true
 549:         return true;
 550:     } // hasOnlyDefaultValues()
 551: 
 552:     /**
 553:      * Hydrates (populates) the object variables with values from the database resultset.
 554:      *
 555:      * An offset (0-based "start column") is specified so that objects can be hydrated
 556:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 557:      * for results of JOIN queries where the resultset row includes columns from two or
 558:      * more tables.
 559:      *
 560:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 561:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 562:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 563:      * @return int             next starting column
 564:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 565:      */
 566:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 567:     {
 568:         try {
 569: 
 570:             $this->assay_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 571:             $this->arraydesign_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
 572:             $this->protocol_id = ($row[$startcol + 2] !== null) ? (int) $row[$startcol + 2] : null;
 573:             $this->assaydate = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
 574:             $this->arrayidentifier = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
 575:             $this->arraybatchidentifier = ($row[$startcol + 5] !== null) ? (string) $row[$startcol + 5] : null;
 576:             $this->operator_id = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
 577:             $this->dbxref_id = ($row[$startcol + 7] !== null) ? (int) $row[$startcol + 7] : null;
 578:             $this->name = ($row[$startcol + 8] !== null) ? (string) $row[$startcol + 8] : null;
 579:             $this->description = ($row[$startcol + 9] !== null) ? (string) $row[$startcol + 9] : null;
 580:             $this->resetModified();
 581: 
 582:             $this->setNew(false);
 583: 
 584:             if ($rehydrate) {
 585:                 $this->ensureConsistency();
 586:             }
 587:             $this->postHydrate($row, $startcol, $rehydrate);
 588:             return $startcol + 10; // 10 = AssayPeer::NUM_HYDRATE_COLUMNS.
 589: 
 590:         } catch (Exception $e) {
 591:             throw new PropelException("Error populating Assay object", $e);
 592:         }
 593:     }
 594: 
 595:     /**
 596:      * Checks and repairs the internal consistency of the object.
 597:      *
 598:      * This method is executed after an already-instantiated object is re-hydrated
 599:      * from the database.  It exists to check any foreign keys to make sure that
 600:      * the objects related to the current object are correct based on foreign key.
 601:      *
 602:      * You can override this method in the stub class, but you should always invoke
 603:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 604:      * in case your model changes.
 605:      *
 606:      * @throws PropelException
 607:      */
 608:     public function ensureConsistency()
 609:     {
 610: 
 611:         if ($this->aProtocol !== null && $this->protocol_id !== $this->aProtocol->getProtocolId()) {
 612:             $this->aProtocol = null;
 613:         }
 614:         if ($this->aContact !== null && $this->operator_id !== $this->aContact->getContactId()) {
 615:             $this->aContact = null;
 616:         }
 617:     } // ensureConsistency
 618: 
 619:     /**
 620:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 621:      *
 622:      * This will only work if the object has been saved and has a valid primary key set.
 623:      *
 624:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 625:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 626:      * @return void
 627:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 628:      */
 629:     public function reload($deep = false, PropelPDO $con = null)
 630:     {
 631:         if ($this->isDeleted()) {
 632:             throw new PropelException("Cannot reload a deleted object.");
 633:         }
 634: 
 635:         if ($this->isNew()) {
 636:             throw new PropelException("Cannot reload an unsaved object.");
 637:         }
 638: 
 639:         if ($con === null) {
 640:             $con = Propel::getConnection(AssayPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 641:         }
 642: 
 643:         // We don't need to alter the object instance pool; we're just modifying this instance
 644:         // already in the pool.
 645: 
 646:         $stmt = AssayPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 647:         $row = $stmt->fetch(PDO::FETCH_NUM);
 648:         $stmt->closeCursor();
 649:         if (!$row) {
 650:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 651:         }
 652:         $this->hydrate($row, 0, true); // rehydrate
 653: 
 654:         if ($deep) {  // also de-associate any related objects?
 655: 
 656:             $this->aContact = null;
 657:             $this->aProtocol = null;
 658:             $this->collAcquisitions = null;
 659: 
 660:             $this->collAssayBiomaterials = null;
 661: 
 662:         } // if (deep)
 663:     }
 664: 
 665:     /**
 666:      * Removes this object from datastore and sets delete attribute.
 667:      *
 668:      * @param PropelPDO $con
 669:      * @return void
 670:      * @throws PropelException
 671:      * @throws Exception
 672:      * @see        BaseObject::setDeleted()
 673:      * @see        BaseObject::isDeleted()
 674:      */
 675:     public function delete(PropelPDO $con = null)
 676:     {
 677:         if ($this->isDeleted()) {
 678:             throw new PropelException("This object has already been deleted.");
 679:         }
 680: 
 681:         if ($con === null) {
 682:             $con = Propel::getConnection(AssayPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 683:         }
 684: 
 685:         $con->beginTransaction();
 686:         try {
 687:             $deleteQuery = AssayQuery::create()
 688:                 ->filterByPrimaryKey($this->getPrimaryKey());
 689:             $ret = $this->preDelete($con);
 690:             if ($ret) {
 691:                 $deleteQuery->delete($con);
 692:                 $this->postDelete($con);
 693:                 $con->commit();
 694:                 $this->setDeleted(true);
 695:             } else {
 696:                 $con->commit();
 697:             }
 698:         } catch (Exception $e) {
 699:             $con->rollBack();
 700:             throw $e;
 701:         }
 702:     }
 703: 
 704:     /**
 705:      * Persists this object to the database.
 706:      *
 707:      * If the object is new, it inserts it; otherwise an update is performed.
 708:      * All modified related objects will also be persisted in the doSave()
 709:      * method.  This method wraps all precipitate database operations in a
 710:      * single transaction.
 711:      *
 712:      * @param PropelPDO $con
 713:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 714:      * @throws PropelException
 715:      * @throws Exception
 716:      * @see        doSave()
 717:      */
 718:     public function save(PropelPDO $con = null)
 719:     {
 720:         if ($this->isDeleted()) {
 721:             throw new PropelException("You cannot save an object that has been deleted.");
 722:         }
 723: 
 724:         if ($con === null) {
 725:             $con = Propel::getConnection(AssayPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 726:         }
 727: 
 728:         $con->beginTransaction();
 729:         $isInsert = $this->isNew();
 730:         try {
 731:             $ret = $this->preSave($con);
 732:             if ($isInsert) {
 733:                 $ret = $ret && $this->preInsert($con);
 734:             } else {
 735:                 $ret = $ret && $this->preUpdate($con);
 736:             }
 737:             if ($ret) {
 738:                 $affectedRows = $this->doSave($con);
 739:                 if ($isInsert) {
 740:                     $this->postInsert($con);
 741:                 } else {
 742:                     $this->postUpdate($con);
 743:                 }
 744:                 $this->postSave($con);
 745:                 AssayPeer::addInstanceToPool($this);
 746:             } else {
 747:                 $affectedRows = 0;
 748:             }
 749:             $con->commit();
 750: 
 751:             return $affectedRows;
 752:         } catch (Exception $e) {
 753:             $con->rollBack();
 754:             throw $e;
 755:         }
 756:     }
 757: 
 758:     /**
 759:      * Performs the work of inserting or updating the row in the database.
 760:      *
 761:      * If the object is new, it inserts it; otherwise an update is performed.
 762:      * All related objects are also updated in this method.
 763:      *
 764:      * @param PropelPDO $con
 765:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 766:      * @throws PropelException
 767:      * @see        save()
 768:      */
 769:     protected function doSave(PropelPDO $con)
 770:     {
 771:         $affectedRows = 0; // initialize var to track total num of affected rows
 772:         if (!$this->alreadyInSave) {
 773:             $this->alreadyInSave = true;
 774: 
 775:             // We call the save method on the following object(s) if they
 776:             // were passed to this object by their coresponding set
 777:             // method.  This object relates to these object(s) by a
 778:             // foreign key reference.
 779: 
 780:             if ($this->aContact !== null) {
 781:                 if ($this->aContact->isModified() || $this->aContact->isNew()) {
 782:                     $affectedRows += $this->aContact->save($con);
 783:                 }
 784:                 $this->setContact($this->aContact);
 785:             }
 786: 
 787:             if ($this->aProtocol !== null) {
 788:                 if ($this->aProtocol->isModified() || $this->aProtocol->isNew()) {
 789:                     $affectedRows += $this->aProtocol->save($con);
 790:                 }
 791:                 $this->setProtocol($this->aProtocol);
 792:             }
 793: 
 794:             if ($this->isNew() || $this->isModified()) {
 795:                 // persist changes
 796:                 if ($this->isNew()) {
 797:                     $this->doInsert($con);
 798:                 } else {
 799:                     $this->doUpdate($con);
 800:                 }
 801:                 $affectedRows += 1;
 802:                 $this->resetModified();
 803:             }
 804: 
 805:             if ($this->acquisitionsScheduledForDeletion !== null) {
 806:                 if (!$this->acquisitionsScheduledForDeletion->isEmpty()) {
 807:                     AcquisitionQuery::create()
 808:                         ->filterByPrimaryKeys($this->acquisitionsScheduledForDeletion->getPrimaryKeys(false))
 809:                         ->delete($con);
 810:                     $this->acquisitionsScheduledForDeletion = null;
 811:                 }
 812:             }
 813: 
 814:             if ($this->collAcquisitions !== null) {
 815:                 foreach ($this->collAcquisitions as $referrerFK) {
 816:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 817:                         $affectedRows += $referrerFK->save($con);
 818:                     }
 819:                 }
 820:             }
 821: 
 822:             if ($this->assayBiomaterialsScheduledForDeletion !== null) {
 823:                 if (!$this->assayBiomaterialsScheduledForDeletion->isEmpty()) {
 824:                     AssayBiomaterialQuery::create()
 825:                         ->filterByPrimaryKeys($this->assayBiomaterialsScheduledForDeletion->getPrimaryKeys(false))
 826:                         ->delete($con);
 827:                     $this->assayBiomaterialsScheduledForDeletion = null;
 828:                 }
 829:             }
 830: 
 831:             if ($this->collAssayBiomaterials !== null) {
 832:                 foreach ($this->collAssayBiomaterials as $referrerFK) {
 833:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 834:                         $affectedRows += $referrerFK->save($con);
 835:                     }
 836:                 }
 837:             }
 838: 
 839:             $this->alreadyInSave = false;
 840: 
 841:         }
 842: 
 843:         return $affectedRows;
 844:     } // doSave()
 845: 
 846:     /**
 847:      * Insert the row in the database.
 848:      *
 849:      * @param PropelPDO $con
 850:      *
 851:      * @throws PropelException
 852:      * @see        doSave()
 853:      */
 854:     protected function doInsert(PropelPDO $con)
 855:     {
 856:         $modifiedColumns = array();
 857:         $index = 0;
 858: 
 859:         $this->modifiedColumns[] = AssayPeer::ASSAY_ID;
 860:         if (null !== $this->assay_id) {
 861:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . AssayPeer::ASSAY_ID . ')');
 862:         }
 863:         if (null === $this->assay_id) {
 864:             try {
 865:                 $stmt = $con->query("SELECT nextval('assay_assay_id_seq')");
 866:                 $row = $stmt->fetch(PDO::FETCH_NUM);
 867:                 $this->assay_id = $row[0];
 868:             } catch (Exception $e) {
 869:                 throw new PropelException('Unable to get sequence id.', $e);
 870:             }
 871:         }
 872: 
 873: 
 874:          // check the columns in natural order for more readable SQL queries
 875:         if ($this->isColumnModified(AssayPeer::ASSAY_ID)) {
 876:             $modifiedColumns[':p' . $index++]  = '"assay_id"';
 877:         }
 878:         if ($this->isColumnModified(AssayPeer::ARRAYDESIGN_ID)) {
 879:             $modifiedColumns[':p' . $index++]  = '"arraydesign_id"';
 880:         }
 881:         if ($this->isColumnModified(AssayPeer::PROTOCOL_ID)) {
 882:             $modifiedColumns[':p' . $index++]  = '"protocol_id"';
 883:         }
 884:         if ($this->isColumnModified(AssayPeer::ASSAYDATE)) {
 885:             $modifiedColumns[':p' . $index++]  = '"assaydate"';
 886:         }
 887:         if ($this->isColumnModified(AssayPeer::ARRAYIDENTIFIER)) {
 888:             $modifiedColumns[':p' . $index++]  = '"arrayidentifier"';
 889:         }
 890:         if ($this->isColumnModified(AssayPeer::ARRAYBATCHIDENTIFIER)) {
 891:             $modifiedColumns[':p' . $index++]  = '"arraybatchidentifier"';
 892:         }
 893:         if ($this->isColumnModified(AssayPeer::OPERATOR_ID)) {
 894:             $modifiedColumns[':p' . $index++]  = '"operator_id"';
 895:         }
 896:         if ($this->isColumnModified(AssayPeer::DBXREF_ID)) {
 897:             $modifiedColumns[':p' . $index++]  = '"dbxref_id"';
 898:         }
 899:         if ($this->isColumnModified(AssayPeer::NAME)) {
 900:             $modifiedColumns[':p' . $index++]  = '"name"';
 901:         }
 902:         if ($this->isColumnModified(AssayPeer::DESCRIPTION)) {
 903:             $modifiedColumns[':p' . $index++]  = '"description"';
 904:         }
 905: 
 906:         $sql = sprintf(
 907:             'INSERT INTO "assay" (%s) VALUES (%s)',
 908:             implode(', ', $modifiedColumns),
 909:             implode(', ', array_keys($modifiedColumns))
 910:         );
 911: 
 912:         try {
 913:             $stmt = $con->prepare($sql);
 914:             foreach ($modifiedColumns as $identifier => $columnName) {
 915:                 switch ($columnName) {
 916:                     case '"assay_id"':
 917:                         $stmt->bindValue($identifier, $this->assay_id, PDO::PARAM_INT);
 918:                         break;
 919:                     case '"arraydesign_id"':
 920:                         $stmt->bindValue($identifier, $this->arraydesign_id, PDO::PARAM_INT);
 921:                         break;
 922:                     case '"protocol_id"':
 923:                         $stmt->bindValue($identifier, $this->protocol_id, PDO::PARAM_INT);
 924:                         break;
 925:                     case '"assaydate"':
 926:                         $stmt->bindValue($identifier, $this->assaydate, PDO::PARAM_STR);
 927:                         break;
 928:                     case '"arrayidentifier"':
 929:                         $stmt->bindValue($identifier, $this->arrayidentifier, PDO::PARAM_STR);
 930:                         break;
 931:                     case '"arraybatchidentifier"':
 932:                         $stmt->bindValue($identifier, $this->arraybatchidentifier, PDO::PARAM_STR);
 933:                         break;
 934:                     case '"operator_id"':
 935:                         $stmt->bindValue($identifier, $this->operator_id, PDO::PARAM_INT);
 936:                         break;
 937:                     case '"dbxref_id"':
 938:                         $stmt->bindValue($identifier, $this->dbxref_id, PDO::PARAM_INT);
 939:                         break;
 940:                     case '"name"':
 941:                         $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
 942:                         break;
 943:                     case '"description"':
 944:                         $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
 945:                         break;
 946:                 }
 947:             }
 948:             $stmt->execute();
 949:         } catch (Exception $e) {
 950:             Propel::log($e->getMessage(), Propel::LOG_ERR);
 951:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
 952:         }
 953: 
 954:         $this->setNew(false);
 955:     }
 956: 
 957:     /**
 958:      * Update the row in the database.
 959:      *
 960:      * @param PropelPDO $con
 961:      *
 962:      * @see        doSave()
 963:      */
 964:     protected function doUpdate(PropelPDO $con)
 965:     {
 966:         $selectCriteria = $this->buildPkeyCriteria();
 967:         $valuesCriteria = $this->buildCriteria();
 968:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
 969:     }
 970: 
 971:     /**
 972:      * Array of ValidationFailed objects.
 973:      * @var        array ValidationFailed[]
 974:      */
 975:     protected $validationFailures = array();
 976: 
 977:     /**
 978:      * Gets any ValidationFailed objects that resulted from last call to validate().
 979:      *
 980:      *
 981:      * @return array ValidationFailed[]
 982:      * @see        validate()
 983:      */
 984:     public function getValidationFailures()
 985:     {
 986:         return $this->validationFailures;
 987:     }
 988: 
 989:     /**
 990:      * Validates the objects modified field values and all objects related to this table.
 991:      *
 992:      * If $columns is either a column name or an array of column names
 993:      * only those columns are validated.
 994:      *
 995:      * @param mixed $columns Column name or an array of column names.
 996:      * @return boolean Whether all columns pass validation.
 997:      * @see        doValidate()
 998:      * @see        getValidationFailures()
 999:      */
1000:     public function validate($columns = null)
1001:     {
1002:         $res = $this->doValidate($columns);
1003:         if ($res === true) {
1004:             $this->validationFailures = array();
1005: 
1006:             return true;
1007:         }
1008: 
1009:         $this->validationFailures = $res;
1010: 
1011:         return false;
1012:     }
1013: 
1014:     /**
1015:      * This function performs the validation work for complex object models.
1016:      *
1017:      * In addition to checking the current object, all related objects will
1018:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
1019:      * an aggreagated array of ValidationFailed objects will be returned.
1020:      *
1021:      * @param array $columns Array of column names to validate.
1022:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
1023:      */
1024:     protected function doValidate($columns = null)
1025:     {
1026:         if (!$this->alreadyInValidation) {
1027:             $this->alreadyInValidation = true;
1028:             $retval = null;
1029: 
1030:             $failureMap = array();
1031: 
1032: 
1033:             // We call the validate method on the following object(s) if they
1034:             // were passed to this object by their coresponding set
1035:             // method.  This object relates to these object(s) by a
1036:             // foreign key reference.
1037: 
1038:             if ($this->aContact !== null) {
1039:                 if (!$this->aContact->validate($columns)) {
1040:                     $failureMap = array_merge($failureMap, $this->aContact->getValidationFailures());
1041:                 }
1042:             }
1043: 
1044:             if ($this->aProtocol !== null) {
1045:                 if (!$this->aProtocol->validate($columns)) {
1046:                     $failureMap = array_merge($failureMap, $this->aProtocol->getValidationFailures());
1047:                 }
1048:             }
1049: 
1050: 
1051:             if (($retval = AssayPeer::doValidate($this, $columns)) !== true) {
1052:                 $failureMap = array_merge($failureMap, $retval);
1053:             }
1054: 
1055: 
1056:                 if ($this->collAcquisitions !== null) {
1057:                     foreach ($this->collAcquisitions as $referrerFK) {
1058:                         if (!$referrerFK->validate($columns)) {
1059:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1060:                         }
1061:                     }
1062:                 }
1063: 
1064:                 if ($this->collAssayBiomaterials !== null) {
1065:                     foreach ($this->collAssayBiomaterials as $referrerFK) {
1066:                         if (!$referrerFK->validate($columns)) {
1067:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1068:                         }
1069:                     }
1070:                 }
1071: 
1072: 
1073:             $this->alreadyInValidation = false;
1074:         }
1075: 
1076:         return (!empty($failureMap) ? $failureMap : true);
1077:     }
1078: 
1079:     /**
1080:      * Retrieves a field from the object by name passed in as a string.
1081:      *
1082:      * @param string $name name
1083:      * @param string $type The type of fieldname the $name is of:
1084:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1085:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1086:      *               Defaults to BasePeer::TYPE_PHPNAME
1087:      * @return mixed Value of field.
1088:      */
1089:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1090:     {
1091:         $pos = AssayPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1092:         $field = $this->getByPosition($pos);
1093: 
1094:         return $field;
1095:     }
1096: 
1097:     /**
1098:      * Retrieves a field from the object by Position as specified in the xml schema.
1099:      * Zero-based.
1100:      *
1101:      * @param int $pos position in xml schema
1102:      * @return mixed Value of field at $pos
1103:      */
1104:     public function getByPosition($pos)
1105:     {
1106:         switch ($pos) {
1107:             case 0:
1108:                 return $this->getAssayId();
1109:                 break;
1110:             case 1:
1111:                 return $this->getArraydesignId();
1112:                 break;
1113:             case 2:
1114:                 return $this->getProtocolId();
1115:                 break;
1116:             case 3:
1117:                 return $this->getAssaydate();
1118:                 break;
1119:             case 4:
1120:                 return $this->getArrayidentifier();
1121:                 break;
1122:             case 5:
1123:                 return $this->getArraybatchidentifier();
1124:                 break;
1125:             case 6:
1126:                 return $this->getOperatorId();
1127:                 break;
1128:             case 7:
1129:                 return $this->getDbxrefId();
1130:                 break;
1131:             case 8:
1132:                 return $this->getName();
1133:                 break;
1134:             case 9:
1135:                 return $this->getDescription();
1136:                 break;
1137:             default:
1138:                 return null;
1139:                 break;
1140:         } // switch()
1141:     }
1142: 
1143:     /**
1144:      * Exports the object as an array.
1145:      *
1146:      * You can specify the key type of the array by passing one of the class
1147:      * type constants.
1148:      *
1149:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1150:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1151:      *                    Defaults to BasePeer::TYPE_PHPNAME.
1152:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
1153:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1154:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1155:      *
1156:      * @return array an associative array containing the field names (as keys) and field values
1157:      */
1158:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1159:     {
1160:         if (isset($alreadyDumpedObjects['Assay'][$this->getPrimaryKey()])) {
1161:             return '*RECURSION*';
1162:         }
1163:         $alreadyDumpedObjects['Assay'][$this->getPrimaryKey()] = true;
1164:         $keys = AssayPeer::getFieldNames($keyType);
1165:         $result = array(
1166:             $keys[0] => $this->getAssayId(),
1167:             $keys[1] => $this->getArraydesignId(),
1168:             $keys[2] => $this->getProtocolId(),
1169:             $keys[3] => $this->getAssaydate(),
1170:             $keys[4] => $this->getArrayidentifier(),
1171:             $keys[5] => $this->getArraybatchidentifier(),
1172:             $keys[6] => $this->getOperatorId(),
1173:             $keys[7] => $this->getDbxrefId(),
1174:             $keys[8] => $this->getName(),
1175:             $keys[9] => $this->getDescription(),
1176:         );
1177:         if ($includeForeignObjects) {
1178:             if (null !== $this->aContact) {
1179:                 $result['Contact'] = $this->aContact->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1180:             }
1181:             if (null !== $this->aProtocol) {
1182:                 $result['Protocol'] = $this->aProtocol->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1183:             }
1184:             if (null !== $this->collAcquisitions) {
1185:                 $result['Acquisitions'] = $this->collAcquisitions->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1186:             }
1187:             if (null !== $this->collAssayBiomaterials) {
1188:                 $result['AssayBiomaterials'] = $this->collAssayBiomaterials->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1189:             }
1190:         }
1191: 
1192:         return $result;
1193:     }
1194: 
1195:     /**
1196:      * Sets a field from the object by name passed in as a string.
1197:      *
1198:      * @param string $name peer name
1199:      * @param mixed $value field value
1200:      * @param string $type The type of fieldname the $name is of:
1201:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1202:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1203:      *                     Defaults to BasePeer::TYPE_PHPNAME
1204:      * @return void
1205:      */
1206:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1207:     {
1208:         $pos = AssayPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1209: 
1210:         $this->setByPosition($pos, $value);
1211:     }
1212: 
1213:     /**
1214:      * Sets a field from the object by Position as specified in the xml schema.
1215:      * Zero-based.
1216:      *
1217:      * @param int $pos position in xml schema
1218:      * @param mixed $value field value
1219:      * @return void
1220:      */
1221:     public function setByPosition($pos, $value)
1222:     {
1223:         switch ($pos) {
1224:             case 0:
1225:                 $this->setAssayId($value);
1226:                 break;
1227:             case 1:
1228:                 $this->setArraydesignId($value);
1229:                 break;
1230:             case 2:
1231:                 $this->setProtocolId($value);
1232:                 break;
1233:             case 3:
1234:                 $this->setAssaydate($value);
1235:                 break;
1236:             case 4:
1237:                 $this->setArrayidentifier($value);
1238:                 break;
1239:             case 5:
1240:                 $this->setArraybatchidentifier($value);
1241:                 break;
1242:             case 6:
1243:                 $this->setOperatorId($value);
1244:                 break;
1245:             case 7:
1246:                 $this->setDbxrefId($value);
1247:                 break;
1248:             case 8:
1249:                 $this->setName($value);
1250:                 break;
1251:             case 9:
1252:                 $this->setDescription($value);
1253:                 break;
1254:         } // switch()
1255:     }
1256: 
1257:     /**
1258:      * Populates the object using an array.
1259:      *
1260:      * This is particularly useful when populating an object from one of the
1261:      * request arrays (e.g. $_POST).  This method goes through the column
1262:      * names, checking to see whether a matching key exists in populated
1263:      * array. If so the setByName() method is called for that column.
1264:      *
1265:      * You can specify the key type of the array by additionally passing one
1266:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1267:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1268:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1269:      *
1270:      * @param array  $arr     An array to populate the object from.
1271:      * @param string $keyType The type of keys the array uses.
1272:      * @return void
1273:      */
1274:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1275:     {
1276:         $keys = AssayPeer::getFieldNames($keyType);
1277: 
1278:         if (array_key_exists($keys[0], $arr)) $this->setAssayId($arr[$keys[0]]);
1279:         if (array_key_exists($keys[1], $arr)) $this->setArraydesignId($arr[$keys[1]]);
1280:         if (array_key_exists($keys[2], $arr)) $this->setProtocolId($arr[$keys[2]]);
1281:         if (array_key_exists($keys[3], $arr)) $this->setAssaydate($arr[$keys[3]]);
1282:         if (array_key_exists($keys[4], $arr)) $this->setArrayidentifier($arr[$keys[4]]);
1283:         if (array_key_exists($keys[5], $arr)) $this->setArraybatchidentifier($arr[$keys[5]]);
1284:         if (array_key_exists($keys[6], $arr)) $this->setOperatorId($arr[$keys[6]]);
1285:         if (array_key_exists($keys[7], $arr)) $this->setDbxrefId($arr[$keys[7]]);
1286:         if (array_key_exists($keys[8], $arr)) $this->setName($arr[$keys[8]]);
1287:         if (array_key_exists($keys[9], $arr)) $this->setDescription($arr[$keys[9]]);
1288:     }
1289: 
1290:     /**
1291:      * Build a Criteria object containing the values of all modified columns in this object.
1292:      *
1293:      * @return Criteria The Criteria object containing all modified values.
1294:      */
1295:     public function buildCriteria()
1296:     {
1297:         $criteria = new Criteria(AssayPeer::DATABASE_NAME);
1298: 
1299:         if ($this->isColumnModified(AssayPeer::ASSAY_ID)) $criteria->add(AssayPeer::ASSAY_ID, $this->assay_id);
1300:         if ($this->isColumnModified(AssayPeer::ARRAYDESIGN_ID)) $criteria->add(AssayPeer::ARRAYDESIGN_ID, $this->arraydesign_id);
1301:         if ($this->isColumnModified(AssayPeer::PROTOCOL_ID)) $criteria->add(AssayPeer::PROTOCOL_ID, $this->protocol_id);
1302:         if ($this->isColumnModified(AssayPeer::ASSAYDATE)) $criteria->add(AssayPeer::ASSAYDATE, $this->assaydate);
1303:         if ($this->isColumnModified(AssayPeer::ARRAYIDENTIFIER)) $criteria->add(AssayPeer::ARRAYIDENTIFIER, $this->arrayidentifier);
1304:         if ($this->isColumnModified(AssayPeer::ARRAYBATCHIDENTIFIER)) $criteria->add(AssayPeer::ARRAYBATCHIDENTIFIER, $this->arraybatchidentifier);
1305:         if ($this->isColumnModified(AssayPeer::OPERATOR_ID)) $criteria->add(AssayPeer::OPERATOR_ID, $this->operator_id);
1306:         if ($this->isColumnModified(AssayPeer::DBXREF_ID)) $criteria->add(AssayPeer::DBXREF_ID, $this->dbxref_id);
1307:         if ($this->isColumnModified(AssayPeer::NAME)) $criteria->add(AssayPeer::NAME, $this->name);
1308:         if ($this->isColumnModified(AssayPeer::DESCRIPTION)) $criteria->add(AssayPeer::DESCRIPTION, $this->description);
1309: 
1310:         return $criteria;
1311:     }
1312: 
1313:     /**
1314:      * Builds a Criteria object containing the primary key for this object.
1315:      *
1316:      * Unlike buildCriteria() this method includes the primary key values regardless
1317:      * of whether or not they have been modified.
1318:      *
1319:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1320:      */
1321:     public function buildPkeyCriteria()
1322:     {
1323:         $criteria = new Criteria(AssayPeer::DATABASE_NAME);
1324:         $criteria->add(AssayPeer::ASSAY_ID, $this->assay_id);
1325: 
1326:         return $criteria;
1327:     }
1328: 
1329:     /**
1330:      * Returns the primary key for this object (row).
1331:      * @return int
1332:      */
1333:     public function getPrimaryKey()
1334:     {
1335:         return $this->getAssayId();
1336:     }
1337: 
1338:     /**
1339:      * Generic method to set the primary key (assay_id column).
1340:      *
1341:      * @param  int $key Primary key.
1342:      * @return void
1343:      */
1344:     public function setPrimaryKey($key)
1345:     {
1346:         $this->setAssayId($key);
1347:     }
1348: 
1349:     /**
1350:      * Returns true if the primary key for this object is null.
1351:      * @return boolean
1352:      */
1353:     public function isPrimaryKeyNull()
1354:     {
1355: 
1356:         return null === $this->getAssayId();
1357:     }
1358: 
1359:     /**
1360:      * Sets contents of passed object to values from current object.
1361:      *
1362:      * If desired, this method can also make copies of all associated (fkey referrers)
1363:      * objects.
1364:      *
1365:      * @param object $copyObj An object of Assay (or compatible) type.
1366:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1367:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1368:      * @throws PropelException
1369:      */
1370:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1371:     {
1372:         $copyObj->setArraydesignId($this->getArraydesignId());
1373:         $copyObj->setProtocolId($this->getProtocolId());
1374:         $copyObj->setAssaydate($this->getAssaydate());
1375:         $copyObj->setArrayidentifier($this->getArrayidentifier());
1376:         $copyObj->setArraybatchidentifier($this->getArraybatchidentifier());
1377:         $copyObj->setOperatorId($this->getOperatorId());
1378:         $copyObj->setDbxrefId($this->getDbxrefId());
1379:         $copyObj->setName($this->getName());
1380:         $copyObj->setDescription($this->getDescription());
1381: 
1382:         if ($deepCopy && !$this->startCopy) {
1383:             // important: temporarily setNew(false) because this affects the behavior of
1384:             // the getter/setter methods for fkey referrer objects.
1385:             $copyObj->setNew(false);
1386:             // store object hash to prevent cycle
1387:             $this->startCopy = true;
1388: 
1389:             foreach ($this->getAcquisitions() as $relObj) {
1390:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1391:                     $copyObj->addAcquisition($relObj->copy($deepCopy));
1392:                 }
1393:             }
1394: 
1395:             foreach ($this->getAssayBiomaterials() as $relObj) {
1396:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1397:                     $copyObj->addAssayBiomaterial($relObj->copy($deepCopy));
1398:                 }
1399:             }
1400: 
1401:             //unflag object copy
1402:             $this->startCopy = false;
1403:         } // if ($deepCopy)
1404: 
1405:         if ($makeNew) {
1406:             $copyObj->setNew(true);
1407:             $copyObj->setAssayId(NULL); // this is a auto-increment column, so set to default value
1408:         }
1409:     }
1410: 
1411:     /**
1412:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1413:      * It creates a new object filling in the simple attributes, but skipping any primary
1414:      * keys that are defined for the table.
1415:      *
1416:      * If desired, this method can also make copies of all associated (fkey referrers)
1417:      * objects.
1418:      *
1419:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1420:      * @return Assay Clone of current object.
1421:      * @throws PropelException
1422:      */
1423:     public function copy($deepCopy = false)
1424:     {
1425:         // we use get_class(), because this might be a subclass
1426:         $clazz = get_class($this);
1427:         $copyObj = new $clazz();
1428:         $this->copyInto($copyObj, $deepCopy);
1429: 
1430:         return $copyObj;
1431:     }
1432: 
1433:     /**
1434:      * Returns a peer instance associated with this om.
1435:      *
1436:      * Since Peer classes are not to have any instance attributes, this method returns the
1437:      * same instance for all member of this class. The method could therefore
1438:      * be static, but this would prevent one from overriding the behavior.
1439:      *
1440:      * @return AssayPeer
1441:      */
1442:     public function getPeer()
1443:     {
1444:         if (self::$peer === null) {
1445:             self::$peer = new AssayPeer();
1446:         }
1447: 
1448:         return self::$peer;
1449:     }
1450: 
1451:     /**
1452:      * Declares an association between this object and a Contact object.
1453:      *
1454:      * @param             Contact $v
1455:      * @return Assay The current object (for fluent API support)
1456:      * @throws PropelException
1457:      */
1458:     public function setContact(Contact $v = null)
1459:     {
1460:         if ($v === null) {
1461:             $this->setOperatorId(NULL);
1462:         } else {
1463:             $this->setOperatorId($v->getContactId());
1464:         }
1465: 
1466:         $this->aContact = $v;
1467: 
1468:         // Add binding for other direction of this n:n relationship.
1469:         // If this object has already been added to the Contact object, it will not be re-added.
1470:         if ($v !== null) {
1471:             $v->addAssay($this);
1472:         }
1473: 
1474: 
1475:         return $this;
1476:     }
1477: 
1478: 
1479:     /**
1480:      * Get the associated Contact object
1481:      *
1482:      * @param PropelPDO $con Optional Connection object.
1483:      * @param $doQuery Executes a query to get the object if required
1484:      * @return Contact The associated Contact object.
1485:      * @throws PropelException
1486:      */
1487:     public function getContact(PropelPDO $con = null, $doQuery = true)
1488:     {
1489:         if ($this->aContact === null && ($this->operator_id !== null) && $doQuery) {
1490:             $this->aContact = ContactQuery::create()->findPk($this->operator_id, $con);
1491:             /* The following can be used additionally to
1492:                 guarantee the related object contains a reference
1493:                 to this object.  This level of coupling may, however, be
1494:                 undesirable since it could result in an only partially populated collection
1495:                 in the referenced object.
1496:                 $this->aContact->addAssays($this);
1497:              */
1498:         }
1499: 
1500:         return $this->aContact;
1501:     }
1502: 
1503:     /**
1504:      * Declares an association between this object and a Protocol object.
1505:      *
1506:      * @param             Protocol $v
1507:      * @return Assay The current object (for fluent API support)
1508:      * @throws PropelException
1509:      */
1510:     public function setProtocol(Protocol $v = null)
1511:     {
1512:         if ($v === null) {
1513:             $this->setProtocolId(NULL);
1514:         } else {
1515:             $this->setProtocolId($v->getProtocolId());
1516:         }
1517: 
1518:         $this->aProtocol = $v;
1519: 
1520:         // Add binding for other direction of this n:n relationship.
1521:         // If this object has already been added to the Protocol object, it will not be re-added.
1522:         if ($v !== null) {
1523:             $v->addAssay($this);
1524:         }
1525: 
1526: 
1527:         return $this;
1528:     }
1529: 
1530: 
1531:     /**
1532:      * Get the associated Protocol object
1533:      *
1534:      * @param PropelPDO $con Optional Connection object.
1535:      * @param $doQuery Executes a query to get the object if required
1536:      * @return Protocol The associated Protocol object.
1537:      * @throws PropelException
1538:      */
1539:     public function getProtocol(PropelPDO $con = null, $doQuery = true)
1540:     {
1541:         if ($this->aProtocol === null && ($this->protocol_id !== null) && $doQuery) {
1542:             $this->aProtocol = ProtocolQuery::create()->findPk($this->protocol_id, $con);
1543:             /* The following can be used additionally to
1544:                 guarantee the related object contains a reference
1545:                 to this object.  This level of coupling may, however, be
1546:                 undesirable since it could result in an only partially populated collection
1547:                 in the referenced object.
1548:                 $this->aProtocol->addAssays($this);
1549:              */
1550:         }
1551: 
1552:         return $this->aProtocol;
1553:     }
1554: 
1555: 
1556:     /**
1557:      * Initializes a collection based on the name of a relation.
1558:      * Avoids crafting an 'init[$relationName]s' method name
1559:      * that wouldn't work when StandardEnglishPluralizer is used.
1560:      *
1561:      * @param string $relationName The name of the relation to initialize
1562:      * @return void
1563:      */
1564:     public function initRelation($relationName)
1565:     {
1566:         if ('Acquisition' == $relationName) {
1567:             $this->initAcquisitions();
1568:         }
1569:         if ('AssayBiomaterial' == $relationName) {
1570:             $this->initAssayBiomaterials();
1571:         }
1572:     }
1573: 
1574:     /**
1575:      * Clears out the collAcquisitions collection
1576:      *
1577:      * This does not modify the database; however, it will remove any associated objects, causing
1578:      * them to be refetched by subsequent calls to accessor method.
1579:      *
1580:      * @return Assay The current object (for fluent API support)
1581:      * @see        addAcquisitions()
1582:      */
1583:     public function clearAcquisitions()
1584:     {
1585:         $this->collAcquisitions = null; // important to set this to null since that means it is uninitialized
1586:         $this->collAcquisitionsPartial = null;
1587: 
1588:         return $this;
1589:     }
1590: 
1591:     /**
1592:      * reset is the collAcquisitions collection loaded partially
1593:      *
1594:      * @return void
1595:      */
1596:     public function resetPartialAcquisitions($v = true)
1597:     {
1598:         $this->collAcquisitionsPartial = $v;
1599:     }
1600: 
1601:     /**
1602:      * Initializes the collAcquisitions collection.
1603:      *
1604:      * By default this just sets the collAcquisitions collection to an empty array (like clearcollAcquisitions());
1605:      * however, you may wish to override this method in your stub class to provide setting appropriate
1606:      * to your application -- for example, setting the initial array to the values stored in database.
1607:      *
1608:      * @param boolean $overrideExisting If set to true, the method call initializes
1609:      *                                        the collection even if it is not empty
1610:      *
1611:      * @return void
1612:      */
1613:     public function initAcquisitions($overrideExisting = true)
1614:     {
1615:         if (null !== $this->collAcquisitions && !$overrideExisting) {
1616:             return;
1617:         }
1618:         $this->collAcquisitions = new PropelObjectCollection();
1619:         $this->collAcquisitions->setModel('Acquisition');
1620:     }
1621: 
1622:     /**
1623:      * Gets an array of Acquisition objects which contain a foreign key that references this object.
1624:      *
1625:      * If the $criteria is not null, it is used to always fetch the results from the database.
1626:      * Otherwise the results are fetched from the database the first time, then cached.
1627:      * Next time the same method is called without $criteria, the cached collection is returned.
1628:      * If this Assay is new, it will return
1629:      * an empty collection or the current collection; the criteria is ignored on a new object.
1630:      *
1631:      * @param Criteria $criteria optional Criteria object to narrow the query
1632:      * @param PropelPDO $con optional connection object
1633:      * @return PropelObjectCollection|Acquisition[] List of Acquisition objects
1634:      * @throws PropelException
1635:      */
1636:     public function getAcquisitions($criteria = null, PropelPDO $con = null)
1637:     {
1638:         $partial = $this->collAcquisitionsPartial && !$this->isNew();
1639:         if (null === $this->collAcquisitions || null !== $criteria  || $partial) {
1640:             if ($this->isNew() && null === $this->collAcquisitions) {
1641:                 // return empty collection
1642:                 $this->initAcquisitions();
1643:             } else {
1644:                 $collAcquisitions = AcquisitionQuery::create(null, $criteria)
1645:                     ->filterByAssay($this)
1646:                     ->find($con);
1647:                 if (null !== $criteria) {
1648:                     if (false !== $this->collAcquisitionsPartial && count($collAcquisitions)) {
1649:                       $this->initAcquisitions(false);
1650: 
1651:                       foreach($collAcquisitions as $obj) {
1652:                         if (false == $this->collAcquisitions->contains($obj)) {
1653:                           $this->collAcquisitions->append($obj);
1654:                         }
1655:                       }
1656: 
1657:                       $this->collAcquisitionsPartial = true;
1658:                     }
1659: 
1660:                     $collAcquisitions->getInternalIterator()->rewind();
1661:                     return $collAcquisitions;
1662:                 }
1663: 
1664:                 if($partial && $this->collAcquisitions) {
1665:                     foreach($this->collAcquisitions as $obj) {
1666:                         if($obj->isNew()) {
1667:                             $collAcquisitions[] = $obj;
1668:                         }
1669:                     }
1670:                 }
1671: 
1672:                 $this->collAcquisitions = $collAcquisitions;
1673:                 $this->collAcquisitionsPartial = false;
1674:             }
1675:         }
1676: 
1677:         return $this->collAcquisitions;
1678:     }
1679: 
1680:     /**
1681:      * Sets a collection of Acquisition objects related by a one-to-many relationship
1682:      * to the current object.
1683:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1684:      * and new objects from the given Propel collection.
1685:      *
1686:      * @param PropelCollection $acquisitions A Propel collection.
1687:      * @param PropelPDO $con Optional connection object
1688:      * @return Assay The current object (for fluent API support)
1689:      */
1690:     public function setAcquisitions(PropelCollection $acquisitions, PropelPDO $con = null)
1691:     {
1692:         $acquisitionsToDelete = $this->getAcquisitions(new Criteria(), $con)->diff($acquisitions);
1693: 
1694:         $this->acquisitionsScheduledForDeletion = unserialize(serialize($acquisitionsToDelete));
1695: 
1696:         foreach ($acquisitionsToDelete as $acquisitionRemoved) {
1697:             $acquisitionRemoved->setAssay(null);
1698:         }
1699: 
1700:         $this->collAcquisitions = null;
1701:         foreach ($acquisitions as $acquisition) {
1702:             $this->addAcquisition($acquisition);
1703:         }
1704: 
1705:         $this->collAcquisitions = $acquisitions;
1706:         $this->collAcquisitionsPartial = false;
1707: 
1708:         return $this;
1709:     }
1710: 
1711:     /**
1712:      * Returns the number of related Acquisition objects.
1713:      *
1714:      * @param Criteria $criteria
1715:      * @param boolean $distinct
1716:      * @param PropelPDO $con
1717:      * @return int             Count of related Acquisition objects.
1718:      * @throws PropelException
1719:      */
1720:     public function countAcquisitions(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1721:     {
1722:         $partial = $this->collAcquisitionsPartial && !$this->isNew();
1723:         if (null === $this->collAcquisitions || null !== $criteria || $partial) {
1724:             if ($this->isNew() && null === $this->collAcquisitions) {
1725:                 return 0;
1726:             }
1727: 
1728:             if($partial && !$criteria) {
1729:                 return count($this->getAcquisitions());
1730:             }
1731:             $query = AcquisitionQuery::create(null, $criteria);
1732:             if ($distinct) {
1733:                 $query->distinct();
1734:             }
1735: 
1736:             return $query
1737:                 ->filterByAssay($this)
1738:                 ->count($con);
1739:         }
1740: 
1741:         return count($this->collAcquisitions);
1742:     }
1743: 
1744:     /**
1745:      * Method called to associate a Acquisition object to this object
1746:      * through the Acquisition foreign key attribute.
1747:      *
1748:      * @param    Acquisition $l Acquisition
1749:      * @return Assay The current object (for fluent API support)
1750:      */
1751:     public function addAcquisition(Acquisition $l)
1752:     {
1753:         if ($this->collAcquisitions === null) {
1754:             $this->initAcquisitions();
1755:             $this->collAcquisitionsPartial = true;
1756:         }
1757:         if (!in_array($l, $this->collAcquisitions->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1758:             $this->doAddAcquisition($l);
1759:         }
1760: 
1761:         return $this;
1762:     }
1763: 
1764:     /**
1765:      * @param   Acquisition $acquisition The acquisition object to add.
1766:      */
1767:     protected function doAddAcquisition($acquisition)
1768:     {
1769:         $this->collAcquisitions[]= $acquisition;
1770:         $acquisition->setAssay($this);
1771:     }
1772: 
1773:     /**
1774:      * @param   Acquisition $acquisition The acquisition object to remove.
1775:      * @return Assay The current object (for fluent API support)
1776:      */
1777:     public function removeAcquisition($acquisition)
1778:     {
1779:         if ($this->getAcquisitions()->contains($acquisition)) {
1780:             $this->collAcquisitions->remove($this->collAcquisitions->search($acquisition));
1781:             if (null === $this->acquisitionsScheduledForDeletion) {
1782:                 $this->acquisitionsScheduledForDeletion = clone $this->collAcquisitions;
1783:                 $this->acquisitionsScheduledForDeletion->clear();
1784:             }
1785:             $this->acquisitionsScheduledForDeletion[]= clone $acquisition;
1786:             $acquisition->setAssay(null);
1787:         }
1788: 
1789:         return $this;
1790:     }
1791: 
1792: 
1793:     /**
1794:      * If this collection has already been initialized with
1795:      * an identical criteria, it returns the collection.
1796:      * Otherwise if this Assay is new, it will return
1797:      * an empty collection; or if this Assay has previously
1798:      * been saved, it will retrieve related Acquisitions from storage.
1799:      *
1800:      * This method is protected by default in order to keep the public
1801:      * api reasonable.  You can provide public methods for those you
1802:      * actually need in Assay.
1803:      *
1804:      * @param Criteria $criteria optional Criteria object to narrow the query
1805:      * @param PropelPDO $con optional connection object
1806:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
1807:      * @return PropelObjectCollection|Acquisition[] List of Acquisition objects
1808:      */
1809:     public function getAcquisitionsJoinProtocol($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
1810:     {
1811:         $query = AcquisitionQuery::create(null, $criteria);
1812:         $query->joinWith('Protocol', $join_behavior);
1813: 
1814:         return $this->getAcquisitions($query, $con);
1815:     }
1816: 
1817:     /**
1818:      * Clears out the collAssayBiomaterials collection
1819:      *
1820:      * This does not modify the database; however, it will remove any associated objects, causing
1821:      * them to be refetched by subsequent calls to accessor method.
1822:      *
1823:      * @return Assay The current object (for fluent API support)
1824:      * @see        addAssayBiomaterials()
1825:      */
1826:     public function clearAssayBiomaterials()
1827:     {
1828:         $this->collAssayBiomaterials = null; // important to set this to null since that means it is uninitialized
1829:         $this->collAssayBiomaterialsPartial = null;
1830: 
1831:         return $this;
1832:     }
1833: 
1834:     /**
1835:      * reset is the collAssayBiomaterials collection loaded partially
1836:      *
1837:      * @return void
1838:      */
1839:     public function resetPartialAssayBiomaterials($v = true)
1840:     {
1841:         $this->collAssayBiomaterialsPartial = $v;
1842:     }
1843: 
1844:     /**
1845:      * Initializes the collAssayBiomaterials collection.
1846:      *
1847:      * By default this just sets the collAssayBiomaterials collection to an empty array (like clearcollAssayBiomaterials());
1848:      * however, you may wish to override this method in your stub class to provide setting appropriate
1849:      * to your application -- for example, setting the initial array to the values stored in database.
1850:      *
1851:      * @param boolean $overrideExisting If set to true, the method call initializes
1852:      *                                        the collection even if it is not empty
1853:      *
1854:      * @return void
1855:      */
1856:     public function initAssayBiomaterials($overrideExisting = true)
1857:     {
1858:         if (null !== $this->collAssayBiomaterials && !$overrideExisting) {
1859:             return;
1860:         }
1861:         $this->collAssayBiomaterials = new PropelObjectCollection();
1862:         $this->collAssayBiomaterials->setModel('AssayBiomaterial');
1863:     }
1864: 
1865:     /**
1866:      * Gets an array of AssayBiomaterial objects which contain a foreign key that references this object.
1867:      *
1868:      * If the $criteria is not null, it is used to always fetch the results from the database.
1869:      * Otherwise the results are fetched from the database the first time, then cached.
1870:      * Next time the same method is called without $criteria, the cached collection is returned.
1871:      * If this Assay is new, it will return
1872:      * an empty collection or the current collection; the criteria is ignored on a new object.
1873:      *
1874:      * @param Criteria $criteria optional Criteria object to narrow the query
1875:      * @param PropelPDO $con optional connection object
1876:      * @return PropelObjectCollection|AssayBiomaterial[] List of AssayBiomaterial objects
1877:      * @throws PropelException
1878:      */
1879:     public function getAssayBiomaterials($criteria = null, PropelPDO $con = null)
1880:     {
1881:         $partial = $this->collAssayBiomaterialsPartial && !$this->isNew();
1882:         if (null === $this->collAssayBiomaterials || null !== $criteria  || $partial) {
1883:             if ($this->isNew() && null === $this->collAssayBiomaterials) {
1884:                 // return empty collection
1885:                 $this->initAssayBiomaterials();
1886:             } else {
1887:                 $collAssayBiomaterials = AssayBiomaterialQuery::create(null, $criteria)
1888:                     ->filterByAssay($this)
1889:                     ->find($con);
1890:                 if (null !== $criteria) {
1891:                     if (false !== $this->collAssayBiomaterialsPartial && count($collAssayBiomaterials)) {
1892:                       $this->initAssayBiomaterials(false);
1893: 
1894:                       foreach($collAssayBiomaterials as $obj) {
1895:                         if (false == $this->collAssayBiomaterials->contains($obj)) {
1896:                           $this->collAssayBiomaterials->append($obj);
1897:                         }
1898:                       }
1899: 
1900:                       $this->collAssayBiomaterialsPartial = true;
1901:                     }
1902: 
1903:                     $collAssayBiomaterials->getInternalIterator()->rewind();
1904:                     return $collAssayBiomaterials;
1905:                 }
1906: 
1907:                 if($partial && $this->collAssayBiomaterials) {
1908:                     foreach($this->collAssayBiomaterials as $obj) {
1909:                         if($obj->isNew()) {
1910:                             $collAssayBiomaterials[] = $obj;
1911:                         }
1912:                     }
1913:                 }
1914: 
1915:                 $this->collAssayBiomaterials = $collAssayBiomaterials;
1916:                 $this->collAssayBiomaterialsPartial = false;
1917:             }
1918:         }
1919: 
1920:         return $this->collAssayBiomaterials;
1921:     }
1922: 
1923:     /**
1924:      * Sets a collection of AssayBiomaterial objects related by a one-to-many relationship
1925:      * to the current object.
1926:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1927:      * and new objects from the given Propel collection.
1928:      *
1929:      * @param PropelCollection $assayBiomaterials A Propel collection.
1930:      * @param PropelPDO $con Optional connection object
1931:      * @return Assay The current object (for fluent API support)
1932:      */
1933:     public function setAssayBiomaterials(PropelCollection $assayBiomaterials, PropelPDO $con = null)
1934:     {
1935:         $assayBiomaterialsToDelete = $this->getAssayBiomaterials(new Criteria(), $con)->diff($assayBiomaterials);
1936: 
1937:         $this->assayBiomaterialsScheduledForDeletion = unserialize(serialize($assayBiomaterialsToDelete));
1938: 
1939:         foreach ($assayBiomaterialsToDelete as $assayBiomaterialRemoved) {
1940:             $assayBiomaterialRemoved->setAssay(null);
1941:         }
1942: 
1943:         $this->collAssayBiomaterials = null;
1944:         foreach ($assayBiomaterials as $assayBiomaterial) {
1945:             $this->addAssayBiomaterial($assayBiomaterial);
1946:         }
1947: 
1948:         $this->collAssayBiomaterials = $assayBiomaterials;
1949:         $this->collAssayBiomaterialsPartial = false;
1950: 
1951:         return $this;
1952:     }
1953: 
1954:     /**
1955:      * Returns the number of related AssayBiomaterial objects.
1956:      *
1957:      * @param Criteria $criteria
1958:      * @param boolean $distinct
1959:      * @param PropelPDO $con
1960:      * @return int             Count of related AssayBiomaterial objects.
1961:      * @throws PropelException
1962:      */
1963:     public function countAssayBiomaterials(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1964:     {
1965:         $partial = $this->collAssayBiomaterialsPartial && !$this->isNew();
1966:         if (null === $this->collAssayBiomaterials || null !== $criteria || $partial) {
1967:             if ($this->isNew() && null === $this->collAssayBiomaterials) {
1968:                 return 0;
1969:             }
1970: 
1971:             if($partial && !$criteria) {
1972:                 return count($this->getAssayBiomaterials());
1973:             }
1974:             $query = AssayBiomaterialQuery::create(null, $criteria);
1975:             if ($distinct) {
1976:                 $query->distinct();
1977:             }
1978: 
1979:             return $query
1980:                 ->filterByAssay($this)
1981:                 ->count($con);
1982:         }
1983: 
1984:         return count($this->collAssayBiomaterials);
1985:     }
1986: 
1987:     /**
1988:      * Method called to associate a AssayBiomaterial object to this object
1989:      * through the AssayBiomaterial foreign key attribute.
1990:      *
1991:      * @param    AssayBiomaterial $l AssayBiomaterial
1992:      * @return Assay The current object (for fluent API support)
1993:      */
1994:     public function addAssayBiomaterial(AssayBiomaterial $l)
1995:     {
1996:         if ($this->collAssayBiomaterials === null) {
1997:             $this->initAssayBiomaterials();
1998:             $this->collAssayBiomaterialsPartial = true;
1999:         }
2000:         if (!in_array($l, $this->collAssayBiomaterials->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2001:             $this->doAddAssayBiomaterial($l);
2002:         }
2003: 
2004:         return $this;
2005:     }
2006: 
2007:     /**
2008:      * @param   AssayBiomaterial $assayBiomaterial The assayBiomaterial object to add.
2009:      */
2010:     protected function doAddAssayBiomaterial($assayBiomaterial)
2011:     {
2012:         $this->collAssayBiomaterials[]= $assayBiomaterial;
2013:         $assayBiomaterial->setAssay($this);
2014:     }
2015: 
2016:     /**
2017:      * @param   AssayBiomaterial $assayBiomaterial The assayBiomaterial object to remove.
2018:      * @return Assay The current object (for fluent API support)
2019:      */
2020:     public function removeAssayBiomaterial($assayBiomaterial)
2021:     {
2022:         if ($this->getAssayBiomaterials()->contains($assayBiomaterial)) {
2023:             $this->collAssayBiomaterials->remove($this->collAssayBiomaterials->search($assayBiomaterial));
2024:             if (null === $this->assayBiomaterialsScheduledForDeletion) {
2025:                 $this->assayBiomaterialsScheduledForDeletion = clone $this->collAssayBiomaterials;
2026:                 $this->assayBiomaterialsScheduledForDeletion->clear();
2027:             }
2028:             $this->assayBiomaterialsScheduledForDeletion[]= clone $assayBiomaterial;
2029:             $assayBiomaterial->setAssay(null);
2030:         }
2031: 
2032:         return $this;
2033:     }
2034: 
2035: 
2036:     /**
2037:      * If this collection has already been initialized with
2038:      * an identical criteria, it returns the collection.
2039:      * Otherwise if this Assay is new, it will return
2040:      * an empty collection; or if this Assay has previously
2041:      * been saved, it will retrieve related AssayBiomaterials from storage.
2042:      *
2043:      * This method is protected by default in order to keep the public
2044:      * api reasonable.  You can provide public methods for those you
2045:      * actually need in Assay.
2046:      *
2047:      * @param Criteria $criteria optional Criteria object to narrow the query
2048:      * @param PropelPDO $con optional connection object
2049:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2050:      * @return PropelObjectCollection|AssayBiomaterial[] List of AssayBiomaterial objects
2051:      */
2052:     public function getAssayBiomaterialsJoinBiomaterial($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2053:     {
2054:         $query = AssayBiomaterialQuery::create(null, $criteria);
2055:         $query->joinWith('Biomaterial', $join_behavior);
2056: 
2057:         return $this->getAssayBiomaterials($query, $con);
2058:     }
2059: 
2060:     /**
2061:      * Clears the current object and sets all attributes to their default values
2062:      */
2063:     public function clear()
2064:     {
2065:         $this->assay_id = null;
2066:         $this->arraydesign_id = null;
2067:         $this->protocol_id = null;
2068:         $this->assaydate = null;
2069:         $this->arrayidentifier = null;
2070:         $this->arraybatchidentifier = null;
2071:         $this->operator_id = null;
2072:         $this->dbxref_id = null;
2073:         $this->name = null;
2074:         $this->description = null;
2075:         $this->alreadyInSave = false;
2076:         $this->alreadyInValidation = false;
2077:         $this->alreadyInClearAllReferencesDeep = false;
2078:         $this->clearAllReferences();
2079:         $this->applyDefaultValues();
2080:         $this->resetModified();
2081:         $this->setNew(true);
2082:         $this->setDeleted(false);
2083:     }
2084: 
2085:     /**
2086:      * Resets all references to other model objects or collections of model objects.
2087:      *
2088:      * This method is a user-space workaround for PHP's inability to garbage collect
2089:      * objects with circular references (even in PHP 5.3). This is currently necessary
2090:      * when using Propel in certain daemon or large-volumne/high-memory operations.
2091:      *
2092:      * @param boolean $deep Whether to also clear the references on all referrer objects.
2093:      */
2094:     public function clearAllReferences($deep = false)
2095:     {
2096:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
2097:             $this->alreadyInClearAllReferencesDeep = true;
2098:             if ($this->collAcquisitions) {
2099:                 foreach ($this->collAcquisitions as $o) {
2100:                     $o->clearAllReferences($deep);
2101:                 }
2102:             }
2103:             if ($this->collAssayBiomaterials) {
2104:                 foreach ($this->collAssayBiomaterials as $o) {
2105:                     $o->clearAllReferences($deep);
2106:                 }
2107:             }
2108:             if ($this->aContact instanceof Persistent) {
2109:               $this->aContact->clearAllReferences($deep);
2110:             }
2111:             if ($this->aProtocol instanceof Persistent) {
2112:               $this->aProtocol->clearAllReferences($deep);
2113:             }
2114: 
2115:             $this->alreadyInClearAllReferencesDeep = false;
2116:         } // if ($deep)
2117: 
2118:         if ($this->collAcquisitions instanceof PropelCollection) {
2119:             $this->collAcquisitions->clearIterator();
2120:         }
2121:         $this->collAcquisitions = null;
2122:         if ($this->collAssayBiomaterials instanceof PropelCollection) {
2123:             $this->collAssayBiomaterials->clearIterator();
2124:         }
2125:         $this->collAssayBiomaterials = null;
2126:         $this->aContact = null;
2127:         $this->aProtocol = null;
2128:     }
2129: 
2130:     /**
2131:      * return the string representation of this object
2132:      *
2133:      * @return string
2134:      */
2135:     public function __toString()
2136:     {
2137:         return (string) $this->exportTo(AssayPeer::DEFAULT_STRING_FORMAT);
2138:     }
2139: 
2140:     /**
2141:      * return true is the object is in saving state
2142:      *
2143:      * @return boolean
2144:      */
2145:     public function isAlreadyInSave()
2146:     {
2147:         return $this->alreadyInSave;
2148:     }
2149: 
2150: }
2151: 
tbro API documentation generated by ApiGen 2.8.0