public function ImportarRegistro($Row) { $resultado = new ResultadoLote(); //$resultado->Registros[] = $Row; $nombreBueno = StringHelper::Desoraclizar($Row['detalle']); $entity = $this->em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.direcciones', 'ImportId' => $Row['secretaria'] . '.' . $Row['direccion'])); if (!$entity) { $nuevoId = $this->em->createQuery('SELECT MAX(r.id) FROM YacareOrganizacionBundle:Departamento r')->getSingleScalarResult(); $entity = new \Yacare\OrganizacionBundle\Entity\Departamento(); $entity->setId(++$nuevoId); $entity->setRango(50); $entity->setImportSrc('rr_hh.direcciones'); $entity->setImportId($Row['secretaria'] . '.' . $Row['direccion']); $resultado->RegistrosNuevos++; } else { $resultado->RegistrosActualizados++; } if ($entity->getNombreOriginal() != $Row['detalle']) { $entity->setNombre($nombreBueno); $entity->setNombreOriginal($Row['detalle']); } if ($Row['fecha_baja']) { $entity->setSuprimido(true); } else { $entity->setSuprimido(false); } $Secre = $this->em->getRepository('YacareOrganizacionBundle:Departamento')->findOneBy(array('ImportSrc' => 'rr_hh.secretarias', 'ImportId' => $Row['secretaria'])); $entity->setParentNode($Secre); $this->em->persist($entity); $this->em->flush(); return $resultado; }