/** * Get related notes * * @return QubitQuery list of QubitNote objects */ public function getRepositoryNotes() { $criteria = new Criteria(); $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID); $criteria->add(QubitNote::OBJECT_ID, $this->id); $criteria->add(QubitNote::SCOPE, 'QubitRepository'); QubitNote::addOrderByPreorder($criteria); return QubitNote::get($criteria); }
public function __get($name) { switch ($name) { case '_maintenanceNote': if (!isset($this->maintenanceNote)) { $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); $criteria->add(QubitNote::TYPE_ID, QubitTerm::MAINTENANCE_NOTE_ID); if (1 == count($query = QubitNote::get($criteria))) { $this->maintenanceNote = $query[0]; } else { $this->maintenanceNote = new QubitNote(); $this->maintenanceNote->typeId = QubitTerm::MAINTENANCE_NOTE_ID; $this->resource->notes[] = $this->maintenanceNote; } } return $this->maintenanceNote; case 'maintenanceNotes': return $this->_maintenanceNote->content; case 'relatedAuthorityRecord': if (!isset($this->relatedAuthorityRecord)) { $criteria = new Criteria(); $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::OBJECT_ID, QubitActor::ID); $this->relatedAuthorityRecord = QubitRelation::get($criteria); } return $this->relatedAuthorityRecord; case 'relatedFunction': if (!isset($this->relatedFunction)) { $criteria = new Criteria(); $criteria->add($criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->resource->id)->addOr($criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->resource->id))); $criteria->addAlias('ro', QubitFunction::TABLE_NAME); $criteria->addJoin(QubitRelation::OBJECT_ID, 'ro.id'); $criteria->addAlias('rs', QubitFunction::TABLE_NAME); $criteria->addJoin(QubitRelation::SUBJECT_ID, 'rs.id'); $criteria->addAscendingOrderByColumn(QubitRelation::TYPE_ID); $this->relatedFunction = QubitRelation::get($criteria); } return $this->relatedFunction; case 'relatedResource': if (!isset($this->relatedResource)) { $criteria = new Criteria(); $criteria->add(QubitRelation::SUBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::OBJECT_ID, QubitInformationObject::ID); $this->relatedResource = QubitRelation::get($criteria); } return $this->relatedResource; case 'sourceCulture': return $this->resource->sourceCulture; } }
public function __get($name) { switch ($name) { case '_maintenanceNote': if (!isset($this->maintenanceNote)) { $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); $criteria->add(QubitNote::TYPE_ID, QubitTerm::MAINTENANCE_NOTE_ID); if (1 == count($query = QubitNote::get($criteria))) { $this->maintenanceNote = $query[0]; } else { $this->maintenanceNote = new QubitNote(); $this->maintenanceNote->typeId = QubitTerm::MAINTENANCE_NOTE_ID; $this->resource->notes[] = $this->maintenanceNote; } } return $this->maintenanceNote; case 'maintenanceNotes': return $this->_maintenanceNote->content; case 'sourceCulture': return $this->resource->sourceCulture; } }
public function getNotesByTaxonomy(array $options = array()) { $criteria = new Criteria(); $criteria->addJoin(QubitNote::TYPE_ID, QubitTerm::ID); $criteria->add(QubitNote::OBJECT_ID, $this->id); if (isset($options['taxonomyId'])) { $criteria->add(QubitTerm::TAXONOMY_ID, $options['taxonomyId']); } return QubitNote::get($criteria); }
public static function getnotesById($id, array $options = array()) { $criteria = new Criteria(); self::addnotesCriteriaById($criteria, $id); return QubitNote::get($criteria, $options); }
public function __set($name, $value) { switch ($name) { case 'biogHist': $this->resource->history = self::fromDiscursiveSet($value); return $this; case 'entityType': switch ($value) { case 'corporateBody': $this->resource->entityTypeId = QubitTerm::CORPORATE_BODY_ID; return $this; case 'family': $this->resource->entityTypeId = QubitTerm::FAMILY_ID; return $this; case 'person': $this->resource->entityTypeId = QubitTerm::PERSON_ID; return $this; } return $this; case 'existDates': // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/> $this->resource->datesOfExistence = $value->text(); return $this; case 'generalContext': $this->resource->generalContext = self::fromDiscursiveSet($value); return $this; case 'maintenanceHistory': // TODO <maintenanceEvent/>, <agent/>, <agentType/> $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); $criteria->add(QubitNote::TYPE_ID, QubitTerm::MAINTENANCE_NOTE_ID); if (1 == count($query = QubitNote::get($criteria))) { $item = $query[0]; } else { $item = new QubitNote(); $item->typeId = QubitTerm::MAINTENANCE_NOTE_ID; $this->resource->notes[] = $item; } $item->content = $value->text(); return $this; case 'maintenanceStatus': // TODO Set $this->resource->descriptionStatus return $this; case 'publicationStatus': // TODO return $this; case 'structureOrGenealogy': $this->resource->internalStructures = self::fromDiscursiveSet($value); return $this; } }
public function importEadNote(array $options = array()) { $newNote = new QubitNote(); $newNote->setScope('QubitInformationObject'); if (isset($options['userId'])) { $newNote->setUserId($options['userId']); } if (isset($options['note'])) { $newNote->setContent($options['note']); } if (isset($options['noteTypeId'])) { $newNote->setTypeId($options['noteTypeId']); } $this->notes[] = $newNote; }
/** * Delete related notes marked for deletion. * * @param sfRequest request object */ protected function deleteNotes() { if (false == isset($this->request->sourceId) && is_array($deleteNotes = $this->request->delete_notes) && count($deleteNotes)) { foreach ($deleteNotes as $noteId => $doDelete) { if ($doDelete == 'delete' && !is_null($deleteNote = QubitNote::getById($noteId))) { $deleteNote->delete(); } } } }
protected function addField($name) { switch ($name) { case 'code': $this->form->setDefault('code', $this->resource->code); $this->form->setValidator('code', new sfValidatorString()); $this->form->setWidget('code', new sfWidgetFormInput()); break; case 'displayNote': case 'scopeNote': case 'sourceNote': $criteria = new Criteria(); $criteria->add(QubitNote::OBJECT_ID, $this->resource->id); switch ($name) { case 'scopeNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SCOPE_NOTE_ID); break; case 'sourceNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::SOURCE_NOTE_ID); break; case 'displayNote': $criteria->add(QubitNote::TYPE_ID, QubitTerm::DISPLAY_NOTE_ID); break; } $value = $defaults = array(); foreach ($this[$name] = QubitNote::get($criteria) as $item) { $defaults[$value[] = $item->id] = $item; } $this->form->setDefault($name, $value); $this->form->setValidator($name, new sfValidatorPass()); $this->form->setWidget($name, new QubitWidgetFormInputMany(array('defaults' => $defaults, 'fieldname' => 'content'))); break; case 'name': $this->form->setDefault('name', $this->resource->name); $this->form->setValidator('name', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $this->form->setWidget('name', new sfWidgetFormInput()); break; case 'narrowTerms': $this->form->setValidator('narrowTerms', new sfValidatorPass()); $this->form->setWidget('narrowTerms', new QubitWidgetFormInputMany(array('defaults' => array()))); break; case 'parent': $this->form->setDefault('parent', $this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))); $this->form->setValidator('parent', new sfValidatorString()); $choices = array(); if (isset($this->resource->parent)) { $choices[$this->context->routing->generate(null, array($this->resource->parent, 'module' => 'term'))] = $this->resource->parent; } if (isset($this->request->parent)) { $this->form->setDefault('parent', $this->request->parent); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->parent)); $choices[$this->request->parent] = $params['_sf_route']->resource; } $this->form->setWidget('parent', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'relatedTerms': $value = $choices = array(); foreach ($this->relations = QubitRelation::getBySubjectOrObjectId($this->resource->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)) as $item) { $choices[$value[] = $this->context->routing->generate(null, array($item->object, 'module' => 'term'))] = $item->object; } $this->form->setDefault('relatedTerms', $value); $this->form->setValidator('relatedTerms', new sfValidatorPass()); $this->form->setWidget('relatedTerms', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true))); break; case 'taxonomy': $this->form->setDefault('taxonomy', $this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))); $this->form->setValidator('taxonomy', new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('This is a mandatory element.')))); $choices = array(); if (isset($this->resource->taxonomy)) { $choices[$this->context->routing->generate(null, array($this->resource->taxonomy, 'module' => 'taxonomy'))] = $this->resource->taxonomy; } if (isset($this->request->taxonomy)) { $this->form->setDefault('taxonomy', $this->request->taxonomy); $params = $this->context->routing->parse(Qubit::pathInfo($this->request->taxonomy)); $choices[$this->request->taxonomy] = $params['_sf_route']->resource; } $this->form->setWidget('taxonomy', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'useFor': $criteria = new Criteria(); $criteria->add(QubitOtherName::OBJECT_ID, $this->resource->id); $criteria->add(QubitOtherName::TYPE_ID, QubitTerm::ALTERNATIVE_LABEL_ID); $value = $defaults = array(); foreach ($this->useFor = QubitOtherName::get($criteria) as $item) { $defaults[$value[] = $item->id] = $item; } $this->form->setDefault('useFor', $value); $this->form->setValidator('useFor', new sfValidatorPass()); $this->form->setWidget('useFor', new QubitWidgetFormInputMany(array('defaults' => $defaults))); break; default: return parent::addField($name); } }