public int getUserDetailsCountBySessionId(String searchq, Long sessionPK) {
    Session session = getSession();
    session.getTransaction().begin();

    int totalRowCount = 0;
    Criteria criteria = session.createCriteria(BrowserDetails.class, "browserDetails");
    criteria.createAlias("browserDetails.sessionDetails", "sessionDetails");
    criteria.createAlias("browserDetails.deviceDetails", "deviceDetails");
    criteria.createAlias("browserDetails.eventDetails", "eventDetails");
    criteria.add(Restrictions.eq("sessionDetails.SID", sessionPK));
    criteria.setProjection(Projections.count("eventDetails.EID"));

    if (!searchq.isEmpty()) {
      criteria.add(
          Restrictions.disjunction()
              .add(Restrictions.ilike("deviceDetails.deviceName", searchq, MatchMode.ANYWHERE))
              .add(Restrictions.ilike("browserName", searchq, MatchMode.ANYWHERE))
              .add(Restrictions.ilike("eventDetails.eventName", searchq, MatchMode.ANYWHERE))
              .add(Restrictions.ilike("eventDetails.orientation", searchq, MatchMode.ANYWHERE)));
    }

    Long value = (Long) criteria.uniqueResult();
    totalRowCount = Integer.valueOf(value.intValue());

    session.getTransaction().commit();
    session.close();

    return totalRowCount;
  }
  public Criteria createCriteria(
      String alias, int joinType, Page page, final Criterion... criterions) {
    Criteria criteria = getSession().createCriteria(entityClass);

    if (joinType == 0) {
      criteria.createAlias(alias, "_" + alias, CriteriaSpecification.INNER_JOIN);
    } else if (joinType == 1) {
      criteria.createAlias(alias, "_" + alias, CriteriaSpecification.LEFT_JOIN);
    } else if (joinType == 4) {
      criteria.createAlias(alias, "_" + alias, CriteriaSpecification.FULL_JOIN);
    }

    for (Criterion c : criterions) {
      criteria.add(c);
    }

    if (page.isOrderBySetted()) {
      String[] orderByArray = StringUtils.split(page.getOrderBy(), ',');
      String[] orderArray = StringUtils.split(page.getOrder(), ',');

      Assert.isTrue(orderByArray.length == orderArray.length, "多重排序参数中,排序字段与排序方向的个数不相等");

      for (int i = 0; i < orderByArray.length; i++) {
        if (Page.ASC.equals(orderArray[i])) {
          criteria.addOrder(Order.asc(orderByArray[i]));
        } else {
          criteria.addOrder(Order.desc(orderByArray[i]));
        }
      }
    }
    return criteria;
  }
示例#3
0
  public int getNumDocuments(String folderId) {
    DmFolder folder = null;
    if (folderId != null) {
      folder = new DmFolder();
      folder.setId(folderId);
    }

    if (folder != null) {
      Disjunction disjunction = Restrictions.disjunction();
      disjunction.add(Restrictions.isNull("docApproval.id"));
      disjunction.add(
          Restrictions.ne("docApproval.status", ApplicationConstants.APPROVAL_STATUS_REJECTED));

      Criteria crit = getSession().createCriteria(DmDocumentFolder.class);
      crit.createAlias("document", "docInfo");
      crit.createAlias("docInfo.approval", "docApproval", CriteriaSpecification.LEFT_JOIN);
      crit.add(Restrictions.eq("folder", folder));
      //            crit.add(Restrictions.eq("docInfo.approved", true));
      crit.add(disjunction);

      return crit.list().size();
    }

    return 0;
  }
