public String finalizar() {

    Statuschamado cham = new Statuschamado();
    chamado.setDataFechamento(Calendar.getInstance().getTime());
    chamado.setUsuario2(loginBean.getUsuarioLogado());
    this.finalizarChamadoDao =
        new GenericDao<FinalizarChamadoDao>(entityManager, Statuschamado.class)
            .ler(3); // lendo o status do bd
    cham.setIdstatusChamado(3);
    descricaoChamado.setChamado(chamado);
    descricaoChamado.setUsuarioBean(loginBean.getUsuarioLogado());
    this.entityManager.getTransaction().begin();
    this.finalizarChamadoDao.finalizarChamado(chamado);
    this.entityManager.getTransaction().commit();
    /*try {

    	this.finalizarChamadoDao.finalizarChamado(chamado);

    	new GenericDao<Descricaochamado>(entityManager, Descricaochamado.class).criar(descricaoChamado);
    	this.entityManager.getTransaction().commit();
    	FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Finalizado com sucesso!", ""));

    } catch (PersistenceException e) {
    	e.printStackTrace();
    	if (this.entityManager.getTransaction()!=null && this.entityManager.getTransaction().isActive()) {
    		this.entityManager.getTransaction().rollback();
    	}
    }*/
    return "telaInicialUsuario.jsf";
  }
Example #2
0
  /**
   * 销售合同列表的实例
   *
   * @param request jsp请求
   * @param isApproveStat 是否在审批状态
   * @return 返回销售合同列表的实例
   */
  public static B_ImportOrder getInstance(HttpServletRequest request) {
    B_ImportOrder b_ImportOrderBean = null;
    HttpSession session = request.getSession(true);
    synchronized (session) {
      String beanName = "b_ImportOrderBean";
      b_ImportOrderBean = (B_ImportOrder) session.getAttribute(beanName);
      if (b_ImportOrderBean == null) {
        // 引用LoginBean
        LoginBean loginBean = LoginBean.getInstance(request);

        b_ImportOrderBean = new B_ImportOrder();
        b_ImportOrderBean.qtyFormat = loginBean.getQtyFormat();
        b_ImportOrderBean.priceFormat = loginBean.getPriceFormat();
        b_ImportOrderBean.sumFormat = loginBean.getSumFormat();

        b_ImportOrderBean.fgsid = loginBean.getFirstDeptID();
        b_ImportOrderBean.loginId = loginBean.getUserID();
        b_ImportOrderBean.loginName = loginBean.getUserName();

        b_ImportOrderBean.user = loginBean.getUser();
        session.setAttribute(beanName, b_ImportOrderBean);
      }
    }
    return b_ImportOrderBean;
  }
Example #3
0
  public static boolean deleteUser(String user) {

    Connection con = null;
    CallableStatement cs = null;
    try {
      con = LoginBean.getConnection();
      Statement st = null;
      Statement st2 = null;
      Statement st4 = null;

      st2 = con.createStatement();
      String sql4 = ("delete from items where seller = '" + user + "';");
      st2.execute(sql4);

      st4 = con.createStatement();
      String sql5 = ("delete from bids where bidder = '" + user + "';");
      st4.execute(sql5);

      st = con.createStatement();
      String sql3 = ("delete from users where username = '******';");
      st.execute(sql3);

      return true;
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      return false;
    } finally {
      try {
        cs.close();
        con.close();
      } catch (Exception ex) {
      }
    }
  }
