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