示例#4
0
  @Override
  public Long getTotalCount(Reply model) {
    Criteria criteria = getCurrentSession().createCriteria(Reply.class);

    criteria.createAlias("potential", "potential", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias(
        "potentialStuStatus", "potentialStuStatus", CriteriaSpecification.LEFT_JOIN);
    criteria.createAlias("user", "user", CriteriaSpecification.LEFT_JOIN);
    if (model != null && model.getPotential().getPotentialId() != null) {
      criteria.add(Restrictions.eq("potential.potentialId", model.getPotential().getPotentialId()));
    }
    if (model != null
        && model.getPotentialStuStatus() != null
        && model.getPotentialStuStatus().getPotentialStuStatusId() != null) {
      criteria.add(
          Restrictions.eq(
              "potentialStuStatus.potentialStuStatusId",
              model.getPotentialStuStatus().getPotentialStuStatusId()));
    }
    if (model != null && model.getReplyDate() != null) {
      criteria.add(Restrictions.eq("replyDate", model.getReplyDate()));
    }
    if (model != null && model.getNextReplyDate() != null) {
      criteria.add(Restrictions.eq("nextReplyDate", model.getNextReplyDate()));
    }
    criteria.setProjection(Projections.rowCount());
    return new Long(criteria.uniqueResult().toString());
  }
  @Test
  @TestForIssue(jiraKey = "HHH-7767")
  public void testCriteriaRestrictionOnIdManyToOne() {
    Session s = openSession();
    s.beginTransaction();

    s.createQuery("from Course c join c.students cs join cs.student s where s.name = 'Foo'").list();

    Criteria criteria = s.createCriteria(Course.class);
    criteria
        .createCriteria("students")
        .createCriteria("student")
        .add(Restrictions.eq("name", "Foo"));
    criteria.list();

    Criteria criteria2 = s.createCriteria(Course.class);
    criteria2.createAlias("students", "cs");
    criteria2.add(Restrictions.eq("cs.value", "Bar"));
    criteria2.createAlias("cs.student", "s");
    criteria2.add(Restrictions.eq("s.name", "Foo"));
    criteria2.list();

    s.getTransaction().commit();
    s.close();
  }
  @Override
  public Long countInscritosPorGradeOficina(
      Integer idCursoSelecionado, Integer idGradeOficina, List<Integer> idsParceiros) {

    List<Integer> idsStatus = new ArrayList<Integer>();
    idsStatus.add(Status.CANCELADO);
    idsStatus.add(Status.AGUARDANDO_VAGA_PRIORIDADE);
    idsStatus.add(Status.AGUARDANDO_VAGA);

    Criteria criteria = getSession().createCriteria(InscricaoGrade.class);
    criteria.createAlias("inscricaoCurso", "i");
    criteria.createAlias("i.curso", "c");
    criteria.add(Restrictions.eq("c.id", idCursoSelecionado));
    criteria.createAlias("i.ultimoStatus", "us");
    criteria.createAlias("us.status", "s");
    criteria.add(Restrictions.not(Restrictions.in("s.id", idsStatus)));
    criteria.add(Restrictions.eq("gradeOficina.id", idGradeOficina));
    if (idsParceiros != null && !idsParceiros.isEmpty()) {
      criteria.createAlias("i.candidato", "cand");
      criteria.add(Restrictions.not(Restrictions.in("cand.id", idsParceiros)));
    }
    criteria.setProjection(Projections.rowCount());
    Long result = (Long) criteria.list().get(0);
    return result;
  }
  @SuppressWarnings("unchecked")
  @Override
  public Collection<FuncionarioAreaTrabajoDTO> consultarFuncionarioAreaTrabajoPorAreaTrabajo(
      Integer codigoAreaTrabajo, String userId, Integer codigoCompania, String usuarioSesion)
      throws SICException {
    try {

      Criteria criteria =
          sessionFactory.getCurrentSession().createCriteria(FuncionarioAreaTrabajoDTO.class);
      criteria.setProjection(
          Projections.projectionList()
              .add(Projections.property("usuarioDTO.userId"), "funcionarioDTO.usuarioDTO.userId")
              .add(
                  Projections.property("usuarioDTO.userCompleteName"),
                  "funcionarioDTO.usuarioDTO.userCompleteName")
              .add(
                  Projections.property("usuarioDTO.userName"), "funcionarioDTO.usuarioDTO.userName")
              .add(
                  Projections.property("areaTrabajoDTO.nombreAreaTrabajo"),
                  "areaTrabajoDTO.nombreAreaTrabajo")
              .add(Projections.property("id.codigoCompania"), "id.codigoCompania")
              .add(Projections.property("id.codigoFuncionario"), "id.codigoFuncionario")
              .add(Projections.property("id.codigoAreaTrabajo"), "id.codigoAreaTrabajo"));

      criteria.createAlias("funcionarioDTO", "funcionarioDTO");
      criteria.createAlias("funcionarioDTO.usuarioDTO", "usuarioDTO");

      criteria.createAlias("areaTrabajoDTO", "areaTrabajoDTO");

      criteria.add(Restrictions.eq("estado", SICConstantes.ESTADO_ACTIVO_LITERAL));
      criteria.add(
          Restrictions.eq("funcionarioDTO.estadoFuncionario", SICConstantes.ESTADO_ACTIVO_LITERAL));
      criteria.add(
          Restrictions.eq("areaTrabajoDTO.estadoAreaTrabajo", SICConstantes.ESTADO_ACTIVO_LITERAL));

      criteria.add(Restrictions.eq("id.codigoCompania", codigoCompania));
      criteria.add(Restrictions.eq("areaTrabajoDTO.id.codigoAreaTrabajo", codigoAreaTrabajo));
      criteria.add(Restrictions.ne("usuarioDTO.userName", usuarioSesion));

      // si el usuario ingresa un nombre o usuario de un funcionario
      if (StringUtils.isNotEmpty(userId)) {
        Disjunction disjunction = Restrictions.disjunction();
        disjunction.add(Restrictions.ilike("usuarioDTO.userName", userId, MatchMode.ANYWHERE));
        disjunction.add(
            Restrictions.ilike("usuarioDTO.userCompleteName", userId, MatchMode.ANYWHERE));
        criteria.add(disjunction);
      }
      criteria.setResultTransformer(new DtoResultTransformer(FuncionarioAreaTrabajoDTO.class));

      Collection<FuncionarioAreaTrabajoDTO> funcionarioAreaTrabajoDTOCol = criteria.list();

      return funcionarioAreaTrabajoDTOCol;

    } catch (HibernateException e) {
      throw new SICException("Error consultarFuncionarioAreaTrabajoPorAreaTrabajo: ", e);
    } catch (Exception e) {
      throw new SICException("Error consultarFuncionarioAreaTrabajoPorAreaTrabajo ", e);
    }
  }
 private Criteria createCriteria() throws HibernateException {
   Session session = HibernateUtils.getSessionFactory().openSession();
   Criteria criteria = session.createCriteria(Emprestimo.class, "c");
   criteria.createAlias("c.bemMaterial", "bema");
   criteria.createAlias("bema.categoria", "cate");
   criteria.createAlias("cate.usuario", "u");
   criteria.add(Restrictions.eq("u.id", getUsrLogado().getId()));
   return criteria;
 }
 @Override
 public List<Motherboard> findMotherboardByCabinet(Cabinet cabinet) {
   Criteria criteria = sessionFactory.getCurrentSession().createCriteria(Motherboard.class);
   criteria.createAlias("cabinetType", "cabinetType");
   criteria.createAlias("cabinetType.cabinetSize", "cabinetSize");
   Criterion criterion = Restrictions.eq("cabinetSize", cabinet.getCabinetType().getCabinetSize());
   criteria.add(criterion);
   List<Motherboard> motherboardList = criteria.list();
   return motherboardList;
 }
  public List<ProducaoAluno> listarFiltro(int id, int tipo, int roteiro) {
    Criteria criteria = getSession().createCriteria(ProducaoAluno.class);
    criteria.createAlias("aluno", "aluno");
    criteria.add(Restrictions.eq("aluno.idAluno", id));

    criteria.createAlias("tipo", "tipo");
    criteria.add(Restrictions.eq("tipo.idtipoProducaoAluno", tipo));
    criteria.createAlias("roteiro", "roteiro");
    criteria.add(Restrictions.eq("roteiro.idroteiro", roteiro));
    List<ProducaoAluno> result = criteria.list();
    return result;
  }
示例#11
0
  public EmployeeBo retrieveEmployeeWithAttr(EmployeeBo inEmployeeBo) {

    if (null == inEmployeeBo || null == inEmployeeBo.getEmployeeId()) {
      return null;
    }

    Session session = getSession();
    session.beginTransaction();
    EmployeeBo employeeBo = null;
    Criteria empCriteria = session.createCriteria(EmployeeBo.class);
    empCriteria.add(Restrictions.eq("employeeId", inEmployeeBo.getEmployeeId()));
    empCriteria.createAlias("empAttributeSet", "empAttr");
    empCriteria.createAlias("empAttributeSet.employeeAttributesBoID.attributeLookup", "attrLookup");
    // empCriteria.createAlias("attrLookup.attrLookupGroup", "attrLookupGrp");

    // attributeLookup

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("employeeId"));
    projectionList.add(Projections.property("firstName"));
    projectionList.add(Projections.property("lastName"));

    // projectionList.add(Projections.property("attrLookupGrp.groupName"));

    projectionList.add(Projections.property("attrLookup.displayOrder"));
    projectionList.add(Projections.property("attrLookup.attrDesc"));

    projectionList.add(Projections.property("empAttr.attributeName"));
    projectionList.add(Projections.property("empAttr.attributeValue"));

    empCriteria.setProjection(projectionList);
    empCriteria.setFetchMode("empAttr", org.hibernate.FetchMode.EAGER);
    empCriteria.setFetchMode("attrLookup", org.hibernate.FetchMode.EAGER);
    // empCriteria.setFetchMode("attrLookupGrp", org.hibernate.FetchMode.EAGER);

    List<Object> empBoList = empCriteria.list();

    if (null != empBoList) {
      System.out.println(" list size " + empBoList.size());
    }

    for (Object data : empBoList) {
      Object[] projecObjArr = (Object[]) data;
      int count = 0;
      for (Object projecObj : projecObjArr) {
        System.out.print(" projecObjArr[" + count + "] " + projecObj);
        count++;
      }
      System.out.println("");
    }

    return employeeBo;
  }
