Ejemplo n.º 1
0
  public void firstUnreadMessage(ActionEvent evt) {
    RequestContext ctx = RequestContext.getCurrentInstance();
    Message m = mm.getFirstAfter(lastUpdate);

    ctx.addCallbackParam("ok", m != null);
    if (m == null) return;

    lastUpdate = m.getDateSent();
    ctx.addCallbackParam("user", m.getUser());
    ctx.addCallbackParam("dateSent", m.getDateSent().toString());
    ctx.addCallbackParam("text", m.getMessage());
  }
  /**
   * update user story on menu backlog (sprint backlog)
   *
   * @param userStoryId
   * @param name
   * @param value
   */
  public void updatePBLOnBacklogPage() {
    try {
      RequestContext requestContext = RequestContext.getCurrentInstance();
      String id = JSFUtils.getRequestParameter("Id");
      String name = JSFUtils.getRequestParameter("name");
      String description = JSFUtils.getRequestParameter("description");
      String value = JSFUtils.getRequestParameter("value");
      String risk = JSFUtils.getRequestParameter("risk");
      UserStory current = userStoryService.findUserStoryById(Long.parseLong(id.trim()));
      if (current == null) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", EXCEPTION);
        return;
      }

      if (name.equals("")) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", EMPTY_ERROR);
        return;
      }

      if ((userStoryService.checkExistUserStory(
                  Utils.standardizeString(name), current.getProject().getProjectId())
              != null)
          && !(current.getName().equals(Utils.standardizeString(name)))) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", DUPPLICATE_ERROR);
        return;
      }
      if (Integer.parseInt(value) > MAX_BUSSINESS_VALUE || Integer.parseInt(value) < 0) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", VALUE_ERROR);
        return;
      }
      if (Integer.parseInt(risk) > MAX_RISK_VALUE || Integer.parseInt(risk) < 0) {
        requestContext.addCallbackParam("userStoryId", id);
        requestContext.addCallbackParam("error", RISK_ERROR);
        return;
      }
      current.setName(name.replaceAll("\\p{Cntrl}", ""));
      current.setValue(Integer.parseInt(value));
      current.setRisk(Integer.parseInt(risk));
      current.setDescription(description.replaceAll("\\p{Cntrl}", ""));
      if (userStoryService.update(current)) {
        userStoryService.updateAllIssueOfUserStoryHaveTheSameContent(current);
      }
      requestContext.execute("PrimeFaces.ab({source:'',update:'form2'});");
    } catch (Exception e) {

    }
  }
Ejemplo n.º 3
0
  public void editIssue() {
    this.issue = this.issueService.findIssueById(this.issue.getIssueId());
    this.issue.setEstimate(
        this.issueService.getPointByFormat(this.issue.getEstimate(), this.issue.getPointFormat()));
    this.issue.setRemain(
        this.issueService.getPointByFormat(this.issue.getRemain(), this.issue.getPointFormat()));
    // save subject issue before save
    // this.subjectIssueBeforeEdit = this.issue.getSubject(); TODO Knight check to use or delete
    resetAttachmentList();

    this.attachmentListByIssue = this.attachmentService.findAttachmentByIssue(this.issue);
    // list all attachment file of User Story
    if (this.issue != null && this.issue.getUserStory() != null) {
      this.attachmentListByIssue.addAll(
          attachmentService.findAttachmentByUserStory(this.issue.getUserStory()));
    }

    resetIssueForm();
    if (this.issue.getParent() == null) {
      this.setProjectId(this.issue.getUserStory().getProject().getProjectId());
    } else {
      this.setProjectId(this.issue.getParent().getUserStory().getProject().getProjectId());
    }
    this.issueParentList = null;
    RequestContext context = org.primefaces.context.RequestContext.getCurrentInstance();
    context.scrollTo("newFrmBtn");
    context.addCallbackParam("edit", true);
  }
  public void register(ActionEvent actionEvent) {
    CustomerDAO cdao = HibernateDAOFactory.instance().getCustomerDAO();

    RequestContext context = RequestContext.getCurrentInstance();
    FacesMessage msg = null;
    boolean loggedIn = false;
    FacesContext fc = FacesContext.getCurrentInstance();
    ExternalContext ec = fc.getExternalContext();

    if (cdao.checklemail(email)) {
      Customer cs = new Customer();
      cs.setEmail(email);
      cs.setPass(pass);
      cs.setFullName(fullName);
      cs.setAddress(address);
      cs.setPhone(phone);
      cs.setVip(vip);
      cdao.add(cs);
      loggedIn = true;
      msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Registe succes! Welcome", email);
      String url = "index.xhtml";
      try {
        ec.redirect(url);
      } catch (IOException ex) {

      }
    } else {
      loggedIn = false;
      msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Registe Error", "Invalid credentials");
    }

    FacesContext.getCurrentInstance().addMessage(null, msg);
    context.addCallbackParam("loggedIn", loggedIn);
  }
