Ejemplo n.º 1
0
  /** Contains Display Logic */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    HttpSession session = request.getSession(true);
    UserModel sessionModel = (UserModel) session.getAttribute("user");

    Long id = sessionModel.getCollegeId();
    Long roleId = sessionModel.getRoleId();

    if (id == 0) {
      id = DataUtility.getLong(request.getParameter("id"));
    }

    CollegeModel model = new CollegeModel();
    System.out.println("org12" + UserFilterManager.getOrganizationId(request));
    model.setOrganizationId(UserFilterManager.getOrganizationId(request));

    if (id > 0) {
      try {
        model = model.findByPK(id);
        ServletUtility.setModel(model, request);
      } catch (ApplicationException e) {
        ServletUtility.handleException(e, request, response);
        return;
      }
    }
    ServletUtility.setModel(model, request);
    ServletUtility.forwardView(ORSView.COLLEGE_VIEW, request, response);
  }
Ejemplo n.º 2
0
 /**
  * Returns logged in user role
  *
  * @param request
  * @return
  */
 public static long getRole(HttpServletRequest request) {
   UserModel model = (UserModel) request.getSession().getAttribute("user");
   if (model != null) {
     return model.getRoleId();
   } else {
     return AppRole.GUEST;
   }
 }
Ejemplo n.º 3
0
  /** Contains Display Logic */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    Long id = DataUtility.getLong(request.getParameter("id"));

    UserModel model = new UserModel();

    if (id > 0) {
      try {
        model = model.findByPK(id);
        ServletUtility.setModel(model, request);
      } catch (ApplicationException e) {
        ServletUtility.handleException(e, request, response);
        return;
      }
    }
    ServletUtility.forwardView(ORSView.USER_VIEW, request, response);
  }
Ejemplo n.º 4
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    log.debug("UserCtl Method doPost Started");
    String op = DataUtility.getString(request.getParameter("operation"));

    // get model
    UserModel model = (UserModel) populateModel(request);

    long id = model.getId();

    if (OP_SAVE.equalsIgnoreCase(op)) {
      try {
        if (id > 0) {
          model.update();

        } else {
          long pk = model.add();
          model.setId(pk);
        }
        ServletUtility.setModel(model, request);
        ServletUtility.setSuccessMessage("Data is successfully saved", request);
      } catch (ApplicationException e) {
        log.error(e);
        ServletUtility.handleException(e, request, response);
        return;
      }

    } else if (OP_DELETE.equalsIgnoreCase(op)) {
      try {
        model.delete();
        ServletUtility.redirect(ORSView.USER_LIST_CTL, request, response);
        return;
      } catch (ApplicationException e) {
        log.error(e);
        ServletUtility.handleException(e, request, response);
        return;
      }
    } else {
      if (id > 0 || op != null) {
        UserModel model1;
        try {
          model1 = model.findByPK(id);
          ServletUtility.setModel(model1, request);
        } catch (ApplicationException e) {

          ServletUtility.handleException(e, request, response);
          return;
        }
      }
    }
    ServletUtility.forwardView(ORSView.USER_VIEW, request, response);
    log.debug("UserCtl Method doPost Ended");
  }
Ejemplo n.º 5
0
  @Override
  protected BaseModel populateModel(HttpServletRequest request) {

    log.debug("UserCtl Method populateModel Started");

    UserModel model = new UserModel();

    model.setId(DataUtility.getLong(request.getParameter("id")));

    model.setRoleId(DataUtility.getLong(request.getParameter("roleId")));

    model.setFirstName(DataUtility.getString(request.getParameter("firstName")));

    model.setLastName(DataUtility.getString(request.getParameter("lastName")));

    model.setLogin(DataUtility.getString(request.getParameter("login")));

    model.setPassword(DataUtility.getString(request.getParameter("password")));

    model.setConfirmPassword(DataUtility.getString(request.getParameter("confirmPassword")));

    model.setGender(DataUtility.getString(request.getParameter("gender")));

    model.setDob(DataUtility.getDate(request.getParameter("dob")));

    populateModel(model, request);

    System.out.println(model.getFirstName());

    log.debug("UserCtl Method populateModel Ended");

    return model;
  }