示例#12
0
    @Override
    public void buildUnordered(Criteria criteria) {

      // Type check
      if (showEventTypesM.getObject().size() < numberOfEventTypes)
        criteria.add(Restrictions.in("type", showEventTypesM.getObject()));
      else log.debug("Not filtering by event type");

      criteria.createAlias("user", "user");

      // Site Check
      List<Site> siteList = showSitesM.getObject();
      if (siteList.size() < numberOfSites || inAPeriod.getObject()) {
        criteria.createAlias("user.periods", "period", JoinType.LEFT_OUTER_JOIN);
        Disjunction siteRestriction = Restrictions.disjunction();
        if (!inAPeriod.getObject())
          siteRestriction.add(Restrictions.isEmpty("user.periods")); // Show users with no periods
        if (!siteList.isEmpty())
          siteRestriction.add(
              Restrictions.in("period.site", siteList)); // Show users with matching periods
        if (inAPeriod.getObject() && siteList.isEmpty()) {
          siteRestriction.add(Restrictions.idEq(-1L)); // Halt query early; don't show anyone.
          criteria.setMaxResults(0);
        }
        criteria.add(siteRestriction);
      } else {
        log.debug("Not filtering by period/site");
      }

      if (fromDateM.getObject() != null && toDateM.getObject() != null) {
        Date startDate = midnightStart(fromDateM.getObject());
        Date endDate = midnightEnd(toDateM.getObject());
        log.debug("Considering events between {} and {}", startDate, endDate);
        criteria.add(Restrictions.between("insertTime", startDate, endDate));
      }

      // set permission check
      if (showPermissionUsers.getObject()) {
        criteria.add(Restrictions.eq("user.permission", true));
      }

      // Also load ResponseData elements in the same query, to avoid thousands of subsequent
      // queries.
      criteria.setFetchMode("responseData", FetchMode.JOIN);

      // The join with periods results in multiple rows for multi-period users.
      // Unfortunately, this confuses the dataprovider, which still counts the duplicates
      // and therefore doesn't return a full page full of items each time.
      criteria.setResultTransformer(
          CriteriaSpecification
              .DISTINCT_ROOT_ENTITY); // Remove duplicate rows as a result of the INNER JOIN
    }
