1: <?php
2:
3: namespace cli_db\propel;
4:
5: use cli_db\propel\om\BaseBiomaterial;
6:
7:
8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19: class Biomaterial extends BaseBiomaterial
20: {
21: function getType(){
22: $props = $this->getBiomaterialprops(BiomaterialpropQuery::create()->filterByTypeId(CV_BIOMATERIAL_TYPE));
23: if (isset($props[0])) return $props[0]->getValue();
24: return "unknown";
25: }
26:
27: function setType($value){
28: $props = $this->getBiomaterialprops(BiomaterialpropQuery::create()->filterByTypeId(CV_BIOMATERIAL_TYPE));
29: if (count($props)>0)
30: $prop = $props[0];
31: else {
32: $prop = new Biomaterialprop();
33: $prop->setTypeId(CV_BIOMATERIAL_TYPE);
34: $this->addBiomaterialprop($prop);
35: }
36: $prop->setValue($value);
37: }
38:
39: function getParent(){
40: $parent_relationship = $this->getBiomaterialRelationshipsRelatedBySubjectId();
41:
42: if (isset($parent_relationship[0]))
43: return BiomaterialQuery::create()->findOneByBiomaterialId($parent_relationship[0]->getObjectId())->getName();
44: }
45:
46: function setParent(Biomaterial $parent_biomaterial){
47: $parent_q = new BiomaterialRelationshipQuery();
48: $parent_q->filterBySubjectId($this->getBiomaterialId());
49: $parent_q->filterByTypeId(CV_BIOMATERIAL_ISA);
50: $parent_rel = $parent_q->findOneOrCreate();
51:
52: $parent_rel->setObjectId($parent_biomaterial->getBiomaterialId());
53: $this->addBiomaterialRelationshipRelatedBySubjectId($parent_rel);
54: }
55: }
56: