public static function get_relation_for_user($uid, $type = NULL, $load_attrs = true)
 {
     $relation = array('subject_service' => 'internal', 'subject_type' => 'user', 'subject_id' => $uid, 'object_service' => 'typedGroup');
     if ($type) {
         $relation['object_type'] = $type;
     }
     $match = parent::load_match($relation, $load_attrs);
     return $match;
 }
コード例 #2
0
 public function createLayersForCxn($cxn, $data)
 {
     $layerType = new LayerType();
     $layerTypes = $layerType->listToConstruction();
     foreach ($layerTypes as $lt) {
         $layer = new Layer();
         $layer->setIdLayerType($lt['idLayerType']);
         $layer->setIdAnnotationSet($this->getId());
         $layer->setRank(1);
         $layer->save();
     }
     // obtem as relações CXN-FR e cria as camadas FE
     $layerCEFE = $layerType->listCEFE();
     $er = new EntityRelation();
     $relations = $er->listCxnFrameRelations($cxn->getIdEntity())->asQuery()->getResult();
     foreach ($relations as $relation) {
         $layer = new Layer();
         $layer->setIdLayerType($layerCEFE[0]['idLayerType']);
         $layer->setIdAnnotationSet($this->getId());
         $layer->setRank(1);
         $layer->save();
     }
 }
コード例 #3
0
 public static function load_match($r, $load_attrs = true)
 {
     $where = " WHERE 1 ";
     $args = array();
     foreach ($r as $k => $v) {
         $where .= " AND {$k}=?";
         $args[] = $v;
     }
     $relations = self::load_many_from_query("EntityRelation", "SELECT * FROM {entityrelations} {$where}", $args);
     if ($load_attrs) {
         // get attributes
         foreach ($relations as $relation) {
             $relation->attributes = EntityRelation::load_attributes($relation->id);
         }
     }
     return $relations;
 }
コード例 #4
0
 public function delSemanticTypeFromEntity($idEntity, $idSemanticTypeEntity = [])
 {
     $rt = new RelationType();
     $c = $rt->getCriteria()->select('idRelationType')->where("entry = 'rel_hassemtype'");
     $er = new EntityRelation();
     $transaction = $er->beginTransaction();
     $criteria = $er->getDeleteCriteria();
     $criteria->where("idEntity1 = {$idEntity}");
     $criteria->where("idEntity2", "IN", $idSemanticTypeEntity);
     $criteria->where("idRelationType", "=", $c);
     $criteria->delete();
     $transaction->commit();
 }