示例#13
0
  @SuppressWarnings("unchecked")
  @Transactional(
      propagation = Propagation.REQUIRES_NEW,
      readOnly = true,
      rollbackFor = Throwable.class)
  public List<Incidencia> getByExample(Incidencia f) {
    try {
      Session currentSession = getSession();
      currentSession.clear();
      Criteria criteria =
          currentSession.createCriteria(Incidencia.class).addOrder(Order.asc("titulo"));

      // titulo
      if (f.getTitulo() != null && f.getTitulo().trim().length() > 0) {
        criteria.add(Restrictions.ilike("titulo", LogicConstants.getGenericString(f.getTitulo())));
      }

      // prioridad
      if (f.getPrioridad() != null) {
        criteria.add(Restrictions.eq("prioridad", f.getPrioridad()));
      }

      // categoria
      if (f.getCategoria() != null) {
        criteria
            .createAlias("categoria", "cat")
            .add(Restrictions.eq("cat.identificador", f.getCategoria().getIdentificador()));
      }

      // estado
      if (f.getEstado() != null) {
        criteria
            .createAlias("estado", "est")
            .add(Restrictions.eq("est.identificador", f.getEstado().getIdentificador()));
      } else {
        criteria.createAlias("estado", "est").add(Restrictions.ne("est.id", 3l));
      }

      List<Incidencia> res = new LinkedList<Incidencia>();
      res = criteria.list();
      for (Incidencia i : res)
        if (i != null) {
          if (i.getCreador() != null) i.getCreador().getId();
          if (i.getEstado() != null) i.getEstado().getId();
          if (i.getCategoria() != null) i.getCategoria().getId();
        }
      return res;
    } catch (Throwable t) {
      log.error("Error extrayendo las categorias de las incidencias", t);
    }
    return new LinkedList<Incidencia>();
  }
示例#14
0
  @Override
  public List<Cliente> listarPorNomes(
      String codigoPequisa,
      String nomePequisa,
      String placaPequisa,
      String ufPequisa,
      String situacao) {

    Criteria c = getSession().createCriteria(Cliente.class);

    Disjunction d = Restrictions.disjunction();

    if (codigoPequisa != null && !codigoPequisa.equals("")) {
      d.add(Restrictions.ilike("codigo", codigoPequisa, MatchMode.ANYWHERE));
    }
    if (nomePequisa != null && !nomePequisa.equals("")) {
      d.add(Restrictions.ilike("nome", nomePequisa, MatchMode.ANYWHERE));
      d.add(Restrictions.ilike("razaoSocial", nomePequisa, MatchMode.ANYWHERE));
    }
    if (ufPequisa != null && !ufPequisa.equals("") && !ufPequisa.equals("---")) {
      c.createAlias("enderecoPrimario", "endp");
      c.createAlias("enderecoSecundario", "ends");
      d.add(Restrictions.eq("endp.uf", ufPequisa));
      d.add(Restrictions.eq("ends.uf", ufPequisa));
    }
    if (placaPequisa != null && !placaPequisa.equals("")) {
      c.createAlias("veiculos", "vei");
      d.add(Restrictions.ilike("vei.placa", placaPequisa, MatchMode.ANYWHERE));
    }

    if (situacao != null && !situacao.equals("Todos")) {
      c.createAlias("contratos", "con");
      for (SituacaoContrato s : SituacaoContrato.values()) {
        if (s.getValor().equals(situacao)) {
          d.add(Restrictions.eq("con.situacao", s));
        }
      }
    }
    c.setFetchMode("contratos", FetchMode.SELECT);

    c.add(d);

    List<Cliente> clis = c.list();

    for (Cliente cliente : clis) {
      Hibernate.initialize(cliente.getContratos());
    }

    return clis;
  }