Example #4
0
  /*
   * Delete item
   */
  public static boolean delete(int itemid) {

    Connection con = null;
    CallableStatement cs = null;
    try {
      con = LoginBean.getConnection();
      Statement st = null;
      st = con.createStatement();
      String sql3 = ("delete from items where itemid = " + itemid + ";");
      st.execute(sql3);
      Statement st2 = null;
      st2 = con.createStatement();
      String sqll3 = ("delete from bids where itemid = " + itemid + ";");
      st2.execute(sqll3);
      return true;
    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      return false;
    } finally {
      try {
        cs.close();
        con.close();
      } catch (Exception ex) {
      }
    }
  }
  public DownloadMaterialApoioBean() {

    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    HttpSession session = (HttpSession) externalContext.getSession(true);
    login = (LoginBean) session.getAttribute("loginBean");

    fachada = FacadeAuth.getInstance();

    root = new CheckboxTreeNode(new Documents("Arquivos", "-", "Pasta"), null);

    TreeNode documents = new CheckboxTreeNode(new Documents("Documentos", "-", "Folder"), root);

    try {

      List<MaterialDeApoio> list = fachada.getMaterialApoio(login.getSession());

      if (null != list) {

        for (int i = 0; i < list.size(); i++) {

          Documents d = new Documents(list.get(i).getUrlArquivo(), "--", list.get(i).getNucleo());

          @SuppressWarnings("unused")
          TreeNode expenses = new CheckboxTreeNode("document", d, documents);
        }
      }

    } catch (NoSuchSessionException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
  /*
   * (non-Javadoc)
   *
   * @see com.intel.stl.ui.console.IConsoleEventListener#onConnect(boolean,
   * String)
   */
  @Override
  public void onConnect(boolean connected, String command) {

    if (connected) {
      consoleLogin.hideLogin();
      consoleControllers.put(consoleNum, console);

      LoginBean loginBean = console.getLoginInfo();
      console.updateInfoPanel(loginBean);

      // Revise the name of the console
      String cmd = (command == null) ? " " : command;

      if (loginBean != null) {
        console.setName(loginBean.getUserName() + "," + cmd);
        subpageView.updatePersonalizedTab(loginBean.getUserName(), cmd);

        Session session = loginBean.getSession();
        if (sessionMap.get(session) == null) {
          sessionMap.put(session, new AtomicInteger(1));
        } else {

          if (sessionMap.get(session) == null) {
            sessionMap.put(session, new AtomicInteger(1));
          } else {
            incrementSessionUsers(session);
          }
        }
      }
    }

    consoleLogin.killProgress();
    tabListener.enableNewTab(true);
    consoleTerminalView.enableCommanding(true);

    // Use the console initializer to issue a "history" command to the
    // remote host, capture the result, and display it in the command field
    // of the console view
    try {
      ConsoleTerminalController.ConsoleInitializer consoleInitializer =
          console.new ConsoleInitializer();
      consoleInitializer.initializeCommands(console.getLoginInfo());
    } catch (NumberFormatException e) {
    } catch (JSchException e) {
      e.printStackTrace();
    }
  }
Example #7
0
 /**
  * Methode de creation d'un nouveau client
  *
  * @return une chaine de caratere referençant une page xhtml client
  */
 public String create() {
   System.out.println("appel create client");
   System.out.println("nouveau client :" + nouveauClient);
   Conseiller conseiller = (Conseiller) ownerBean.getEmploye();
   clientList = (List<Client>) conseiller.getListeClients();
   serviceClient.createOrUpdate(nouveauClient);
   clientList.add(nouveauClient);
   serviceEmploye.createOrUpdate(conseiller);
   addMessage("Ajout client effectué");
   return "client";
 }
Example #8
0
  public static boolean updateUser(
      String user, String fname, String lname, String address, String phone) {

    Connection con = null;
    CallableStatement cs = null;
    try {
      con = LoginBean.getConnection();
      Statement st = null;
      st = con.createStatement();
      Statement st2 = null;
      st2 = con.createStatement();
      Statement st3 = null;
      st3 = con.createStatement();
      Statement st4 = null;
      st4 = con.createStatement();
      System.out.println(fname);
      System.out.println(lname);
      System.out.println(address);
      System.out.println(phone);

      if (fname != null) {
        String sql3 = ("update users set fname= '" + fname + "' where username = '******';");
        st.execute(sql3);
      }

      if (lname != null) {
        String sql4 = ("update users set lname= '" + lname + "' where username = '******';");
        st2.execute(sql4);
      }

      if (address != null) {
        String sql5 =
            ("update users set address= '" + address + "' where username = '******';");
        st3.execute(sql5);
      }

      if (phone != null) {
        String sql6 = ("update users set phone= '" + phone + "' where username = '******';");
        st4.execute(sql6);
      }

      return true;

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      return false;
    } finally {
      try {
        cs.close();
        con.close();
      } catch (Exception ex) {
      }
    }
  }
Example #9
0
 /**
  * Methode de supression d'un client en base de données
  *
  * @return une chaine de caratere referencant la page xhtml client
  */
 public String delete() {
   Conseiller conseiller = (Conseiller) ownerBean.getEmploye();
   clientList = (List<Client>) conseiller.getListeClients();
   System.out.println(clientList);
   System.out.println(selectedClient);
   System.out.println(clientList.remove(selectedClient));
   System.out.println(clientList);
   serviceEmploye.createOrUpdate(conseiller);
   serviceClient.delete(selectedClient);
   addMessage("Supression client effectuée");
   return "client";
 }
Example #10
0
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    response.setContentType("text/html");
    PrintWriter out = response.getWriter();

    String name = request.getParameter("name");
    String password = request.getParameter("password");

    LoginBean bean = new LoginBean();
    bean.setName(name);
    bean.setPassword(password);
    request.setAttribute("bean", bean);

    boolean status = bean.validate();

    if (status) {
      RequestDispatcher rd = request.getRequestDispatcher("login-success.jsp");
      rd.forward(request, response);
    } else {
      RequestDispatcher rd = request.getRequestDispatcher("login-error.jsp");
      rd.forward(request, response);
    }
  }
  /**
   * Associa a quantidade de créditos ao quadrimestre atual e ao docente que está fazendo o
   * planejamento
   *
   * @param q Long
   */
  public void salvarCreditos(Long q) {

    Integer quad = (int) (long) q;

    // Verifica se já existe um planejamento de credito para aquele quadrimestre
    List<Credito> listCreditos = docente.getCreditos();

    Credito credito = creditoFacade.creditoQuadrimestre(docente, quad);
    if (credito != null) { // Já existe um planejamento para o quadrimestre
      try {
        int posicao = listCreditos.indexOf(credito);
        credito.setQuantidade(creditosPlanejados);
        listCreditos.add(posicao, credito);
        docente.setCreditos(listCreditos);
        creditoFacade.edit(credito);
        JsfUtil.addSuccessMessage("Créditos editados com sucesso!");
      } catch (Exception e) {
        JsfUtil.addErrorMessage(
            e,
            "Ocorreu um erro de persistência, não foi possível editar os créditos "
                + e.getMessage());
      }

    } else {
      credito = new Credito();
      credito.setQuadrimestre(quad);
      credito.setQuantidade(creditosPlanejados);
      credito.setDocente(docente);
      listCreditos.add(credito);
      docente.setCreditos(listCreditos);

      try {
        creditoFacade.save(credito);

        JsfUtil.addSuccessMessage("Créditos salvos com sucesso!");

      } catch (Exception e) {
        JsfUtil.addErrorMessage(
            e,
            "Ocorreu um erro de persistência, não foi possível salvar os créditos "
                + e.getMessage());
      }
    }

    creditosPlanejados = 0.0;

    // Atualiza o usuário logado
    LoginBean.setUsuario(docente);
  }
Example #12
0
 @Before
 public void init() {
   user = UserMother.validUser1();
   loginBean.setUser(UserMother.validUser1());
   tripService.addTripType(new TripType("Timebound"));
   tripService.addTripType(new TripType("Public"));
   tripService.addTripType(new TripType("Private"));
   Calendar cal;
   cal = Calendar.getInstance();
   cal.set(2013, Calendar.MARCH, 29, 12, 00);
   tripBean.setTitle("trip");
   tripBean.setDescription("Een publieke test trip");
   tripBean.setStartTime(cal.getTime());
   cal.set(2013, Calendar.MARCH, 29, 12, 00);
   tripBean.setEndTime(cal.getTime());
   tripBean.setLabel("Test");
   tripBean.setTripType("Timebound");
   tripBean.setPublic(true);
   tripBean.addTrip();
 }
Example #13
0
 /**
  * 得到客户信誉额度信息的实例
  *
  * @param request jsp请求
  * @param isApproveStat 是否在审批状态
  * @return 返回报价资料信息的实例
  */
 public static B_CustomerProductDiscount getInstance(HttpServletRequest request) {
   B_CustomerProductDiscount xs_khcpzkbean = null;
   HttpSession session = request.getSession(true);
   synchronized (session) {
     String beanName = "xs_khcpzkbean";
     xs_khcpzkbean = (B_CustomerProductDiscount) session.getAttribute(beanName);
     // 判断该session是否有该bean的实例
     if (xs_khcpzkbean == null) {
       LoginBean loginBean = LoginBean.getInstance(request);
       xs_khcpzkbean = new B_CustomerProductDiscount();
       xs_khcpzkbean.fgsid = loginBean.getFirstDeptID();
       xs_khcpzkbean.loginId = loginBean.getUserID();
       xs_khcpzkbean.loginName = loginBean.getUserName();
       xs_khcpzkbean.user = loginBean.getUser();
       // 设置格式化的字段
       xs_khcpzkbean.dsxs_khcpzkTable.setColumnFormat("zk", loginBean.getPriceFormat());
       xs_khcpzkbean.dsxs_khcpzkTable.setColumnFormat("dj", loginBean.getPriceFormat());
       xs_khcpzkbean.dsxs_khcpzkTable.setColumnFormat("bj", loginBean.getPriceFormat());
       session.setAttribute(beanName, xs_khcpzkbean);
     }
   }
   return xs_khcpzkbean;
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.intel.stl.ui.console.IConsoleEventListener#onConnectFail(java.lang
   * .Exception)
   */
  @Override
  public void onConnectFail(ConsoleTerminalController console, int reason, Exception e) {

    if (e instanceof NumberFormatException) {
      consoleLogin.showMessage(
          UILabels.STL80002_INVALID_PORT_NUMBER.getDescription(defaultLoginBean.getPortNum()));

    } else if (e instanceof JSchException) {
      String msg = new String();
      if (e.getMessage().compareTo("Auth fail") == 0) {
        msg = UILabels.STL80003_AUTHENTICATION_FAILURE.getDescription();

      } else if (e.getMessage().startsWith("SSH_MSG_DISCONNECT")) {
        msg = e.getMessage();

      } else {
        msg =
            UILabels.STL80001_CONSOLE_CONNECTION_ERROR.getDescription()
                + " "
                + consoleLogin.getHostName()
                + ": "
                + e.getMessage();
      }
      consoleLogin.showMessage(msg);
    } else {
      consoleLogin.showMessage(StringUtils.getErrorMessage(e));
    }

    consoleLogin.killProgress();
    tabListener.enableNewTab(true);
    consoleTerminalView.enableCommanding(true);
    if ((console != null) && (reason == REASON_INIT)) {
      console.shutDownConsole();
      closeChannel(console);
      closeSession(console);
    }
  }
Example #15
0
  @Test
  public void testGetTotalCostPerUser() throws SQLException, IOException {

    assertEquals(" should be 0.0", (Object) 0.0, costBean.getTotalCostPerUser(loginBean.getUser()));
  }
  /*
   * (non-Javadoc)
   *
   * @see
   * com.intel.stl.ui.console.IConsoleDispatchListener#updateTab(java.lang
   * .String, java.lang.String)
   */
  @Override
  public void updatePersonalizedTab(LoginBean loginBean, String command) {

    // Put the username and command on the subpage tab
    subpageView.updatePersonalizedTab(loginBean.getUserName(), command);
  }
  // Construtor (pega o usuario Logado)
  public DisponibilidadeController() {

    docente = (Docente) LoginBean.getUsuario();
  }
Example #18
0
  public static Boolean bidForItem(String buyer, int itemid, int bidprice) {

    Connection con = null;
    Statement s1 = null;
    Statement stmt2 = null;
    Statement stmt3 = null;
    Statement st4 = null;
    Statement stmt5 = null;

    Statement st6 = null;

    try {
      con = LoginBean.getConnection();
      con.setAutoCommit(false);

      s1 = con.createStatement();
      ResultSet r6 =
          s1.executeQuery(
              "Select startPrice, maxBid, seller from items where itemID=" + itemid + ";");
      r6.next();
      int initPrice = r6.getInt(1);
      int mbid = r6.getInt(2);
      String seller = r6.getString(3);

      boolean validBid = true;

      if (bidprice < initPrice || bidprice <= mbid) {
        validBid = false;
      }
      System.out.println(buyer);
      System.out.println(seller);
      int match;
      match = buyer.compareTo(seller);
      if (match == 0) {
        validBid = false;
      }

      String empty = "";
      int match2;
      match2 = buyer.compareTo(empty);

      if (match2 == 0) {
        validBid = false;
      }

      if (validBid) {

        stmt3 = con.createStatement();

        String sql1 =
            "insert into bids(itemid, bidder, bidPrice) values("
                + itemid
                + ", '"
                + buyer
                + "', "
                + bidprice
                + ");";
        stmt3 = con.createStatement();
        stmt3.execute(sql1);

        st4 = con.createStatement();
        ResultSet r =
            st4.executeQuery(
                "select bidder, bidprice from bids where bidprice=(select max(bidprice) from bids where itemid ="
                    + itemid
                    + ");");

        r.next();

        String bidder = r.getString(1);
        int highestBid = r.getInt(2);
        System.out.println(bidder);
        System.out.println(highestBid);

        st6 = con.createStatement();
        String sql3 =
            ("update items i, (select min(biddate) biddate from bids where itemid="
                + itemid
                + ")m set enddate = adddate(biddate,1) where itemid ="
                + itemid
                + ";");
        st6.execute(sql3);
        st6 = con.createStatement();

        stmt2 = con.createStatement();
        String sql2 =
            ("update items set maxBid = " + highestBid + "  where itemid = " + itemid + ";");
        stmt2.execute(sql2);
        stmt2 = con.createStatement();

        stmt5 = con.createStatement();
        String sql4 = ("update items set buyer = '" + bidder + "'  where itemid = " + itemid + ";");
        stmt5.execute(sql4);
        stmt5 = con.createStatement();

      } else {
        return false;
      }

      con.commit();

      return true;

    } catch (Exception ex) {
      System.out.println(ex.getMessage());
      return false;
    } finally {
      try {
        if (con != null) con.close();
      } catch (Exception ex) {
      }
    }
  }