Ejemplo n.º 6
0
  /** Loads pre-loaded data like Dropdown List. */
  @Override
  protected void preload(HttpServletRequest request) {
    HttpSession session = request.getSession(true);
    UserModel sessionModel = (UserModel) session.getAttribute("user");
    Long id = sessionModel.getCollegeId();
    if (id == 0) {
      id = DataUtility.getLong(request.getParameter("id"));
    }
    IndustryModel model = new IndustryModel();
    CountryModel countryModel = new CountryModel();
    StateModel statemodel = new StateModel();
    PrincipalEmployerModel principalModel = new PrincipalEmployerModel();
    try {
      List list = model.search();
      request.setAttribute("industryList", list);
      List countryList = countryModel.search();
      request.setAttribute("countryList", countryList);
      List esicStateList = statemodel.search();
      request.setAttribute("esicStateList", esicStateList);
      List epfStateList = statemodel.search();
      request.setAttribute("epfStateList", epfStateList);
      List profStateList = statemodel.search();
      request.setAttribute("profStateList", profStateList);
      List serStateList = statemodel.search();
      request.setAttribute("serStateList", serStateList);

      principalModel.setId(UserFilterManager.getOrganizationId(request));
      System.out.println("model" + UserFilterManager.getOrganizationId(request));
      List organizationList = principalModel.search();
      request.setAttribute("organizationList", organizationList);

      if (id > 0) {
        CollegeModel collegemodel = new CollegeModel();
        StateModel stateModel = new StateModel();
        DistrictModel districtModel = new DistrictModel();
        AreaModel areaModel = new AreaModel();
        CityModel cityModel = new CityModel();
        PostOfficeModel postOfficeModel = new PostOfficeModel();

        collegemodel.setOrganizationId(UserFilterManager.getOrganizationId(request));
        collegemodel = collegemodel.findByPK(id);
        if (collegemodel.getStateId() > 0) {
          stateModel.setId(collegemodel.getStateId());
          List stateList = stateModel.search();
          request.setAttribute("stateList", stateList);
        }

        if (collegemodel.getDistrictId() > 0) {
          districtModel.setId(collegemodel.getDistrictId());
          List districtList = districtModel.search();
          request.setAttribute("districtList", districtList);
        }

        if (collegemodel.getCityId() > 0) {
          cityModel.setId(collegemodel.getCityId());
          List cityList = cityModel.search();
          request.setAttribute("cityList", cityList);
        }

        if (collegemodel.getAreaId() > 0) {
          areaModel.setId(collegemodel.getAreaId());
          List areaList = areaModel.search();
          request.setAttribute("areaList", areaList);
        }

        if (collegemodel.getPostOfficeId() > 0) {
          postOfficeModel.setId(collegemodel.getPostOfficeId());
          List postOfficeList = postOfficeModel.search();
          request.setAttribute("postOfficeList", postOfficeList);
        }
        if (collegemodel.getEsicDistrictId() > 0) {
          districtModel.setId(collegemodel.getEsicDistrictId());
          List esicDistrictList = districtModel.search();
          request.setAttribute("esicDistrictList", esicDistrictList);
        }
        if (collegemodel.getEpfDistrictId() > 0) {
          districtModel.setId(collegemodel.getEpfDistrictId());
          List epfDistrictList = districtModel.search();
          request.setAttribute("epfDistrictList", epfDistrictList);
        }
        if (collegemodel.getProfDistrictId() > 0) {
          districtModel.setId(collegemodel.getProfDistrictId());
          List profDistrictList = districtModel.search();
          request.setAttribute("profDistrictList", profDistrictList);
        }
        if (collegemodel.getSerDistrictId() > 0) {
          districtModel.setId(collegemodel.getSerDistrictId());
          List serDistrictList = districtModel.search();
          request.setAttribute("serDistrictList", serDistrictList);
        }
        if (collegemodel.getStateOneId() > 0) {
          stateModel.setId(collegemodel.getStateOneId());
          List stateOneList = stateModel.search();
          request.setAttribute("stateOneList", stateOneList);
        }
        if (collegemodel.getStateTwoId() > 0) {
          stateModel.setId(collegemodel.getStateTwoId());
          List stateTwoList = stateModel.search();
          request.setAttribute("stateTwoList", stateTwoList);
        }
        if (collegemodel.getStateThreeId() > 0) {
          stateModel.setId(collegemodel.getStateThreeId());
          List stateThreeList = stateModel.search();
          request.setAttribute("stateThreeList", stateThreeList);
        }
        if (collegemodel.getState4Id() > 0) {
          stateModel.setId(collegemodel.getState4Id());
          List state4List = stateModel.search();
          request.setAttribute("state4List", state4List);
        }
        if (collegemodel.getDistrict1Id() > 0) {
          districtModel.setId(collegemodel.getDistrict1Id());
          List district1List = districtModel.search();
          request.setAttribute("district1List", district1List);
        }
        if (collegemodel.getDistrict2Id() > 0) {
          districtModel.setId(collegemodel.getDistrict2Id());
          List district2List = districtModel.search();
          request.setAttribute("district2List", district2List);
        }
        if (collegemodel.getDistrict3Id() > 0) {
          districtModel.setId(collegemodel.getDistrict3Id());
          List district3List = districtModel.search();
          request.setAttribute("district3List", district3List);
        }
        if (collegemodel.getDistrict4Id() > 0) {
          districtModel.setId(collegemodel.getDistrict4Id());
          List district4List = districtModel.search();
          request.setAttribute("district4List", district4List);
        }
        if (collegemodel.getOwnerStateId() > 0) {
          stateModel.setId(collegemodel.getOwnerStateId());
          List ownerStateList = stateModel.search();
          request.setAttribute("ownerStateList", ownerStateList);
        }
        if (collegemodel.getOwnerDistrictId() > 0) {
          districtModel.setId(collegemodel.getOwnerDistrictId());
          List ownerDistrictList = districtModel.search();
          request.setAttribute("ownerDistrictList", ownerDistrictList);
        }
        if (collegemodel.getOwnerCityId() > 0) {
          cityModel.setId(collegemodel.getOwnerCityId());
          List ownerCityList = cityModel.search();
          request.setAttribute("ownerCityList", ownerCityList);
        }
        if (collegemodel.getOwnerAreaId() > 0) {
          areaModel.setId(collegemodel.getOwnerAreaId());
          List ownerAreaList = areaModel.search();
          request.setAttribute("ownerAreaList", ownerAreaList);
        }

        if (collegemodel.getOwnerPostOfficeId() > 0) {
          postOfficeModel.setId(collegemodel.getOwnerPostOfficeId());
          List ownerPostOfficeList = postOfficeModel.search();
          request.setAttribute("ownerPostOfficeList", ownerPostOfficeList);
        }
      }
    } catch (ApplicationException e) {
      log.error(e);
    }
  }