示例#15
0
  public List<Employee> searchEmployees(EmployeeSearchDTO searchParams) {

    Criteria criteria =
        getCurrentSession()
            .createCriteria(Assignment.class, "assignment")
            .createAlias("assignment.employee", "employee");
    if (null != searchParams.getCode() && !searchParams.getCode().isEmpty())
      criteria.add(Restrictions.eq("employee.code", searchParams.getCode()));
    if (null != searchParams.getName() && !searchParams.getName().isEmpty())
      criteria.add(Restrictions.eq("employee.name", searchParams.getName()));
    if (null != searchParams.getAadhaar() && !searchParams.getAadhaar().isEmpty())
      criteria.add(Restrictions.eq("employee.aadhaar", searchParams.getAadhaar()));
    if (null != searchParams.getMobileNumber() && !searchParams.getMobileNumber().isEmpty())
      criteria.add(Restrictions.eq("employee.mobileNumber", searchParams.getMobileNumber()));
    if (null != searchParams.getPan() && !searchParams.getPan().isEmpty())
      criteria.add(Restrictions.eq("employee.pan", searchParams.getPan()));
    if (null != searchParams.getEmail() && !searchParams.getEmail().isEmpty())
      criteria.add(Restrictions.eq("employee.emailId", searchParams.getEmail()));
    if (null != searchParams.getStatus() && !searchParams.getStatus().isEmpty())
      criteria.add(
          Restrictions.eq(
              "employee.employeeStatus", EmployeeStatus.valueOf(searchParams.getStatus())));
    if (null != searchParams.getEmployeeType() && !searchParams.getEmployeeType().isEmpty()) {
      criteria.createAlias("employee.employeeType", "employeeType");
      criteria.add(Restrictions.eq("employeeType.name", searchParams.getEmployeeType()));
    }
    if (null != searchParams.getDepartment() && !searchParams.getDepartment().isEmpty()) {
      criteria.createAlias("assignment.department", "department");
      criteria.add(Restrictions.eq("department.name", searchParams.getDepartment()));
    }
    if (null != searchParams.getDesignation() && !searchParams.getDesignation().isEmpty()) {
      criteria.createAlias("assignment.designation", "designation");
      criteria.add(Restrictions.eq("designation.name", searchParams.getDesignation()));
    }
    if (null != searchParams.getFunctionary() && !searchParams.getFunctionary().isEmpty()) {
      criteria.createAlias("assignment.functionary", "functionary");
      criteria.add(Restrictions.eq("functionary.name", searchParams.getFunctionary()));
    }
    if (null != searchParams.getFunction() && !searchParams.getFunction().isEmpty()) {
      criteria.createAlias("assignment.function", "function");
      criteria.add(Restrictions.eq("function.name", searchParams.getFunction()));
    }

    final ProjectionList projections =
        Projections.projectionList().add(Projections.property("assignment.employee"));
    criteria.setProjection(projections);
    criteria.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);

    return (List<Employee>) criteria.list();
  }
