public function delete($connection = null) { // Cascade delete descendants if (0 < count($children = $this->getChildren())) { foreach ($children as $child) { $child->delete($connection); } } // Delete relations $criteria = new Criteria(); $cton1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->id); $cton2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->id); $cton1->addOr($cton2); $criteria->add($cton1); if (0 < count($relations = QubitRelation::get($criteria))) { foreach ($relations as $relation) { $relation->delete($connection); } } // Delete relation to objects $criteria = new Criteria(); $criteria->add(QubitObjectTermRelation::TERM_ID, $this->id); if (0 < count($otRelations = QubitObjectTermRelation::get($criteria))) { foreach ($otRelations as $otRelation) { $otRelation->delete($connection); } } parent::delete($connection); }
/** * Delete relation records linking this physical object to information objects */ public function deleteInformationObjectRelations() { $informationObjectRelations = QubitRelation::getRelationsBySubjectId($this->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)); foreach ($informationObjectRelations as $relation) { $relation->delete(); } }
public function execute($request) { $this->resource = $request->getAttribute('sf_route')->resource; $criteria = new Criteria(); $criteria->add(QubitEvent::ACTOR_ID, $this->resource->id); $criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID, QubitInformationObject::ID); $criteria->addAscendingOrderByColumn(QubitEvent::TYPE_ID); // Sort info objects alphabetically (w/ fallback) $criteria->addAscendingOrderByColumn('title'); $criteria = QubitCultureFallback::addFallbackCriteria($criteria, 'QubitInformationObject'); // Filter draft descriptions $criteria = QubitAcl::addFilterDraftsCriteria($criteria); $this->relatedInfoObjects = array(); foreach (QubitEvent::get($criteria) as $item) { $this->relatedInfoObjects[$item->type->getRole()][] = $item->informationObject; } // Get "subject of" information objects (name access point) $criteria = new Criteria(); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID); $this->subjectInfoObjects = array(); foreach (QubitRelation::get($criteria) as $item) { $this->subjectInfoObjects[] = $item->subject; } }
public function delete($connection = null) { // Make sure that the associated QubitRelation object is removed before foreach (QubitRelation::getRelationsByObjectId($this->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) { $item->delete(); } parent::delete($connection); }
public function execute($request) { $this->resource = $request->getAttribute('sf_route')->resource; $this->physicalObjects = array(); foreach (QubitRelation::getRelatedSubjectsByObjectId('QubitPhysicalObject', $this->resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as $item) { $this->physicalObjects[$item->id] = $item; } if (1 > count($this->physicalObjects)) { return sfView::NONE; } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; if ($request->isMethod('delete')) { foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'rightsholder', 'action' => 'browse')); } }
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 execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; if ($request->isMethod('delete')) { foreach ($this->resource->informationObjects as $item) { unset($item->repository); $item->save(); } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'repository', 'action' => 'browse')); } }
public function execute($request) { parent::execute($request); $this->isad = new sfIsadPlugin($this->resource); if (1 > strlen($title = $this->resource)) { $title = $this->context->i18n->__('Untitled'); } $this->response->setTitle("{$title} - {$this->response->getTitle()}"); // Function relations $criteria = new Criteria(); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->addJoin(QubitRelation::SUBJECT_ID, QubitFunction::ID); $this->functionRelations = QubitRelation::get($criteria); if (QubitAcl::check($this->resource, 'update')) { $validatorSchema = new sfValidatorSchema(); $values = array(); $validatorSchema->creators = new QubitValidatorCountable(array('required' => true), array('required' => $this->context->i18n->__('This archival description, or one of its higher levels, %1%requires%2% at least one %3%creator%4%.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#3.2.1">', '%4%' => '</a>')))); foreach ($this->resource->ancestors->andSelf()->orderBy('rgt') as $item) { $values['creators'] = $item->getCreators(); if (0 < count($values['creators'])) { break; } } $validatorSchema->dateRange = new QubitValidatorIsadDates(array(), array('invalid' => $this->context->i18n->__('%1%Date(s)%2% - are not consistent with %3%higher levels%2%.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.3">', '%2%' => '</a>', '%3%' => '<a href="%ancestor%">')))); $values['dateRange'] = $this->resource; $validatorSchema->dates = new QubitValidatorCountable(array('required' => true), array('required' => $this->context->i18n->__('%1%Date(s)%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.3">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['dates'] = $this->resource->getDates(); $validatorSchema->extentAndMedium = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Extent and medium%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.5">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['extentAndMedium'] = $this->resource->getExtentAndMedium(array('cultureFallback' => true)); $validatorSchema->identifier = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Identifier%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.1">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['identifier'] = $this->resource->identifier; $this->addField($validatorSchema, 'levelOfDescription'); $validatorSchema->levelOfDescription->setMessage('forbidden', $this->context->i18n->__('%1%Level of description%2% - Value "%value%" is not consistent with higher levels.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.4">', '%2%' => '</a>'))); $validatorSchema->levelOfDescription->setMessage('required', $this->context->i18n->__('%1%Level of description%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.4">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>'))); if (isset($this->resource->levelOfDescription)) { $values['levelOfDescription'] = $this->resource->levelOfDescription->getName(array('sourceCulture' => true)); } $validatorSchema->title = new sfValidatorString(array('required' => true), array('required' => $this->context->i18n->__('%1%Title%2% - This is a %3%mandatory%4% element.', array('%1%' => '<a href="http://ica-atom.org/doc/RS-1#3.1.2">', '%2%' => '</a>', '%3%' => '<a href="http://ica-atom.org/doc/RS-1#I.12">', '%4%' => '</a>')))); $values['title'] = $this->resource->getTitle(array('cultureFallback' => true)); try { $validatorSchema->clean($values); } catch (sfValidatorErrorSchema $e) { $this->errorSchema = $e; } } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check user authorization if (!QubitAcl::check($this->resource, 'delete')) { QubitAcl::forwardUnauthorized(); } if ($request->isMethod('delete')) { foreach ($this->resource->deaccessions as $item) { $item->delete(); } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $item) { $item->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'accession', 'action' => 'list')); } }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; // Check that this isn't the root if (!isset($this->resource->parent)) { $this->forward404(); } if ($request->isMethod('delete')) { foreach ($this->resource->events as $item) { if (isset($item->informationObject) && isset($item->type)) { unset($item->actor); $item->save(); } else { $item->delete(); } } foreach (QubitRelation::getBySubjectOrObjectId($this->resource->id) as $relation) { $relation->delete(); } $this->resource->delete(); $this->redirect(array('module' => 'actor', 'action' => 'browse')); } }
echo render_show(__('Type'), $resource->type); ?> <?php echo render_show(__('Location'), $resource->getLocation(array('cultureFallback' => true))); ?> <div class="field"> <h3><?php echo __('Related resources'); ?> </h3> <div> <ul> <?php foreach (QubitRelation::getRelatedObjectsBySubjectId('QubitInformationObject', $resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)) as $item) { ?> <li><?php echo link_to(render_title($item), array($item, 'module' => 'informationobject')); ?> </li> <?php } ?> </ul> </div> </div> </div> <div class="actions section">
/** * Get all relations from/to given object $id * * @param integer $id primary key of object * @param array $options optional parameters * @return QubitQuery collection of QubitRelation objects */ public static function getBySubjectOrObjectId($id, $options = array()) { $criteria = new Criteria(); $criterion1 = $criteria->getNewCriterion(QubitRelation::OBJECT_ID, $id); $criterion2 = $criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $id); $criterion1->addOr($criterion2); // If restricting by relation type if (isset($options['typeId'])) { $criterion3 = $criteria->getNewCriterion(QubitRelation::TYPE_ID, $options['typeId']); $criterion1->addAnd($criterion3); } $criteria->add($criterion1); $criteria->addAscendingOrderByColumn(QubitRelation::TYPE_ID); return QubitRelation::get($criteria); }
public function __get($name) { switch ($name) { case 'biogHist': return self::toDiscursiveSet($this->resource->history); case 'entityType': switch ($this->resource->entityTypeId) { case QubitTerm::CORPORATE_BODY_ID: return 'corporateBody'; case QubitTerm::FAMILY_ID: return 'family'; case QubitTerm::PERSON_ID: return 'person'; } return; case 'existDates': // TODO <date/>, <dateRange/>, <dateSet/>, <descriptiveNote/>, simple // natural language parsing? return '<date>' . esc_specialchars($this->resource->datesOfExistence) . '</date>'; case 'generalContext': return self::toDiscursiveSet($this->resource->generalContext); case 'maintenanceHistory': ProjectConfiguration::getActive()->loadHelpers('Date'); $createdAt = format_date($this->resource->createdAt, 's'); $updatedAt = format_date($this->resource->updatedAt, 's'); $createdDisplay = format_date($this->resource->createdAt, 'F'); $updatedDisplay = format_date($this->resource->updatedAt, 'F'); return <<<return <maintenanceEvent> <eventType>created</eventType> <eventDateTime standardDateTime="{$createdAt}">{$createdDisplay}</eventDateTime> <agentType>human</agentType> <agent/> </maintenanceEvent> <maintenanceEvent> <eventType>revised</eventType> <eventDateTime standardDateTime="{$updatedAt}">{$updatedDisplay}</eventDateTime> <agentType>human</agentType> <agent/> </maintenanceEvent> return; case 'maintenanceStatus': switch (strtolower($this->resource->descriptionStatus)) { case 'revised': return 'revised'; default: return 'new'; } case 'publicationStatus': return 'approved'; case 'resourceRelation': $criteria = new Criteria(); $criteria->add(QubitEvent::ACTOR_ID, $this->resource->id); $criteria->addJoin(QubitEvent::INFORMATION_OBJECT_ID, QubitInformationObject::ID); return QubitEvent::get($criteria); case 'functionRelation': $criteria = new Criteria(); $criteria->addAlias('subj', QubitObject::TABLE_NAME); $criteria->addJoin(QubitRelation::SUBJECT_ID, 'subj.id'); $criteria->add(QubitRelation::OBJECT_ID, $this->resource->id); $criteria->add('subj.class_name', 'QubitFunction'); return QubitRelation::get($criteria); case 'structureOrGenealogy': return self::toDiscursiveSet($this->resource->internalStructures); } }
/** * Override base delete method to unlink related digital assets (thumbnail * and file) * * @param sfConnection A database connection */ public function delete($connection = null) { $criteria = new Criteria(); $criteria->add(QubitDigitalObject::PARENT_ID, $this->id); $children = QubitDigitalObject::get($criteria); // Delete children foreach ($children as $child) { foreach (QubitRelation::getBySubjectOrObjectId($this->id) as $item) { $item->delete(); } $child->delete(); } // Delete digital asset if (file_exists($this->getAbsolutePath())) { unlink($this->getAbsolutePath()); } // Prune asset directory, if empty self::pruneEmptyDirs(sfConfig::get('sf_web_dir') . $this->path); foreach (QubitRelation::getBySubjectOrObjectId($this->id) as $item) { $item->delete(); } // Update search index before deleting self if (!empty($this->informationObjectId)) { QubitSearch::updateInformationObject($this->getInformationObject()); } // Delete self parent::delete($connection); }
public function execute($request) { parent::execute($request); $this->form->getWidgetSchema()->setNameFormat('relatedDonor[%s]'); $this->relatedDonorRecord = QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::DONOR_ID)); }
<?php echo get_component('right', 'relatedRights', array('resource' => $resource)); ?> </div> <!-- /.section#rightsArea --> <div class="section" id="informationObjectArea"> <h2><?php echo __('Information object area'); ?> </h2> <?php foreach (QubitRelation::getRelationsByObjectId($resource->id, array('typeId' => QubitTerm::ACCESSION_ID)) as $item) { ?> <div class="field"> <h3>Information object</h3> <div> <?php echo link_to(render_title($item->subject), array($item->subject, 'module' => 'informationobject')); ?> </div> </div> <?php } ?>
public function execute($request) { $this->form = new sfForm(); $this->form->getValidatorSchema()->setOption('allow_extra_fields', true); if (isset($this->nameFormat)) { $this->form->getWidgetSchema()->setNameFormat($this->nameFormat); } else { $this->form->getWidgetSchema()->setNameFormat('editRight[%s]'); } foreach ($this::$NAMES as $name) { $this->addField($name); } $this->rights = QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::RIGHT_ID)); }
<div class="field"> <h3><?php echo __('Associated terms'); ?> </h3> <div> <div class="field"> <h3><?php echo render_title($resource); ?> </h3> <div> <ul> <?php foreach (QubitRelation::getBySubjectOrObjectId($resource->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)) as $item) { ?> <li><?php echo __('RT %1%', array('%1%' => link_to(render_title($item->getOpposedObject($resource->id)), array($item->getOpposedObject($resource->id), 'module' => 'term')))); ?> </li> <?php } ?> </ul> </div> </div> </div> </div>
public static function getrelationsById($id, array $options = array()) { $criteria = new Criteria(); self::addrelationsCriteriaById($criteria, $id); return QubitRelation::get($criteria, $options); }
protected function processForm() { // If object is being duplicated if (isset($this->request->sourceId)) { $sourceInformationObject = QubitInformationObject::getById($this->request->sourceId); // Duplicate physical object relations foreach ($sourceInformationObject->getPhysicalObjects() as $physicalObject) { $this->resource->addPhysicalObject($physicalObject); } // Duplicate notes foreach ($sourceInformationObject->notes as $sourceNote) { if (!isset($this->request->delete_notes[$sourceNote->id])) { $note = new QubitNote(); $note->content = $sourceNote->content; $note->typeId = $sourceNote->type->id; $note->userId = $this->context->user->getAttribute('user_id'); $this->resource->notes[] = $note; } } foreach (QubitRelation::getRelationsBySubjectId($sourceInformationObject->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) { $sourceRight = $item->object; if (false === array_search($this->context->routing->generate(null, array($sourceRight, 'module' => 'right')), (array) $this->request->deleteRights)) { $right = new QubitRights(); $right->act = $sourceRight->act; $right->startDate = $sourceRight->startDate; $right->endDate = $sourceRight->endDate; $right->basis = $sourceRight->basis; $right->restriction = $sourceRight->restriction; $right->copyrightStatus = $sourceRight->copyrightStatus; $right->copyrightStatusDate = $sourceRight->copyrightStatusDate; $right->copyrightJurisdiction = $sourceRight->copyrightJurisdiction; $right->statuteNote = $sourceRight->statuteNote; // Right holder if (isset($sourceRight->rightsHolder)) { $right->rightsHolder = $sourceRight->rightsHolder; } // I18n $right->rightsNote = $sourceRight->rightsNote; $right->copyrightNote = $sourceRight->copyrightNote; $right->licenseIdentifier = $sourceRight->licenseIdentifier; $right->licenseTerms = $sourceRight->licenseTerms; $right->licenseNote = $sourceRight->licenseNote; $right->statuteJurisdiction = $sourceRight->statuteJurisdiction; $right->statuteCitation = $sourceRight->statuteCitation; $right->statuteDeterminationDate = $sourceRight->statuteDeterminationDate; foreach ($sourceRight->rightsI18ns as $sourceRightI18n) { if ($this->context->user->getCulture() == $sourceRightI18n->culture) { continue; } $rightI18n = new QubitRightsI18n(); $rightI18n->rightNote = $sourceRightI18n->rightNote; $rightI18n->copyrightNote = $sourceRightI18n->copyrightNote; $rightI18n->licenseIdentifier = $sourceRightI18n->licenseIdentifier; $rightI18n->licenseTerms = $sourceRightI18n->licenseTerms; $rightI18n->licenseNote = $sourceRightI18n->licenseNote; $rightI18n->statuteJurisdiction = $sourceRightI18n->statuteJurisdiction; $rightI18n->statuteCitation = $sourceRightI18n->statuteCitation; $rightI18n->statuteNote = $sourceRightI18n->statuteNote; $rightI18n->culture = $sourceRightI18n->culture; $right->rightsI18ns[] = $rightI18n; } $right->save(); $relation = new QubitRelation(); $relation->object = $right; $relation->typeId = QubitTerm::RIGHT_ID; $this->resource->relationsRelatedBysubjectId[] = $relation; } } if ('sfIsadPlugin' != $this->request->module) { foreach ($sourceInformationObject->events as $sourceEvent) { if (false === array_search($this->context->routing->generate(null, array($sourceEvent, 'module' => 'event')), (array) $this->request->deleteEvents)) { $event = new QubitEvent(); $event->actorId = $sourceEvent->actorId; $event->typeId = $sourceEvent->typeId; $event->startDate = $sourceEvent->startDate; $event->endDate = $sourceEvent->endDate; $event->sourceCulture = $sourceEvent->sourceCulture; // I18n $event->name = $sourceEvent->name; $event->description = $sourceEvent->description; $event->date = $sourceEvent->date; foreach ($sourceEvent->eventI18ns as $sourceEventI18n) { if ($this->context->user->getCulture() == $sourceEventI18n->culture) { continue; } $eventI18n = new QubitEventI18n(); $eventI18n->name = $sourceEventI18n->name; $eventI18n->description = $sourceEventI18n->description; $eventI18n->date = $sourceEventI18n->date; $eventI18n->culture = $sourceEventI18n->culture; $event->eventI18ns[] = $eventI18n; } // Place if (null !== ($place = QubitObjectTermRelation::getOneByObjectId($sourceEvent->id))) { $termRelation = new QubitObjectTermRelation(); $termRelation->term = $place->term; $event->objectTermRelationsRelatedByobjectId[] = $termRelation; } $this->resource->events[] = $event; } } } } parent::processForm(); $this->deleteNotes(); $this->updateChildLevels(); $this->updateStatus(); // Must come after updateChildLevels() }
public function __get($name) { switch ($name) { case '_event': // Because simple Dublin Core cannot qualify the <date/> or <coverage/> // elements, we only return a limited set of events: just those that // are related to creation/origination $event = array(); foreach ($this->resource->events as $item) { switch ($item->typeId) { case QubitTerm::CREATION_ID: case QubitTerm::CONTRIBUTION_ID: case QubitTerm::PUBLICATION_ID: case QubitTerm::COLLECTION_ID: case QubitTerm::ACCUMULATION_ID: $event[] = $item; break; } } return $event; case 'coverage': $coverage = array(); foreach ($this->resource->events as $item) { if (null !== ($place = $item->getPlace())) { $coverage[] = $place; } } foreach ($this->resource->getPlaceAccessPoints() as $item) { $coverage[] = $item->term; } return $coverage; case 'date': $list = array(); foreach ($this->_event as $item) { if (isset($item->startDate)) { $date = $item->startDate; if (isset($item->endDate)) { $date .= "/{$item->endDate}"; } $list[] = $date; } } return $list; case 'format': $format = array(); if (null !== ($digitalObject = $this->resource->getDigitalObject())) { if (isset($digitalObject->mimeType)) { $format[] = $digitalObject->mimeType; } } if (isset($this->resource->extentAndMedium)) { $format[] = $this->resource->getExtentAndMedium(array('cultureFallback' => true)); } return $format; case 'identifier': return $this->resource->referenceCode; case 'sourceCulture': return $this->resource->sourceCulture; case 'subject': $subject = array(); foreach ($this->resource->getSubjectAccessPoints() as $item) { $subject[] = $item->term; } // Add name access points $criteria = new Criteria(); $criteria = $this->resource->addrelationsRelatedBysubjectIdCriteria($criteria); $criteria->add(QubitRelation::TYPE_ID, QubitTerm::NAME_ACCESS_POINT_ID); foreach (QubitRelation::get($criteria) as $item) { $subject[] = $item->object; } return $subject; case 'type': $type = array(); foreach ($this->resource->getTermRelations(QubitTaxonomy::DC_TYPE_ID) as $item) { $type[] = $item->term; } // Map media type to DCMI type vocabulary if (null !== ($digitalObject = $this->resource->getDigitalObject())) { switch ($digitalObject->mediaType) { case 'Image': $type[] = 'image'; break; case 'Video': $type[] = 'moving image'; break; case 'Audio': $type[] = 'sound'; break; case 'Text': $type[] = 'text'; break; } } return $type; } }
public function execute($request) { parent::execute($request); $this->relations = QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)); if ($request->isMethod('post')) { $this->form->bind($request->getPostParameters()); if ($this->form->isValid()) { $this->processForm(); $this->resource->save(); $this->redirect(array($this->resource, 'module' => 'informationobject')); } } }
/** * Get actor-to-actor relations linked to this actor * * @return QubitQuery collection of QubitRelation objects */ public function getActorRelations() { $criteria = new Criteria(); $criteria->addJoin(QubitRelation::TYPE_ID, QubitTerm::ID); $criteria->add($criteria->getNewCriterion(QubitRelation::OBJECT_ID, $this->id)->addOr($criteria->getNewCriterion(QubitRelation::SUBJECT_ID, $this->id))->addAnd($criteria->getNewCriterion(QubitTerm::TAXONOMY_ID, QubitTaxonomy::ACTOR_RELATION_TYPE_ID))); $criteria->addAscendingOrderByColumn(QubitRelation::TYPE_ID); $criteria->addDescendingOrderByColumn(QubitRelation::START_DATE); return QubitRelation::get($criteria); }
protected function addField($name) { switch ($name) { case 'acquisitionType': $this->form->setDefault('acquisitionType', $this->context->routing->generate(null, array($this->resource->acquisitionType, 'module' => 'term'))); $this->form->setValidator('acquisitionType', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_ACQUISITION_TYPE_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('acquisitionType', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'processingPriority': $this->form->setDefault('processingPriority', $this->context->routing->generate(null, array($this->resource->processingPriority, 'module' => 'term'))); $this->form->setValidator('processingPriority', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_PRIORITY_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('processingPriority', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'processingStatus': $this->form->setDefault('processingStatus', $this->context->routing->generate(null, array($this->resource->processingStatus, 'module' => 'term'))); $this->form->setValidator('processingStatus', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_PROCESSING_STATUS_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('processingStatus', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'resourceType': $this->form->setDefault('resourceType', $this->context->routing->generate(null, array($this->resource->resourceType, 'module' => 'term'))); $this->form->setValidator('resourceType', new sfValidatorString()); $choices = array(); $choices[null] = null; foreach (QubitTaxonomy::getTermsById(QubitTaxonomy::ACCESSION_RESOURCE_TYPE_ID) as $item) { $choices[$this->context->routing->generate(null, array($item, 'module' => 'term'))] = $item; } $this->form->setWidget('resourceType', new sfWidgetFormSelect(array('choices' => $choices))); break; case 'creators': $value = $choices = array(); foreach ($this->creators = QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::CREATION_ID)) as $item) { $choices[$value[] = $this->context->routing->generate(null, array($item->subject, 'module' => 'actor'))] = $item->subject; } $this->form->setDefault('creators', $value); $this->form->setValidator('creators', new sfValidatorPass()); $this->form->setWidget('creators', new sfWidgetFormSelect(array('choices' => $choices, 'multiple' => true))); break; case 'date': $this->form->setDefault('date', Qubit::renderDate($this->resource['date'])); if (!isset($this->resource->id)) { $dt = new DateTime(); $this->form->setDefault('date', $dt->format('Y-m-d')); } $this->form->setValidator('date', new sfValidatorString()); $this->form->setWidget('date', new sfWidgetFormInput()); break; case 'identifier': $this->form->setDefault('identifier', $this->resource['identifier']); if (!isset($this->resource->id)) { $dt = new DateTime(); $this->form->setDefault('identifier', QubitAccession::generateAccessionIdentifier()); } $this->form->setValidator('identifier', new sfValidatorString()); $this->form->setWidget('identifier', new sfWidgetFormInput(array(), array('disabled' => 'disabled'))); break; case 'receivedExtentUnits': case 'title': $this->form->setDefault($name, $this->resource[$name]); $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormInput()); break; case 'appraisal': case 'archivalHistory': case 'locationInformation': case 'physicalCharacteristics': case 'processingNotes': case 'scopeAndContent': case 'sourceOfAcquisition': $this->form->setDefault($name, $this->resource[$name]); $this->form->setValidator($name, new sfValidatorString()); $this->form->setWidget($name, new sfWidgetFormTextarea()); break; default: return parent::addField($name); } }
?> <?php foreach ($term->getChildren() as $child) { ?> <skos:narrower rdf:resource="<?php echo url_for(array($child, 'module' => 'term'), true); ?> "/> <?php } // children ?> <?php if (0 < count($relations = QubitRelation::getBySubjectOrObjectId($term->id, array('typeId' => QubitTerm::TERM_RELATION_ASSOCIATIVE_ID)))) { ?> <?php foreach ($relations as $relation) { ?> <skos:related rdf:resource="<?php echo url_for(array($relation->getOpposedObject($term->id), 'module' => 'term'), true); ?> "/> <?php } ?> <?php } ?>
protected function addTermRelations($concept) { $subjectUri = $concept->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'about'); if (!$subjectUri instanceof DOMAttr || !isset($this->terms[$subjectUri->nodeValue])) { continue; } foreach ($this->xpath->query('./skos:related', $concept) as $related) { $objectUri = $related->getAttributeNodeNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'resource'); if (!$objectUri instanceof DomAttr || !isset($this->terms[$objectUri->nodeValue])) { continue; } // Don't duplicate relationship foreach ($this->relations as $r) { if ($r['subject'] == $objectUri->nodeValue && $r['object'] == $subjectUri->nodeValue || $r['subject'] == $subjectUri->nodeValue && $r['object'] == $objectUri->nodeValue) { continue 2; } } $relation = new QubitRelation(); $relation->typeId = QubitTerm::TERM_RELATION_ASSOCIATIVE_ID; $relation->subject = $this->terms[$subjectUri->nodeValue]; $relation->object = $this->terms[$objectUri->nodeValue]; $relation->save(); $this->relations[] = array('subject' => $subjectUri->nodeValue, 'object' => $objectUri->nodeValue); } return $this; }
/** * Cascade delete child records in q_relation * */ protected function deletePhysicalObjectRelations() { $relations = QubitRelation::getRelationsByObjectId($this->id, array('typeId' => QubitTerm::HAS_PHYSICAL_OBJECT_ID)); foreach ($relations as $relation) { $relation->delete(); } }
public function getRights($options = array()) { return QubitRelation::getRelationsBySubjectId($this->id, array('typeId' => QubitTerm::RIGHT_ID)); }
public function execute($request) { $this->form = new sfForm(); $this->resource = $this->getRoute()->resource; if (!QubitAcl::check(QubitInformationObject::getRoot(), 'update')) { QubitAcl::forwardUnauthorized(); } // Create new information object $informationObject = new QubitInformationObject(); $informationObject->setRoot(); // Populate fields $informationObject->title = $this->resource->title; $informationObject->physicalCharacteristics = $this->resource->physicalCharacteristics; $informationObject->scopeAndContent = $this->resource->scopeAndContent; $informationObject->archivalHistory = $this->resource->archivalHistory; // Copy (not link) rights foreach (QubitRelation::getRelationsBySubjectId($this->resource->id, array('typeId' => QubitTerm::RIGHT_ID)) as $item) { $sourceRight = $item->object; $right = new QubitRights(); $right->act = $sourceRight->act; $right->startDate = $sourceRight->startDate; $right->endDate = $sourceRight->endDate; $right->basis = $sourceRight->basis; $right->restriction = $sourceRight->restriction; $right->copyrightStatus = $sourceRight->copyrightStatus; $right->copyrightStatusDate = $sourceRight->copyrightStatusDate; $right->copyrightJurisdiction = $sourceRight->copyrightJurisdiction; $right->statuteNote = $sourceRight->statuteNote; // Right holder if (isset($sourceRight->rightsHolder)) { $right->rightsHolder = $sourceRight->rightsHolder; } // I18n $right->rightsNote = $sourceRight->rightsNote; $right->copyrightNote = $sourceRight->copyrightNote; $right->licenseIdentifier = $sourceRight->licenseIdentifier; $right->licenseTerms = $sourceRight->licenseTerms; $right->licenseNote = $sourceRight->licenseNote; $right->statuteJurisdiction = $sourceRight->statuteJurisdiction; $right->statuteCitation = $sourceRight->statuteCitation; $right->statuteDeterminationDate = $sourceRight->statuteDeterminationDate; foreach ($sourceRight->rightsI18ns as $sourceRightI18n) { if ($this->context->user->getCulture() == $sourceRightI18n->culture) { continue; } $rightI18n = new QubitRightsI18n(); $rightI18n->rightNote = $sourceRightI18n->rightNote; $rightI18n->copyrightNote = $sourceRightI18n->copyrightNote; $rightI18n->licenseIdentifier = $sourceRightI18n->licenseIdentifier; $rightI18n->licenseTerms = $sourceRightI18n->licenseTerms; $rightI18n->licenseNote = $sourceRightI18n->licenseNote; $rightI18n->statuteJurisdiction = $sourceRightI18n->statuteJurisdiction; $rightI18n->statuteCitation = $sourceRightI18n->statuteCitation; $rightI18n->statuteNote = $sourceRightI18n->statuteNote; $rightI18n->culture = $sourceRightI18n->culture; $right->rightsI18ns[] = $rightI18n; } $right->save(); $relation = new QubitRelation(); $relation->object = $right; $relation->typeId = QubitTerm::RIGHT_ID; $informationObject->relationsRelatedBysubjectId[] = $relation; } // Populate creators (from QubitRelation to QubitEvent) foreach (QubitRelation::getRelationsByObjectId($this->resource->id, array('typeId' => QubitTerm::CREATION_ID)) as $item) { $event = new QubitEvent(); $event->actor = $item->subject; $event->typeId = QubitTerm::CREATION_ID; $informationObject->events[] = $event; } // Relationship between the information object and accession record $relation = new QubitRelation(); $relation->object = $this->resource; $relation->typeId = QubitTerm::ACCESSION_ID; $informationObject->relationsRelatedBysubjectId[] = $relation; // Set publication status $informationObject->setPublicationStatus(sfConfig::get('app_defaultPubStatus', QubitTerm::PUBLICATION_STATUS_DRAFT_ID)); $informationObject->save(); $this->redirect(array($informationObject, 'module' => 'informationobject')); }