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