示例#16
0
 public LclUnitWhseImpl getLclUnitWhseDetails(Long unitId, Long headerId) throws Exception {
   Criteria criteria = getSession().createCriteria(LclUnitWhseImpl.class, "lclUnitWhse");
   criteria.createAlias("lclUnitWhse.lclUnit", "lclUnit");
   criteria.createAlias("lclUnitWhse.lclSsHeader", "lclSsHeader");
   if (!CommonUtil.isEmpty(unitId)) {
     criteria.add(Restrictions.eq("lclUnit.id", unitId));
   }
   if (!CommonUtil.isEmpty(headerId)) {
     criteria.add(Restrictions.eq("lclSsHeader.id", headerId));
   }
   criteria.addOrder(Order.desc("id"));
   criteria.setMaxResults(1);
   return (LclUnitWhseImpl) criteria.uniqueResult();
 }
  public List<UserDetailsDTO> analyseUserBySessionId(Long sid) {
    List<UserDetailsDTO> list = null;

    Session session = getSession();
    session.getTransaction().begin();

    Criteria criteria = session.createCriteria(BrowserDetails.class, "browserDetails");
    criteria.createAlias("browserDetails.sessionDetails", "sessionDetails");
    criteria.createAlias("browserDetails.deviceDetails", "deviceDetails");
    criteria.createAlias("browserDetails.eventDetails", "eventDetails");
    criteria.add(Restrictions.eq("sessionDetails.SID", sid));
    criteria.addOrder(Order.desc("eventDetails.EID"));

    criteria.setProjection(
        Projections.projectionList()
            .add(Projections.property("sessionDetails.SID").as("sid"))
            .add(Projections.property("sessionDetails.lastAccessTime").as("lastAccessTime"))
            .add(Projections.property("sessionDetails.sessionCreatedTime").as("firstAccessTime"))
            .add(Projections.property("eventDetails.EID").as("eid"))
            .add(Projections.property("eventDetails.triggeredTime").as("eventTriggeredTime"))
            .add(Projections.property("eventDetails.eventTypes").as("eventName"))
            .add(Projections.property("eventDetails.coordinateX").as("coordinateX"))
            .add(Projections.property("eventDetails.coordinateY").as("coordinateY"))
            .add(Projections.property("eventDetails.screenWidth").as("screenWidth"))
            .add(Projections.property("eventDetails.screenHeight").as("screenHeight"))
            .add(Projections.property("eventDetails.orientation").as("orientation"))
            .add(Projections.property("eventDetails.viewportHeight").as("viewportHeight"))
            .add(Projections.property("eventDetails.viewportWidth").as("viewportWidth"))
            .add(Projections.property("eventDetails.numOfTaps").as("numOfTaps"))
            .add(Projections.property("eventDetails.tagName").as("tagName"))
            .add(Projections.property("eventDetails.scrollTop").as("scrollTop"))
            .add(Projections.property("eventDetails.timeZone").as("timeZone"))
            .add(Projections.property("eventDetails.zoneDateTime").as("zoneDateTime"))
            .add(Projections.property("eventDetails.imageName").as("imageName"))
            .add(Projections.property("BID").as("bid"))
            .add(Projections.property("browserName").as("browserName"))
            .add(Projections.property("browserVersion").as("browserVersion"))
            .add(Projections.property("userAgetntId").as("userAgentId"))
            .add(Projections.property("deviceDetails.DID").as("did"))
            .add(Projections.property("deviceDetails.osName").as("osName"))
            .add(Projections.property("deviceDetails.deviceName").as("deviceName")));
    list = criteria.setResultTransformer(Transformers.aliasToBean(UserDetailsDTO.class)).list();

    session.getTransaction().commit();
    session.close();

    list = getPID(list);
    return list;
  }
示例#18
0
  @Override
  public int obtenhaQuantidadePorUF(UF estado) {

    Criteria c = getSession().createCriteria(Cliente.class);

    c.createAlias("enderecoPrimario", "endp");
    c.createAlias("enderecoSecundario", "ends");
    Disjunction d = Restrictions.disjunction();
    d.add(Restrictions.eq("endp.uf", estado.getSigla()));
    d.add(Restrictions.eq("ends.uf", estado.getSigla()));
    c.setProjection(Projections.count("codigo"));
    c.add(d);

    return (int) c.uniqueResult();
  }
  private void addLocationRestriction(Criteria criteria, Location medicalRecordLocation) {

    // in our current workflow, both paper records should always have the same record location, but,
    // just in case,
    // we fetch any merge reqeusts where *either* of the records are associated with the specified
    // record location
    criteria.createAlias("preferredPaperRecord", "ppr");
    criteria.createAlias("notPreferredPaperRecord", "nppr");

    Disjunction locationDisjunction = Restrictions.disjunction();
    locationDisjunction.add(Restrictions.eq("ppr.recordLocation", medicalRecordLocation));
    locationDisjunction.add(Restrictions.eq("nppr.recordLocation", medicalRecordLocation));

    criteria.add(locationDisjunction);
  }
示例#20
0
 @Override
 @LocalizedDatabaseGet
 public LanguageEntity getByLocale(String locale) {
   final Criteria criteria = getCriteria();
   criteria.createAlias("locales", "locale").add(Restrictions.eq("locale.locale", locale));
   return (LanguageEntity) criteria.uniqueResult();
 }
