public function listLUByWordForm($wordform)
 {
     $criteria = $this->getCriteria();
     $criteria->select('lexeme.lexemeentries.lemma.lus.idLU');
     $criteria->where("upper(form) = upper('{$wordform}')");
     $lus = $criteria->asQuery()->chunkResult('idLU', 'idLU');
     if (count($lus) > 0) {
         $lu = new LU();
         $criteria = $lu->getCriteria()->select("idLU, concat(frame.entries.name,'.',name) as fullName");
         Base::relation($criteria, 'lu', 'frame', 'rel_evokes');
         Base::entryLanguage($criteria, 'frame');
         $criteria->where("idLU", "IN", $lus);
         $criteria->where("lemma.idLanguage", "=", "frame.entries.idLanguage");
         return $criteria->asQuery()->chunkResult('idLU', 'fullName');
     } else {
         return new \stdClass();
     }
 }
 public function updateLU()
 {
     try {
         $model = new LU($this->data->lu->idLU);
         $model->setData($this->data->lu);
         $model->save();
         $this->renderPrompt('information', 'OK');
     } catch (\Exception $e) {
         $this->renderPrompt('error', $e->getMessage());
     }
 }
 public function addManualSubCorpusLU($data)
 {
     $transaction = $this->beginTransaction();
     try {
         // verifica se a LU já tem um SubCorpus manually-added
         $criteria = $this->getCriteria()->select('min(idSubCorpus) as idSubCorpusManual');
         Base::relation($criteria, 'lu', 'subcorpus', 'rel_hassubcorpus');
         $criteria->where("lu.idLU = {$data->idLU}");
         $criteria->where("entity.alias like 'sco_manually-added%'");
         $idSubCorpus = $criteria->asQuery()->getResult()[0]['idSubCorpusManual'];
         if ($idSubCorpus) {
             $this->getById($idSubCorpus);
         } else {
             $entity = Base::createEntity('SC', 'sco_manually-added');
             $this->setName('manually-added');
             $this->setRank(0);
             $this->setIdEntity($entity->getId());
             $this->save();
         }
         $lu = LU::create($data->idLU);
         Base::createEntityRelation($lu->getIdEntity(), 'rel_hassubcorpus', $this->getIdEntity());
         $annotationSet = new AnnotationSet();
         $annotationSet->setIdSubCorpus($this->getId());
         $annotationSet->setIdSentence($data->idSentence);
         $annotationSet->setIdAnnotationStatus('ast_manual');
         $annotationSet->save();
         $annotationSet->createLayersForLU($lu, $data);
         $transaction->commit();
     } catch (\Exception $ex) {
         $transaction->rollback();
         throw new \Exception($ex->getMessage());
     }
 }
 public function getConstraintsLU()
 {
     $idUser = $this->data->id;
     $user = new User($idUser);
     $lus = $user->getConfigData('fnbr20ConstraintsLU');
     $lu = new LU();
     if (is_array($lus) && count($lus)) {
         $result = $lu->listForConstraint($lus)->asQuery()->getResult();
         foreach ($result as $row) {
             $l[] = (object) $row;
         }
         $r = $l;
     } else {
         $r = null;
     }
     $this->renderJson(json_encode($r));
 }