public function putLayers($layers) { //mdump($layers); $layerCE = new \StdClass(); $type = new Type(); $instances = $type->getInstantiationType('int_normal')->asQuery()->getResult(); $itNormal = $instances[0]['idInstantiationType']; $hasFE = []; try { $transaction = $this->beginTransaction(); $label = new Label(); foreach ($layers as $layer) { $idLayer = $layer->idLayer; if ($idLayer == '') { continue; } if ($layer->layerTypeEntry == 'lty_ce') { $layerCE = $layer; } $labels = array(); if ($layer->idLayerType != 0) { $delCriteria = $label->getDeleteCriteria()->where("idLayer = {$idLayer}")->delete(); if ($layer->layerTypeEntry == 'lty_cefe') { $idFrame = $layer->idFrame; unset($layer); $layer = clone $layerCE; $layer->layerTypeEntry = 'lty_cefe'; $queryCEFE = $this->getElementCxnFrame($idFrame); $cefe = $queryCEFE->chunkResult('idEntityCE', 'idEntityFE'); foreach ($layerCE as $key => $value) { if (substr($key, 0, 2) == 'wf') { if ($cefe[$value]) { $layer->{$key} = $cefe[$value]; } } } } $i = -1; $l = 0; $o = -1; foreach ($layer as $key => $value) { if (substr($key, 0, 2) == 'wf') { $idLabelType = $layer->{$key}; if ($idLabelType == '') { continue; } $pos = (int) substr($key, 2); if ($idLabelType != $l || $pos > $o) { $i++; $labels[$i] = (object) ['idLabelType' => $idLabelType, 'startChar' => $pos, 'endChar' => $pos]; $l = $idLabelType; } else { $labels[$i]->endChar = $pos; } $o = $pos + 1; } } } if (count($labels)) { if ($layer->layerTypeEntry == 'lty_fe') { $hasFE[$layer->idAnnotationSet] = true; } if ($layer->layerTypeEntry == 'lty_ce') { $hasFE[$layer->idAnnotationSet] = true; } foreach ($labels as $labelObj) { $label->setPersistent(FALSE); $label->setIdLayer($idLayer); $label->setIdLabelType($labelObj->idLabelType); $label->setStartChar($labelObj->startChar); $label->setEndChar($labelObj->endChar); $label->setMulti(0); $label->setIdInstantiationType($itNormal); $label->save(); } } if ($layer->ni->{$idLayer}) { $hasFE[$layer->idAnnotationSet] = true; foreach ($layer->ni->{$idLayer} as $idLabelType => $ni) { $label->setPersistent(FALSE); $label->setIdLayer($idLayer); $label->setIdLabelType($idLabelType); $label->setidInstantiationType($ni->idInstantiationType); $label->setStartChar(NULL); $label->setEndChar(NULL); $label->setMulti(0); $label->save(); } } } $transaction->commit(); return $hasFE; } catch (EModelException $e) { $transaction->rollback(); throw new EModelException($e->getMessage()); } }