示例#21
0
  public List<Ticket> findTicketsForLaborHour(
      Date startDate, Date endDate, int hour, String userType, Terminal terminal) {
    Session session = null;
    try {
      session = getSession();
      Criteria criteria = session.createCriteria(getReferenceClass());
      criteria.add(Restrictions.ge(Ticket.PROP_ACTIVE_DATE, startDate));
      criteria.add(Restrictions.le(Ticket.PROP_ACTIVE_DATE, endDate));
      criteria.add(Restrictions.eq(Ticket.PROP_CREATION_HOUR, Integer.valueOf(hour)));
      // criteria.add(Restrictions.eq(Ticket.PROP_CLOSED, Boolean.TRUE));
      // criteria.add(Restrictions.eq(Ticket.PROP_VOIDED, Boolean.FALSE));

      if (userType != null) {
        criteria.createAlias(Ticket.PROP_OWNER, "u");
        criteria.add(Restrictions.eq("u.type", userType));
      }
      if (terminal != null) {
        criteria.add(Restrictions.eq(Ticket.PROP_TERMINAL, terminal));
      }

      return criteria.list();
    } finally {
      closeSession(session);
    }
  }
示例#22
0
 public List<User> getUser(User user) throws HibernateException {
   List<User> users;
   try {
     session = sessionFactory.openSession();
     tx = session.beginTransaction();
     criteria = session.createCriteria(User.class);
     if (user.getUserId() != null) {
       criteria.add(Restrictions.eq("userId", user.getUserId()));
     }
     if (user.getFirstName() != null) {
       criteria.add(Restrictions.eq("firstName", user.getFirstName()));
     }
     if (user.getLastName() != null) {
       criteria.add(Restrictions.eq("lastName", user.getLastName()));
     }
     if (user.getMi() != null) {
       criteria.add(Restrictions.eq("mi", user.getMi()));
     }
     if (user.getActivated() != '\u0000') {
       criteria.add(Restrictions.eq("activated", user.getActivated()));
     }
     if (user.getLoginCredential() != null && user.getLoginCredential().getUserName() != null) {
       criteria.createAlias("loginCredential", "lc");
       criteria.add(Restrictions.eq("lc.userName", user.getLoginCredential().getUserName()));
     }
     users = criteria.list();
     tx.commit();
     return users;
   } catch (HibernateException e) {
     if (tx != null) tx.rollback();
     throw e;
   } finally {
     session.close();
   }
 }
示例#23
0
  public ArrayList<Zone> getZones(int idcountry) {
    Session session = HibernateUtils.getSessionFactory().openSession();
    ArrayList<Zone> list = new ArrayList<Zone>();
    try {
      session.clear();
      Criteria cr = session.createCriteria(TblZone.class, "zone");
      cr.createAlias("zone.country", "country");
      cr.add(Restrictions.eq("country.idcountry", idcountry));
      cr.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      List<TblZone> zones = cr.list();
      if (zones.size() > 0) {
        for (Iterator<TblZone> iterator = zones.iterator(); iterator.hasNext(); ) {
          TblZone tblzone = iterator.next();
          Zone zone = new Zone();
          zone.convertFromTable(tblzone);
          list.add(zone);
        }
      }
      session.clear();
    } catch (HibernateException e) {
      System.err.println("ERROR IN LIST!!!!!!");
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    } finally {

      session.close();
    }
    return list;
  }
示例#24
0
  public List<Ticket> findTicketsForShift(
      Date startDate, Date endDate, Shift shit, String userType, Terminal terminal) {
    Session session = null;
    try {
      session = getSession();
      Criteria criteria = session.createCriteria(getReferenceClass());
      criteria.add(Restrictions.ge(Ticket.PROP_CREATE_DATE, startDate));
      criteria.add(Restrictions.le(Ticket.PROP_CREATE_DATE, endDate));
      criteria.add(Restrictions.eq(Ticket.PROP_SHIFT, shit));
      criteria.add(Restrictions.eq(Ticket.PROP_CLOSED, Boolean.TRUE));
      criteria.add(Restrictions.eq(Ticket.PROP_VOIDED, Boolean.FALSE));
      criteria.add(Restrictions.eq(Ticket.PROP_REFUNDED, Boolean.FALSE));

      if (userType != null) {
        criteria.createAlias(Ticket.PROP_OWNER, "u");
        criteria.add(Restrictions.eq("u.type", userType));
      }
      if (terminal != null) {
        criteria.add(Restrictions.eq(Ticket.PROP_TERMINAL, terminal));
      }

      return criteria.list();
    } finally {
      closeSession(session);
    }
  }
 private Criteria createCriteriaByCriteres(CritereRechercheContratDto criteres) {
   final Criteria crit = createCriteria(Contrat.class);
   crit.createAlias("statut", "statut");
   if (criteres != null && criteres.getIdAssure() != null) {
     crit.add(Restrictions.eq("uidAssure", criteres.getIdAssure()));
   }
   if (criteres != null && criteres.getIdSouscripteur() != null) {
     crit.add(Restrictions.eq("uidSouscripteur", criteres.getIdSouscripteur()));
   }
   if (criteres != null && criteres.isIdAssureNull()) {
     crit.add(Restrictions.isNull("uidAssure"));
   }
   if (criteres != null && StringUtils.isNotBlank(criteres.getNumeroContrat())) {
     crit.add(Restrictions.ilike("numeroContrat", criteres.getNumeroContrat() + "%"));
   }
   if (criteres != null
       && criteres.getHasContratEnCours() != null
       && criteres.getHasContratEnCours()) {
     crit.add(Restrictions.eq("statut.id", adherentMappingService.getIdStatutContratEnCours()));
   }
   if (criteres != null
       && criteres.getContratEid() != null
       && StringUtils.isNotBlank(criteres.getContratEid())) {
     crit.add(Restrictions.like("identifiantExterieur", "%" + criteres.getContratEid() + "%"));
   }
   crit.add(Restrictions.eq("isVisible", true));
   return crit;
 }
