コード例 #1
0
 public static function autoIndexSearch()
 {
     $em = UtilRepository2::getEntityManager();
     $leyes = UtilRepository2::getRepo("CatarinoBundle:Ley")->findAll();
     $i = 1;
     foreach ($leyes as $ley) {
         $array = DiccionarioIndexacion::excludefromSearch($ley->__toString());
         foreach ($array as $arr) {
             $palabra = UtilRepository2::getRepo("CatarinoBundle:Palabra")->findOneBy(array('valor_norm' => DiccionarioIndexacion::normalizeString($arr)));
             if ($palabra != null) {
                 $palabraLey = UtilRepository2::getRepo("CatarinoBundle:PalabraLey")->findBy(array("palabra" => $palabra->getId(), "ley" => $ley->getId()));
                 if ($palabraLey != null) {
                     $palabraLey = $palabraLey[0];
                     $palabraLey->setFrecuencia($palabraLey->getFrecuencia() + 1);
                     $em->persist($palabraLey);
                     $em->flush();
                 } else {
                     $palabraLey = new PalabraLey();
                     $palabraLey->setValor(" ");
                     $palabraLey->setPeso("0.15");
                     $palabraLey->setFrecuencia("1");
                     $palabraLey->setPalabra($palabra);
                     $palabraLey->setLey($ley);
                     $em->persist($palabraLey);
                     $em->flush();
                 }
             } else {
                 $palabra = new Palabra();
                 $palabra->setClave("0.15");
                 $palabra->setValor($arr);
                 $palabra->setValorNorm(DiccionarioIndexacion::normalizeString($arr));
                 $em->persist($palabra);
                 $palabraLey = new PalabraLey();
                 $palabraLey->setValor(" ");
                 $palabraLey->setPeso("0.15");
                 $palabraLey->setFrecuencia("1");
                 $palabraLey->setPalabra($palabra);
                 $palabraLey->setLey($ley);
                 $em->persist($palabraLey);
                 $em->flush();
             }
         }
     }
     return;
 }
コード例 #2
0
 /**
  * @Route("/read")
  * @Template()
  */
 public function readAction()
 {
     $em = UtilRepository2::getEntityManager();
     $repo = $this->getDoctrine()->getRepository("BaseBundle:Litigante");
     $tramite = $repo->obtenerXEscritoDemanda(18);
     ldd($tramite);
     //        $this->get('comunes.motorgtr')->registrarTramite($tramite);
     //        $em->flush();
     //        $em->persist($tramite);
     //        $em->flush();
     die('paco');
     //        $this->parameters = UtilRepository2::createFiltersFromRequest($this->getRequest());
     //        $method = $this->method;
     //        $result = $repo->$method($this->parameters);
     //        return new \Symfony\Component\HttpFoundation\Response(json_encode($result));
     //        $obj = $repo->generateEnumFromCollection($repo->filterObjects(array('tipoEstado'=> \backend\ComunBundle\Enums\ETipoEstado::Tramite)),'EEstadoTramite');
     //        $obj = $repo->generateEnumToEntity();
     //        $var['total']= UtilRepository2::getSession()->get('total');
     //        ld($table);
     //        ldd(\backend\ComunBundle\Util\UtilRepository2::getEntityManager()->getRepository('ComunBundle:'.$table)->filterObjects());
     //        ldd(\backend\BiomexpressServicesBundle\Manager\BiomexpressServiceManager::authenticate(1, 1));
     //       ldd($obj);
 }
コード例 #3
0
 /**
  * @Route("/crud/tree/delete",name="comun_tree_crud_delete")
  * @return array
  */
 public function deleteAction()
 {
     $result = array();
     $result['success'] = false;
     $entity = $this->get($this->treeModelService)->getEntity();
     $id = $this->getParameter('id');
     if (!is_numeric($id)) {
         $array = explode("_", $id);
         $id = $array[count($array) - 1];
     }
     if ($id && is_numeric($id)) {
         if (!is_array($id)) {
             $id = array($id);
         }
         if (count($id) > 0) {
             $q = UtilRepository2::getEntityManager()->createQuery("delete from {$entity} t where t.id in (:ids)")->setParameter('ids', $id);
             $q->execute();
             $result["success"] = true;
             // pass custom message(useful for getting status of group actions)
             if (count($id) == 1) {
                 $result["sMessage"] = "Elemento eliminado satisfactoriamente.";
             } else {
                 $result["sMessage"] = "Elementos eliminados satisfactoriamente.";
             }
         }
     }
     return new JsonResponse($result);
 }
コード例 #4
0
 /**
  * @return array
  */
 public function deleteAction()
 {
     $id = $this->getParameter('selected');
     try {
         $result = array();
         $entity = $this->get($this->tableModelService)->getEntity();
         if ($id != null) {
             if (!is_array($id)) {
                 $id = array($id);
             }
             if (count($id) > 0) {
                 $q = UtilRepository2::getEntityManager()->createQuery("delete from {$entity} t where t.id in (:ids)")->setParameter('ids', $id);
                 $q->execute();
                 $result["success"] = true;
                 // pass custom message(useful for getting status of group actions)
                 if (count($id) == 1) {
                     $result["sMessage"] = "Elemento eliminado satisfactoriamente.";
                 } else {
                     $result["sMessage"] = "Elementos eliminados satisfactoriamente.";
                 }
             }
         }
         //        return new ArrayResponse($result);
         $data = $this->get($this->tableModelService)->getTransformedData();
         return new JsonResponse(array_merge($result, $data));
     } catch (DBALException $e) {
         //23503 FOREIGN Key Violation
         //            ldd($e);
         $data = $this->get($this->tableModelService)->getTransformedData();
         return new JsonResponse(array_merge_recursive(array('success' => false, 'sMessage' => 'No se puede eliminar un elemento referenciado.', 'code' => $e->getMessage()), $data));
     }
 }