Package br.com.procempa.modus.session

Examples of br.com.procempa.modus.session.PersistentAccess


  }
 
  public static List<RelatorioExcecaoVO> getListVO(Long dataInicial,
      Long dataFinal) throws Exception {
    List<RelatorioExcecaoVO> excecoes = new ArrayList<RelatorioExcecaoVO>();
    PersistentAccess pa = PersistentAccessFactory.getInstance();
    HashMap<String, Object> params = new HashMap<String, Object>();
   
    params.put("dataInicio", new Timestamp(dataInicial));
    params.put("dataFim", new Timestamp(dataFinal))
   
    List<Persistent> list = pa
        .search(
            "FROM ExceptionLog WHERE timestamp >= :dataInicio AND timestamp <= :dataFim",
            params);

    for (Persistent persistent : list) {
View Full Code Here


    return excecoes;
  }
 
  public static List<ExceptionLog> getList() throws Exception {
    List<ExceptionLog> exceptions = new ArrayList<ExceptionLog>();
    PersistentAccess pa = PersistentAccessFactory.getInstance();
    List<Persistent> list = pa.search("FROM ExceptionLog");
    for (Persistent persistent : list) {
      exceptions.add((ExceptionLog) persistent);
    }
    return exceptions;
  }
View Full Code Here

    }
    return exceptions;
  }

  public static ExceptionLog updateUserDescription(ExceptionLog log, String userDesc) {
    PersistentAccess pa;
    try {
      pa = PersistentAccessFactory.getInstance();
      log = (ExceptionLog) pa.find(ExceptionLog.class, log.getId());
      log.setUserDescription(userDesc);
      log = (ExceptionLog) pa.persist(log);
    } catch (NamingException e) {
      e.printStackTrace();
    }
    return log;
  }
View Full Code Here

import br.com.procempa.modus.session.PersistentAccess;

public class UsuarioDataServices implements DataServices {

  public static Usuario getUsuario(Long id) throws Exception {
    PersistentAccess pa = PersistentAccessFactory.getInstance();
    Usuario u = (Usuario) pa.find(Usuario.class, id);
    return u;
  }
View Full Code Here

  }

  public static Usuario getUsuarioByRg(String rg) throws UsuarioException {
    Usuario u = null;
    try {
      PersistentAccess pa = PersistentAccessFactory.getInstance();
      HashMap<String, Object> params = new HashMap<String, Object>();
      params.put("rg", rg);
      List<Persistent> l = pa.search("from Usuario where rg = :rg", params);
      if (!l.isEmpty()) {
        u = (Usuario) l.get(0);
      }
    } catch (Exception e) {
      throw new UsuarioException(e.getClass().getName() + ": "
View Full Code Here

   * @throws UsuarioException
   */
  public static List<Usuario> getList() throws UsuarioException {
    List<Usuario> users = new ArrayList<Usuario>();
    try {
      PersistentAccess pa = PersistentAccessFactory.getInstance();
      List<Persistent> list = pa.search("from Usuario");
      for (Persistent persistent : list) {
        users.add((Usuario) persistent);
      }
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

  }

  public static Usuario persist(Usuario usuario, List<String> messages)
      throws UsuarioException {
    try {
      PersistentAccess pa = PersistentAccessFactory.getInstance();

      if (isValid(usuario, messages)) {
        usuario = (Usuario) pa.persist(usuario);
      }
    } catch (Exception e) {
      e.printStackTrace();
      throw new UsuarioException(e.getClass().getName() + ": "
          + e.getMessage());
View Full Code Here

    return usuario;
  }

  public static void removeUsuario(Long id) throws Exception {
    PersistentAccess pa = PersistentAccessFactory.getInstance();
    HashMap<String, Object> params = new HashMap<String, Object>();
    params.put("id", id);
    List<Persistent> users = pa.search("from Usuario as u left join fetch u.visitaList where u.id = :id", params);

    if (!users.isEmpty()) {
      Usuario u = (Usuario) users.get(0);
      if (u.getVisitaList().isEmpty()) {
        pa.remove(u);
      } else {
        throw new BusinessException(
            "Desculpe, mas n�o � poss�vel remover um usu�rio com visitas registradas.");
      }
    }
View Full Code Here

      status = false;
    } else {
      // Se isInsert, precisa testar a exist�ncia de
      // usu�rio com o mesmo RG
      if (isInsert) {
        PersistentAccess pa = PersistentAccessFactory.getInstance();
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("rg", u.getRg());
        List l = pa.search("from Usuario where rg = :rg", params);

        if (!l.isEmpty()) {
          messages.add("J� existe um usu�rio cadastrado com o RG "
              + u.getRg());
          status = false;
        }
      }
    }

    // Testar a exist�ncia do email, pois � chave �nica
    if (isInsert && StringUtils.isNotEmpty(u.getEmail())) {
      if (isValidEmail(u.getEmail())) {
        PersistentAccess pa = PersistentAccessFactory.getInstance();
        HashMap<String, Object> params = new HashMap<String, Object>();
        params.put("email", u.getEmail());
        List l = pa.search("from Usuario where email= :email", params);

        if (!l.isEmpty()) {
          messages.add("J� existe um usu�rio cadastrado com o email "
              + u.getEmail());
          status = false;
View Full Code Here

public class PresencaDataServices implements DataServices {
 
  public static List<Presenca> getList() throws Exception {
    List<Presenca> presencas = new ArrayList<Presenca>();
    PersistentAccess pa = PersistentAccessFactory.getInstance();
    List<Persistent> list = pa.search("FROM Presenca");
    for (Persistent persistent : list) {
      presencas.add((Presenca) persistent);
    }
    return presencas;
  }
View Full Code Here

TOP

Related Classes of br.com.procempa.modus.session.PersistentAccess

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.