Example #1
0
  public void addUser() {
    try {
      logger.info("addUser");
      UserProfile model = new UserProfile();
      model.setUsername(getUsername());
      model.setDepartment(getDepartment());
      model.setDivision(getDivision());
      model.setFirstName(getFirstName());
      model.setLastName(getLastName());
      model.setSection(getSection());
      model.setUpdatedBy(FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());

      UserRole qcUserRole = new UserRole();
      qcUserRole.setId(1);
      model.setQcUserRole(qcUserRole);
      userProfileService.update(model);
      String f = "";
      try {
        if (getAtt() != null) {
          f = FileUtils.copyFile(getAtt());
          FileManage fModel;
          fModel = new FileManage();
          fModel.setFkEntityId(model.getUsername());
          fModel.setPath(f);
          fModel.setSource(ParameterModel.USER_ENTITY);
          fModel.setType("");
          fModel.setUpdatedBy(
              FacesContext.getCurrentInstance().getExternalContext().getRemoteUser());
          fileManageService.add(fModel);
        }
      } catch (IOException e) {
        e.printStackTrace();
      }
      setUsername("");
      setDepartment("");
      setDivision("");
      setFirstName("");
      setLastName("");
      setSection("");
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              new FacesMessage(FacesMessage.SEVERITY_INFO, ParameterModel.STATUS_SAVE_SUCCESS, ""));
    } catch (Exception e) {
      e.printStackTrace();
      FacesContext.getCurrentInstance()
          .addMessage(
              null,
              new FacesMessage(FacesMessage.SEVERITY_ERROR, ParameterModel.STATUS_SAVE_FAIL, ""));
    }
  }
Example #2
0
 public void initUser() {
   if (username != null) {
     UserProfile d = userProfileService.getById(username);
     setDepartment(d.getDepartment());
     setDivision(d.getDivision());
     setFirstName(d.getFirstName());
     setLastName(d.getLastName());
     setSection(d.getSection());
   }
 }