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()); } }