Ejemplo n.º 5
0
 public void login(ActionEvent actionEvent) {
   SecurityUtils.getSubject()
       .login(new UsernamePasswordToken(getNombre(), getClave(), isRemember()));
   WebUtils.getAndClearSavedRequest(
       (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest());
   logeado = SecurityUtils.getSubject().isAuthenticated();
   final RequestContext context = RequestContext.getCurrentInstance();
   FacesMessage msg = null;
   if (logeado) {
     msg =
         new FacesMessage(
             FacesMessage.SEVERITY_INFO,
             Messages.getString("LoginBean.message.welcome"), // $NON-NLS-1$
             nombre);
     LogManager.info(Messages.getString("LoginBean.log.message.access", nombre)); // $NON-NLS-1$
   } else {
     msg =
         new FacesMessage(
             FacesMessage.SEVERITY_WARN,
             Messages.getString("LoginBean.message.error"), // $NON-NLS-1$
             Messages.getString("LoginBean.message.error.details")); // $NON-NLS-1$
     LogManager.warn(Messages.getString("LoginBean.log.message.error", nombre)); // $NON-NLS-1$
   }
   FacesContext.getCurrentInstance().addMessage(null, msg);
   context.addCallbackParam("estaLogeado", logeado);
   if (logeado) {
     continuar("home.xhtml");
   }
 }
Ejemplo n.º 6
0
  @Override
  public void update(ActionEvent event) {
    // TODO Auto-generated method stub
    RequestContext context = RequestContext.getCurrentInstance();
    boolean saved = true;

    if (this.operationGroups.size() == 0) {
      FacesMessage msg =
          new FacesMessage(
              FacesMessage.SEVERITY_ERROR,
              "Operation",
              "Please, configure at least one Operation Group.");

      FacesContext.getCurrentInstance().addMessage(null, msg);
      return;
    }
    this.operation.setListOperationGroup(this.operationGroups);

    logicalFlow.validateNodes();
    // logicalFlow.align();

    FacesMessage msg =
        new FacesMessage(
            FacesMessage.SEVERITY_INFO, "Operation", this.operation.getName() + " - Updated!");

    ServicesFactory.getInstance().getIvrEditorService().getBean().setEditing(true);
    FacesContext.getCurrentInstance().addMessage(null, msg);
    context.addCallbackParam("saved", saved);
  }
Ejemplo n.º 7
0
 public boolean eliminar() {
   boolean ok = false;
   RequestContext context = RequestContext.getCurrentInstance();
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "eliminar: mbUpc");
   try {
     if (this.listaUpcs.size() > 2 && this.upc.isActual()) {
       fMsg.setSeverity(FacesMessage.SEVERITY_WARN);
       fMsg.setDetail("No se puede eliminar, cambie primero de actual");
     } else {
       this.dao = new DAOUpcs();
       this.dao.Eliminar(this.upc.getUpc());
       this.cargaListaUpcs();
       ok = true;
     }
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   context.addCallbackParam("okUpc", ok);
   return ok;
 }
  public void editBusinessInformation() {
    RequestContext context = RequestContext.getCurrentInstance();

    boolean checkImage = true;
    if (!imageLogo.equalsIgnoreCase(business.getBusinessLogo().toString().trim())) {
      checkImage = upload.deleteImage(business.getBusinessLogo().toString().trim());
      business.setBusinessLogo(imageLogo);
    }

    boolean checkUpdate = commonEJB.updateData(business);
    if (checkUpdate == true) {
      showMessage("Success", "Information details have changed successful", "info");
      context.addCallbackParam("editBusiness", "yes");
    } else {
      showMessage("Fail", "Cannot persist to database", "error");
      context.addCallbackParam("editBusiness", "");
    }
  }
Ejemplo n.º 9
0
  public void comprobarFacturasSeleccionados() {
    RequestContext context = RequestContext.getCurrentInstance();
    boolean error = false;

    if (listaFacturasSeleccionados == null || listaFacturasSeleccionados.isEmpty()) {
      presentaMensaje(FacesMessage.SEVERITY_WARN, "ESCOJA POR LO MENOS UNA FACTURA");
      error = true;
    }
    context.addCallbackParam("error1", error ? true : false);
  }
  public void changePassword() {
    RequestContext context = RequestContext.getCurrentInstance();

    Business b =
        (Business)
            commonEJB.getSingleInfo(
                "select b from Business b where b.username = '******'");
    if (b.getPassword().toString().trim().equals(oldPassword.trim())) {
      b.setPassword(newPassword);
      boolean checkChangePass = commonEJB.updateData(b);
      if (checkChangePass == true) {
        showMessage("Success", "Password has changed successful", "info");
      } else {
        showMessage("Fail", "Cannot persist to database", "error");
      }
      context.addCallbackParam("changedPass", "yes");
    } else {
      showMessage("Old password is incorrect", null, "error");
      context.addCallbackParam("changedPass", "");
    }
  }
  /** Create new user story with information entered in view, then save it into database */
  public void addUserStory() {
    RequestContext requestContext = RequestContext.getCurrentInstance();

    if (getProjectId() == 0) {
      requestContext.addCallbackParam("success", false);
      return;
    }
    try {
      UserStory us = new UserStory();

      // Remove Control Characters
      us.setName(Utils.standardizeString(userStory.getName()).replaceAll("\\p{Cntrl}", ""));
      us.setDescription(userStory.getDescription().replaceAll("\\p{Cntrl}", ""));

      us.setStatus(UserStory.StatusType.TODO);
      us.setValue(userStory.getValue());
      us.setProject(projectService.findProjectById(getProjectId()));
      us.setRisk(0);
      us.setPriority(UserStory.PriorityType.NONE);
      if (userStoryService.create(us)) {
        saveAttachmentsToDatabase(us);

        resetUserStoryValue();
        setValueForUsList();
        setCreateMode(false);
        requestContext.addCallbackParam("success", true);
        JSFUtils.resloveMethodExpression(
            "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
      } else {
        throw new Exception();
      }
    } catch (Exception e) {
      requestContext.addCallbackParam("success", false);
      LOGGER.error("HomePage addUserStory: " + e);
    }
  }
Ejemplo n.º 12
0
  public void insertarCobro() {
    RequestContext context = RequestContext.getCurrentInstance();
    boolean error = false;

    // if (listaPagoEntrada == null || listaPagoEntrada.isEmpty()) {
    // presentaMensaje(FacesMessage.SEVERITY_WARN,
    // "INGRESE POR LO MENOS UN PAGO");
    // error = true;
    // } else {
    // pagoEntradaService.cobro(listaPagoEntrada, listaFacturas,
    // listaFacturasSeleccionados);
    // listaPagoEntrada = new ArrayList<PagoEntrada>();
    totalCuota = new BigDecimal("0");
    listaFacturasSeleccionados = new ArrayList<CobroReporte>();
    totalTotal = newBigDecimal();
    totalAbonos = newBigDecimal();
    totalSaldo = newBigDecimal();
    fechapago = new Date();
    // }
    context.addCallbackParam("error", error ? true : false);
  }
Ejemplo n.º 13
0
  public void login(ActionEvent event) {
    RequestContext context = RequestContext.getCurrentInstance();
    FacesMessage message = null;

    boolean loggedIn = false;

    if (true
        == validar(entidadSeleccionada.getTxtUsuario(), entidadSeleccionada.getTxtPassword())) {
      loggedIn = true;
      entidad = entidadSeleccionada;
      // message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido",
      // entidad.getPersona().getTxtNombres());
    } else {
      loggedIn = false;
      message =
          new FacesMessage(
              FacesMessage.SEVERITY_WARN, "Error de Autenticacion", "Credenciales Invalidas");
      FacesContext.getCurrentInstance().addMessage(null, message);
    }

    context.addCallbackParam("loggedIn", loggedIn);
  }
Ejemplo n.º 14
0
  public void login() {
    RequestContext context = RequestContext.getCurrentInstance();
    FacesMessage msg = null;
    boolean loggedIn = false;

    if (username != null && password != null) {
      SystemUser su = seguridadService.logIn(username, password);
      if (su != null) {
        loggedIn = true;
        msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Bienvenido", su.getNombreCompleto());
        FacesContext.getCurrentInstance()
            .getExternalContext()
            .getSessionMap()
            .put("systemUser", su);
        Map<String, Object> appMap =
            FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
        HttpSession session1 = (HttpSession) appMap.get(su.getNombre());
        HttpSession session2 =
            (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
        if ((session1 != null) && !(session1.equals(session2))) {
          try {
            session1.invalidate();
          } catch (IllegalStateException e) {
          }
        }
        appMap.put(su.getNombre(), session2);
      } else {
        loggedIn = false;
        msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Credenciales inválidas");
      }
    } else {
      loggedIn = false;
      msg = new FacesMessage(FacesMessage.SEVERITY_WARN, "Login Error", "Credenciales inválidas");
    }

    FacesContext.getCurrentInstance().addMessage(null, msg);
    context.addCallbackParam("loggedIn", loggedIn);
  }
Ejemplo n.º 15
0
 public void cargaListaUpcs() {
   boolean ok = false;
   RequestContext context = RequestContext.getCurrentInstance();
   FacesMessage fMsg = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Aviso:", "cargaListaUpcs");
   this.listaUpcs = new ArrayList<SelectItem>();
   Upc u0 = this.nuevoLista(this.upc.getIdProducto());
   this.listaUpcs.add(new SelectItem(u0, u0.toString()));
   try {
     this.dao = new DAOUpcs();
     for (Upc u : this.dao.obtenerUpcs(this.upc.getIdProducto())) {
       this.listaUpcs.add(new SelectItem(u, u.toString()));
     }
     ok = true;
   } catch (NamingException ex) {
     fMsg.setDetail(ex.getMessage());
   } catch (SQLException ex) {
     fMsg.setDetail(ex.getErrorCode() + " " + ex.getMessage());
   }
   if (!ok) {
     FacesContext.getCurrentInstance().addMessage(null, fMsg);
   }
   context.addCallbackParam("okUpc", ok);
 }
Ejemplo n.º 16
0
 /**
  * 前台返回参数
  *
  * @param name
  * @param value
  */
 protected void addCallbackParam(String name, Object value) {
   RequestContext rcontext = RequestContext.getCurrentInstance();
   rcontext.addCallbackParam(name, value);
 }
Ejemplo n.º 17
0
  public void save(ActionEvent event) {

    if (this.logicNodeBean != null) {

      List<LogicNodeOperationEntity> listEntity = this.logicNodeBean.getListNodeOperation();

      for (int index = 0; index < listEntity.size(); index++) {
        LogicNodeOperationEntity operation = listEntity.get(index);
        if (!operation.getId().equals(this.nodeOperation.getId())) {
          if (operation.getOrderNum().equals(this.nodeOperation.getOrderNum())) {

            FacesMessage msg =
                new FacesMessage(
                    FacesMessage.SEVERITY_ERROR,
                    "Logic Node Operation",
                    "Number Order '"
                        + this.nodeOperation.getOrderNum()
                        + "' already exists on Logic Node "
                        + this.logicNodeBean.getLogicNode().getName());

            FacesContext.getCurrentInstance().addMessage(null, msg);

            return;
          }
        }
      }
      if (this.listNodeOperationValue.size() == 0) {
        FacesMessage msg =
            new FacesMessage(
                FacesMessage.SEVERITY_ERROR,
                "Logic Node Operation",
                "You must configure at least one value on field 'Values'");

        FacesContext.getCurrentInstance().addMessage(null, msg);

        return;
      }
      for (LogicNodeValueEntity value : this.listNodeOperationValue) {
        if (value.getResultService().equals(1)) {
          if (this.logicNodeBean.getMapId() != null && this.logicNodeBean.getMapId().length() > 0) {
            LogicMapEntity map =
                ServicesFactory.getInstance()
                    .getLogicMapService()
                    .get(this.logicNodeBean.getMapId());
            if (map.getReturnType().equals("TEXT")
                && (value.getOperation().equals(">")
                    || value.getOperation().equals("<")
                    || value.getOperation().equals("BETWEEN"))) {
              FacesMessage msg =
                  new FacesMessage(
                      FacesMessage.SEVERITY_ERROR,
                      "Logic Node Operation",
                      "Return of MAP is TEXT and doesn't work properly with logical test '"
                          + value.getOperation()
                          + "' in VALUE number order '"
                          + value.getOrderNum()
                          + "' ");
              FacesContext.getCurrentInstance().addMessage(null, msg);
              return;
            }
          }
        }
      }
      this.nodeOperation.setListLogicNodeValues(this.listNodeOperationValue);

      if (this.insert) {
        this.logicNodeBean.getListNodeOperation().add(this.nodeOperation);
      }

      init();

      RequestContext context = RequestContext.getCurrentInstance();
      boolean saved = true;
      context.addCallbackParam("saved", saved);
    }
  }
  public void updateUserStory() {
    RequestContext context = RequestContext.getCurrentInstance();
    if (userStory == null) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EXCEPTION);
      return;
    }

    if (userStory.getName().equals("")) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EMPTY_ERROR);
      return;
    }

    if (userStoryService.checkExistUserStory(
                Utils.standardizeString(userStory.getName()), getProjectId())
            != null
        && !(userStory.getName().equals(Utils.standardizeString(userStory.getName())))) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", DUPPLICATE_ERROR);
      return;
    }

    if (userStory.getValue() > MAX_BUSSINESS_VALUE || userStory.getValue() < 0) {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", VALUE_ERROR);
      return;
    }

    userStory.setName(userStory.getName().replaceAll("\\p{Cntrl}", ""));
    userStory.setDescription(userStory.getDescription().replaceAll("\\p{Cntrl}", ""));

    if (userStoryService.update(userStory)) {
      userStoryService.updateAllIssueOfUserStoryHaveTheSameContent(userStory);
      setValueForUsList();
      context.addCallbackParam("error", NO_ERROR);
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      JSFUtils.resloveMethodExpression(
          "#{homeBean.setDefaultHistoryList}", Void.class, new Class<?>[0], new Object[0]);
    } else {
      context.addCallbackParam("userStoryId", userStory.getUserStoryId());
      context.addCallbackParam("error", EXCEPTION);
    }
  }
Ejemplo n.º 19
0
 protected static final void adicionarParametroCallBackContextoResposta(
     String nomeParametro, boolean valorParametro) {
   RequestContext contexto = RequestContext.getCurrentInstance();
   contexto.addCallbackParam(nomeParametro, valorParametro);
 }