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\BiomaterialRelationship;
  17: use cli_db\propel\BiomaterialRelationshipQuery;
  18: use cli_db\propel\Biomaterialprop;
  19: use cli_db\propel\BiomaterialpropQuery;
  20: use cli_db\propel\Contact;
  21: use cli_db\propel\ContactQuery;
  22: use cli_db\propel\Cv;
  23: use cli_db\propel\CvQuery;
  24: use cli_db\propel\Cvterm;
  25: use cli_db\propel\CvtermPeer;
  26: use cli_db\propel\CvtermQuery;
  27: use cli_db\propel\Feature;
  28: use cli_db\propel\FeatureCvterm;
  29: use cli_db\propel\FeatureCvtermQuery;
  30: use cli_db\propel\FeatureCvtermprop;
  31: use cli_db\propel\FeatureCvtermpropQuery;
  32: use cli_db\propel\FeatureQuery;
  33: use cli_db\propel\Protocol;
  34: use cli_db\propel\ProtocolQuery;
  35: use cli_db\propel\Pub;
  36: use cli_db\propel\PubQuery;
  37: use cli_db\propel\PubRelationship;
  38: use cli_db\propel\PubRelationshipQuery;
  39: use cli_db\propel\Pubprop;
  40: use cli_db\propel\PubpropQuery;
  41: use cli_db\propel\Synonym;
  42: use cli_db\propel\SynonymQuery;
  43: 
  44: /**
  45:  * Base class that represents a row from the 'cvterm' table.
  46:  *
  47:  *
  48:  *
  49:  * @package    propel.generator.cli_db.om
  50:  */
  51: abstract class BaseCvterm extends BaseObject implements Persistent
  52: {
  53:     /**
  54:      * Peer class name
  55:      */
  56:     const PEER = 'cli_db\\propel\\CvtermPeer';
  57: 
  58:     /**
  59:      * The Peer class.
  60:      * Instance provides a convenient way of calling static methods on a class
  61:      * that calling code may not be able to identify.
  62:      * @var        CvtermPeer
  63:      */
  64:     protected static $peer;
  65: 
  66:     /**
  67:      * The flag var to prevent infinit loop in deep copy
  68:      * @var       boolean
  69:      */
  70:     protected $startCopy = false;
  71: 
  72:     /**
  73:      * The value for the cvterm_id field.
  74:      * @var        int
  75:      */
  76:     protected $cvterm_id;
  77: 
  78:     /**
  79:      * The value for the cv_id field.
  80:      * @var        int
  81:      */
  82:     protected $cv_id;
  83: 
  84:     /**
  85:      * The value for the name field.
  86:      * @var        string
  87:      */
  88:     protected $name;
  89: 
  90:     /**
  91:      * The value for the definition field.
  92:      * @var        string
  93:      */
  94:     protected $definition;
  95: 
  96:     /**
  97:      * The value for the dbxref_id field.
  98:      * @var        int
  99:      */
 100:     protected $dbxref_id;
 101: 
 102:     /**
 103:      * The value for the is_obsolete field.
 104:      * Note: this column has a database default value of: 0
 105:      * @var        int
 106:      */
 107:     protected $is_obsolete;
 108: 
 109:     /**
 110:      * The value for the is_relationshiptype field.
 111:      * Note: this column has a database default value of: 0
 112:      * @var        int
 113:      */
 114:     protected $is_relationshiptype;
 115: 
 116:     /**
 117:      * @var        Cv
 118:      */
 119:     protected $aCv;
 120: 
 121:     /**
 122:      * @var        PropelObjectCollection|BiomaterialRelationship[] Collection to store aggregation of BiomaterialRelationship objects.
 123:      */
 124:     protected $collBiomaterialRelationships;
 125:     protected $collBiomaterialRelationshipsPartial;
 126: 
 127:     /**
 128:      * @var        PropelObjectCollection|Biomaterialprop[] Collection to store aggregation of Biomaterialprop objects.
 129:      */
 130:     protected $collBiomaterialprops;
 131:     protected $collBiomaterialpropsPartial;
 132: 
 133:     /**
 134:      * @var        PropelObjectCollection|Contact[] Collection to store aggregation of Contact objects.
 135:      */
 136:     protected $collContacts;
 137:     protected $collContactsPartial;
 138: 
 139:     /**
 140:      * @var        PropelObjectCollection|Feature[] Collection to store aggregation of Feature objects.
 141:      */
 142:     protected $collFeatures;
 143:     protected $collFeaturesPartial;
 144: 
 145:     /**
 146:      * @var        PropelObjectCollection|FeatureCvterm[] Collection to store aggregation of FeatureCvterm objects.
 147:      */
 148:     protected $collFeatureCvterms;
 149:     protected $collFeatureCvtermsPartial;
 150: 
 151:     /**
 152:      * @var        PropelObjectCollection|FeatureCvtermprop[] Collection to store aggregation of FeatureCvtermprop objects.
 153:      */
 154:     protected $collFeatureCvtermprops;
 155:     protected $collFeatureCvtermpropsPartial;
 156: 
 157:     /**
 158:      * @var        PropelObjectCollection|Protocol[] Collection to store aggregation of Protocol objects.
 159:      */
 160:     protected $collProtocols;
 161:     protected $collProtocolsPartial;
 162: 
 163:     /**
 164:      * @var        PropelObjectCollection|Pub[] Collection to store aggregation of Pub objects.
 165:      */
 166:     protected $collPubs;
 167:     protected $collPubsPartial;
 168: 
 169:     /**
 170:      * @var        PropelObjectCollection|PubRelationship[] Collection to store aggregation of PubRelationship objects.
 171:      */
 172:     protected $collPubRelationships;
 173:     protected $collPubRelationshipsPartial;
 174: 
 175:     /**
 176:      * @var        PropelObjectCollection|Pubprop[] Collection to store aggregation of Pubprop objects.
 177:      */
 178:     protected $collPubprops;
 179:     protected $collPubpropsPartial;
 180: 
 181:     /**
 182:      * @var        PropelObjectCollection|Synonym[] Collection to store aggregation of Synonym objects.
 183:      */
 184:     protected $collSynonyms;
 185:     protected $collSynonymsPartial;
 186: 
 187:     /**
 188:      * Flag to prevent endless save loop, if this object is referenced
 189:      * by another object which falls in this transaction.
 190:      * @var        boolean
 191:      */
 192:     protected $alreadyInSave = false;
 193: 
 194:     /**
 195:      * Flag to prevent endless validation loop, if this object is referenced
 196:      * by another object which falls in this transaction.
 197:      * @var        boolean
 198:      */
 199:     protected $alreadyInValidation = false;
 200: 
 201:     /**
 202:      * Flag to prevent endless clearAllReferences($deep=true) loop, if this object is referenced
 203:      * @var        boolean
 204:      */
 205:     protected $alreadyInClearAllReferencesDeep = false;
 206: 
 207:     /**
 208:      * An array of objects scheduled for deletion.
 209:      * @var     PropelObjectCollection
 210:      */
 211:     protected $biomaterialRelationshipsScheduledForDeletion = null;
 212: 
 213:     /**
 214:      * An array of objects scheduled for deletion.
 215:      * @var     PropelObjectCollection
 216:      */
 217:     protected $biomaterialpropsScheduledForDeletion = null;
 218: 
 219:     /**
 220:      * An array of objects scheduled for deletion.
 221:      * @var     PropelObjectCollection
 222:      */
 223:     protected $contactsScheduledForDeletion = null;
 224: 
 225:     /**
 226:      * An array of objects scheduled for deletion.
 227:      * @var     PropelObjectCollection
 228:      */
 229:     protected $featuresScheduledForDeletion = null;
 230: 
 231:     /**
 232:      * An array of objects scheduled for deletion.
 233:      * @var     PropelObjectCollection
 234:      */
 235:     protected $featureCvtermsScheduledForDeletion = null;
 236: 
 237:     /**
 238:      * An array of objects scheduled for deletion.
 239:      * @var     PropelObjectCollection
 240:      */
 241:     protected $featureCvtermpropsScheduledForDeletion = null;
 242: 
 243:     /**
 244:      * An array of objects scheduled for deletion.
 245:      * @var     PropelObjectCollection
 246:      */
 247:     protected $protocolsScheduledForDeletion = null;
 248: 
 249:     /**
 250:      * An array of objects scheduled for deletion.
 251:      * @var     PropelObjectCollection
 252:      */
 253:     protected $pubsScheduledForDeletion = null;
 254: 
 255:     /**
 256:      * An array of objects scheduled for deletion.
 257:      * @var     PropelObjectCollection
 258:      */
 259:     protected $pubRelationshipsScheduledForDeletion = null;
 260: 
 261:     /**
 262:      * An array of objects scheduled for deletion.
 263:      * @var     PropelObjectCollection
 264:      */
 265:     protected $pubpropsScheduledForDeletion = null;
 266: 
 267:     /**
 268:      * An array of objects scheduled for deletion.
 269:      * @var     PropelObjectCollection
 270:      */
 271:     protected $synonymsScheduledForDeletion = null;
 272: 
 273:     /**
 274:      * Applies default values to this object.
 275:      * This method should be called from the object's constructor (or
 276:      * equivalent initialization method).
 277:      * @see        __construct()
 278:      */
 279:     public function applyDefaultValues()
 280:     {
 281:         $this->is_obsolete = 0;
 282:         $this->is_relationshiptype = 0;
 283:     }
 284: 
 285:     /**
 286:      * Initializes internal state of BaseCvterm object.
 287:      * @see        applyDefaults()
 288:      */
 289:     public function __construct()
 290:     {
 291:         parent::__construct();
 292:         $this->applyDefaultValues();
 293:     }
 294: 
 295:     /**
 296:      * Get the [cvterm_id] column value.
 297:      *
 298:      * @return int
 299:      */
 300:     public function getCvtermId()
 301:     {
 302:         return $this->cvterm_id;
 303:     }
 304: 
 305:     /**
 306:      * Get the [cv_id] column value.
 307:      *
 308:      * @return int
 309:      */
 310:     public function getCvId()
 311:     {
 312:         return $this->cv_id;
 313:     }
 314: 
 315:     /**
 316:      * Get the [name] column value.
 317:      *
 318:      * @return string
 319:      */
 320:     public function getName()
 321:     {
 322:         return $this->name;
 323:     }
 324: 
 325:     /**
 326:      * Get the [definition] column value.
 327:      *
 328:      * @return string
 329:      */
 330:     public function getDefinition()
 331:     {
 332:         return $this->definition;
 333:     }
 334: 
 335:     /**
 336:      * Get the [dbxref_id] column value.
 337:      *
 338:      * @return int
 339:      */
 340:     public function getDbxrefId()
 341:     {
 342:         return $this->dbxref_id;
 343:     }
 344: 
 345:     /**
 346:      * Get the [is_obsolete] column value.
 347:      *
 348:      * @return int
 349:      */
 350:     public function getIsObsolete()
 351:     {
 352:         return $this->is_obsolete;
 353:     }
 354: 
 355:     /**
 356:      * Get the [is_relationshiptype] column value.
 357:      *
 358:      * @return int
 359:      */
 360:     public function getIsRelationshiptype()
 361:     {
 362:         return $this->is_relationshiptype;
 363:     }
 364: 
 365:     /**
 366:      * Set the value of [cvterm_id] column.
 367:      *
 368:      * @param int $v new value
 369:      * @return Cvterm The current object (for fluent API support)
 370:      */
 371:     public function setCvtermId($v)
 372:     {
 373:         if ($v !== null && is_numeric($v)) {
 374:             $v = (int) $v;
 375:         }
 376: 
 377:         if ($this->cvterm_id !== $v) {
 378:             $this->cvterm_id = $v;
 379:             $this->modifiedColumns[] = CvtermPeer::CVTERM_ID;
 380:         }
 381: 
 382: 
 383:         return $this;
 384:     } // setCvtermId()
 385: 
 386:     /**
 387:      * Set the value of [cv_id] column.
 388:      *
 389:      * @param int $v new value
 390:      * @return Cvterm The current object (for fluent API support)
 391:      */
 392:     public function setCvId($v)
 393:     {
 394:         if ($v !== null && is_numeric($v)) {
 395:             $v = (int) $v;
 396:         }
 397: 
 398:         if ($this->cv_id !== $v) {
 399:             $this->cv_id = $v;
 400:             $this->modifiedColumns[] = CvtermPeer::CV_ID;
 401:         }
 402: 
 403:         if ($this->aCv !== null && $this->aCv->getCvId() !== $v) {
 404:             $this->aCv = null;
 405:         }
 406: 
 407: 
 408:         return $this;
 409:     } // setCvId()
 410: 
 411:     /**
 412:      * Set the value of [name] column.
 413:      *
 414:      * @param string $v new value
 415:      * @return Cvterm The current object (for fluent API support)
 416:      */
 417:     public function setName($v)
 418:     {
 419:         if ($v !== null && is_numeric($v)) {
 420:             $v = (string) $v;
 421:         }
 422: 
 423:         if ($this->name !== $v) {
 424:             $this->name = $v;
 425:             $this->modifiedColumns[] = CvtermPeer::NAME;
 426:         }
 427: 
 428: 
 429:         return $this;
 430:     } // setName()
 431: 
 432:     /**
 433:      * Set the value of [definition] column.
 434:      *
 435:      * @param string $v new value
 436:      * @return Cvterm The current object (for fluent API support)
 437:      */
 438:     public function setDefinition($v)
 439:     {
 440:         if ($v !== null && is_numeric($v)) {
 441:             $v = (string) $v;
 442:         }
 443: 
 444:         if ($this->definition !== $v) {
 445:             $this->definition = $v;
 446:             $this->modifiedColumns[] = CvtermPeer::DEFINITION;
 447:         }
 448: 
 449: 
 450:         return $this;
 451:     } // setDefinition()
 452: 
 453:     /**
 454:      * Set the value of [dbxref_id] column.
 455:      *
 456:      * @param int $v new value
 457:      * @return Cvterm The current object (for fluent API support)
 458:      */
 459:     public function setDbxrefId($v)
 460:     {
 461:         if ($v !== null && is_numeric($v)) {
 462:             $v = (int) $v;
 463:         }
 464: 
 465:         if ($this->dbxref_id !== $v) {
 466:             $this->dbxref_id = $v;
 467:             $this->modifiedColumns[] = CvtermPeer::DBXREF_ID;
 468:         }
 469: 
 470: 
 471:         return $this;
 472:     } // setDbxrefId()
 473: 
 474:     /**
 475:      * Set the value of [is_obsolete] column.
 476:      *
 477:      * @param int $v new value
 478:      * @return Cvterm The current object (for fluent API support)
 479:      */
 480:     public function setIsObsolete($v)
 481:     {
 482:         if ($v !== null && is_numeric($v)) {
 483:             $v = (int) $v;
 484:         }
 485: 
 486:         if ($this->is_obsolete !== $v) {
 487:             $this->is_obsolete = $v;
 488:             $this->modifiedColumns[] = CvtermPeer::IS_OBSOLETE;
 489:         }
 490: 
 491: 
 492:         return $this;
 493:     } // setIsObsolete()
 494: 
 495:     /**
 496:      * Set the value of [is_relationshiptype] column.
 497:      *
 498:      * @param int $v new value
 499:      * @return Cvterm The current object (for fluent API support)
 500:      */
 501:     public function setIsRelationshiptype($v)
 502:     {
 503:         if ($v !== null && is_numeric($v)) {
 504:             $v = (int) $v;
 505:         }
 506: 
 507:         if ($this->is_relationshiptype !== $v) {
 508:             $this->is_relationshiptype = $v;
 509:             $this->modifiedColumns[] = CvtermPeer::IS_RELATIONSHIPTYPE;
 510:         }
 511: 
 512: 
 513:         return $this;
 514:     } // setIsRelationshiptype()
 515: 
 516:     /**
 517:      * Indicates whether the columns in this object are only set to default values.
 518:      *
 519:      * This method can be used in conjunction with isModified() to indicate whether an object is both
 520:      * modified _and_ has some values set which are non-default.
 521:      *
 522:      * @return boolean Whether the columns in this object are only been set with default values.
 523:      */
 524:     public function hasOnlyDefaultValues()
 525:     {
 526:             if ($this->is_obsolete !== 0) {
 527:                 return false;
 528:             }
 529: 
 530:             if ($this->is_relationshiptype !== 0) {
 531:                 return false;
 532:             }
 533: 
 534:         // otherwise, everything was equal, so return true
 535:         return true;
 536:     } // hasOnlyDefaultValues()
 537: 
 538:     /**
 539:      * Hydrates (populates) the object variables with values from the database resultset.
 540:      *
 541:      * An offset (0-based "start column") is specified so that objects can be hydrated
 542:      * with a subset of the columns in the resultset rows.  This is needed, for example,
 543:      * for results of JOIN queries where the resultset row includes columns from two or
 544:      * more tables.
 545:      *
 546:      * @param array $row The row returned by PDOStatement->fetch(PDO::FETCH_NUM)
 547:      * @param int $startcol 0-based offset column which indicates which restultset column to start with.
 548:      * @param boolean $rehydrate Whether this object is being re-hydrated from the database.
 549:      * @return int             next starting column
 550:      * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
 551:      */
 552:     public function hydrate($row, $startcol = 0, $rehydrate = false)
 553:     {
 554:         try {
 555: 
 556:             $this->cvterm_id = ($row[$startcol + 0] !== null) ? (int) $row[$startcol + 0] : null;
 557:             $this->cv_id = ($row[$startcol + 1] !== null) ? (int) $row[$startcol + 1] : null;
 558:             $this->name = ($row[$startcol + 2] !== null) ? (string) $row[$startcol + 2] : null;
 559:             $this->definition = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
 560:             $this->dbxref_id = ($row[$startcol + 4] !== null) ? (int) $row[$startcol + 4] : null;
 561:             $this->is_obsolete = ($row[$startcol + 5] !== null) ? (int) $row[$startcol + 5] : null;
 562:             $this->is_relationshiptype = ($row[$startcol + 6] !== null) ? (int) $row[$startcol + 6] : null;
 563:             $this->resetModified();
 564: 
 565:             $this->setNew(false);
 566: 
 567:             if ($rehydrate) {
 568:                 $this->ensureConsistency();
 569:             }
 570:             $this->postHydrate($row, $startcol, $rehydrate);
 571:             return $startcol + 7; // 7 = CvtermPeer::NUM_HYDRATE_COLUMNS.
 572: 
 573:         } catch (Exception $e) {
 574:             throw new PropelException("Error populating Cvterm object", $e);
 575:         }
 576:     }
 577: 
 578:     /**
 579:      * Checks and repairs the internal consistency of the object.
 580:      *
 581:      * This method is executed after an already-instantiated object is re-hydrated
 582:      * from the database.  It exists to check any foreign keys to make sure that
 583:      * the objects related to the current object are correct based on foreign key.
 584:      *
 585:      * You can override this method in the stub class, but you should always invoke
 586:      * the base method from the overridden method (i.e. parent::ensureConsistency()),
 587:      * in case your model changes.
 588:      *
 589:      * @throws PropelException
 590:      */
 591:     public function ensureConsistency()
 592:     {
 593: 
 594:         if ($this->aCv !== null && $this->cv_id !== $this->aCv->getCvId()) {
 595:             $this->aCv = null;
 596:         }
 597:     } // ensureConsistency
 598: 
 599:     /**
 600:      * Reloads this object from datastore based on primary key and (optionally) resets all associated objects.
 601:      *
 602:      * This will only work if the object has been saved and has a valid primary key set.
 603:      *
 604:      * @param boolean $deep (optional) Whether to also de-associated any related objects.
 605:      * @param PropelPDO $con (optional) The PropelPDO connection to use.
 606:      * @return void
 607:      * @throws PropelException - if this object is deleted, unsaved or doesn't have pk match in db
 608:      */
 609:     public function reload($deep = false, PropelPDO $con = null)
 610:     {
 611:         if ($this->isDeleted()) {
 612:             throw new PropelException("Cannot reload a deleted object.");
 613:         }
 614: 
 615:         if ($this->isNew()) {
 616:             throw new PropelException("Cannot reload an unsaved object.");
 617:         }
 618: 
 619:         if ($con === null) {
 620:             $con = Propel::getConnection(CvtermPeer::DATABASE_NAME, Propel::CONNECTION_READ);
 621:         }
 622: 
 623:         // We don't need to alter the object instance pool; we're just modifying this instance
 624:         // already in the pool.
 625: 
 626:         $stmt = CvtermPeer::doSelectStmt($this->buildPkeyCriteria(), $con);
 627:         $row = $stmt->fetch(PDO::FETCH_NUM);
 628:         $stmt->closeCursor();
 629:         if (!$row) {
 630:             throw new PropelException('Cannot find matching row in the database to reload object values.');
 631:         }
 632:         $this->hydrate($row, 0, true); // rehydrate
 633: 
 634:         if ($deep) {  // also de-associate any related objects?
 635: 
 636:             $this->aCv = null;
 637:             $this->collBiomaterialRelationships = null;
 638: 
 639:             $this->collBiomaterialprops = null;
 640: 
 641:             $this->collContacts = null;
 642: 
 643:             $this->collFeatures = null;
 644: 
 645:             $this->collFeatureCvterms = null;
 646: 
 647:             $this->collFeatureCvtermprops = null;
 648: 
 649:             $this->collProtocols = null;
 650: 
 651:             $this->collPubs = null;
 652: 
 653:             $this->collPubRelationships = null;
 654: 
 655:             $this->collPubprops = null;
 656: 
 657:             $this->collSynonyms = null;
 658: 
 659:         } // if (deep)
 660:     }
 661: 
 662:     /**
 663:      * Removes this object from datastore and sets delete attribute.
 664:      *
 665:      * @param PropelPDO $con
 666:      * @return void
 667:      * @throws PropelException
 668:      * @throws Exception
 669:      * @see        BaseObject::setDeleted()
 670:      * @see        BaseObject::isDeleted()
 671:      */
 672:     public function delete(PropelPDO $con = null)
 673:     {
 674:         if ($this->isDeleted()) {
 675:             throw new PropelException("This object has already been deleted.");
 676:         }
 677: 
 678:         if ($con === null) {
 679:             $con = Propel::getConnection(CvtermPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 680:         }
 681: 
 682:         $con->beginTransaction();
 683:         try {
 684:             $deleteQuery = CvtermQuery::create()
 685:                 ->filterByPrimaryKey($this->getPrimaryKey());
 686:             $ret = $this->preDelete($con);
 687:             if ($ret) {
 688:                 $deleteQuery->delete($con);
 689:                 $this->postDelete($con);
 690:                 $con->commit();
 691:                 $this->setDeleted(true);
 692:             } else {
 693:                 $con->commit();
 694:             }
 695:         } catch (Exception $e) {
 696:             $con->rollBack();
 697:             throw $e;
 698:         }
 699:     }
 700: 
 701:     /**
 702:      * Persists this object to the database.
 703:      *
 704:      * If the object is new, it inserts it; otherwise an update is performed.
 705:      * All modified related objects will also be persisted in the doSave()
 706:      * method.  This method wraps all precipitate database operations in a
 707:      * single transaction.
 708:      *
 709:      * @param PropelPDO $con
 710:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 711:      * @throws PropelException
 712:      * @throws Exception
 713:      * @see        doSave()
 714:      */
 715:     public function save(PropelPDO $con = null)
 716:     {
 717:         if ($this->isDeleted()) {
 718:             throw new PropelException("You cannot save an object that has been deleted.");
 719:         }
 720: 
 721:         if ($con === null) {
 722:             $con = Propel::getConnection(CvtermPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
 723:         }
 724: 
 725:         $con->beginTransaction();
 726:         $isInsert = $this->isNew();
 727:         try {
 728:             $ret = $this->preSave($con);
 729:             if ($isInsert) {
 730:                 $ret = $ret && $this->preInsert($con);
 731:             } else {
 732:                 $ret = $ret && $this->preUpdate($con);
 733:             }
 734:             if ($ret) {
 735:                 $affectedRows = $this->doSave($con);
 736:                 if ($isInsert) {
 737:                     $this->postInsert($con);
 738:                 } else {
 739:                     $this->postUpdate($con);
 740:                 }
 741:                 $this->postSave($con);
 742:                 CvtermPeer::addInstanceToPool($this);
 743:             } else {
 744:                 $affectedRows = 0;
 745:             }
 746:             $con->commit();
 747: 
 748:             return $affectedRows;
 749:         } catch (Exception $e) {
 750:             $con->rollBack();
 751:             throw $e;
 752:         }
 753:     }
 754: 
 755:     /**
 756:      * Performs the work of inserting or updating the row in the database.
 757:      *
 758:      * If the object is new, it inserts it; otherwise an update is performed.
 759:      * All related objects are also updated in this method.
 760:      *
 761:      * @param PropelPDO $con
 762:      * @return int             The number of rows affected by this insert/update and any referring fk objects' save() operations.
 763:      * @throws PropelException
 764:      * @see        save()
 765:      */
 766:     protected function doSave(PropelPDO $con)
 767:     {
 768:         $affectedRows = 0; // initialize var to track total num of affected rows
 769:         if (!$this->alreadyInSave) {
 770:             $this->alreadyInSave = true;
 771: 
 772:             // We call the save method on the following object(s) if they
 773:             // were passed to this object by their coresponding set
 774:             // method.  This object relates to these object(s) by a
 775:             // foreign key reference.
 776: 
 777:             if ($this->aCv !== null) {
 778:                 if ($this->aCv->isModified() || $this->aCv->isNew()) {
 779:                     $affectedRows += $this->aCv->save($con);
 780:                 }
 781:                 $this->setCv($this->aCv);
 782:             }
 783: 
 784:             if ($this->isNew() || $this->isModified()) {
 785:                 // persist changes
 786:                 if ($this->isNew()) {
 787:                     $this->doInsert($con);
 788:                 } else {
 789:                     $this->doUpdate($con);
 790:                 }
 791:                 $affectedRows += 1;
 792:                 $this->resetModified();
 793:             }
 794: 
 795:             if ($this->biomaterialRelationshipsScheduledForDeletion !== null) {
 796:                 if (!$this->biomaterialRelationshipsScheduledForDeletion->isEmpty()) {
 797:                     BiomaterialRelationshipQuery::create()
 798:                         ->filterByPrimaryKeys($this->biomaterialRelationshipsScheduledForDeletion->getPrimaryKeys(false))
 799:                         ->delete($con);
 800:                     $this->biomaterialRelationshipsScheduledForDeletion = null;
 801:                 }
 802:             }
 803: 
 804:             if ($this->collBiomaterialRelationships !== null) {
 805:                 foreach ($this->collBiomaterialRelationships as $referrerFK) {
 806:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 807:                         $affectedRows += $referrerFK->save($con);
 808:                     }
 809:                 }
 810:             }
 811: 
 812:             if ($this->biomaterialpropsScheduledForDeletion !== null) {
 813:                 if (!$this->biomaterialpropsScheduledForDeletion->isEmpty()) {
 814:                     BiomaterialpropQuery::create()
 815:                         ->filterByPrimaryKeys($this->biomaterialpropsScheduledForDeletion->getPrimaryKeys(false))
 816:                         ->delete($con);
 817:                     $this->biomaterialpropsScheduledForDeletion = null;
 818:                 }
 819:             }
 820: 
 821:             if ($this->collBiomaterialprops !== null) {
 822:                 foreach ($this->collBiomaterialprops as $referrerFK) {
 823:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 824:                         $affectedRows += $referrerFK->save($con);
 825:                     }
 826:                 }
 827:             }
 828: 
 829:             if ($this->contactsScheduledForDeletion !== null) {
 830:                 if (!$this->contactsScheduledForDeletion->isEmpty()) {
 831:                     foreach ($this->contactsScheduledForDeletion as $contact) {
 832:                         // need to save related object because we set the relation to null
 833:                         $contact->save($con);
 834:                     }
 835:                     $this->contactsScheduledForDeletion = null;
 836:                 }
 837:             }
 838: 
 839:             if ($this->collContacts !== null) {
 840:                 foreach ($this->collContacts as $referrerFK) {
 841:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 842:                         $affectedRows += $referrerFK->save($con);
 843:                     }
 844:                 }
 845:             }
 846: 
 847:             if ($this->featuresScheduledForDeletion !== null) {
 848:                 if (!$this->featuresScheduledForDeletion->isEmpty()) {
 849:                     FeatureQuery::create()
 850:                         ->filterByPrimaryKeys($this->featuresScheduledForDeletion->getPrimaryKeys(false))
 851:                         ->delete($con);
 852:                     $this->featuresScheduledForDeletion = null;
 853:                 }
 854:             }
 855: 
 856:             if ($this->collFeatures !== null) {
 857:                 foreach ($this->collFeatures as $referrerFK) {
 858:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 859:                         $affectedRows += $referrerFK->save($con);
 860:                     }
 861:                 }
 862:             }
 863: 
 864:             if ($this->featureCvtermsScheduledForDeletion !== null) {
 865:                 if (!$this->featureCvtermsScheduledForDeletion->isEmpty()) {
 866:                     FeatureCvtermQuery::create()
 867:                         ->filterByPrimaryKeys($this->featureCvtermsScheduledForDeletion->getPrimaryKeys(false))
 868:                         ->delete($con);
 869:                     $this->featureCvtermsScheduledForDeletion = null;
 870:                 }
 871:             }
 872: 
 873:             if ($this->collFeatureCvterms !== null) {
 874:                 foreach ($this->collFeatureCvterms as $referrerFK) {
 875:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 876:                         $affectedRows += $referrerFK->save($con);
 877:                     }
 878:                 }
 879:             }
 880: 
 881:             if ($this->featureCvtermpropsScheduledForDeletion !== null) {
 882:                 if (!$this->featureCvtermpropsScheduledForDeletion->isEmpty()) {
 883:                     FeatureCvtermpropQuery::create()
 884:                         ->filterByPrimaryKeys($this->featureCvtermpropsScheduledForDeletion->getPrimaryKeys(false))
 885:                         ->delete($con);
 886:                     $this->featureCvtermpropsScheduledForDeletion = null;
 887:                 }
 888:             }
 889: 
 890:             if ($this->collFeatureCvtermprops !== null) {
 891:                 foreach ($this->collFeatureCvtermprops as $referrerFK) {
 892:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 893:                         $affectedRows += $referrerFK->save($con);
 894:                     }
 895:                 }
 896:             }
 897: 
 898:             if ($this->protocolsScheduledForDeletion !== null) {
 899:                 if (!$this->protocolsScheduledForDeletion->isEmpty()) {
 900:                     ProtocolQuery::create()
 901:                         ->filterByPrimaryKeys($this->protocolsScheduledForDeletion->getPrimaryKeys(false))
 902:                         ->delete($con);
 903:                     $this->protocolsScheduledForDeletion = null;
 904:                 }
 905:             }
 906: 
 907:             if ($this->collProtocols !== null) {
 908:                 foreach ($this->collProtocols as $referrerFK) {
 909:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 910:                         $affectedRows += $referrerFK->save($con);
 911:                     }
 912:                 }
 913:             }
 914: 
 915:             if ($this->pubsScheduledForDeletion !== null) {
 916:                 if (!$this->pubsScheduledForDeletion->isEmpty()) {
 917:                     PubQuery::create()
 918:                         ->filterByPrimaryKeys($this->pubsScheduledForDeletion->getPrimaryKeys(false))
 919:                         ->delete($con);
 920:                     $this->pubsScheduledForDeletion = null;
 921:                 }
 922:             }
 923: 
 924:             if ($this->collPubs !== null) {
 925:                 foreach ($this->collPubs as $referrerFK) {
 926:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 927:                         $affectedRows += $referrerFK->save($con);
 928:                     }
 929:                 }
 930:             }
 931: 
 932:             if ($this->pubRelationshipsScheduledForDeletion !== null) {
 933:                 if (!$this->pubRelationshipsScheduledForDeletion->isEmpty()) {
 934:                     PubRelationshipQuery::create()
 935:                         ->filterByPrimaryKeys($this->pubRelationshipsScheduledForDeletion->getPrimaryKeys(false))
 936:                         ->delete($con);
 937:                     $this->pubRelationshipsScheduledForDeletion = null;
 938:                 }
 939:             }
 940: 
 941:             if ($this->collPubRelationships !== null) {
 942:                 foreach ($this->collPubRelationships as $referrerFK) {
 943:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 944:                         $affectedRows += $referrerFK->save($con);
 945:                     }
 946:                 }
 947:             }
 948: 
 949:             if ($this->pubpropsScheduledForDeletion !== null) {
 950:                 if (!$this->pubpropsScheduledForDeletion->isEmpty()) {
 951:                     PubpropQuery::create()
 952:                         ->filterByPrimaryKeys($this->pubpropsScheduledForDeletion->getPrimaryKeys(false))
 953:                         ->delete($con);
 954:                     $this->pubpropsScheduledForDeletion = null;
 955:                 }
 956:             }
 957: 
 958:             if ($this->collPubprops !== null) {
 959:                 foreach ($this->collPubprops as $referrerFK) {
 960:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 961:                         $affectedRows += $referrerFK->save($con);
 962:                     }
 963:                 }
 964:             }
 965: 
 966:             if ($this->synonymsScheduledForDeletion !== null) {
 967:                 if (!$this->synonymsScheduledForDeletion->isEmpty()) {
 968:                     SynonymQuery::create()
 969:                         ->filterByPrimaryKeys($this->synonymsScheduledForDeletion->getPrimaryKeys(false))
 970:                         ->delete($con);
 971:                     $this->synonymsScheduledForDeletion = null;
 972:                 }
 973:             }
 974: 
 975:             if ($this->collSynonyms !== null) {
 976:                 foreach ($this->collSynonyms as $referrerFK) {
 977:                     if (!$referrerFK->isDeleted() && ($referrerFK->isNew() || $referrerFK->isModified())) {
 978:                         $affectedRows += $referrerFK->save($con);
 979:                     }
 980:                 }
 981:             }
 982: 
 983:             $this->alreadyInSave = false;
 984: 
 985:         }
 986: 
 987:         return $affectedRows;
 988:     } // doSave()
 989: 
 990:     /**
 991:      * Insert the row in the database.
 992:      *
 993:      * @param PropelPDO $con
 994:      *
 995:      * @throws PropelException
 996:      * @see        doSave()
 997:      */
 998:     protected function doInsert(PropelPDO $con)
 999:     {
1000:         $modifiedColumns = array();
1001:         $index = 0;
1002: 
1003:         $this->modifiedColumns[] = CvtermPeer::CVTERM_ID;
1004:         if (null !== $this->cvterm_id) {
1005:             throw new PropelException('Cannot insert a value for auto-increment primary key (' . CvtermPeer::CVTERM_ID . ')');
1006:         }
1007:         if (null === $this->cvterm_id) {
1008:             try {
1009:                 $stmt = $con->query("SELECT nextval('cvterm_cvterm_id_seq')");
1010:                 $row = $stmt->fetch(PDO::FETCH_NUM);
1011:                 $this->cvterm_id = $row[0];
1012:             } catch (Exception $e) {
1013:                 throw new PropelException('Unable to get sequence id.', $e);
1014:             }
1015:         }
1016: 
1017: 
1018:          // check the columns in natural order for more readable SQL queries
1019:         if ($this->isColumnModified(CvtermPeer::CVTERM_ID)) {
1020:             $modifiedColumns[':p' . $index++]  = '"cvterm_id"';
1021:         }
1022:         if ($this->isColumnModified(CvtermPeer::CV_ID)) {
1023:             $modifiedColumns[':p' . $index++]  = '"cv_id"';
1024:         }
1025:         if ($this->isColumnModified(CvtermPeer::NAME)) {
1026:             $modifiedColumns[':p' . $index++]  = '"name"';
1027:         }
1028:         if ($this->isColumnModified(CvtermPeer::DEFINITION)) {
1029:             $modifiedColumns[':p' . $index++]  = '"definition"';
1030:         }
1031:         if ($this->isColumnModified(CvtermPeer::DBXREF_ID)) {
1032:             $modifiedColumns[':p' . $index++]  = '"dbxref_id"';
1033:         }
1034:         if ($this->isColumnModified(CvtermPeer::IS_OBSOLETE)) {
1035:             $modifiedColumns[':p' . $index++]  = '"is_obsolete"';
1036:         }
1037:         if ($this->isColumnModified(CvtermPeer::IS_RELATIONSHIPTYPE)) {
1038:             $modifiedColumns[':p' . $index++]  = '"is_relationshiptype"';
1039:         }
1040: 
1041:         $sql = sprintf(
1042:             'INSERT INTO "cvterm" (%s) VALUES (%s)',
1043:             implode(', ', $modifiedColumns),
1044:             implode(', ', array_keys($modifiedColumns))
1045:         );
1046: 
1047:         try {
1048:             $stmt = $con->prepare($sql);
1049:             foreach ($modifiedColumns as $identifier => $columnName) {
1050:                 switch ($columnName) {
1051:                     case '"cvterm_id"':
1052:                         $stmt->bindValue($identifier, $this->cvterm_id, PDO::PARAM_INT);
1053:                         break;
1054:                     case '"cv_id"':
1055:                         $stmt->bindValue($identifier, $this->cv_id, PDO::PARAM_INT);
1056:                         break;
1057:                     case '"name"':
1058:                         $stmt->bindValue($identifier, $this->name, PDO::PARAM_STR);
1059:                         break;
1060:                     case '"definition"':
1061:                         $stmt->bindValue($identifier, $this->definition, PDO::PARAM_STR);
1062:                         break;
1063:                     case '"dbxref_id"':
1064:                         $stmt->bindValue($identifier, $this->dbxref_id, PDO::PARAM_INT);
1065:                         break;
1066:                     case '"is_obsolete"':
1067:                         $stmt->bindValue($identifier, $this->is_obsolete, PDO::PARAM_INT);
1068:                         break;
1069:                     case '"is_relationshiptype"':
1070:                         $stmt->bindValue($identifier, $this->is_relationshiptype, PDO::PARAM_INT);
1071:                         break;
1072:                 }
1073:             }
1074:             $stmt->execute();
1075:         } catch (Exception $e) {
1076:             Propel::log($e->getMessage(), Propel::LOG_ERR);
1077:             throw new PropelException(sprintf('Unable to execute INSERT statement [%s]', $sql), $e);
1078:         }
1079: 
1080:         $this->setNew(false);
1081:     }
1082: 
1083:     /**
1084:      * Update the row in the database.
1085:      *
1086:      * @param PropelPDO $con
1087:      *
1088:      * @see        doSave()
1089:      */
1090:     protected function doUpdate(PropelPDO $con)
1091:     {
1092:         $selectCriteria = $this->buildPkeyCriteria();
1093:         $valuesCriteria = $this->buildCriteria();
1094:         BasePeer::doUpdate($selectCriteria, $valuesCriteria, $con);
1095:     }
1096: 
1097:     /**
1098:      * Array of ValidationFailed objects.
1099:      * @var        array ValidationFailed[]
1100:      */
1101:     protected $validationFailures = array();
1102: 
1103:     /**
1104:      * Gets any ValidationFailed objects that resulted from last call to validate().
1105:      *
1106:      *
1107:      * @return array ValidationFailed[]
1108:      * @see        validate()
1109:      */
1110:     public function getValidationFailures()
1111:     {
1112:         return $this->validationFailures;
1113:     }
1114: 
1115:     /**
1116:      * Validates the objects modified field values and all objects related to this table.
1117:      *
1118:      * If $columns is either a column name or an array of column names
1119:      * only those columns are validated.
1120:      *
1121:      * @param mixed $columns Column name or an array of column names.
1122:      * @return boolean Whether all columns pass validation.
1123:      * @see        doValidate()
1124:      * @see        getValidationFailures()
1125:      */
1126:     public function validate($columns = null)
1127:     {
1128:         $res = $this->doValidate($columns);
1129:         if ($res === true) {
1130:             $this->validationFailures = array();
1131: 
1132:             return true;
1133:         }
1134: 
1135:         $this->validationFailures = $res;
1136: 
1137:         return false;
1138:     }
1139: 
1140:     /**
1141:      * This function performs the validation work for complex object models.
1142:      *
1143:      * In addition to checking the current object, all related objects will
1144:      * also be validated.  If all pass then <code>true</code> is returned; otherwise
1145:      * an aggreagated array of ValidationFailed objects will be returned.
1146:      *
1147:      * @param array $columns Array of column names to validate.
1148:      * @return mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
1149:      */
1150:     protected function doValidate($columns = null)
1151:     {
1152:         if (!$this->alreadyInValidation) {
1153:             $this->alreadyInValidation = true;
1154:             $retval = null;
1155: 
1156:             $failureMap = array();
1157: 
1158: 
1159:             // We call the validate method on the following object(s) if they
1160:             // were passed to this object by their coresponding set
1161:             // method.  This object relates to these object(s) by a
1162:             // foreign key reference.
1163: 
1164:             if ($this->aCv !== null) {
1165:                 if (!$this->aCv->validate($columns)) {
1166:                     $failureMap = array_merge($failureMap, $this->aCv->getValidationFailures());
1167:                 }
1168:             }
1169: 
1170: 
1171:             if (($retval = CvtermPeer::doValidate($this, $columns)) !== true) {
1172:                 $failureMap = array_merge($failureMap, $retval);
1173:             }
1174: 
1175: 
1176:                 if ($this->collBiomaterialRelationships !== null) {
1177:                     foreach ($this->collBiomaterialRelationships as $referrerFK) {
1178:                         if (!$referrerFK->validate($columns)) {
1179:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1180:                         }
1181:                     }
1182:                 }
1183: 
1184:                 if ($this->collBiomaterialprops !== null) {
1185:                     foreach ($this->collBiomaterialprops as $referrerFK) {
1186:                         if (!$referrerFK->validate($columns)) {
1187:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1188:                         }
1189:                     }
1190:                 }
1191: 
1192:                 if ($this->collContacts !== null) {
1193:                     foreach ($this->collContacts as $referrerFK) {
1194:                         if (!$referrerFK->validate($columns)) {
1195:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1196:                         }
1197:                     }
1198:                 }
1199: 
1200:                 if ($this->collFeatures !== null) {
1201:                     foreach ($this->collFeatures as $referrerFK) {
1202:                         if (!$referrerFK->validate($columns)) {
1203:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1204:                         }
1205:                     }
1206:                 }
1207: 
1208:                 if ($this->collFeatureCvterms !== null) {
1209:                     foreach ($this->collFeatureCvterms as $referrerFK) {
1210:                         if (!$referrerFK->validate($columns)) {
1211:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1212:                         }
1213:                     }
1214:                 }
1215: 
1216:                 if ($this->collFeatureCvtermprops !== null) {
1217:                     foreach ($this->collFeatureCvtermprops as $referrerFK) {
1218:                         if (!$referrerFK->validate($columns)) {
1219:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1220:                         }
1221:                     }
1222:                 }
1223: 
1224:                 if ($this->collProtocols !== null) {
1225:                     foreach ($this->collProtocols as $referrerFK) {
1226:                         if (!$referrerFK->validate($columns)) {
1227:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1228:                         }
1229:                     }
1230:                 }
1231: 
1232:                 if ($this->collPubs !== null) {
1233:                     foreach ($this->collPubs as $referrerFK) {
1234:                         if (!$referrerFK->validate($columns)) {
1235:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1236:                         }
1237:                     }
1238:                 }
1239: 
1240:                 if ($this->collPubRelationships !== null) {
1241:                     foreach ($this->collPubRelationships as $referrerFK) {
1242:                         if (!$referrerFK->validate($columns)) {
1243:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1244:                         }
1245:                     }
1246:                 }
1247: 
1248:                 if ($this->collPubprops !== null) {
1249:                     foreach ($this->collPubprops as $referrerFK) {
1250:                         if (!$referrerFK->validate($columns)) {
1251:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1252:                         }
1253:                     }
1254:                 }
1255: 
1256:                 if ($this->collSynonyms !== null) {
1257:                     foreach ($this->collSynonyms as $referrerFK) {
1258:                         if (!$referrerFK->validate($columns)) {
1259:                             $failureMap = array_merge($failureMap, $referrerFK->getValidationFailures());
1260:                         }
1261:                     }
1262:                 }
1263: 
1264: 
1265:             $this->alreadyInValidation = false;
1266:         }
1267: 
1268:         return (!empty($failureMap) ? $failureMap : true);
1269:     }
1270: 
1271:     /**
1272:      * Retrieves a field from the object by name passed in as a string.
1273:      *
1274:      * @param string $name name
1275:      * @param string $type The type of fieldname the $name is of:
1276:      *               one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1277:      *               BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1278:      *               Defaults to BasePeer::TYPE_PHPNAME
1279:      * @return mixed Value of field.
1280:      */
1281:     public function getByName($name, $type = BasePeer::TYPE_PHPNAME)
1282:     {
1283:         $pos = CvtermPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1284:         $field = $this->getByPosition($pos);
1285: 
1286:         return $field;
1287:     }
1288: 
1289:     /**
1290:      * Retrieves a field from the object by Position as specified in the xml schema.
1291:      * Zero-based.
1292:      *
1293:      * @param int $pos position in xml schema
1294:      * @return mixed Value of field at $pos
1295:      */
1296:     public function getByPosition($pos)
1297:     {
1298:         switch ($pos) {
1299:             case 0:
1300:                 return $this->getCvtermId();
1301:                 break;
1302:             case 1:
1303:                 return $this->getCvId();
1304:                 break;
1305:             case 2:
1306:                 return $this->getName();
1307:                 break;
1308:             case 3:
1309:                 return $this->getDefinition();
1310:                 break;
1311:             case 4:
1312:                 return $this->getDbxrefId();
1313:                 break;
1314:             case 5:
1315:                 return $this->getIsObsolete();
1316:                 break;
1317:             case 6:
1318:                 return $this->getIsRelationshiptype();
1319:                 break;
1320:             default:
1321:                 return null;
1322:                 break;
1323:         } // switch()
1324:     }
1325: 
1326:     /**
1327:      * Exports the object as an array.
1328:      *
1329:      * You can specify the key type of the array by passing one of the class
1330:      * type constants.
1331:      *
1332:      * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1333:      *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1334:      *                    Defaults to BasePeer::TYPE_PHPNAME.
1335:      * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
1336:      * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
1337:      * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
1338:      *
1339:      * @return array an associative array containing the field names (as keys) and field values
1340:      */
1341:     public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
1342:     {
1343:         if (isset($alreadyDumpedObjects['Cvterm'][$this->getPrimaryKey()])) {
1344:             return '*RECURSION*';
1345:         }
1346:         $alreadyDumpedObjects['Cvterm'][$this->getPrimaryKey()] = true;
1347:         $keys = CvtermPeer::getFieldNames($keyType);
1348:         $result = array(
1349:             $keys[0] => $this->getCvtermId(),
1350:             $keys[1] => $this->getCvId(),
1351:             $keys[2] => $this->getName(),
1352:             $keys[3] => $this->getDefinition(),
1353:             $keys[4] => $this->getDbxrefId(),
1354:             $keys[5] => $this->getIsObsolete(),
1355:             $keys[6] => $this->getIsRelationshiptype(),
1356:         );
1357:         if ($includeForeignObjects) {
1358:             if (null !== $this->aCv) {
1359:                 $result['Cv'] = $this->aCv->toArray($keyType, $includeLazyLoadColumns,  $alreadyDumpedObjects, true);
1360:             }
1361:             if (null !== $this->collBiomaterialRelationships) {
1362:                 $result['BiomaterialRelationships'] = $this->collBiomaterialRelationships->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1363:             }
1364:             if (null !== $this->collBiomaterialprops) {
1365:                 $result['Biomaterialprops'] = $this->collBiomaterialprops->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1366:             }
1367:             if (null !== $this->collContacts) {
1368:                 $result['Contacts'] = $this->collContacts->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1369:             }
1370:             if (null !== $this->collFeatures) {
1371:                 $result['Features'] = $this->collFeatures->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1372:             }
1373:             if (null !== $this->collFeatureCvterms) {
1374:                 $result['FeatureCvterms'] = $this->collFeatureCvterms->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1375:             }
1376:             if (null !== $this->collFeatureCvtermprops) {
1377:                 $result['FeatureCvtermprops'] = $this->collFeatureCvtermprops->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1378:             }
1379:             if (null !== $this->collProtocols) {
1380:                 $result['Protocols'] = $this->collProtocols->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1381:             }
1382:             if (null !== $this->collPubs) {
1383:                 $result['Pubs'] = $this->collPubs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1384:             }
1385:             if (null !== $this->collPubRelationships) {
1386:                 $result['PubRelationships'] = $this->collPubRelationships->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1387:             }
1388:             if (null !== $this->collPubprops) {
1389:                 $result['Pubprops'] = $this->collPubprops->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1390:             }
1391:             if (null !== $this->collSynonyms) {
1392:                 $result['Synonyms'] = $this->collSynonyms->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
1393:             }
1394:         }
1395: 
1396:         return $result;
1397:     }
1398: 
1399:     /**
1400:      * Sets a field from the object by name passed in as a string.
1401:      *
1402:      * @param string $name peer name
1403:      * @param mixed $value field value
1404:      * @param string $type The type of fieldname the $name is of:
1405:      *                     one of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
1406:      *                     BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1407:      *                     Defaults to BasePeer::TYPE_PHPNAME
1408:      * @return void
1409:      */
1410:     public function setByName($name, $value, $type = BasePeer::TYPE_PHPNAME)
1411:     {
1412:         $pos = CvtermPeer::translateFieldName($name, $type, BasePeer::TYPE_NUM);
1413: 
1414:         $this->setByPosition($pos, $value);
1415:     }
1416: 
1417:     /**
1418:      * Sets a field from the object by Position as specified in the xml schema.
1419:      * Zero-based.
1420:      *
1421:      * @param int $pos position in xml schema
1422:      * @param mixed $value field value
1423:      * @return void
1424:      */
1425:     public function setByPosition($pos, $value)
1426:     {
1427:         switch ($pos) {
1428:             case 0:
1429:                 $this->setCvtermId($value);
1430:                 break;
1431:             case 1:
1432:                 $this->setCvId($value);
1433:                 break;
1434:             case 2:
1435:                 $this->setName($value);
1436:                 break;
1437:             case 3:
1438:                 $this->setDefinition($value);
1439:                 break;
1440:             case 4:
1441:                 $this->setDbxrefId($value);
1442:                 break;
1443:             case 5:
1444:                 $this->setIsObsolete($value);
1445:                 break;
1446:             case 6:
1447:                 $this->setIsRelationshiptype($value);
1448:                 break;
1449:         } // switch()
1450:     }
1451: 
1452:     /**
1453:      * Populates the object using an array.
1454:      *
1455:      * This is particularly useful when populating an object from one of the
1456:      * request arrays (e.g. $_POST).  This method goes through the column
1457:      * names, checking to see whether a matching key exists in populated
1458:      * array. If so the setByName() method is called for that column.
1459:      *
1460:      * You can specify the key type of the array by additionally passing one
1461:      * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
1462:      * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
1463:      * The default key type is the column's BasePeer::TYPE_PHPNAME
1464:      *
1465:      * @param array  $arr     An array to populate the object from.
1466:      * @param string $keyType The type of keys the array uses.
1467:      * @return void
1468:      */
1469:     public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
1470:     {
1471:         $keys = CvtermPeer::getFieldNames($keyType);
1472: 
1473:         if (array_key_exists($keys[0], $arr)) $this->setCvtermId($arr[$keys[0]]);
1474:         if (array_key_exists($keys[1], $arr)) $this->setCvId($arr[$keys[1]]);
1475:         if (array_key_exists($keys[2], $arr)) $this->setName($arr[$keys[2]]);
1476:         if (array_key_exists($keys[3], $arr)) $this->setDefinition($arr[$keys[3]]);
1477:         if (array_key_exists($keys[4], $arr)) $this->setDbxrefId($arr[$keys[4]]);
1478:         if (array_key_exists($keys[5], $arr)) $this->setIsObsolete($arr[$keys[5]]);
1479:         if (array_key_exists($keys[6], $arr)) $this->setIsRelationshiptype($arr[$keys[6]]);
1480:     }
1481: 
1482:     /**
1483:      * Build a Criteria object containing the values of all modified columns in this object.
1484:      *
1485:      * @return Criteria The Criteria object containing all modified values.
1486:      */
1487:     public function buildCriteria()
1488:     {
1489:         $criteria = new Criteria(CvtermPeer::DATABASE_NAME);
1490: 
1491:         if ($this->isColumnModified(CvtermPeer::CVTERM_ID)) $criteria->add(CvtermPeer::CVTERM_ID, $this->cvterm_id);
1492:         if ($this->isColumnModified(CvtermPeer::CV_ID)) $criteria->add(CvtermPeer::CV_ID, $this->cv_id);
1493:         if ($this->isColumnModified(CvtermPeer::NAME)) $criteria->add(CvtermPeer::NAME, $this->name);
1494:         if ($this->isColumnModified(CvtermPeer::DEFINITION)) $criteria->add(CvtermPeer::DEFINITION, $this->definition);
1495:         if ($this->isColumnModified(CvtermPeer::DBXREF_ID)) $criteria->add(CvtermPeer::DBXREF_ID, $this->dbxref_id);
1496:         if ($this->isColumnModified(CvtermPeer::IS_OBSOLETE)) $criteria->add(CvtermPeer::IS_OBSOLETE, $this->is_obsolete);
1497:         if ($this->isColumnModified(CvtermPeer::IS_RELATIONSHIPTYPE)) $criteria->add(CvtermPeer::IS_RELATIONSHIPTYPE, $this->is_relationshiptype);
1498: 
1499:         return $criteria;
1500:     }
1501: 
1502:     /**
1503:      * Builds a Criteria object containing the primary key for this object.
1504:      *
1505:      * Unlike buildCriteria() this method includes the primary key values regardless
1506:      * of whether or not they have been modified.
1507:      *
1508:      * @return Criteria The Criteria object containing value(s) for primary key(s).
1509:      */
1510:     public function buildPkeyCriteria()
1511:     {
1512:         $criteria = new Criteria(CvtermPeer::DATABASE_NAME);
1513:         $criteria->add(CvtermPeer::CVTERM_ID, $this->cvterm_id);
1514: 
1515:         return $criteria;
1516:     }
1517: 
1518:     /**
1519:      * Returns the primary key for this object (row).
1520:      * @return int
1521:      */
1522:     public function getPrimaryKey()
1523:     {
1524:         return $this->getCvtermId();
1525:     }
1526: 
1527:     /**
1528:      * Generic method to set the primary key (cvterm_id column).
1529:      *
1530:      * @param  int $key Primary key.
1531:      * @return void
1532:      */
1533:     public function setPrimaryKey($key)
1534:     {
1535:         $this->setCvtermId($key);
1536:     }
1537: 
1538:     /**
1539:      * Returns true if the primary key for this object is null.
1540:      * @return boolean
1541:      */
1542:     public function isPrimaryKeyNull()
1543:     {
1544: 
1545:         return null === $this->getCvtermId();
1546:     }
1547: 
1548:     /**
1549:      * Sets contents of passed object to values from current object.
1550:      *
1551:      * If desired, this method can also make copies of all associated (fkey referrers)
1552:      * objects.
1553:      *
1554:      * @param object $copyObj An object of Cvterm (or compatible) type.
1555:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1556:      * @param boolean $makeNew Whether to reset autoincrement PKs and make the object new.
1557:      * @throws PropelException
1558:      */
1559:     public function copyInto($copyObj, $deepCopy = false, $makeNew = true)
1560:     {
1561:         $copyObj->setCvId($this->getCvId());
1562:         $copyObj->setName($this->getName());
1563:         $copyObj->setDefinition($this->getDefinition());
1564:         $copyObj->setDbxrefId($this->getDbxrefId());
1565:         $copyObj->setIsObsolete($this->getIsObsolete());
1566:         $copyObj->setIsRelationshiptype($this->getIsRelationshiptype());
1567: 
1568:         if ($deepCopy && !$this->startCopy) {
1569:             // important: temporarily setNew(false) because this affects the behavior of
1570:             // the getter/setter methods for fkey referrer objects.
1571:             $copyObj->setNew(false);
1572:             // store object hash to prevent cycle
1573:             $this->startCopy = true;
1574: 
1575:             foreach ($this->getBiomaterialRelationships() as $relObj) {
1576:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1577:                     $copyObj->addBiomaterialRelationship($relObj->copy($deepCopy));
1578:                 }
1579:             }
1580: 
1581:             foreach ($this->getBiomaterialprops() as $relObj) {
1582:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1583:                     $copyObj->addBiomaterialprop($relObj->copy($deepCopy));
1584:                 }
1585:             }
1586: 
1587:             foreach ($this->getContacts() as $relObj) {
1588:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1589:                     $copyObj->addContact($relObj->copy($deepCopy));
1590:                 }
1591:             }
1592: 
1593:             foreach ($this->getFeatures() as $relObj) {
1594:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1595:                     $copyObj->addFeature($relObj->copy($deepCopy));
1596:                 }
1597:             }
1598: 
1599:             foreach ($this->getFeatureCvterms() as $relObj) {
1600:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1601:                     $copyObj->addFeatureCvterm($relObj->copy($deepCopy));
1602:                 }
1603:             }
1604: 
1605:             foreach ($this->getFeatureCvtermprops() as $relObj) {
1606:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1607:                     $copyObj->addFeatureCvtermprop($relObj->copy($deepCopy));
1608:                 }
1609:             }
1610: 
1611:             foreach ($this->getProtocols() as $relObj) {
1612:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1613:                     $copyObj->addProtocol($relObj->copy($deepCopy));
1614:                 }
1615:             }
1616: 
1617:             foreach ($this->getPubs() as $relObj) {
1618:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1619:                     $copyObj->addPub($relObj->copy($deepCopy));
1620:                 }
1621:             }
1622: 
1623:             foreach ($this->getPubRelationships() as $relObj) {
1624:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1625:                     $copyObj->addPubRelationship($relObj->copy($deepCopy));
1626:                 }
1627:             }
1628: 
1629:             foreach ($this->getPubprops() as $relObj) {
1630:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1631:                     $copyObj->addPubprop($relObj->copy($deepCopy));
1632:                 }
1633:             }
1634: 
1635:             foreach ($this->getSynonyms() as $relObj) {
1636:                 if ($relObj !== $this) {  // ensure that we don't try to copy a reference to ourselves
1637:                     $copyObj->addSynonym($relObj->copy($deepCopy));
1638:                 }
1639:             }
1640: 
1641:             //unflag object copy
1642:             $this->startCopy = false;
1643:         } // if ($deepCopy)
1644: 
1645:         if ($makeNew) {
1646:             $copyObj->setNew(true);
1647:             $copyObj->setCvtermId(NULL); // this is a auto-increment column, so set to default value
1648:         }
1649:     }
1650: 
1651:     /**
1652:      * Makes a copy of this object that will be inserted as a new row in table when saved.
1653:      * It creates a new object filling in the simple attributes, but skipping any primary
1654:      * keys that are defined for the table.
1655:      *
1656:      * If desired, this method can also make copies of all associated (fkey referrers)
1657:      * objects.
1658:      *
1659:      * @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
1660:      * @return Cvterm Clone of current object.
1661:      * @throws PropelException
1662:      */
1663:     public function copy($deepCopy = false)
1664:     {
1665:         // we use get_class(), because this might be a subclass
1666:         $clazz = get_class($this);
1667:         $copyObj = new $clazz();
1668:         $this->copyInto($copyObj, $deepCopy);
1669: 
1670:         return $copyObj;
1671:     }
1672: 
1673:     /**
1674:      * Returns a peer instance associated with this om.
1675:      *
1676:      * Since Peer classes are not to have any instance attributes, this method returns the
1677:      * same instance for all member of this class. The method could therefore
1678:      * be static, but this would prevent one from overriding the behavior.
1679:      *
1680:      * @return CvtermPeer
1681:      */
1682:     public function getPeer()
1683:     {
1684:         if (self::$peer === null) {
1685:             self::$peer = new CvtermPeer();
1686:         }
1687: 
1688:         return self::$peer;
1689:     }
1690: 
1691:     /**
1692:      * Declares an association between this object and a Cv object.
1693:      *
1694:      * @param             Cv $v
1695:      * @return Cvterm The current object (for fluent API support)
1696:      * @throws PropelException
1697:      */
1698:     public function setCv(Cv $v = null)
1699:     {
1700:         if ($v === null) {
1701:             $this->setCvId(NULL);
1702:         } else {
1703:             $this->setCvId($v->getCvId());
1704:         }
1705: 
1706:         $this->aCv = $v;
1707: 
1708:         // Add binding for other direction of this n:n relationship.
1709:         // If this object has already been added to the Cv object, it will not be re-added.
1710:         if ($v !== null) {
1711:             $v->addCvterm($this);
1712:         }
1713: 
1714: 
1715:         return $this;
1716:     }
1717: 
1718: 
1719:     /**
1720:      * Get the associated Cv object
1721:      *
1722:      * @param PropelPDO $con Optional Connection object.
1723:      * @param $doQuery Executes a query to get the object if required
1724:      * @return Cv The associated Cv object.
1725:      * @throws PropelException
1726:      */
1727:     public function getCv(PropelPDO $con = null, $doQuery = true)
1728:     {
1729:         if ($this->aCv === null && ($this->cv_id !== null) && $doQuery) {
1730:             $this->aCv = CvQuery::create()->findPk($this->cv_id, $con);
1731:             /* The following can be used additionally to
1732:                 guarantee the related object contains a reference
1733:                 to this object.  This level of coupling may, however, be
1734:                 undesirable since it could result in an only partially populated collection
1735:                 in the referenced object.
1736:                 $this->aCv->addCvterms($this);
1737:              */
1738:         }
1739: 
1740:         return $this->aCv;
1741:     }
1742: 
1743: 
1744:     /**
1745:      * Initializes a collection based on the name of a relation.
1746:      * Avoids crafting an 'init[$relationName]s' method name
1747:      * that wouldn't work when StandardEnglishPluralizer is used.
1748:      *
1749:      * @param string $relationName The name of the relation to initialize
1750:      * @return void
1751:      */
1752:     public function initRelation($relationName)
1753:     {
1754:         if ('BiomaterialRelationship' == $relationName) {
1755:             $this->initBiomaterialRelationships();
1756:         }
1757:         if ('Biomaterialprop' == $relationName) {
1758:             $this->initBiomaterialprops();
1759:         }
1760:         if ('Contact' == $relationName) {
1761:             $this->initContacts();
1762:         }
1763:         if ('Feature' == $relationName) {
1764:             $this->initFeatures();
1765:         }
1766:         if ('FeatureCvterm' == $relationName) {
1767:             $this->initFeatureCvterms();
1768:         }
1769:         if ('FeatureCvtermprop' == $relationName) {
1770:             $this->initFeatureCvtermprops();
1771:         }
1772:         if ('Protocol' == $relationName) {
1773:             $this->initProtocols();
1774:         }
1775:         if ('Pub' == $relationName) {
1776:             $this->initPubs();
1777:         }
1778:         if ('PubRelationship' == $relationName) {
1779:             $this->initPubRelationships();
1780:         }
1781:         if ('Pubprop' == $relationName) {
1782:             $this->initPubprops();
1783:         }
1784:         if ('Synonym' == $relationName) {
1785:             $this->initSynonyms();
1786:         }
1787:     }
1788: 
1789:     /**
1790:      * Clears out the collBiomaterialRelationships collection
1791:      *
1792:      * This does not modify the database; however, it will remove any associated objects, causing
1793:      * them to be refetched by subsequent calls to accessor method.
1794:      *
1795:      * @return Cvterm The current object (for fluent API support)
1796:      * @see        addBiomaterialRelationships()
1797:      */
1798:     public function clearBiomaterialRelationships()
1799:     {
1800:         $this->collBiomaterialRelationships = null; // important to set this to null since that means it is uninitialized
1801:         $this->collBiomaterialRelationshipsPartial = null;
1802: 
1803:         return $this;
1804:     }
1805: 
1806:     /**
1807:      * reset is the collBiomaterialRelationships collection loaded partially
1808:      *
1809:      * @return void
1810:      */
1811:     public function resetPartialBiomaterialRelationships($v = true)
1812:     {
1813:         $this->collBiomaterialRelationshipsPartial = $v;
1814:     }
1815: 
1816:     /**
1817:      * Initializes the collBiomaterialRelationships collection.
1818:      *
1819:      * By default this just sets the collBiomaterialRelationships collection to an empty array (like clearcollBiomaterialRelationships());
1820:      * however, you may wish to override this method in your stub class to provide setting appropriate
1821:      * to your application -- for example, setting the initial array to the values stored in database.
1822:      *
1823:      * @param boolean $overrideExisting If set to true, the method call initializes
1824:      *                                        the collection even if it is not empty
1825:      *
1826:      * @return void
1827:      */
1828:     public function initBiomaterialRelationships($overrideExisting = true)
1829:     {
1830:         if (null !== $this->collBiomaterialRelationships && !$overrideExisting) {
1831:             return;
1832:         }
1833:         $this->collBiomaterialRelationships = new PropelObjectCollection();
1834:         $this->collBiomaterialRelationships->setModel('BiomaterialRelationship');
1835:     }
1836: 
1837:     /**
1838:      * Gets an array of BiomaterialRelationship objects which contain a foreign key that references this object.
1839:      *
1840:      * If the $criteria is not null, it is used to always fetch the results from the database.
1841:      * Otherwise the results are fetched from the database the first time, then cached.
1842:      * Next time the same method is called without $criteria, the cached collection is returned.
1843:      * If this Cvterm is new, it will return
1844:      * an empty collection or the current collection; the criteria is ignored on a new object.
1845:      *
1846:      * @param Criteria $criteria optional Criteria object to narrow the query
1847:      * @param PropelPDO $con optional connection object
1848:      * @return PropelObjectCollection|BiomaterialRelationship[] List of BiomaterialRelationship objects
1849:      * @throws PropelException
1850:      */
1851:     public function getBiomaterialRelationships($criteria = null, PropelPDO $con = null)
1852:     {
1853:         $partial = $this->collBiomaterialRelationshipsPartial && !$this->isNew();
1854:         if (null === $this->collBiomaterialRelationships || null !== $criteria  || $partial) {
1855:             if ($this->isNew() && null === $this->collBiomaterialRelationships) {
1856:                 // return empty collection
1857:                 $this->initBiomaterialRelationships();
1858:             } else {
1859:                 $collBiomaterialRelationships = BiomaterialRelationshipQuery::create(null, $criteria)
1860:                     ->filterByCvterm($this)
1861:                     ->find($con);
1862:                 if (null !== $criteria) {
1863:                     if (false !== $this->collBiomaterialRelationshipsPartial && count($collBiomaterialRelationships)) {
1864:                       $this->initBiomaterialRelationships(false);
1865: 
1866:                       foreach($collBiomaterialRelationships as $obj) {
1867:                         if (false == $this->collBiomaterialRelationships->contains($obj)) {
1868:                           $this->collBiomaterialRelationships->append($obj);
1869:                         }
1870:                       }
1871: 
1872:                       $this->collBiomaterialRelationshipsPartial = true;
1873:                     }
1874: 
1875:                     $collBiomaterialRelationships->getInternalIterator()->rewind();
1876:                     return $collBiomaterialRelationships;
1877:                 }
1878: 
1879:                 if($partial && $this->collBiomaterialRelationships) {
1880:                     foreach($this->collBiomaterialRelationships as $obj) {
1881:                         if($obj->isNew()) {
1882:                             $collBiomaterialRelationships[] = $obj;
1883:                         }
1884:                     }
1885:                 }
1886: 
1887:                 $this->collBiomaterialRelationships = $collBiomaterialRelationships;
1888:                 $this->collBiomaterialRelationshipsPartial = false;
1889:             }
1890:         }
1891: 
1892:         return $this->collBiomaterialRelationships;
1893:     }
1894: 
1895:     /**
1896:      * Sets a collection of BiomaterialRelationship objects related by a one-to-many relationship
1897:      * to the current object.
1898:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
1899:      * and new objects from the given Propel collection.
1900:      *
1901:      * @param PropelCollection $biomaterialRelationships A Propel collection.
1902:      * @param PropelPDO $con Optional connection object
1903:      * @return Cvterm The current object (for fluent API support)
1904:      */
1905:     public function setBiomaterialRelationships(PropelCollection $biomaterialRelationships, PropelPDO $con = null)
1906:     {
1907:         $biomaterialRelationshipsToDelete = $this->getBiomaterialRelationships(new Criteria(), $con)->diff($biomaterialRelationships);
1908: 
1909:         $this->biomaterialRelationshipsScheduledForDeletion = unserialize(serialize($biomaterialRelationshipsToDelete));
1910: 
1911:         foreach ($biomaterialRelationshipsToDelete as $biomaterialRelationshipRemoved) {
1912:             $biomaterialRelationshipRemoved->setCvterm(null);
1913:         }
1914: 
1915:         $this->collBiomaterialRelationships = null;
1916:         foreach ($biomaterialRelationships as $biomaterialRelationship) {
1917:             $this->addBiomaterialRelationship($biomaterialRelationship);
1918:         }
1919: 
1920:         $this->collBiomaterialRelationships = $biomaterialRelationships;
1921:         $this->collBiomaterialRelationshipsPartial = false;
1922: 
1923:         return $this;
1924:     }
1925: 
1926:     /**
1927:      * Returns the number of related BiomaterialRelationship objects.
1928:      *
1929:      * @param Criteria $criteria
1930:      * @param boolean $distinct
1931:      * @param PropelPDO $con
1932:      * @return int             Count of related BiomaterialRelationship objects.
1933:      * @throws PropelException
1934:      */
1935:     public function countBiomaterialRelationships(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
1936:     {
1937:         $partial = $this->collBiomaterialRelationshipsPartial && !$this->isNew();
1938:         if (null === $this->collBiomaterialRelationships || null !== $criteria || $partial) {
1939:             if ($this->isNew() && null === $this->collBiomaterialRelationships) {
1940:                 return 0;
1941:             }
1942: 
1943:             if($partial && !$criteria) {
1944:                 return count($this->getBiomaterialRelationships());
1945:             }
1946:             $query = BiomaterialRelationshipQuery::create(null, $criteria);
1947:             if ($distinct) {
1948:                 $query->distinct();
1949:             }
1950: 
1951:             return $query
1952:                 ->filterByCvterm($this)
1953:                 ->count($con);
1954:         }
1955: 
1956:         return count($this->collBiomaterialRelationships);
1957:     }
1958: 
1959:     /**
1960:      * Method called to associate a BiomaterialRelationship object to this object
1961:      * through the BiomaterialRelationship foreign key attribute.
1962:      *
1963:      * @param    BiomaterialRelationship $l BiomaterialRelationship
1964:      * @return Cvterm The current object (for fluent API support)
1965:      */
1966:     public function addBiomaterialRelationship(BiomaterialRelationship $l)
1967:     {
1968:         if ($this->collBiomaterialRelationships === null) {
1969:             $this->initBiomaterialRelationships();
1970:             $this->collBiomaterialRelationshipsPartial = true;
1971:         }
1972:         if (!in_array($l, $this->collBiomaterialRelationships->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
1973:             $this->doAddBiomaterialRelationship($l);
1974:         }
1975: 
1976:         return $this;
1977:     }
1978: 
1979:     /**
1980:      * @param   BiomaterialRelationship $biomaterialRelationship The biomaterialRelationship object to add.
1981:      */
1982:     protected function doAddBiomaterialRelationship($biomaterialRelationship)
1983:     {
1984:         $this->collBiomaterialRelationships[]= $biomaterialRelationship;
1985:         $biomaterialRelationship->setCvterm($this);
1986:     }
1987: 
1988:     /**
1989:      * @param   BiomaterialRelationship $biomaterialRelationship The biomaterialRelationship object to remove.
1990:      * @return Cvterm The current object (for fluent API support)
1991:      */
1992:     public function removeBiomaterialRelationship($biomaterialRelationship)
1993:     {
1994:         if ($this->getBiomaterialRelationships()->contains($biomaterialRelationship)) {
1995:             $this->collBiomaterialRelationships->remove($this->collBiomaterialRelationships->search($biomaterialRelationship));
1996:             if (null === $this->biomaterialRelationshipsScheduledForDeletion) {
1997:                 $this->biomaterialRelationshipsScheduledForDeletion = clone $this->collBiomaterialRelationships;
1998:                 $this->biomaterialRelationshipsScheduledForDeletion->clear();
1999:             }
2000:             $this->biomaterialRelationshipsScheduledForDeletion[]= clone $biomaterialRelationship;
2001:             $biomaterialRelationship->setCvterm(null);
2002:         }
2003: 
2004:         return $this;
2005:     }
2006: 
2007: 
2008:     /**
2009:      * If this collection has already been initialized with
2010:      * an identical criteria, it returns the collection.
2011:      * Otherwise if this Cvterm is new, it will return
2012:      * an empty collection; or if this Cvterm has previously
2013:      * been saved, it will retrieve related BiomaterialRelationships from storage.
2014:      *
2015:      * This method is protected by default in order to keep the public
2016:      * api reasonable.  You can provide public methods for those you
2017:      * actually need in Cvterm.
2018:      *
2019:      * @param Criteria $criteria optional Criteria object to narrow the query
2020:      * @param PropelPDO $con optional connection object
2021:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2022:      * @return PropelObjectCollection|BiomaterialRelationship[] List of BiomaterialRelationship objects
2023:      */
2024:     public function getBiomaterialRelationshipsJoinBiomaterialRelatedByObjectId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2025:     {
2026:         $query = BiomaterialRelationshipQuery::create(null, $criteria);
2027:         $query->joinWith('BiomaterialRelatedByObjectId', $join_behavior);
2028: 
2029:         return $this->getBiomaterialRelationships($query, $con);
2030:     }
2031: 
2032: 
2033:     /**
2034:      * If this collection has already been initialized with
2035:      * an identical criteria, it returns the collection.
2036:      * Otherwise if this Cvterm is new, it will return
2037:      * an empty collection; or if this Cvterm has previously
2038:      * been saved, it will retrieve related BiomaterialRelationships from storage.
2039:      *
2040:      * This method is protected by default in order to keep the public
2041:      * api reasonable.  You can provide public methods for those you
2042:      * actually need in Cvterm.
2043:      *
2044:      * @param Criteria $criteria optional Criteria object to narrow the query
2045:      * @param PropelPDO $con optional connection object
2046:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2047:      * @return PropelObjectCollection|BiomaterialRelationship[] List of BiomaterialRelationship objects
2048:      */
2049:     public function getBiomaterialRelationshipsJoinBiomaterialRelatedBySubjectId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2050:     {
2051:         $query = BiomaterialRelationshipQuery::create(null, $criteria);
2052:         $query->joinWith('BiomaterialRelatedBySubjectId', $join_behavior);
2053: 
2054:         return $this->getBiomaterialRelationships($query, $con);
2055:     }
2056: 
2057:     /**
2058:      * Clears out the collBiomaterialprops collection
2059:      *
2060:      * This does not modify the database; however, it will remove any associated objects, causing
2061:      * them to be refetched by subsequent calls to accessor method.
2062:      *
2063:      * @return Cvterm The current object (for fluent API support)
2064:      * @see        addBiomaterialprops()
2065:      */
2066:     public function clearBiomaterialprops()
2067:     {
2068:         $this->collBiomaterialprops = null; // important to set this to null since that means it is uninitialized
2069:         $this->collBiomaterialpropsPartial = null;
2070: 
2071:         return $this;
2072:     }
2073: 
2074:     /**
2075:      * reset is the collBiomaterialprops collection loaded partially
2076:      *
2077:      * @return void
2078:      */
2079:     public function resetPartialBiomaterialprops($v = true)
2080:     {
2081:         $this->collBiomaterialpropsPartial = $v;
2082:     }
2083: 
2084:     /**
2085:      * Initializes the collBiomaterialprops collection.
2086:      *
2087:      * By default this just sets the collBiomaterialprops collection to an empty array (like clearcollBiomaterialprops());
2088:      * however, you may wish to override this method in your stub class to provide setting appropriate
2089:      * to your application -- for example, setting the initial array to the values stored in database.
2090:      *
2091:      * @param boolean $overrideExisting If set to true, the method call initializes
2092:      *                                        the collection even if it is not empty
2093:      *
2094:      * @return void
2095:      */
2096:     public function initBiomaterialprops($overrideExisting = true)
2097:     {
2098:         if (null !== $this->collBiomaterialprops && !$overrideExisting) {
2099:             return;
2100:         }
2101:         $this->collBiomaterialprops = new PropelObjectCollection();
2102:         $this->collBiomaterialprops->setModel('Biomaterialprop');
2103:     }
2104: 
2105:     /**
2106:      * Gets an array of Biomaterialprop objects which contain a foreign key that references this object.
2107:      *
2108:      * If the $criteria is not null, it is used to always fetch the results from the database.
2109:      * Otherwise the results are fetched from the database the first time, then cached.
2110:      * Next time the same method is called without $criteria, the cached collection is returned.
2111:      * If this Cvterm is new, it will return
2112:      * an empty collection or the current collection; the criteria is ignored on a new object.
2113:      *
2114:      * @param Criteria $criteria optional Criteria object to narrow the query
2115:      * @param PropelPDO $con optional connection object
2116:      * @return PropelObjectCollection|Biomaterialprop[] List of Biomaterialprop objects
2117:      * @throws PropelException
2118:      */
2119:     public function getBiomaterialprops($criteria = null, PropelPDO $con = null)
2120:     {
2121:         $partial = $this->collBiomaterialpropsPartial && !$this->isNew();
2122:         if (null === $this->collBiomaterialprops || null !== $criteria  || $partial) {
2123:             if ($this->isNew() && null === $this->collBiomaterialprops) {
2124:                 // return empty collection
2125:                 $this->initBiomaterialprops();
2126:             } else {
2127:                 $collBiomaterialprops = BiomaterialpropQuery::create(null, $criteria)
2128:                     ->filterByCvterm($this)
2129:                     ->find($con);
2130:                 if (null !== $criteria) {
2131:                     if (false !== $this->collBiomaterialpropsPartial && count($collBiomaterialprops)) {
2132:                       $this->initBiomaterialprops(false);
2133: 
2134:                       foreach($collBiomaterialprops as $obj) {
2135:                         if (false == $this->collBiomaterialprops->contains($obj)) {
2136:                           $this->collBiomaterialprops->append($obj);
2137:                         }
2138:                       }
2139: 
2140:                       $this->collBiomaterialpropsPartial = true;
2141:                     }
2142: 
2143:                     $collBiomaterialprops->getInternalIterator()->rewind();
2144:                     return $collBiomaterialprops;
2145:                 }
2146: 
2147:                 if($partial && $this->collBiomaterialprops) {
2148:                     foreach($this->collBiomaterialprops as $obj) {
2149:                         if($obj->isNew()) {
2150:                             $collBiomaterialprops[] = $obj;
2151:                         }
2152:                     }
2153:                 }
2154: 
2155:                 $this->collBiomaterialprops = $collBiomaterialprops;
2156:                 $this->collBiomaterialpropsPartial = false;
2157:             }
2158:         }
2159: 
2160:         return $this->collBiomaterialprops;
2161:     }
2162: 
2163:     /**
2164:      * Sets a collection of Biomaterialprop objects related by a one-to-many relationship
2165:      * to the current object.
2166:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2167:      * and new objects from the given Propel collection.
2168:      *
2169:      * @param PropelCollection $biomaterialprops A Propel collection.
2170:      * @param PropelPDO $con Optional connection object
2171:      * @return Cvterm The current object (for fluent API support)
2172:      */
2173:     public function setBiomaterialprops(PropelCollection $biomaterialprops, PropelPDO $con = null)
2174:     {
2175:         $biomaterialpropsToDelete = $this->getBiomaterialprops(new Criteria(), $con)->diff($biomaterialprops);
2176: 
2177:         $this->biomaterialpropsScheduledForDeletion = unserialize(serialize($biomaterialpropsToDelete));
2178: 
2179:         foreach ($biomaterialpropsToDelete as $biomaterialpropRemoved) {
2180:             $biomaterialpropRemoved->setCvterm(null);
2181:         }
2182: 
2183:         $this->collBiomaterialprops = null;
2184:         foreach ($biomaterialprops as $biomaterialprop) {
2185:             $this->addBiomaterialprop($biomaterialprop);
2186:         }
2187: 
2188:         $this->collBiomaterialprops = $biomaterialprops;
2189:         $this->collBiomaterialpropsPartial = false;
2190: 
2191:         return $this;
2192:     }
2193: 
2194:     /**
2195:      * Returns the number of related Biomaterialprop objects.
2196:      *
2197:      * @param Criteria $criteria
2198:      * @param boolean $distinct
2199:      * @param PropelPDO $con
2200:      * @return int             Count of related Biomaterialprop objects.
2201:      * @throws PropelException
2202:      */
2203:     public function countBiomaterialprops(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2204:     {
2205:         $partial = $this->collBiomaterialpropsPartial && !$this->isNew();
2206:         if (null === $this->collBiomaterialprops || null !== $criteria || $partial) {
2207:             if ($this->isNew() && null === $this->collBiomaterialprops) {
2208:                 return 0;
2209:             }
2210: 
2211:             if($partial && !$criteria) {
2212:                 return count($this->getBiomaterialprops());
2213:             }
2214:             $query = BiomaterialpropQuery::create(null, $criteria);
2215:             if ($distinct) {
2216:                 $query->distinct();
2217:             }
2218: 
2219:             return $query
2220:                 ->filterByCvterm($this)
2221:                 ->count($con);
2222:         }
2223: 
2224:         return count($this->collBiomaterialprops);
2225:     }
2226: 
2227:     /**
2228:      * Method called to associate a Biomaterialprop object to this object
2229:      * through the Biomaterialprop foreign key attribute.
2230:      *
2231:      * @param    Biomaterialprop $l Biomaterialprop
2232:      * @return Cvterm The current object (for fluent API support)
2233:      */
2234:     public function addBiomaterialprop(Biomaterialprop $l)
2235:     {
2236:         if ($this->collBiomaterialprops === null) {
2237:             $this->initBiomaterialprops();
2238:             $this->collBiomaterialpropsPartial = true;
2239:         }
2240:         if (!in_array($l, $this->collBiomaterialprops->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2241:             $this->doAddBiomaterialprop($l);
2242:         }
2243: 
2244:         return $this;
2245:     }
2246: 
2247:     /**
2248:      * @param   Biomaterialprop $biomaterialprop The biomaterialprop object to add.
2249:      */
2250:     protected function doAddBiomaterialprop($biomaterialprop)
2251:     {
2252:         $this->collBiomaterialprops[]= $biomaterialprop;
2253:         $biomaterialprop->setCvterm($this);
2254:     }
2255: 
2256:     /**
2257:      * @param   Biomaterialprop $biomaterialprop The biomaterialprop object to remove.
2258:      * @return Cvterm The current object (for fluent API support)
2259:      */
2260:     public function removeBiomaterialprop($biomaterialprop)
2261:     {
2262:         if ($this->getBiomaterialprops()->contains($biomaterialprop)) {
2263:             $this->collBiomaterialprops->remove($this->collBiomaterialprops->search($biomaterialprop));
2264:             if (null === $this->biomaterialpropsScheduledForDeletion) {
2265:                 $this->biomaterialpropsScheduledForDeletion = clone $this->collBiomaterialprops;
2266:                 $this->biomaterialpropsScheduledForDeletion->clear();
2267:             }
2268:             $this->biomaterialpropsScheduledForDeletion[]= clone $biomaterialprop;
2269:             $biomaterialprop->setCvterm(null);
2270:         }
2271: 
2272:         return $this;
2273:     }
2274: 
2275: 
2276:     /**
2277:      * If this collection has already been initialized with
2278:      * an identical criteria, it returns the collection.
2279:      * Otherwise if this Cvterm is new, it will return
2280:      * an empty collection; or if this Cvterm has previously
2281:      * been saved, it will retrieve related Biomaterialprops from storage.
2282:      *
2283:      * This method is protected by default in order to keep the public
2284:      * api reasonable.  You can provide public methods for those you
2285:      * actually need in Cvterm.
2286:      *
2287:      * @param Criteria $criteria optional Criteria object to narrow the query
2288:      * @param PropelPDO $con optional connection object
2289:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2290:      * @return PropelObjectCollection|Biomaterialprop[] List of Biomaterialprop objects
2291:      */
2292:     public function getBiomaterialpropsJoinBiomaterial($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2293:     {
2294:         $query = BiomaterialpropQuery::create(null, $criteria);
2295:         $query->joinWith('Biomaterial', $join_behavior);
2296: 
2297:         return $this->getBiomaterialprops($query, $con);
2298:     }
2299: 
2300:     /**
2301:      * Clears out the collContacts collection
2302:      *
2303:      * This does not modify the database; however, it will remove any associated objects, causing
2304:      * them to be refetched by subsequent calls to accessor method.
2305:      *
2306:      * @return Cvterm The current object (for fluent API support)
2307:      * @see        addContacts()
2308:      */
2309:     public function clearContacts()
2310:     {
2311:         $this->collContacts = null; // important to set this to null since that means it is uninitialized
2312:         $this->collContactsPartial = null;
2313: 
2314:         return $this;
2315:     }
2316: 
2317:     /**
2318:      * reset is the collContacts collection loaded partially
2319:      *
2320:      * @return void
2321:      */
2322:     public function resetPartialContacts($v = true)
2323:     {
2324:         $this->collContactsPartial = $v;
2325:     }
2326: 
2327:     /**
2328:      * Initializes the collContacts collection.
2329:      *
2330:      * By default this just sets the collContacts collection to an empty array (like clearcollContacts());
2331:      * however, you may wish to override this method in your stub class to provide setting appropriate
2332:      * to your application -- for example, setting the initial array to the values stored in database.
2333:      *
2334:      * @param boolean $overrideExisting If set to true, the method call initializes
2335:      *                                        the collection even if it is not empty
2336:      *
2337:      * @return void
2338:      */
2339:     public function initContacts($overrideExisting = true)
2340:     {
2341:         if (null !== $this->collContacts && !$overrideExisting) {
2342:             return;
2343:         }
2344:         $this->collContacts = new PropelObjectCollection();
2345:         $this->collContacts->setModel('Contact');
2346:     }
2347: 
2348:     /**
2349:      * Gets an array of Contact objects which contain a foreign key that references this object.
2350:      *
2351:      * If the $criteria is not null, it is used to always fetch the results from the database.
2352:      * Otherwise the results are fetched from the database the first time, then cached.
2353:      * Next time the same method is called without $criteria, the cached collection is returned.
2354:      * If this Cvterm is new, it will return
2355:      * an empty collection or the current collection; the criteria is ignored on a new object.
2356:      *
2357:      * @param Criteria $criteria optional Criteria object to narrow the query
2358:      * @param PropelPDO $con optional connection object
2359:      * @return PropelObjectCollection|Contact[] List of Contact objects
2360:      * @throws PropelException
2361:      */
2362:     public function getContacts($criteria = null, PropelPDO $con = null)
2363:     {
2364:         $partial = $this->collContactsPartial && !$this->isNew();
2365:         if (null === $this->collContacts || null !== $criteria  || $partial) {
2366:             if ($this->isNew() && null === $this->collContacts) {
2367:                 // return empty collection
2368:                 $this->initContacts();
2369:             } else {
2370:                 $collContacts = ContactQuery::create(null, $criteria)
2371:                     ->filterByCvterm($this)
2372:                     ->find($con);
2373:                 if (null !== $criteria) {
2374:                     if (false !== $this->collContactsPartial && count($collContacts)) {
2375:                       $this->initContacts(false);
2376: 
2377:                       foreach($collContacts as $obj) {
2378:                         if (false == $this->collContacts->contains($obj)) {
2379:                           $this->collContacts->append($obj);
2380:                         }
2381:                       }
2382: 
2383:                       $this->collContactsPartial = true;
2384:                     }
2385: 
2386:                     $collContacts->getInternalIterator()->rewind();
2387:                     return $collContacts;
2388:                 }
2389: 
2390:                 if($partial && $this->collContacts) {
2391:                     foreach($this->collContacts as $obj) {
2392:                         if($obj->isNew()) {
2393:                             $collContacts[] = $obj;
2394:                         }
2395:                     }
2396:                 }
2397: 
2398:                 $this->collContacts = $collContacts;
2399:                 $this->collContactsPartial = false;
2400:             }
2401:         }
2402: 
2403:         return $this->collContacts;
2404:     }
2405: 
2406:     /**
2407:      * Sets a collection of Contact objects related by a one-to-many relationship
2408:      * to the current object.
2409:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2410:      * and new objects from the given Propel collection.
2411:      *
2412:      * @param PropelCollection $contacts A Propel collection.
2413:      * @param PropelPDO $con Optional connection object
2414:      * @return Cvterm The current object (for fluent API support)
2415:      */
2416:     public function setContacts(PropelCollection $contacts, PropelPDO $con = null)
2417:     {
2418:         $contactsToDelete = $this->getContacts(new Criteria(), $con)->diff($contacts);
2419: 
2420:         $this->contactsScheduledForDeletion = unserialize(serialize($contactsToDelete));
2421: 
2422:         foreach ($contactsToDelete as $contactRemoved) {
2423:             $contactRemoved->setCvterm(null);
2424:         }
2425: 
2426:         $this->collContacts = null;
2427:         foreach ($contacts as $contact) {
2428:             $this->addContact($contact);
2429:         }
2430: 
2431:         $this->collContacts = $contacts;
2432:         $this->collContactsPartial = false;
2433: 
2434:         return $this;
2435:     }
2436: 
2437:     /**
2438:      * Returns the number of related Contact objects.
2439:      *
2440:      * @param Criteria $criteria
2441:      * @param boolean $distinct
2442:      * @param PropelPDO $con
2443:      * @return int             Count of related Contact objects.
2444:      * @throws PropelException
2445:      */
2446:     public function countContacts(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2447:     {
2448:         $partial = $this->collContactsPartial && !$this->isNew();
2449:         if (null === $this->collContacts || null !== $criteria || $partial) {
2450:             if ($this->isNew() && null === $this->collContacts) {
2451:                 return 0;
2452:             }
2453: 
2454:             if($partial && !$criteria) {
2455:                 return count($this->getContacts());
2456:             }
2457:             $query = ContactQuery::create(null, $criteria);
2458:             if ($distinct) {
2459:                 $query->distinct();
2460:             }
2461: 
2462:             return $query
2463:                 ->filterByCvterm($this)
2464:                 ->count($con);
2465:         }
2466: 
2467:         return count($this->collContacts);
2468:     }
2469: 
2470:     /**
2471:      * Method called to associate a Contact object to this object
2472:      * through the Contact foreign key attribute.
2473:      *
2474:      * @param    Contact $l Contact
2475:      * @return Cvterm The current object (for fluent API support)
2476:      */
2477:     public function addContact(Contact $l)
2478:     {
2479:         if ($this->collContacts === null) {
2480:             $this->initContacts();
2481:             $this->collContactsPartial = true;
2482:         }
2483:         if (!in_array($l, $this->collContacts->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2484:             $this->doAddContact($l);
2485:         }
2486: 
2487:         return $this;
2488:     }
2489: 
2490:     /**
2491:      * @param   Contact $contact The contact object to add.
2492:      */
2493:     protected function doAddContact($contact)
2494:     {
2495:         $this->collContacts[]= $contact;
2496:         $contact->setCvterm($this);
2497:     }
2498: 
2499:     /**
2500:      * @param   Contact $contact The contact object to remove.
2501:      * @return Cvterm The current object (for fluent API support)
2502:      */
2503:     public function removeContact($contact)
2504:     {
2505:         if ($this->getContacts()->contains($contact)) {
2506:             $this->collContacts->remove($this->collContacts->search($contact));
2507:             if (null === $this->contactsScheduledForDeletion) {
2508:                 $this->contactsScheduledForDeletion = clone $this->collContacts;
2509:                 $this->contactsScheduledForDeletion->clear();
2510:             }
2511:             $this->contactsScheduledForDeletion[]= $contact;
2512:             $contact->setCvterm(null);
2513:         }
2514: 
2515:         return $this;
2516:     }
2517: 
2518:     /**
2519:      * Clears out the collFeatures collection
2520:      *
2521:      * This does not modify the database; however, it will remove any associated objects, causing
2522:      * them to be refetched by subsequent calls to accessor method.
2523:      *
2524:      * @return Cvterm The current object (for fluent API support)
2525:      * @see        addFeatures()
2526:      */
2527:     public function clearFeatures()
2528:     {
2529:         $this->collFeatures = null; // important to set this to null since that means it is uninitialized
2530:         $this->collFeaturesPartial = null;
2531: 
2532:         return $this;
2533:     }
2534: 
2535:     /**
2536:      * reset is the collFeatures collection loaded partially
2537:      *
2538:      * @return void
2539:      */
2540:     public function resetPartialFeatures($v = true)
2541:     {
2542:         $this->collFeaturesPartial = $v;
2543:     }
2544: 
2545:     /**
2546:      * Initializes the collFeatures collection.
2547:      *
2548:      * By default this just sets the collFeatures collection to an empty array (like clearcollFeatures());
2549:      * however, you may wish to override this method in your stub class to provide setting appropriate
2550:      * to your application -- for example, setting the initial array to the values stored in database.
2551:      *
2552:      * @param boolean $overrideExisting If set to true, the method call initializes
2553:      *                                        the collection even if it is not empty
2554:      *
2555:      * @return void
2556:      */
2557:     public function initFeatures($overrideExisting = true)
2558:     {
2559:         if (null !== $this->collFeatures && !$overrideExisting) {
2560:             return;
2561:         }
2562:         $this->collFeatures = new PropelObjectCollection();
2563:         $this->collFeatures->setModel('Feature');
2564:     }
2565: 
2566:     /**
2567:      * Gets an array of Feature objects which contain a foreign key that references this object.
2568:      *
2569:      * If the $criteria is not null, it is used to always fetch the results from the database.
2570:      * Otherwise the results are fetched from the database the first time, then cached.
2571:      * Next time the same method is called without $criteria, the cached collection is returned.
2572:      * If this Cvterm is new, it will return
2573:      * an empty collection or the current collection; the criteria is ignored on a new object.
2574:      *
2575:      * @param Criteria $criteria optional Criteria object to narrow the query
2576:      * @param PropelPDO $con optional connection object
2577:      * @return PropelObjectCollection|Feature[] List of Feature objects
2578:      * @throws PropelException
2579:      */
2580:     public function getFeatures($criteria = null, PropelPDO $con = null)
2581:     {
2582:         $partial = $this->collFeaturesPartial && !$this->isNew();
2583:         if (null === $this->collFeatures || null !== $criteria  || $partial) {
2584:             if ($this->isNew() && null === $this->collFeatures) {
2585:                 // return empty collection
2586:                 $this->initFeatures();
2587:             } else {
2588:                 $collFeatures = FeatureQuery::create(null, $criteria)
2589:                     ->filterByCvterm($this)
2590:                     ->find($con);
2591:                 if (null !== $criteria) {
2592:                     if (false !== $this->collFeaturesPartial && count($collFeatures)) {
2593:                       $this->initFeatures(false);
2594: 
2595:                       foreach($collFeatures as $obj) {
2596:                         if (false == $this->collFeatures->contains($obj)) {
2597:                           $this->collFeatures->append($obj);
2598:                         }
2599:                       }
2600: 
2601:                       $this->collFeaturesPartial = true;
2602:                     }
2603: 
2604:                     $collFeatures->getInternalIterator()->rewind();
2605:                     return $collFeatures;
2606:                 }
2607: 
2608:                 if($partial && $this->collFeatures) {
2609:                     foreach($this->collFeatures as $obj) {
2610:                         if($obj->isNew()) {
2611:                             $collFeatures[] = $obj;
2612:                         }
2613:                     }
2614:                 }
2615: 
2616:                 $this->collFeatures = $collFeatures;
2617:                 $this->collFeaturesPartial = false;
2618:             }
2619:         }
2620: 
2621:         return $this->collFeatures;
2622:     }
2623: 
2624:     /**
2625:      * Sets a collection of Feature objects related by a one-to-many relationship
2626:      * to the current object.
2627:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2628:      * and new objects from the given Propel collection.
2629:      *
2630:      * @param PropelCollection $features A Propel collection.
2631:      * @param PropelPDO $con Optional connection object
2632:      * @return Cvterm The current object (for fluent API support)
2633:      */
2634:     public function setFeatures(PropelCollection $features, PropelPDO $con = null)
2635:     {
2636:         $featuresToDelete = $this->getFeatures(new Criteria(), $con)->diff($features);
2637: 
2638:         $this->featuresScheduledForDeletion = unserialize(serialize($featuresToDelete));
2639: 
2640:         foreach ($featuresToDelete as $featureRemoved) {
2641:             $featureRemoved->setCvterm(null);
2642:         }
2643: 
2644:         $this->collFeatures = null;
2645:         foreach ($features as $feature) {
2646:             $this->addFeature($feature);
2647:         }
2648: 
2649:         $this->collFeatures = $features;
2650:         $this->collFeaturesPartial = false;
2651: 
2652:         return $this;
2653:     }
2654: 
2655:     /**
2656:      * Returns the number of related Feature objects.
2657:      *
2658:      * @param Criteria $criteria
2659:      * @param boolean $distinct
2660:      * @param PropelPDO $con
2661:      * @return int             Count of related Feature objects.
2662:      * @throws PropelException
2663:      */
2664:     public function countFeatures(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2665:     {
2666:         $partial = $this->collFeaturesPartial && !$this->isNew();
2667:         if (null === $this->collFeatures || null !== $criteria || $partial) {
2668:             if ($this->isNew() && null === $this->collFeatures) {
2669:                 return 0;
2670:             }
2671: 
2672:             if($partial && !$criteria) {
2673:                 return count($this->getFeatures());
2674:             }
2675:             $query = FeatureQuery::create(null, $criteria);
2676:             if ($distinct) {
2677:                 $query->distinct();
2678:             }
2679: 
2680:             return $query
2681:                 ->filterByCvterm($this)
2682:                 ->count($con);
2683:         }
2684: 
2685:         return count($this->collFeatures);
2686:     }
2687: 
2688:     /**
2689:      * Method called to associate a Feature object to this object
2690:      * through the Feature foreign key attribute.
2691:      *
2692:      * @param    Feature $l Feature
2693:      * @return Cvterm The current object (for fluent API support)
2694:      */
2695:     public function addFeature(Feature $l)
2696:     {
2697:         if ($this->collFeatures === null) {
2698:             $this->initFeatures();
2699:             $this->collFeaturesPartial = true;
2700:         }
2701:         if (!in_array($l, $this->collFeatures->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2702:             $this->doAddFeature($l);
2703:         }
2704: 
2705:         return $this;
2706:     }
2707: 
2708:     /**
2709:      * @param   Feature $feature The feature object to add.
2710:      */
2711:     protected function doAddFeature($feature)
2712:     {
2713:         $this->collFeatures[]= $feature;
2714:         $feature->setCvterm($this);
2715:     }
2716: 
2717:     /**
2718:      * @param   Feature $feature The feature object to remove.
2719:      * @return Cvterm The current object (for fluent API support)
2720:      */
2721:     public function removeFeature($feature)
2722:     {
2723:         if ($this->getFeatures()->contains($feature)) {
2724:             $this->collFeatures->remove($this->collFeatures->search($feature));
2725:             if (null === $this->featuresScheduledForDeletion) {
2726:                 $this->featuresScheduledForDeletion = clone $this->collFeatures;
2727:                 $this->featuresScheduledForDeletion->clear();
2728:             }
2729:             $this->featuresScheduledForDeletion[]= clone $feature;
2730:             $feature->setCvterm(null);
2731:         }
2732: 
2733:         return $this;
2734:     }
2735: 
2736: 
2737:     /**
2738:      * If this collection has already been initialized with
2739:      * an identical criteria, it returns the collection.
2740:      * Otherwise if this Cvterm is new, it will return
2741:      * an empty collection; or if this Cvterm has previously
2742:      * been saved, it will retrieve related Features from storage.
2743:      *
2744:      * This method is protected by default in order to keep the public
2745:      * api reasonable.  You can provide public methods for those you
2746:      * actually need in Cvterm.
2747:      *
2748:      * @param Criteria $criteria optional Criteria object to narrow the query
2749:      * @param PropelPDO $con optional connection object
2750:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2751:      * @return PropelObjectCollection|Feature[] List of Feature objects
2752:      */
2753:     public function getFeaturesJoinDbxref($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2754:     {
2755:         $query = FeatureQuery::create(null, $criteria);
2756:         $query->joinWith('Dbxref', $join_behavior);
2757: 
2758:         return $this->getFeatures($query, $con);
2759:     }
2760: 
2761: 
2762:     /**
2763:      * If this collection has already been initialized with
2764:      * an identical criteria, it returns the collection.
2765:      * Otherwise if this Cvterm is new, it will return
2766:      * an empty collection; or if this Cvterm has previously
2767:      * been saved, it will retrieve related Features from storage.
2768:      *
2769:      * This method is protected by default in order to keep the public
2770:      * api reasonable.  You can provide public methods for those you
2771:      * actually need in Cvterm.
2772:      *
2773:      * @param Criteria $criteria optional Criteria object to narrow the query
2774:      * @param PropelPDO $con optional connection object
2775:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
2776:      * @return PropelObjectCollection|Feature[] List of Feature objects
2777:      */
2778:     public function getFeaturesJoinOrganism($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
2779:     {
2780:         $query = FeatureQuery::create(null, $criteria);
2781:         $query->joinWith('Organism', $join_behavior);
2782: 
2783:         return $this->getFeatures($query, $con);
2784:     }
2785: 
2786:     /**
2787:      * Clears out the collFeatureCvterms collection
2788:      *
2789:      * This does not modify the database; however, it will remove any associated objects, causing
2790:      * them to be refetched by subsequent calls to accessor method.
2791:      *
2792:      * @return Cvterm The current object (for fluent API support)
2793:      * @see        addFeatureCvterms()
2794:      */
2795:     public function clearFeatureCvterms()
2796:     {
2797:         $this->collFeatureCvterms = null; // important to set this to null since that means it is uninitialized
2798:         $this->collFeatureCvtermsPartial = null;
2799: 
2800:         return $this;
2801:     }
2802: 
2803:     /**
2804:      * reset is the collFeatureCvterms collection loaded partially
2805:      *
2806:      * @return void
2807:      */
2808:     public function resetPartialFeatureCvterms($v = true)
2809:     {
2810:         $this->collFeatureCvtermsPartial = $v;
2811:     }
2812: 
2813:     /**
2814:      * Initializes the collFeatureCvterms collection.
2815:      *
2816:      * By default this just sets the collFeatureCvterms collection to an empty array (like clearcollFeatureCvterms());
2817:      * however, you may wish to override this method in your stub class to provide setting appropriate
2818:      * to your application -- for example, setting the initial array to the values stored in database.
2819:      *
2820:      * @param boolean $overrideExisting If set to true, the method call initializes
2821:      *                                        the collection even if it is not empty
2822:      *
2823:      * @return void
2824:      */
2825:     public function initFeatureCvterms($overrideExisting = true)
2826:     {
2827:         if (null !== $this->collFeatureCvterms && !$overrideExisting) {
2828:             return;
2829:         }
2830:         $this->collFeatureCvterms = new PropelObjectCollection();
2831:         $this->collFeatureCvterms->setModel('FeatureCvterm');
2832:     }
2833: 
2834:     /**
2835:      * Gets an array of FeatureCvterm objects which contain a foreign key that references this object.
2836:      *
2837:      * If the $criteria is not null, it is used to always fetch the results from the database.
2838:      * Otherwise the results are fetched from the database the first time, then cached.
2839:      * Next time the same method is called without $criteria, the cached collection is returned.
2840:      * If this Cvterm is new, it will return
2841:      * an empty collection or the current collection; the criteria is ignored on a new object.
2842:      *
2843:      * @param Criteria $criteria optional Criteria object to narrow the query
2844:      * @param PropelPDO $con optional connection object
2845:      * @return PropelObjectCollection|FeatureCvterm[] List of FeatureCvterm objects
2846:      * @throws PropelException
2847:      */
2848:     public function getFeatureCvterms($criteria = null, PropelPDO $con = null)
2849:     {
2850:         $partial = $this->collFeatureCvtermsPartial && !$this->isNew();
2851:         if (null === $this->collFeatureCvterms || null !== $criteria  || $partial) {
2852:             if ($this->isNew() && null === $this->collFeatureCvterms) {
2853:                 // return empty collection
2854:                 $this->initFeatureCvterms();
2855:             } else {
2856:                 $collFeatureCvterms = FeatureCvtermQuery::create(null, $criteria)
2857:                     ->filterByCvterm($this)
2858:                     ->find($con);
2859:                 if (null !== $criteria) {
2860:                     if (false !== $this->collFeatureCvtermsPartial && count($collFeatureCvterms)) {
2861:                       $this->initFeatureCvterms(false);
2862: 
2863:                       foreach($collFeatureCvterms as $obj) {
2864:                         if (false == $this->collFeatureCvterms->contains($obj)) {
2865:                           $this->collFeatureCvterms->append($obj);
2866:                         }
2867:                       }
2868: 
2869:                       $this->collFeatureCvtermsPartial = true;
2870:                     }
2871: 
2872:                     $collFeatureCvterms->getInternalIterator()->rewind();
2873:                     return $collFeatureCvterms;
2874:                 }
2875: 
2876:                 if($partial && $this->collFeatureCvterms) {
2877:                     foreach($this->collFeatureCvterms as $obj) {
2878:                         if($obj->isNew()) {
2879:                             $collFeatureCvterms[] = $obj;
2880:                         }
2881:                     }
2882:                 }
2883: 
2884:                 $this->collFeatureCvterms = $collFeatureCvterms;
2885:                 $this->collFeatureCvtermsPartial = false;
2886:             }
2887:         }
2888: 
2889:         return $this->collFeatureCvterms;
2890:     }
2891: 
2892:     /**
2893:      * Sets a collection of FeatureCvterm objects related by a one-to-many relationship
2894:      * to the current object.
2895:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
2896:      * and new objects from the given Propel collection.
2897:      *
2898:      * @param PropelCollection $featureCvterms A Propel collection.
2899:      * @param PropelPDO $con Optional connection object
2900:      * @return Cvterm The current object (for fluent API support)
2901:      */
2902:     public function setFeatureCvterms(PropelCollection $featureCvterms, PropelPDO $con = null)
2903:     {
2904:         $featureCvtermsToDelete = $this->getFeatureCvterms(new Criteria(), $con)->diff($featureCvterms);
2905: 
2906:         $this->featureCvtermsScheduledForDeletion = unserialize(serialize($featureCvtermsToDelete));
2907: 
2908:         foreach ($featureCvtermsToDelete as $featureCvtermRemoved) {
2909:             $featureCvtermRemoved->setCvterm(null);
2910:         }
2911: 
2912:         $this->collFeatureCvterms = null;
2913:         foreach ($featureCvterms as $featureCvterm) {
2914:             $this->addFeatureCvterm($featureCvterm);
2915:         }
2916: 
2917:         $this->collFeatureCvterms = $featureCvterms;
2918:         $this->collFeatureCvtermsPartial = false;
2919: 
2920:         return $this;
2921:     }
2922: 
2923:     /**
2924:      * Returns the number of related FeatureCvterm objects.
2925:      *
2926:      * @param Criteria $criteria
2927:      * @param boolean $distinct
2928:      * @param PropelPDO $con
2929:      * @return int             Count of related FeatureCvterm objects.
2930:      * @throws PropelException
2931:      */
2932:     public function countFeatureCvterms(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
2933:     {
2934:         $partial = $this->collFeatureCvtermsPartial && !$this->isNew();
2935:         if (null === $this->collFeatureCvterms || null !== $criteria || $partial) {
2936:             if ($this->isNew() && null === $this->collFeatureCvterms) {
2937:                 return 0;
2938:             }
2939: 
2940:             if($partial && !$criteria) {
2941:                 return count($this->getFeatureCvterms());
2942:             }
2943:             $query = FeatureCvtermQuery::create(null, $criteria);
2944:             if ($distinct) {
2945:                 $query->distinct();
2946:             }
2947: 
2948:             return $query
2949:                 ->filterByCvterm($this)
2950:                 ->count($con);
2951:         }
2952: 
2953:         return count($this->collFeatureCvterms);
2954:     }
2955: 
2956:     /**
2957:      * Method called to associate a FeatureCvterm object to this object
2958:      * through the FeatureCvterm foreign key attribute.
2959:      *
2960:      * @param    FeatureCvterm $l FeatureCvterm
2961:      * @return Cvterm The current object (for fluent API support)
2962:      */
2963:     public function addFeatureCvterm(FeatureCvterm $l)
2964:     {
2965:         if ($this->collFeatureCvterms === null) {
2966:             $this->initFeatureCvterms();
2967:             $this->collFeatureCvtermsPartial = true;
2968:         }
2969:         if (!in_array($l, $this->collFeatureCvterms->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
2970:             $this->doAddFeatureCvterm($l);
2971:         }
2972: 
2973:         return $this;
2974:     }
2975: 
2976:     /**
2977:      * @param   FeatureCvterm $featureCvterm The featureCvterm object to add.
2978:      */
2979:     protected function doAddFeatureCvterm($featureCvterm)
2980:     {
2981:         $this->collFeatureCvterms[]= $featureCvterm;
2982:         $featureCvterm->setCvterm($this);
2983:     }
2984: 
2985:     /**
2986:      * @param   FeatureCvterm $featureCvterm The featureCvterm object to remove.
2987:      * @return Cvterm The current object (for fluent API support)
2988:      */
2989:     public function removeFeatureCvterm($featureCvterm)
2990:     {
2991:         if ($this->getFeatureCvterms()->contains($featureCvterm)) {
2992:             $this->collFeatureCvterms->remove($this->collFeatureCvterms->search($featureCvterm));
2993:             if (null === $this->featureCvtermsScheduledForDeletion) {
2994:                 $this->featureCvtermsScheduledForDeletion = clone $this->collFeatureCvterms;
2995:                 $this->featureCvtermsScheduledForDeletion->clear();
2996:             }
2997:             $this->featureCvtermsScheduledForDeletion[]= clone $featureCvterm;
2998:             $featureCvterm->setCvterm(null);
2999:         }
3000: 
3001:         return $this;
3002:     }
3003: 
3004: 
3005:     /**
3006:      * If this collection has already been initialized with
3007:      * an identical criteria, it returns the collection.
3008:      * Otherwise if this Cvterm is new, it will return
3009:      * an empty collection; or if this Cvterm has previously
3010:      * been saved, it will retrieve related FeatureCvterms from storage.
3011:      *
3012:      * This method is protected by default in order to keep the public
3013:      * api reasonable.  You can provide public methods for those you
3014:      * actually need in Cvterm.
3015:      *
3016:      * @param Criteria $criteria optional Criteria object to narrow the query
3017:      * @param PropelPDO $con optional connection object
3018:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3019:      * @return PropelObjectCollection|FeatureCvterm[] List of FeatureCvterm objects
3020:      */
3021:     public function getFeatureCvtermsJoinFeature($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3022:     {
3023:         $query = FeatureCvtermQuery::create(null, $criteria);
3024:         $query->joinWith('Feature', $join_behavior);
3025: 
3026:         return $this->getFeatureCvterms($query, $con);
3027:     }
3028: 
3029: 
3030:     /**
3031:      * If this collection has already been initialized with
3032:      * an identical criteria, it returns the collection.
3033:      * Otherwise if this Cvterm is new, it will return
3034:      * an empty collection; or if this Cvterm has previously
3035:      * been saved, it will retrieve related FeatureCvterms from storage.
3036:      *
3037:      * This method is protected by default in order to keep the public
3038:      * api reasonable.  You can provide public methods for those you
3039:      * actually need in Cvterm.
3040:      *
3041:      * @param Criteria $criteria optional Criteria object to narrow the query
3042:      * @param PropelPDO $con optional connection object
3043:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3044:      * @return PropelObjectCollection|FeatureCvterm[] List of FeatureCvterm objects
3045:      */
3046:     public function getFeatureCvtermsJoinPub($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3047:     {
3048:         $query = FeatureCvtermQuery::create(null, $criteria);
3049:         $query->joinWith('Pub', $join_behavior);
3050: 
3051:         return $this->getFeatureCvterms($query, $con);
3052:     }
3053: 
3054:     /**
3055:      * Clears out the collFeatureCvtermprops collection
3056:      *
3057:      * This does not modify the database; however, it will remove any associated objects, causing
3058:      * them to be refetched by subsequent calls to accessor method.
3059:      *
3060:      * @return Cvterm The current object (for fluent API support)
3061:      * @see        addFeatureCvtermprops()
3062:      */
3063:     public function clearFeatureCvtermprops()
3064:     {
3065:         $this->collFeatureCvtermprops = null; // important to set this to null since that means it is uninitialized
3066:         $this->collFeatureCvtermpropsPartial = null;
3067: 
3068:         return $this;
3069:     }
3070: 
3071:     /**
3072:      * reset is the collFeatureCvtermprops collection loaded partially
3073:      *
3074:      * @return void
3075:      */
3076:     public function resetPartialFeatureCvtermprops($v = true)
3077:     {
3078:         $this->collFeatureCvtermpropsPartial = $v;
3079:     }
3080: 
3081:     /**
3082:      * Initializes the collFeatureCvtermprops collection.
3083:      *
3084:      * By default this just sets the collFeatureCvtermprops collection to an empty array (like clearcollFeatureCvtermprops());
3085:      * however, you may wish to override this method in your stub class to provide setting appropriate
3086:      * to your application -- for example, setting the initial array to the values stored in database.
3087:      *
3088:      * @param boolean $overrideExisting If set to true, the method call initializes
3089:      *                                        the collection even if it is not empty
3090:      *
3091:      * @return void
3092:      */
3093:     public function initFeatureCvtermprops($overrideExisting = true)
3094:     {
3095:         if (null !== $this->collFeatureCvtermprops && !$overrideExisting) {
3096:             return;
3097:         }
3098:         $this->collFeatureCvtermprops = new PropelObjectCollection();
3099:         $this->collFeatureCvtermprops->setModel('FeatureCvtermprop');
3100:     }
3101: 
3102:     /**
3103:      * Gets an array of FeatureCvtermprop objects which contain a foreign key that references this object.
3104:      *
3105:      * If the $criteria is not null, it is used to always fetch the results from the database.
3106:      * Otherwise the results are fetched from the database the first time, then cached.
3107:      * Next time the same method is called without $criteria, the cached collection is returned.
3108:      * If this Cvterm is new, it will return
3109:      * an empty collection or the current collection; the criteria is ignored on a new object.
3110:      *
3111:      * @param Criteria $criteria optional Criteria object to narrow the query
3112:      * @param PropelPDO $con optional connection object
3113:      * @return PropelObjectCollection|FeatureCvtermprop[] List of FeatureCvtermprop objects
3114:      * @throws PropelException
3115:      */
3116:     public function getFeatureCvtermprops($criteria = null, PropelPDO $con = null)
3117:     {
3118:         $partial = $this->collFeatureCvtermpropsPartial && !$this->isNew();
3119:         if (null === $this->collFeatureCvtermprops || null !== $criteria  || $partial) {
3120:             if ($this->isNew() && null === $this->collFeatureCvtermprops) {
3121:                 // return empty collection
3122:                 $this->initFeatureCvtermprops();
3123:             } else {
3124:                 $collFeatureCvtermprops = FeatureCvtermpropQuery::create(null, $criteria)
3125:                     ->filterByCvterm($this)
3126:                     ->find($con);
3127:                 if (null !== $criteria) {
3128:                     if (false !== $this->collFeatureCvtermpropsPartial && count($collFeatureCvtermprops)) {
3129:                       $this->initFeatureCvtermprops(false);
3130: 
3131:                       foreach($collFeatureCvtermprops as $obj) {
3132:                         if (false == $this->collFeatureCvtermprops->contains($obj)) {
3133:                           $this->collFeatureCvtermprops->append($obj);
3134:                         }
3135:                       }
3136: 
3137:                       $this->collFeatureCvtermpropsPartial = true;
3138:                     }
3139: 
3140:                     $collFeatureCvtermprops->getInternalIterator()->rewind();
3141:                     return $collFeatureCvtermprops;
3142:                 }
3143: 
3144:                 if($partial && $this->collFeatureCvtermprops) {
3145:                     foreach($this->collFeatureCvtermprops as $obj) {
3146:                         if($obj->isNew()) {
3147:                             $collFeatureCvtermprops[] = $obj;
3148:                         }
3149:                     }
3150:                 }
3151: 
3152:                 $this->collFeatureCvtermprops = $collFeatureCvtermprops;
3153:                 $this->collFeatureCvtermpropsPartial = false;
3154:             }
3155:         }
3156: 
3157:         return $this->collFeatureCvtermprops;
3158:     }
3159: 
3160:     /**
3161:      * Sets a collection of FeatureCvtermprop objects related by a one-to-many relationship
3162:      * to the current object.
3163:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3164:      * and new objects from the given Propel collection.
3165:      *
3166:      * @param PropelCollection $featureCvtermprops A Propel collection.
3167:      * @param PropelPDO $con Optional connection object
3168:      * @return Cvterm The current object (for fluent API support)
3169:      */
3170:     public function setFeatureCvtermprops(PropelCollection $featureCvtermprops, PropelPDO $con = null)
3171:     {
3172:         $featureCvtermpropsToDelete = $this->getFeatureCvtermprops(new Criteria(), $con)->diff($featureCvtermprops);
3173: 
3174:         $this->featureCvtermpropsScheduledForDeletion = unserialize(serialize($featureCvtermpropsToDelete));
3175: 
3176:         foreach ($featureCvtermpropsToDelete as $featureCvtermpropRemoved) {
3177:             $featureCvtermpropRemoved->setCvterm(null);
3178:         }
3179: 
3180:         $this->collFeatureCvtermprops = null;
3181:         foreach ($featureCvtermprops as $featureCvtermprop) {
3182:             $this->addFeatureCvtermprop($featureCvtermprop);
3183:         }
3184: 
3185:         $this->collFeatureCvtermprops = $featureCvtermprops;
3186:         $this->collFeatureCvtermpropsPartial = false;
3187: 
3188:         return $this;
3189:     }
3190: 
3191:     /**
3192:      * Returns the number of related FeatureCvtermprop objects.
3193:      *
3194:      * @param Criteria $criteria
3195:      * @param boolean $distinct
3196:      * @param PropelPDO $con
3197:      * @return int             Count of related FeatureCvtermprop objects.
3198:      * @throws PropelException
3199:      */
3200:     public function countFeatureCvtermprops(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3201:     {
3202:         $partial = $this->collFeatureCvtermpropsPartial && !$this->isNew();
3203:         if (null === $this->collFeatureCvtermprops || null !== $criteria || $partial) {
3204:             if ($this->isNew() && null === $this->collFeatureCvtermprops) {
3205:                 return 0;
3206:             }
3207: 
3208:             if($partial && !$criteria) {
3209:                 return count($this->getFeatureCvtermprops());
3210:             }
3211:             $query = FeatureCvtermpropQuery::create(null, $criteria);
3212:             if ($distinct) {
3213:                 $query->distinct();
3214:             }
3215: 
3216:             return $query
3217:                 ->filterByCvterm($this)
3218:                 ->count($con);
3219:         }
3220: 
3221:         return count($this->collFeatureCvtermprops);
3222:     }
3223: 
3224:     /**
3225:      * Method called to associate a FeatureCvtermprop object to this object
3226:      * through the FeatureCvtermprop foreign key attribute.
3227:      *
3228:      * @param    FeatureCvtermprop $l FeatureCvtermprop
3229:      * @return Cvterm The current object (for fluent API support)
3230:      */
3231:     public function addFeatureCvtermprop(FeatureCvtermprop $l)
3232:     {
3233:         if ($this->collFeatureCvtermprops === null) {
3234:             $this->initFeatureCvtermprops();
3235:             $this->collFeatureCvtermpropsPartial = true;
3236:         }
3237:         if (!in_array($l, $this->collFeatureCvtermprops->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3238:             $this->doAddFeatureCvtermprop($l);
3239:         }
3240: 
3241:         return $this;
3242:     }
3243: 
3244:     /**
3245:      * @param   FeatureCvtermprop $featureCvtermprop The featureCvtermprop object to add.
3246:      */
3247:     protected function doAddFeatureCvtermprop($featureCvtermprop)
3248:     {
3249:         $this->collFeatureCvtermprops[]= $featureCvtermprop;
3250:         $featureCvtermprop->setCvterm($this);
3251:     }
3252: 
3253:     /**
3254:      * @param   FeatureCvtermprop $featureCvtermprop The featureCvtermprop object to remove.
3255:      * @return Cvterm The current object (for fluent API support)
3256:      */
3257:     public function removeFeatureCvtermprop($featureCvtermprop)
3258:     {
3259:         if ($this->getFeatureCvtermprops()->contains($featureCvtermprop)) {
3260:             $this->collFeatureCvtermprops->remove($this->collFeatureCvtermprops->search($featureCvtermprop));
3261:             if (null === $this->featureCvtermpropsScheduledForDeletion) {
3262:                 $this->featureCvtermpropsScheduledForDeletion = clone $this->collFeatureCvtermprops;
3263:                 $this->featureCvtermpropsScheduledForDeletion->clear();
3264:             }
3265:             $this->featureCvtermpropsScheduledForDeletion[]= clone $featureCvtermprop;
3266:             $featureCvtermprop->setCvterm(null);
3267:         }
3268: 
3269:         return $this;
3270:     }
3271: 
3272: 
3273:     /**
3274:      * If this collection has already been initialized with
3275:      * an identical criteria, it returns the collection.
3276:      * Otherwise if this Cvterm is new, it will return
3277:      * an empty collection; or if this Cvterm has previously
3278:      * been saved, it will retrieve related FeatureCvtermprops from storage.
3279:      *
3280:      * This method is protected by default in order to keep the public
3281:      * api reasonable.  You can provide public methods for those you
3282:      * actually need in Cvterm.
3283:      *
3284:      * @param Criteria $criteria optional Criteria object to narrow the query
3285:      * @param PropelPDO $con optional connection object
3286:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3287:      * @return PropelObjectCollection|FeatureCvtermprop[] List of FeatureCvtermprop objects
3288:      */
3289:     public function getFeatureCvtermpropsJoinFeatureCvterm($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3290:     {
3291:         $query = FeatureCvtermpropQuery::create(null, $criteria);
3292:         $query->joinWith('FeatureCvterm', $join_behavior);
3293: 
3294:         return $this->getFeatureCvtermprops($query, $con);
3295:     }
3296: 
3297:     /**
3298:      * Clears out the collProtocols collection
3299:      *
3300:      * This does not modify the database; however, it will remove any associated objects, causing
3301:      * them to be refetched by subsequent calls to accessor method.
3302:      *
3303:      * @return Cvterm The current object (for fluent API support)
3304:      * @see        addProtocols()
3305:      */
3306:     public function clearProtocols()
3307:     {
3308:         $this->collProtocols = null; // important to set this to null since that means it is uninitialized
3309:         $this->collProtocolsPartial = null;
3310: 
3311:         return $this;
3312:     }
3313: 
3314:     /**
3315:      * reset is the collProtocols collection loaded partially
3316:      *
3317:      * @return void
3318:      */
3319:     public function resetPartialProtocols($v = true)
3320:     {
3321:         $this->collProtocolsPartial = $v;
3322:     }
3323: 
3324:     /**
3325:      * Initializes the collProtocols collection.
3326:      *
3327:      * By default this just sets the collProtocols collection to an empty array (like clearcollProtocols());
3328:      * however, you may wish to override this method in your stub class to provide setting appropriate
3329:      * to your application -- for example, setting the initial array to the values stored in database.
3330:      *
3331:      * @param boolean $overrideExisting If set to true, the method call initializes
3332:      *                                        the collection even if it is not empty
3333:      *
3334:      * @return void
3335:      */
3336:     public function initProtocols($overrideExisting = true)
3337:     {
3338:         if (null !== $this->collProtocols && !$overrideExisting) {
3339:             return;
3340:         }
3341:         $this->collProtocols = new PropelObjectCollection();
3342:         $this->collProtocols->setModel('Protocol');
3343:     }
3344: 
3345:     /**
3346:      * Gets an array of Protocol objects which contain a foreign key that references this object.
3347:      *
3348:      * If the $criteria is not null, it is used to always fetch the results from the database.
3349:      * Otherwise the results are fetched from the database the first time, then cached.
3350:      * Next time the same method is called without $criteria, the cached collection is returned.
3351:      * If this Cvterm is new, it will return
3352:      * an empty collection or the current collection; the criteria is ignored on a new object.
3353:      *
3354:      * @param Criteria $criteria optional Criteria object to narrow the query
3355:      * @param PropelPDO $con optional connection object
3356:      * @return PropelObjectCollection|Protocol[] List of Protocol objects
3357:      * @throws PropelException
3358:      */
3359:     public function getProtocols($criteria = null, PropelPDO $con = null)
3360:     {
3361:         $partial = $this->collProtocolsPartial && !$this->isNew();
3362:         if (null === $this->collProtocols || null !== $criteria  || $partial) {
3363:             if ($this->isNew() && null === $this->collProtocols) {
3364:                 // return empty collection
3365:                 $this->initProtocols();
3366:             } else {
3367:                 $collProtocols = ProtocolQuery::create(null, $criteria)
3368:                     ->filterByCvterm($this)
3369:                     ->find($con);
3370:                 if (null !== $criteria) {
3371:                     if (false !== $this->collProtocolsPartial && count($collProtocols)) {
3372:                       $this->initProtocols(false);
3373: 
3374:                       foreach($collProtocols as $obj) {
3375:                         if (false == $this->collProtocols->contains($obj)) {
3376:                           $this->collProtocols->append($obj);
3377:                         }
3378:                       }
3379: 
3380:                       $this->collProtocolsPartial = true;
3381:                     }
3382: 
3383:                     $collProtocols->getInternalIterator()->rewind();
3384:                     return $collProtocols;
3385:                 }
3386: 
3387:                 if($partial && $this->collProtocols) {
3388:                     foreach($this->collProtocols as $obj) {
3389:                         if($obj->isNew()) {
3390:                             $collProtocols[] = $obj;
3391:                         }
3392:                     }
3393:                 }
3394: 
3395:                 $this->collProtocols = $collProtocols;
3396:                 $this->collProtocolsPartial = false;
3397:             }
3398:         }
3399: 
3400:         return $this->collProtocols;
3401:     }
3402: 
3403:     /**
3404:      * Sets a collection of Protocol objects related by a one-to-many relationship
3405:      * to the current object.
3406:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3407:      * and new objects from the given Propel collection.
3408:      *
3409:      * @param PropelCollection $protocols A Propel collection.
3410:      * @param PropelPDO $con Optional connection object
3411:      * @return Cvterm The current object (for fluent API support)
3412:      */
3413:     public function setProtocols(PropelCollection $protocols, PropelPDO $con = null)
3414:     {
3415:         $protocolsToDelete = $this->getProtocols(new Criteria(), $con)->diff($protocols);
3416: 
3417:         $this->protocolsScheduledForDeletion = unserialize(serialize($protocolsToDelete));
3418: 
3419:         foreach ($protocolsToDelete as $protocolRemoved) {
3420:             $protocolRemoved->setCvterm(null);
3421:         }
3422: 
3423:         $this->collProtocols = null;
3424:         foreach ($protocols as $protocol) {
3425:             $this->addProtocol($protocol);
3426:         }
3427: 
3428:         $this->collProtocols = $protocols;
3429:         $this->collProtocolsPartial = false;
3430: 
3431:         return $this;
3432:     }
3433: 
3434:     /**
3435:      * Returns the number of related Protocol objects.
3436:      *
3437:      * @param Criteria $criteria
3438:      * @param boolean $distinct
3439:      * @param PropelPDO $con
3440:      * @return int             Count of related Protocol objects.
3441:      * @throws PropelException
3442:      */
3443:     public function countProtocols(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3444:     {
3445:         $partial = $this->collProtocolsPartial && !$this->isNew();
3446:         if (null === $this->collProtocols || null !== $criteria || $partial) {
3447:             if ($this->isNew() && null === $this->collProtocols) {
3448:                 return 0;
3449:             }
3450: 
3451:             if($partial && !$criteria) {
3452:                 return count($this->getProtocols());
3453:             }
3454:             $query = ProtocolQuery::create(null, $criteria);
3455:             if ($distinct) {
3456:                 $query->distinct();
3457:             }
3458: 
3459:             return $query
3460:                 ->filterByCvterm($this)
3461:                 ->count($con);
3462:         }
3463: 
3464:         return count($this->collProtocols);
3465:     }
3466: 
3467:     /**
3468:      * Method called to associate a Protocol object to this object
3469:      * through the Protocol foreign key attribute.
3470:      *
3471:      * @param    Protocol $l Protocol
3472:      * @return Cvterm The current object (for fluent API support)
3473:      */
3474:     public function addProtocol(Protocol $l)
3475:     {
3476:         if ($this->collProtocols === null) {
3477:             $this->initProtocols();
3478:             $this->collProtocolsPartial = true;
3479:         }
3480:         if (!in_array($l, $this->collProtocols->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3481:             $this->doAddProtocol($l);
3482:         }
3483: 
3484:         return $this;
3485:     }
3486: 
3487:     /**
3488:      * @param   Protocol $protocol The protocol object to add.
3489:      */
3490:     protected function doAddProtocol($protocol)
3491:     {
3492:         $this->collProtocols[]= $protocol;
3493:         $protocol->setCvterm($this);
3494:     }
3495: 
3496:     /**
3497:      * @param   Protocol $protocol The protocol object to remove.
3498:      * @return Cvterm The current object (for fluent API support)
3499:      */
3500:     public function removeProtocol($protocol)
3501:     {
3502:         if ($this->getProtocols()->contains($protocol)) {
3503:             $this->collProtocols->remove($this->collProtocols->search($protocol));
3504:             if (null === $this->protocolsScheduledForDeletion) {
3505:                 $this->protocolsScheduledForDeletion = clone $this->collProtocols;
3506:                 $this->protocolsScheduledForDeletion->clear();
3507:             }
3508:             $this->protocolsScheduledForDeletion[]= clone $protocol;
3509:             $protocol->setCvterm(null);
3510:         }
3511: 
3512:         return $this;
3513:     }
3514: 
3515:     /**
3516:      * Clears out the collPubs collection
3517:      *
3518:      * This does not modify the database; however, it will remove any associated objects, causing
3519:      * them to be refetched by subsequent calls to accessor method.
3520:      *
3521:      * @return Cvterm The current object (for fluent API support)
3522:      * @see        addPubs()
3523:      */
3524:     public function clearPubs()
3525:     {
3526:         $this->collPubs = null; // important to set this to null since that means it is uninitialized
3527:         $this->collPubsPartial = null;
3528: 
3529:         return $this;
3530:     }
3531: 
3532:     /**
3533:      * reset is the collPubs collection loaded partially
3534:      *
3535:      * @return void
3536:      */
3537:     public function resetPartialPubs($v = true)
3538:     {
3539:         $this->collPubsPartial = $v;
3540:     }
3541: 
3542:     /**
3543:      * Initializes the collPubs collection.
3544:      *
3545:      * By default this just sets the collPubs collection to an empty array (like clearcollPubs());
3546:      * however, you may wish to override this method in your stub class to provide setting appropriate
3547:      * to your application -- for example, setting the initial array to the values stored in database.
3548:      *
3549:      * @param boolean $overrideExisting If set to true, the method call initializes
3550:      *                                        the collection even if it is not empty
3551:      *
3552:      * @return void
3553:      */
3554:     public function initPubs($overrideExisting = true)
3555:     {
3556:         if (null !== $this->collPubs && !$overrideExisting) {
3557:             return;
3558:         }
3559:         $this->collPubs = new PropelObjectCollection();
3560:         $this->collPubs->setModel('Pub');
3561:     }
3562: 
3563:     /**
3564:      * Gets an array of Pub objects which contain a foreign key that references this object.
3565:      *
3566:      * If the $criteria is not null, it is used to always fetch the results from the database.
3567:      * Otherwise the results are fetched from the database the first time, then cached.
3568:      * Next time the same method is called without $criteria, the cached collection is returned.
3569:      * If this Cvterm is new, it will return
3570:      * an empty collection or the current collection; the criteria is ignored on a new object.
3571:      *
3572:      * @param Criteria $criteria optional Criteria object to narrow the query
3573:      * @param PropelPDO $con optional connection object
3574:      * @return PropelObjectCollection|Pub[] List of Pub objects
3575:      * @throws PropelException
3576:      */
3577:     public function getPubs($criteria = null, PropelPDO $con = null)
3578:     {
3579:         $partial = $this->collPubsPartial && !$this->isNew();
3580:         if (null === $this->collPubs || null !== $criteria  || $partial) {
3581:             if ($this->isNew() && null === $this->collPubs) {
3582:                 // return empty collection
3583:                 $this->initPubs();
3584:             } else {
3585:                 $collPubs = PubQuery::create(null, $criteria)
3586:                     ->filterByCvterm($this)
3587:                     ->find($con);
3588:                 if (null !== $criteria) {
3589:                     if (false !== $this->collPubsPartial && count($collPubs)) {
3590:                       $this->initPubs(false);
3591: 
3592:                       foreach($collPubs as $obj) {
3593:                         if (false == $this->collPubs->contains($obj)) {
3594:                           $this->collPubs->append($obj);
3595:                         }
3596:                       }
3597: 
3598:                       $this->collPubsPartial = true;
3599:                     }
3600: 
3601:                     $collPubs->getInternalIterator()->rewind();
3602:                     return $collPubs;
3603:                 }
3604: 
3605:                 if($partial && $this->collPubs) {
3606:                     foreach($this->collPubs as $obj) {
3607:                         if($obj->isNew()) {
3608:                             $collPubs[] = $obj;
3609:                         }
3610:                     }
3611:                 }
3612: 
3613:                 $this->collPubs = $collPubs;
3614:                 $this->collPubsPartial = false;
3615:             }
3616:         }
3617: 
3618:         return $this->collPubs;
3619:     }
3620: 
3621:     /**
3622:      * Sets a collection of Pub objects related by a one-to-many relationship
3623:      * to the current object.
3624:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3625:      * and new objects from the given Propel collection.
3626:      *
3627:      * @param PropelCollection $pubs A Propel collection.
3628:      * @param PropelPDO $con Optional connection object
3629:      * @return Cvterm The current object (for fluent API support)
3630:      */
3631:     public function setPubs(PropelCollection $pubs, PropelPDO $con = null)
3632:     {
3633:         $pubsToDelete = $this->getPubs(new Criteria(), $con)->diff($pubs);
3634: 
3635:         $this->pubsScheduledForDeletion = unserialize(serialize($pubsToDelete));
3636: 
3637:         foreach ($pubsToDelete as $pubRemoved) {
3638:             $pubRemoved->setCvterm(null);
3639:         }
3640: 
3641:         $this->collPubs = null;
3642:         foreach ($pubs as $pub) {
3643:             $this->addPub($pub);
3644:         }
3645: 
3646:         $this->collPubs = $pubs;
3647:         $this->collPubsPartial = false;
3648: 
3649:         return $this;
3650:     }
3651: 
3652:     /**
3653:      * Returns the number of related Pub objects.
3654:      *
3655:      * @param Criteria $criteria
3656:      * @param boolean $distinct
3657:      * @param PropelPDO $con
3658:      * @return int             Count of related Pub objects.
3659:      * @throws PropelException
3660:      */
3661:     public function countPubs(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3662:     {
3663:         $partial = $this->collPubsPartial && !$this->isNew();
3664:         if (null === $this->collPubs || null !== $criteria || $partial) {
3665:             if ($this->isNew() && null === $this->collPubs) {
3666:                 return 0;
3667:             }
3668: 
3669:             if($partial && !$criteria) {
3670:                 return count($this->getPubs());
3671:             }
3672:             $query = PubQuery::create(null, $criteria);
3673:             if ($distinct) {
3674:                 $query->distinct();
3675:             }
3676: 
3677:             return $query
3678:                 ->filterByCvterm($this)
3679:                 ->count($con);
3680:         }
3681: 
3682:         return count($this->collPubs);
3683:     }
3684: 
3685:     /**
3686:      * Method called to associate a Pub object to this object
3687:      * through the Pub foreign key attribute.
3688:      *
3689:      * @param    Pub $l Pub
3690:      * @return Cvterm The current object (for fluent API support)
3691:      */
3692:     public function addPub(Pub $l)
3693:     {
3694:         if ($this->collPubs === null) {
3695:             $this->initPubs();
3696:             $this->collPubsPartial = true;
3697:         }
3698:         if (!in_array($l, $this->collPubs->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3699:             $this->doAddPub($l);
3700:         }
3701: 
3702:         return $this;
3703:     }
3704: 
3705:     /**
3706:      * @param   Pub $pub The pub object to add.
3707:      */
3708:     protected function doAddPub($pub)
3709:     {
3710:         $this->collPubs[]= $pub;
3711:         $pub->setCvterm($this);
3712:     }
3713: 
3714:     /**
3715:      * @param   Pub $pub The pub object to remove.
3716:      * @return Cvterm The current object (for fluent API support)
3717:      */
3718:     public function removePub($pub)
3719:     {
3720:         if ($this->getPubs()->contains($pub)) {
3721:             $this->collPubs->remove($this->collPubs->search($pub));
3722:             if (null === $this->pubsScheduledForDeletion) {
3723:                 $this->pubsScheduledForDeletion = clone $this->collPubs;
3724:                 $this->pubsScheduledForDeletion->clear();
3725:             }
3726:             $this->pubsScheduledForDeletion[]= clone $pub;
3727:             $pub->setCvterm(null);
3728:         }
3729: 
3730:         return $this;
3731:     }
3732: 
3733:     /**
3734:      * Clears out the collPubRelationships collection
3735:      *
3736:      * This does not modify the database; however, it will remove any associated objects, causing
3737:      * them to be refetched by subsequent calls to accessor method.
3738:      *
3739:      * @return Cvterm The current object (for fluent API support)
3740:      * @see        addPubRelationships()
3741:      */
3742:     public function clearPubRelationships()
3743:     {
3744:         $this->collPubRelationships = null; // important to set this to null since that means it is uninitialized
3745:         $this->collPubRelationshipsPartial = null;
3746: 
3747:         return $this;
3748:     }
3749: 
3750:     /**
3751:      * reset is the collPubRelationships collection loaded partially
3752:      *
3753:      * @return void
3754:      */
3755:     public function resetPartialPubRelationships($v = true)
3756:     {
3757:         $this->collPubRelationshipsPartial = $v;
3758:     }
3759: 
3760:     /**
3761:      * Initializes the collPubRelationships collection.
3762:      *
3763:      * By default this just sets the collPubRelationships collection to an empty array (like clearcollPubRelationships());
3764:      * however, you may wish to override this method in your stub class to provide setting appropriate
3765:      * to your application -- for example, setting the initial array to the values stored in database.
3766:      *
3767:      * @param boolean $overrideExisting If set to true, the method call initializes
3768:      *                                        the collection even if it is not empty
3769:      *
3770:      * @return void
3771:      */
3772:     public function initPubRelationships($overrideExisting = true)
3773:     {
3774:         if (null !== $this->collPubRelationships && !$overrideExisting) {
3775:             return;
3776:         }
3777:         $this->collPubRelationships = new PropelObjectCollection();
3778:         $this->collPubRelationships->setModel('PubRelationship');
3779:     }
3780: 
3781:     /**
3782:      * Gets an array of PubRelationship objects which contain a foreign key that references this object.
3783:      *
3784:      * If the $criteria is not null, it is used to always fetch the results from the database.
3785:      * Otherwise the results are fetched from the database the first time, then cached.
3786:      * Next time the same method is called without $criteria, the cached collection is returned.
3787:      * If this Cvterm is new, it will return
3788:      * an empty collection or the current collection; the criteria is ignored on a new object.
3789:      *
3790:      * @param Criteria $criteria optional Criteria object to narrow the query
3791:      * @param PropelPDO $con optional connection object
3792:      * @return PropelObjectCollection|PubRelationship[] List of PubRelationship objects
3793:      * @throws PropelException
3794:      */
3795:     public function getPubRelationships($criteria = null, PropelPDO $con = null)
3796:     {
3797:         $partial = $this->collPubRelationshipsPartial && !$this->isNew();
3798:         if (null === $this->collPubRelationships || null !== $criteria  || $partial) {
3799:             if ($this->isNew() && null === $this->collPubRelationships) {
3800:                 // return empty collection
3801:                 $this->initPubRelationships();
3802:             } else {
3803:                 $collPubRelationships = PubRelationshipQuery::create(null, $criteria)
3804:                     ->filterByCvterm($this)
3805:                     ->find($con);
3806:                 if (null !== $criteria) {
3807:                     if (false !== $this->collPubRelationshipsPartial && count($collPubRelationships)) {
3808:                       $this->initPubRelationships(false);
3809: 
3810:                       foreach($collPubRelationships as $obj) {
3811:                         if (false == $this->collPubRelationships->contains($obj)) {
3812:                           $this->collPubRelationships->append($obj);
3813:                         }
3814:                       }
3815: 
3816:                       $this->collPubRelationshipsPartial = true;
3817:                     }
3818: 
3819:                     $collPubRelationships->getInternalIterator()->rewind();
3820:                     return $collPubRelationships;
3821:                 }
3822: 
3823:                 if($partial && $this->collPubRelationships) {
3824:                     foreach($this->collPubRelationships as $obj) {
3825:                         if($obj->isNew()) {
3826:                             $collPubRelationships[] = $obj;
3827:                         }
3828:                     }
3829:                 }
3830: 
3831:                 $this->collPubRelationships = $collPubRelationships;
3832:                 $this->collPubRelationshipsPartial = false;
3833:             }
3834:         }
3835: 
3836:         return $this->collPubRelationships;
3837:     }
3838: 
3839:     /**
3840:      * Sets a collection of PubRelationship objects related by a one-to-many relationship
3841:      * to the current object.
3842:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
3843:      * and new objects from the given Propel collection.
3844:      *
3845:      * @param PropelCollection $pubRelationships A Propel collection.
3846:      * @param PropelPDO $con Optional connection object
3847:      * @return Cvterm The current object (for fluent API support)
3848:      */
3849:     public function setPubRelationships(PropelCollection $pubRelationships, PropelPDO $con = null)
3850:     {
3851:         $pubRelationshipsToDelete = $this->getPubRelationships(new Criteria(), $con)->diff($pubRelationships);
3852: 
3853:         $this->pubRelationshipsScheduledForDeletion = unserialize(serialize($pubRelationshipsToDelete));
3854: 
3855:         foreach ($pubRelationshipsToDelete as $pubRelationshipRemoved) {
3856:             $pubRelationshipRemoved->setCvterm(null);
3857:         }
3858: 
3859:         $this->collPubRelationships = null;
3860:         foreach ($pubRelationships as $pubRelationship) {
3861:             $this->addPubRelationship($pubRelationship);
3862:         }
3863: 
3864:         $this->collPubRelationships = $pubRelationships;
3865:         $this->collPubRelationshipsPartial = false;
3866: 
3867:         return $this;
3868:     }
3869: 
3870:     /**
3871:      * Returns the number of related PubRelationship objects.
3872:      *
3873:      * @param Criteria $criteria
3874:      * @param boolean $distinct
3875:      * @param PropelPDO $con
3876:      * @return int             Count of related PubRelationship objects.
3877:      * @throws PropelException
3878:      */
3879:     public function countPubRelationships(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
3880:     {
3881:         $partial = $this->collPubRelationshipsPartial && !$this->isNew();
3882:         if (null === $this->collPubRelationships || null !== $criteria || $partial) {
3883:             if ($this->isNew() && null === $this->collPubRelationships) {
3884:                 return 0;
3885:             }
3886: 
3887:             if($partial && !$criteria) {
3888:                 return count($this->getPubRelationships());
3889:             }
3890:             $query = PubRelationshipQuery::create(null, $criteria);
3891:             if ($distinct) {
3892:                 $query->distinct();
3893:             }
3894: 
3895:             return $query
3896:                 ->filterByCvterm($this)
3897:                 ->count($con);
3898:         }
3899: 
3900:         return count($this->collPubRelationships);
3901:     }
3902: 
3903:     /**
3904:      * Method called to associate a PubRelationship object to this object
3905:      * through the PubRelationship foreign key attribute.
3906:      *
3907:      * @param    PubRelationship $l PubRelationship
3908:      * @return Cvterm The current object (for fluent API support)
3909:      */
3910:     public function addPubRelationship(PubRelationship $l)
3911:     {
3912:         if ($this->collPubRelationships === null) {
3913:             $this->initPubRelationships();
3914:             $this->collPubRelationshipsPartial = true;
3915:         }
3916:         if (!in_array($l, $this->collPubRelationships->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
3917:             $this->doAddPubRelationship($l);
3918:         }
3919: 
3920:         return $this;
3921:     }
3922: 
3923:     /**
3924:      * @param   PubRelationship $pubRelationship The pubRelationship object to add.
3925:      */
3926:     protected function doAddPubRelationship($pubRelationship)
3927:     {
3928:         $this->collPubRelationships[]= $pubRelationship;
3929:         $pubRelationship->setCvterm($this);
3930:     }
3931: 
3932:     /**
3933:      * @param   PubRelationship $pubRelationship The pubRelationship object to remove.
3934:      * @return Cvterm The current object (for fluent API support)
3935:      */
3936:     public function removePubRelationship($pubRelationship)
3937:     {
3938:         if ($this->getPubRelationships()->contains($pubRelationship)) {
3939:             $this->collPubRelationships->remove($this->collPubRelationships->search($pubRelationship));
3940:             if (null === $this->pubRelationshipsScheduledForDeletion) {
3941:                 $this->pubRelationshipsScheduledForDeletion = clone $this->collPubRelationships;
3942:                 $this->pubRelationshipsScheduledForDeletion->clear();
3943:             }
3944:             $this->pubRelationshipsScheduledForDeletion[]= clone $pubRelationship;
3945:             $pubRelationship->setCvterm(null);
3946:         }
3947: 
3948:         return $this;
3949:     }
3950: 
3951: 
3952:     /**
3953:      * If this collection has already been initialized with
3954:      * an identical criteria, it returns the collection.
3955:      * Otherwise if this Cvterm is new, it will return
3956:      * an empty collection; or if this Cvterm has previously
3957:      * been saved, it will retrieve related PubRelationships from storage.
3958:      *
3959:      * This method is protected by default in order to keep the public
3960:      * api reasonable.  You can provide public methods for those you
3961:      * actually need in Cvterm.
3962:      *
3963:      * @param Criteria $criteria optional Criteria object to narrow the query
3964:      * @param PropelPDO $con optional connection object
3965:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3966:      * @return PropelObjectCollection|PubRelationship[] List of PubRelationship objects
3967:      */
3968:     public function getPubRelationshipsJoinPubRelatedByObjectId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3969:     {
3970:         $query = PubRelationshipQuery::create(null, $criteria);
3971:         $query->joinWith('PubRelatedByObjectId', $join_behavior);
3972: 
3973:         return $this->getPubRelationships($query, $con);
3974:     }
3975: 
3976: 
3977:     /**
3978:      * If this collection has already been initialized with
3979:      * an identical criteria, it returns the collection.
3980:      * Otherwise if this Cvterm is new, it will return
3981:      * an empty collection; or if this Cvterm has previously
3982:      * been saved, it will retrieve related PubRelationships from storage.
3983:      *
3984:      * This method is protected by default in order to keep the public
3985:      * api reasonable.  You can provide public methods for those you
3986:      * actually need in Cvterm.
3987:      *
3988:      * @param Criteria $criteria optional Criteria object to narrow the query
3989:      * @param PropelPDO $con optional connection object
3990:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
3991:      * @return PropelObjectCollection|PubRelationship[] List of PubRelationship objects
3992:      */
3993:     public function getPubRelationshipsJoinPubRelatedBySubjectId($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
3994:     {
3995:         $query = PubRelationshipQuery::create(null, $criteria);
3996:         $query->joinWith('PubRelatedBySubjectId', $join_behavior);
3997: 
3998:         return $this->getPubRelationships($query, $con);
3999:     }
4000: 
4001:     /**
4002:      * Clears out the collPubprops collection
4003:      *
4004:      * This does not modify the database; however, it will remove any associated objects, causing
4005:      * them to be refetched by subsequent calls to accessor method.
4006:      *
4007:      * @return Cvterm The current object (for fluent API support)
4008:      * @see        addPubprops()
4009:      */
4010:     public function clearPubprops()
4011:     {
4012:         $this->collPubprops = null; // important to set this to null since that means it is uninitialized
4013:         $this->collPubpropsPartial = null;
4014: 
4015:         return $this;
4016:     }
4017: 
4018:     /**
4019:      * reset is the collPubprops collection loaded partially
4020:      *
4021:      * @return void
4022:      */
4023:     public function resetPartialPubprops($v = true)
4024:     {
4025:         $this->collPubpropsPartial = $v;
4026:     }
4027: 
4028:     /**
4029:      * Initializes the collPubprops collection.
4030:      *
4031:      * By default this just sets the collPubprops collection to an empty array (like clearcollPubprops());
4032:      * however, you may wish to override this method in your stub class to provide setting appropriate
4033:      * to your application -- for example, setting the initial array to the values stored in database.
4034:      *
4035:      * @param boolean $overrideExisting If set to true, the method call initializes
4036:      *                                        the collection even if it is not empty
4037:      *
4038:      * @return void
4039:      */
4040:     public function initPubprops($overrideExisting = true)
4041:     {
4042:         if (null !== $this->collPubprops && !$overrideExisting) {
4043:             return;
4044:         }
4045:         $this->collPubprops = new PropelObjectCollection();
4046:         $this->collPubprops->setModel('Pubprop');
4047:     }
4048: 
4049:     /**
4050:      * Gets an array of Pubprop objects which contain a foreign key that references this object.
4051:      *
4052:      * If the $criteria is not null, it is used to always fetch the results from the database.
4053:      * Otherwise the results are fetched from the database the first time, then cached.
4054:      * Next time the same method is called without $criteria, the cached collection is returned.
4055:      * If this Cvterm is new, it will return
4056:      * an empty collection or the current collection; the criteria is ignored on a new object.
4057:      *
4058:      * @param Criteria $criteria optional Criteria object to narrow the query
4059:      * @param PropelPDO $con optional connection object
4060:      * @return PropelObjectCollection|Pubprop[] List of Pubprop objects
4061:      * @throws PropelException
4062:      */
4063:     public function getPubprops($criteria = null, PropelPDO $con = null)
4064:     {
4065:         $partial = $this->collPubpropsPartial && !$this->isNew();
4066:         if (null === $this->collPubprops || null !== $criteria  || $partial) {
4067:             if ($this->isNew() && null === $this->collPubprops) {
4068:                 // return empty collection
4069:                 $this->initPubprops();
4070:             } else {
4071:                 $collPubprops = PubpropQuery::create(null, $criteria)
4072:                     ->filterByCvterm($this)
4073:                     ->find($con);
4074:                 if (null !== $criteria) {
4075:                     if (false !== $this->collPubpropsPartial && count($collPubprops)) {
4076:                       $this->initPubprops(false);
4077: 
4078:                       foreach($collPubprops as $obj) {
4079:                         if (false == $this->collPubprops->contains($obj)) {
4080:                           $this->collPubprops->append($obj);
4081:                         }
4082:                       }
4083: 
4084:                       $this->collPubpropsPartial = true;
4085:                     }
4086: 
4087:                     $collPubprops->getInternalIterator()->rewind();
4088:                     return $collPubprops;
4089:                 }
4090: 
4091:                 if($partial && $this->collPubprops) {
4092:                     foreach($this->collPubprops as $obj) {
4093:                         if($obj->isNew()) {
4094:                             $collPubprops[] = $obj;
4095:                         }
4096:                     }
4097:                 }
4098: 
4099:                 $this->collPubprops = $collPubprops;
4100:                 $this->collPubpropsPartial = false;
4101:             }
4102:         }
4103: 
4104:         return $this->collPubprops;
4105:     }
4106: 
4107:     /**
4108:      * Sets a collection of Pubprop objects related by a one-to-many relationship
4109:      * to the current object.
4110:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
4111:      * and new objects from the given Propel collection.
4112:      *
4113:      * @param PropelCollection $pubprops A Propel collection.
4114:      * @param PropelPDO $con Optional connection object
4115:      * @return Cvterm The current object (for fluent API support)
4116:      */
4117:     public function setPubprops(PropelCollection $pubprops, PropelPDO $con = null)
4118:     {
4119:         $pubpropsToDelete = $this->getPubprops(new Criteria(), $con)->diff($pubprops);
4120: 
4121:         $this->pubpropsScheduledForDeletion = unserialize(serialize($pubpropsToDelete));
4122: 
4123:         foreach ($pubpropsToDelete as $pubpropRemoved) {
4124:             $pubpropRemoved->setCvterm(null);
4125:         }
4126: 
4127:         $this->collPubprops = null;
4128:         foreach ($pubprops as $pubprop) {
4129:             $this->addPubprop($pubprop);
4130:         }
4131: 
4132:         $this->collPubprops = $pubprops;
4133:         $this->collPubpropsPartial = false;
4134: 
4135:         return $this;
4136:     }
4137: 
4138:     /**
4139:      * Returns the number of related Pubprop objects.
4140:      *
4141:      * @param Criteria $criteria
4142:      * @param boolean $distinct
4143:      * @param PropelPDO $con
4144:      * @return int             Count of related Pubprop objects.
4145:      * @throws PropelException
4146:      */
4147:     public function countPubprops(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4148:     {
4149:         $partial = $this->collPubpropsPartial && !$this->isNew();
4150:         if (null === $this->collPubprops || null !== $criteria || $partial) {
4151:             if ($this->isNew() && null === $this->collPubprops) {
4152:                 return 0;
4153:             }
4154: 
4155:             if($partial && !$criteria) {
4156:                 return count($this->getPubprops());
4157:             }
4158:             $query = PubpropQuery::create(null, $criteria);
4159:             if ($distinct) {
4160:                 $query->distinct();
4161:             }
4162: 
4163:             return $query
4164:                 ->filterByCvterm($this)
4165:                 ->count($con);
4166:         }
4167: 
4168:         return count($this->collPubprops);
4169:     }
4170: 
4171:     /**
4172:      * Method called to associate a Pubprop object to this object
4173:      * through the Pubprop foreign key attribute.
4174:      *
4175:      * @param    Pubprop $l Pubprop
4176:      * @return Cvterm The current object (for fluent API support)
4177:      */
4178:     public function addPubprop(Pubprop $l)
4179:     {
4180:         if ($this->collPubprops === null) {
4181:             $this->initPubprops();
4182:             $this->collPubpropsPartial = true;
4183:         }
4184:         if (!in_array($l, $this->collPubprops->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
4185:             $this->doAddPubprop($l);
4186:         }
4187: 
4188:         return $this;
4189:     }
4190: 
4191:     /**
4192:      * @param   Pubprop $pubprop The pubprop object to add.
4193:      */
4194:     protected function doAddPubprop($pubprop)
4195:     {
4196:         $this->collPubprops[]= $pubprop;
4197:         $pubprop->setCvterm($this);
4198:     }
4199: 
4200:     /**
4201:      * @param   Pubprop $pubprop The pubprop object to remove.
4202:      * @return Cvterm The current object (for fluent API support)
4203:      */
4204:     public function removePubprop($pubprop)
4205:     {
4206:         if ($this->getPubprops()->contains($pubprop)) {
4207:             $this->collPubprops->remove($this->collPubprops->search($pubprop));
4208:             if (null === $this->pubpropsScheduledForDeletion) {
4209:                 $this->pubpropsScheduledForDeletion = clone $this->collPubprops;
4210:                 $this->pubpropsScheduledForDeletion->clear();
4211:             }
4212:             $this->pubpropsScheduledForDeletion[]= clone $pubprop;
4213:             $pubprop->setCvterm(null);
4214:         }
4215: 
4216:         return $this;
4217:     }
4218: 
4219: 
4220:     /**
4221:      * If this collection has already been initialized with
4222:      * an identical criteria, it returns the collection.
4223:      * Otherwise if this Cvterm is new, it will return
4224:      * an empty collection; or if this Cvterm has previously
4225:      * been saved, it will retrieve related Pubprops from storage.
4226:      *
4227:      * This method is protected by default in order to keep the public
4228:      * api reasonable.  You can provide public methods for those you
4229:      * actually need in Cvterm.
4230:      *
4231:      * @param Criteria $criteria optional Criteria object to narrow the query
4232:      * @param PropelPDO $con optional connection object
4233:      * @param string $join_behavior optional join type to use (defaults to Criteria::LEFT_JOIN)
4234:      * @return PropelObjectCollection|Pubprop[] List of Pubprop objects
4235:      */
4236:     public function getPubpropsJoinPub($criteria = null, $con = null, $join_behavior = Criteria::LEFT_JOIN)
4237:     {
4238:         $query = PubpropQuery::create(null, $criteria);
4239:         $query->joinWith('Pub', $join_behavior);
4240: 
4241:         return $this->getPubprops($query, $con);
4242:     }
4243: 
4244:     /**
4245:      * Clears out the collSynonyms collection
4246:      *
4247:      * This does not modify the database; however, it will remove any associated objects, causing
4248:      * them to be refetched by subsequent calls to accessor method.
4249:      *
4250:      * @return Cvterm The current object (for fluent API support)
4251:      * @see        addSynonyms()
4252:      */
4253:     public function clearSynonyms()
4254:     {
4255:         $this->collSynonyms = null; // important to set this to null since that means it is uninitialized
4256:         $this->collSynonymsPartial = null;
4257: 
4258:         return $this;
4259:     }
4260: 
4261:     /**
4262:      * reset is the collSynonyms collection loaded partially
4263:      *
4264:      * @return void
4265:      */
4266:     public function resetPartialSynonyms($v = true)
4267:     {
4268:         $this->collSynonymsPartial = $v;
4269:     }
4270: 
4271:     /**
4272:      * Initializes the collSynonyms collection.
4273:      *
4274:      * By default this just sets the collSynonyms collection to an empty array (like clearcollSynonyms());
4275:      * however, you may wish to override this method in your stub class to provide setting appropriate
4276:      * to your application -- for example, setting the initial array to the values stored in database.
4277:      *
4278:      * @param boolean $overrideExisting If set to true, the method call initializes
4279:      *                                        the collection even if it is not empty
4280:      *
4281:      * @return void
4282:      */
4283:     public function initSynonyms($overrideExisting = true)
4284:     {
4285:         if (null !== $this->collSynonyms && !$overrideExisting) {
4286:             return;
4287:         }
4288:         $this->collSynonyms = new PropelObjectCollection();
4289:         $this->collSynonyms->setModel('Synonym');
4290:     }
4291: 
4292:     /**
4293:      * Gets an array of Synonym objects which contain a foreign key that references this object.
4294:      *
4295:      * If the $criteria is not null, it is used to always fetch the results from the database.
4296:      * Otherwise the results are fetched from the database the first time, then cached.
4297:      * Next time the same method is called without $criteria, the cached collection is returned.
4298:      * If this Cvterm is new, it will return
4299:      * an empty collection or the current collection; the criteria is ignored on a new object.
4300:      *
4301:      * @param Criteria $criteria optional Criteria object to narrow the query
4302:      * @param PropelPDO $con optional connection object
4303:      * @return PropelObjectCollection|Synonym[] List of Synonym objects
4304:      * @throws PropelException
4305:      */
4306:     public function getSynonyms($criteria = null, PropelPDO $con = null)
4307:     {
4308:         $partial = $this->collSynonymsPartial && !$this->isNew();
4309:         if (null === $this->collSynonyms || null !== $criteria  || $partial) {
4310:             if ($this->isNew() && null === $this->collSynonyms) {
4311:                 // return empty collection
4312:                 $this->initSynonyms();
4313:             } else {
4314:                 $collSynonyms = SynonymQuery::create(null, $criteria)
4315:                     ->filterByCvterm($this)
4316:                     ->find($con);
4317:                 if (null !== $criteria) {
4318:                     if (false !== $this->collSynonymsPartial && count($collSynonyms)) {
4319:                       $this->initSynonyms(false);
4320: 
4321:                       foreach($collSynonyms as $obj) {
4322:                         if (false == $this->collSynonyms->contains($obj)) {
4323:                           $this->collSynonyms->append($obj);
4324:                         }
4325:                       }
4326: 
4327:                       $this->collSynonymsPartial = true;
4328:                     }
4329: 
4330:                     $collSynonyms->getInternalIterator()->rewind();
4331:                     return $collSynonyms;
4332:                 }
4333: 
4334:                 if($partial && $this->collSynonyms) {
4335:                     foreach($this->collSynonyms as $obj) {
4336:                         if($obj->isNew()) {
4337:                             $collSynonyms[] = $obj;
4338:                         }
4339:                     }
4340:                 }
4341: 
4342:                 $this->collSynonyms = $collSynonyms;
4343:                 $this->collSynonymsPartial = false;
4344:             }
4345:         }
4346: 
4347:         return $this->collSynonyms;
4348:     }
4349: 
4350:     /**
4351:      * Sets a collection of Synonym objects related by a one-to-many relationship
4352:      * to the current object.
4353:      * It will also schedule objects for deletion based on a diff between old objects (aka persisted)
4354:      * and new objects from the given Propel collection.
4355:      *
4356:      * @param PropelCollection $synonyms A Propel collection.
4357:      * @param PropelPDO $con Optional connection object
4358:      * @return Cvterm The current object (for fluent API support)
4359:      */
4360:     public function setSynonyms(PropelCollection $synonyms, PropelPDO $con = null)
4361:     {
4362:         $synonymsToDelete = $this->getSynonyms(new Criteria(), $con)->diff($synonyms);
4363: 
4364:         $this->synonymsScheduledForDeletion = unserialize(serialize($synonymsToDelete));
4365: 
4366:         foreach ($synonymsToDelete as $synonymRemoved) {
4367:             $synonymRemoved->setCvterm(null);
4368:         }
4369: 
4370:         $this->collSynonyms = null;
4371:         foreach ($synonyms as $synonym) {
4372:             $this->addSynonym($synonym);
4373:         }
4374: 
4375:         $this->collSynonyms = $synonyms;
4376:         $this->collSynonymsPartial = false;
4377: 
4378:         return $this;
4379:     }
4380: 
4381:     /**
4382:      * Returns the number of related Synonym objects.
4383:      *
4384:      * @param Criteria $criteria
4385:      * @param boolean $distinct
4386:      * @param PropelPDO $con
4387:      * @return int             Count of related Synonym objects.
4388:      * @throws PropelException
4389:      */
4390:     public function countSynonyms(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
4391:     {
4392:         $partial = $this->collSynonymsPartial && !$this->isNew();
4393:         if (null === $this->collSynonyms || null !== $criteria || $partial) {
4394:             if ($this->isNew() && null === $this->collSynonyms) {
4395:                 return 0;
4396:             }
4397: 
4398:             if($partial && !$criteria) {
4399:                 return count($this->getSynonyms());
4400:             }
4401:             $query = SynonymQuery::create(null, $criteria);
4402:             if ($distinct) {
4403:                 $query->distinct();
4404:             }
4405: 
4406:             return $query
4407:                 ->filterByCvterm($this)
4408:                 ->count($con);
4409:         }
4410: 
4411:         return count($this->collSynonyms);
4412:     }
4413: 
4414:     /**
4415:      * Method called to associate a Synonym object to this object
4416:      * through the Synonym foreign key attribute.
4417:      *
4418:      * @param    Synonym $l Synonym
4419:      * @return Cvterm The current object (for fluent API support)
4420:      */
4421:     public function addSynonym(Synonym $l)
4422:     {
4423:         if ($this->collSynonyms === null) {
4424:             $this->initSynonyms();
4425:             $this->collSynonymsPartial = true;
4426:         }
4427:         if (!in_array($l, $this->collSynonyms->getArrayCopy(), true)) { // only add it if the **same** object is not already associated
4428:             $this->doAddSynonym($l);
4429:         }
4430: 
4431:         return $this;
4432:     }
4433: 
4434:     /**
4435:      * @param   Synonym $synonym The synonym object to add.
4436:      */
4437:     protected function doAddSynonym($synonym)
4438:     {
4439:         $this->collSynonyms[]= $synonym;
4440:         $synonym->setCvterm($this);
4441:     }
4442: 
4443:     /**
4444:      * @param   Synonym $synonym The synonym object to remove.
4445:      * @return Cvterm The current object (for fluent API support)
4446:      */
4447:     public function removeSynonym($synonym)
4448:     {
4449:         if ($this->getSynonyms()->contains($synonym)) {
4450:             $this->collSynonyms->remove($this->collSynonyms->search($synonym));
4451:             if (null === $this->synonymsScheduledForDeletion) {
4452:                 $this->synonymsScheduledForDeletion = clone $this->collSynonyms;
4453:                 $this->synonymsScheduledForDeletion->clear();
4454:             }
4455:             $this->synonymsScheduledForDeletion[]= clone $synonym;
4456:             $synonym->setCvterm(null);
4457:         }
4458: 
4459:         return $this;
4460:     }
4461: 
4462:     /**
4463:      * Clears the current object and sets all attributes to their default values
4464:      */
4465:     public function clear()
4466:     {
4467:         $this->cvterm_id = null;
4468:         $this->cv_id = null;
4469:         $this->name = null;
4470:         $this->definition = null;
4471:         $this->dbxref_id = null;
4472:         $this->is_obsolete = null;
4473:         $this->is_relationshiptype = null;
4474:         $this->alreadyInSave = false;
4475:         $this->alreadyInValidation = false;
4476:         $this->alreadyInClearAllReferencesDeep = false;
4477:         $this->clearAllReferences();
4478:         $this->applyDefaultValues();
4479:         $this->resetModified();
4480:         $this->setNew(true);
4481:         $this->setDeleted(false);
4482:     }
4483: 
4484:     /**
4485:      * Resets all references to other model objects or collections of model objects.
4486:      *
4487:      * This method is a user-space workaround for PHP's inability to garbage collect
4488:      * objects with circular references (even in PHP 5.3). This is currently necessary
4489:      * when using Propel in certain daemon or large-volumne/high-memory operations.
4490:      *
4491:      * @param boolean $deep Whether to also clear the references on all referrer objects.
4492:      */
4493:     public function clearAllReferences($deep = false)
4494:     {
4495:         if ($deep && !$this->alreadyInClearAllReferencesDeep) {
4496:             $this->alreadyInClearAllReferencesDeep = true;
4497:             if ($this->collBiomaterialRelationships) {
4498:                 foreach ($this->collBiomaterialRelationships as $o) {
4499:                     $o->clearAllReferences($deep);
4500:                 }
4501:             }
4502:             if ($this->collBiomaterialprops) {
4503:                 foreach ($this->collBiomaterialprops as $o) {
4504:                     $o->clearAllReferences($deep);
4505:                 }
4506:             }
4507:             if ($this->collContacts) {
4508:                 foreach ($this->collContacts as $o) {
4509:                     $o->clearAllReferences($deep);
4510:                 }
4511:             }
4512:             if ($this->collFeatures) {
4513:                 foreach ($this->collFeatures as $o) {
4514:                     $o->clearAllReferences($deep);
4515:                 }
4516:             }
4517:             if ($this->collFeatureCvterms) {
4518:                 foreach ($this->collFeatureCvterms as $o) {
4519:                     $o->clearAllReferences($deep);
4520:                 }
4521:             }
4522:             if ($this->collFeatureCvtermprops) {
4523:                 foreach ($this->collFeatureCvtermprops as $o) {
4524:                     $o->clearAllReferences($deep);
4525:                 }
4526:             }
4527:             if ($this->collProtocols) {
4528:                 foreach ($this->collProtocols as $o) {
4529:                     $o->clearAllReferences($deep);
4530:                 }
4531:             }
4532:             if ($this->collPubs) {
4533:                 foreach ($this->collPubs as $o) {
4534:                     $o->clearAllReferences($deep);
4535:                 }
4536:             }
4537:             if ($this->collPubRelationships) {
4538:                 foreach ($this->collPubRelationships as $o) {
4539:                     $o->clearAllReferences($deep);
4540:                 }
4541:             }
4542:             if ($this->collPubprops) {
4543:                 foreach ($this->collPubprops as $o) {
4544:                     $o->clearAllReferences($deep);
4545:                 }
4546:             }
4547:             if ($this->collSynonyms) {
4548:                 foreach ($this->collSynonyms as $o) {
4549:                     $o->clearAllReferences($deep);
4550:                 }
4551:             }
4552:             if ($this->aCv instanceof Persistent) {
4553:               $this->aCv->clearAllReferences($deep);
4554:             }
4555: 
4556:             $this->alreadyInClearAllReferencesDeep = false;
4557:         } // if ($deep)
4558: 
4559:         if ($this->collBiomaterialRelationships instanceof PropelCollection) {
4560:             $this->collBiomaterialRelationships->clearIterator();
4561:         }
4562:         $this->collBiomaterialRelationships = null;
4563:         if ($this->collBiomaterialprops instanceof PropelCollection) {
4564:             $this->collBiomaterialprops->clearIterator();
4565:         }
4566:         $this->collBiomaterialprops = null;
4567:         if ($this->collContacts instanceof PropelCollection) {
4568:             $this->collContacts->clearIterator();
4569:         }
4570:         $this->collContacts = null;
4571:         if ($this->collFeatures instanceof PropelCollection) {
4572:             $this->collFeatures->clearIterator();
4573:         }
4574:         $this->collFeatures = null;
4575:         if ($this->collFeatureCvterms instanceof PropelCollection) {
4576:             $this->collFeatureCvterms->clearIterator();
4577:         }
4578:         $this->collFeatureCvterms = null;
4579:         if ($this->collFeatureCvtermprops instanceof PropelCollection) {
4580:             $this->collFeatureCvtermprops->clearIterator();
4581:         }
4582:         $this->collFeatureCvtermprops = null;
4583:         if ($this->collProtocols instanceof PropelCollection) {
4584:             $this->collProtocols->clearIterator();
4585:         }
4586:         $this->collProtocols = null;
4587:         if ($this->collPubs instanceof PropelCollection) {
4588:             $this->collPubs->clearIterator();
4589:         }
4590:         $this->collPubs = null;
4591:         if ($this->collPubRelationships instanceof PropelCollection) {
4592:             $this->collPubRelationships->clearIterator();
4593:         }
4594:         $this->collPubRelationships = null;
4595:         if ($this->collPubprops instanceof PropelCollection) {
4596:             $this->collPubprops->clearIterator();
4597:         }
4598:         $this->collPubprops = null;
4599:         if ($this->collSynonyms instanceof PropelCollection) {
4600:             $this->collSynonyms->clearIterator();
4601:         }
4602:         $this->collSynonyms = null;
4603:         $this->aCv = null;
4604:     }
4605: 
4606:     /**
4607:      * return the string representation of this object
4608:      *
4609:      * @return string
4610:      */
4611:     public function __toString()
4612:     {
4613:         return (string) $this->exportTo(CvtermPeer::DEFAULT_STRING_FORMAT);
4614:     }
4615: 
4616:     /**
4617:      * return true is the object is in saving state
4618:      *
4619:      * @return boolean
4620:      */
4621:     public function isAlreadyInSave()
4622:     {
4623:         return $this->alreadyInSave;
4624:     }
4625: 
4626: }
4627: 
tbro API documentation generated by ApiGen 2.8.0