示例#26
0
  public ArrayList<City> getCitiesByZone(int idzone) {
    Session session = HibernateUtils.getSessionFactory().openSession();
    ArrayList<City> list = new ArrayList<City>();
    try {
      session.clear();
      Criteria cr = session.createCriteria(TblCity.class, "city");
      cr.createAlias("city.zone", "zone");
      cr.add(Restrictions.eq("zone.idzone", idzone));
      cr.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
      List<TblCity> cities = cr.list();
      if (cities.size() > 0) {
        for (Iterator<TblCity> iterator = cities.iterator(); iterator.hasNext(); ) {
          TblCity tblcity = iterator.next();
          City city = new City();
          city.convertFromTable(tblcity);
          list.add(city);
        }
      }
      session.clear();
    } catch (HibernateException e) {
      System.err.println("ERROR IN LIST!!!!!!");
      e.printStackTrace();
      throw new ExceptionInInitializerError(e);
    } finally {

      session.close();
    }
    return list;
  }
  public boolean isDuplicateWeblogCategoryName(WeblogCategoryData cat) throws RollerException {
    // ensure that no sibling categories share the same name
    WeblogCategoryData parent =
        null == cat.getId() ? (WeblogCategoryData) cat.getNewParent() : cat.getParent();

    if (null != parent) // don't worry about root
    {
      List sameNames;
      try {
        Session session = ((HibernatePersistenceStrategy) this.strategy).getSession();
        Criteria criteria = session.createCriteria(WeblogCategoryAssoc.class);
        criteria.createAlias("category", "c");
        criteria.add(Expression.eq("c.name", cat.getName()));
        criteria.add(Expression.eq("ancestorCategory", parent));
        criteria.add(Expression.eq("relation", Assoc.PARENT));
        sameNames = criteria.list();
      } catch (HibernateException e) {
        throw new RollerException(e);
      }
      if (sameNames.size() > 0) {
        return true;
      }
    }
    return false;
  }
 public void build(Criteria criteria) {
   SortParam sort = sortState.getSort();
   String property;
   if (sort != null && sort.getProperty() != null) {
     property = sort.getProperty();
     asc = sort.isAscending();
   } else {
     property = defaultProperty;
   }
   if (property != null) {
     if (property.contains(".")) {
       // for 'dot' properties we need to add aliases
       // e.g. for the property 'orderbook.order.item.name' we need to add an aliases for 'order'
       // and 'order.item'
       String path[] = property.split("\\.");
       for (int ii = 0; ii < path.length - 1; ii++) {
         StringBuffer sb = new StringBuffer();
         for (int jj = 0; jj <= ii; jj++) {
           if (sb.length() > 0) sb.append(".");
           sb.append(path[jj]);
         }
         criteria.createAlias(sb.toString(), path[ii], CriteriaSpecification.LEFT_JOIN);
       }
       // when we have a 'dot' property we want to sort by the sub tables field
       // e.g. for the property 'orderbook.order.item.name' we need to sort by 'item.name'
       if (path.length > 1)
         property = String.format("%s.%s", path[path.length - 2], path[path.length - 1]);
       else property = path[path.length - 1];
     }
     Order order = asc ? Order.asc(property) : Order.desc(property);
     order = cased ? order : order.ignoreCase();
     criteria.addOrder(order);
   }
 }
 public List<ProducaoAluno> listarAluno(int id) {
   Criteria criteria = getSession().createCriteria(ProducaoAluno.class);
   criteria.createAlias("aluno", "aluno");
   criteria.add(Restrictions.eq("aluno.idAluno", id));
   List<ProducaoAluno> result = criteria.list();
   return result;
 }
 @SuppressWarnings("unchecked")
 @Override
 public Set<Paper> getForAuthor(long authorId, int start, int max) {
   Criteria crit = getSession().createCriteria(Paper.class);
   crit.createAlias("authors", "a");
   crit.add(Restrictions.eq("a.id", authorId));
   return new HashSet<Paper>(crit.list());
 }