Exemple #1
0
  public ActionForward list(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:list() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    try {
      PersonManager clientHandler = new PersonManager();

      CommonLogger.logDebug(
          log, "The person type is " + request.getParameter(BSIConstants.PERSON_TYPE));

      List personsList = clientHandler.listPersons(request.getParameter(BSIConstants.PERSON_TYPE));

      request.getSession().setAttribute(BSIConstants.OBJECTS_LIST, personsList);
      /*
       *
       * List supplierList = clientHandler.listSuppliers();
       *
       * request.getSession().setAttribute(BSIConstants.SUPPLIER_LIST,
       * supplierList);
       * request.getSession().setAttribute(BSIConstants.SORT_LIST_NAME
       * ,BSIConstants.SUPPLIER_LIST);
       *
       *
       * SortParams sortParams = new SortParams();
       * sortParams.setActionType("goto"); sortParams.setSortColumn("Id");
       * sortParams.setSortOrder("asc"); sortParams.setRowsPerPage(3);
       * sortParams.setGoToPage(2);
       *
       * request.getSession().setAttribute(BSIConstants.SORT_PARAMS,sortParams
       * );
       */

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:list() \n exception occured. Exception message is " + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    }

    // Forward to result page
    return mapping.findForward("success");
  }
Exemple #2
0
  /**
   * createPerson
   *
   * <p>This method creates only the Person.
   *
   * @param mapping ActionMapping
   * @param form ActionForm
   * @param request HttpServletRequest
   * @param response HttpServletResponse
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward createPerson(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:createPerson() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }
    Object obj = null;
    // ActionRedirect redirect = null;
    try {
      PersonManager clientHandler = new PersonManager();
      obj = clientHandler.createPerson(form);
      String personType = ((PersonForm) form).getPersonType();
      ActionMessages msgs = new ActionMessages();
      if (personType != null && personType.equalsIgnoreCase(BSIConstants.SUPPLIER)) {
        msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("Supplier.creation.succesfull"));
      } else if (personType != null && personType.equalsIgnoreCase(BSIConstants.REGION_ADMIN)) {
        msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("RegAdmin.create.succesfully"));
      }
      saveMessages(request, msgs);
      /*			HttpSession session = request.getSession(true);
      			session.setAttribute(BSIConstants.CREATED_ENTITIY, obj);
      */
      // dynaForm.getMap().clear();

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:createPerson() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);

    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.CREATE);
      request.getSession().setAttribute(BSIConstants.CREATED_ENTITIY, obj);

      /*			redirect = new ActionRedirect(mapping.findForward("success"));
      			redirect.addParameter(BSIConstants.CREATED_ENTITIY, obj);
      */
    }
    return mapping.findForward("success");
    // return redirect;
  }
Exemple #3
0
  public ActionForward getPersonInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // If user pressed 'Cancel' button,
    // return to home page

    ActionForward forward = null;

    CommonLogger.logDebug(log, "In PersonAction:getPersonInfo() ");

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    String personId = request.getParameter(BSIConstants.PERSON_ID);
    User user = (User) request.getSession().getAttribute(BSIConstants.USER);
    // String personId = user.getPerson().getId().toString();

    CommonLogger.logInfo(log, "Executing the view action for the person id:" + personId);

    try {
      PersonManager clientHandler = new PersonManager();
      Person personObj = clientHandler.getPerson(personId);

      CommonLogger.logDebug(log, "Populating the person form");
      PersonForm personForm = (PersonForm) form;
      PropertyUtils.copyProperties(personForm, personObj);
      CommonLogger.logDebug(
          log, "After Populating the person form, the name is " + personForm.getName());
      String personType = personForm.getPersonType();
      if (personType != null && personType.equalsIgnoreCase(BSIConstants.BUYER)) {
        forward = mapping.findForward("Buyer");
      } else if (personType != null && personType.equalsIgnoreCase(BSIConstants.SUPPLIER)) {
        forward = mapping.findForward("Supplier");
      }
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In BuyerAction:editPersonalInfo() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT);
    }
    return forward;
  }
Exemple #4
0
  /**
   * Process the request and return an <code>ActionForward</code> instance describing where and how
   * control should be forwarded, or <code>null</code>if the response has already been completed.
   *
   * @param mapping The ActionMapping used to select this instance
   * @param form The optional ActionForm bean for this request (if any)
   * @param request The HTTP request we are processing
   * @param response The HTTP response we are creating
   * @exception Exception if the application logic throws an exception
   * @return the ActionForward for the next view
   */
  public ActionForward subSrvsDisplay(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In SupplierAction:create() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    try {
      // Get the list of all services available.
      ServiceManager svsMgr = new ServiceManager();
      List svsList = svsMgr.getAllServices();
      request.getSession().setAttribute(BSIConstants.SERVICES_LIST, svsList);
      // Get the list of all countries.
      List locnList = getCountriesList();
      request.setAttribute(BSIConstants.COUNTRY_LIST, locnList);

      SubscribeServiceForm ssform = (SubscribeServiceForm) form;
      ssform.reset(mapping, request);
      ArrayList locns = new ArrayList();

      LocationForm locform = null;

      for (int i = 0; i < 1; i++) {
        locform = new LocationForm();
        locns.add(locform);
      }

      ssform.populateForm(locns);

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:add() \n exception occured. Exception message is " + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(
          BSIConstants.ACTION_TYPE, request.getParameter(BSIConstants.ACTION_TYPE));
    }
    return mapping.findForward("success");
  }
Exemple #5
0
  public ActionForward updatePersonInfo(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:updatePersonInfo() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    // Person personObj = new Person();

    // PropertyUtils.copyProperties(personObj, (PersonForm)form);

    try {
      PersonManager clientHandler = new PersonManager();

      Person oldPersonObj = clientHandler.getPerson(((PersonForm) form).getId().toString());
      CommonLogger.logDebug(log, "the retrieved person id is " + oldPersonObj.getId());
      PropertyUtils.copyProperties(oldPersonObj, (PersonForm) form);
      clientHandler.updatePersonInfo(oldPersonObj);
      ActionMessages msgs = new ActionMessages();
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("common.update.succesfull"));
      saveMessages(request, msgs);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:updatePersonInfo() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT);
    }

    return mapping.findForward("success");
  }
Exemple #6
0
  public ActionForward unSubscribeSrvs(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:unSubscribeSrvs() ");

    try {
      String personId = request.getParameter(BSIConstants.PERSON_ID);
      String serviceId = request.getParameter(BSIConstants.SERVICE_ID);
      String personType = request.getParameter(BSIConstants.PERSON_TYPE);

      CommonLogger.logDebug(
          log,
          "The personId is "
              + personId
              + ", the service id is "
              + serviceId
              + ", person type is "
              + personType);

      PersonManager clientHandler = new PersonManager();
      clientHandler.unSubscribeService(personId, serviceId, personType);
      ActionMessages msgs = new ActionMessages();
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("creation.action.succesfull"));
      saveMessages(request, msgs);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:subscribeSrvs() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    }

    return mapping.findForward("success");
  }
Exemple #7
0
  public ActionForward delete(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:delete() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    try {
      // Get the list of all services available.
      String personId = request.getParameter(BSIConstants.PERSON_ID);
      PersonManager personMgr = new PersonManager();
      personMgr.deletePerson(new Long(personId));
      ActionMessages msgs = new ActionMessages();
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("creation.action.succesfull"));
      saveMessages(request, msgs);

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:delete() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    }
    return mapping.findForward("success");
  }
Exemple #8
0
  public ActionForward create(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:create() ");

    // If user pressed 'Cancel' button,
    // return to home page

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    try {
      // Get the list of all services available.
      ServiceManager svsMgr = new ServiceManager();
      List svsList = svsMgr.getAllServices();
      request.getSession().setAttribute(BSIConstants.SERVICES_LIST, svsList);
      // Get the list of all countries.
      List locnList = getCountriesList();
      request.getSession().setAttribute(BSIConstants.COUNTRY_LIST, locnList);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:add() \n exception occured. Exception message is " + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.CREATE);
    }
    return mapping.findForward("success");
  }
Exemple #9
0
  public ActionForward listPersonsMatchingServiceProperties(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction.listPersonsMatchingServiceProperties()");

    String serviceId = request.getParameter(BSIConstants.SERVICE_ID);
    String personType = request.getParameter(BSIConstants.PERSON_TYPE);
    Set personSet = null;
    List newPersonList = new ArrayList();

    CommonLogger.logDebug(log, "The request parameters are, serviceId=" + serviceId);
    try {

      // Get the service region
      SubscribeServiceForm ssform = (SubscribeServiceForm) form;
      ArrayList locns = ssform.getLocns();

      List<Long> regionIds = new ArrayList<Long>();
      HashMap locnMap = null;
      LocationForm locn = null;

      for (int x = 0; x < locns.size(); x++) {
        locn = (LocationForm) locns.get(x);
        regionIds.addAll(locn.getSubscribedRegionIds());
      }

      if (regionIds.size() == 0) throw new Exception("No regions selected");

      // LocationManager locMgr = new LocationManager();
      // List srvRegnIds = locMgr.getServiceRegions(locnList);

      // Get the buyer/supplier properties
      List propertyValueList = null;
      if ((personType.equalsIgnoreCase(BSIConstants.BUYER))
          || (personType.equalsIgnoreCase(BSIConstants.SUPPLIER))) {
        propertyValueList = ((BuyerPropertiesForm) ssform).getPropertiesValues();
      }
      //

      PersonManager personMgr = new PersonManager();
      personSet =
          personMgr.getPersonsMatchingServiceProperties(
              serviceId, regionIds, personType, propertyValueList);

      // Convert this supplier set to the list
      if (personSet != null) {
        Iterator iter = personSet.iterator();

        while (iter.hasNext()) {
          Person person = (Person) iter.next();
          CommonLogger.logDebug(log, "The person name is " + person.getName());
          newPersonList.add(person);
        }
      }
      CommonLogger.logDebug(log, "The person set contains : " + newPersonList);
      // request.getSession().setAttribute(BSIConstants.PERSONS_LIST,
      // suppSet);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:listPersonsForService()  \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } finally {
      request.getSession().setAttribute(BSIConstants.OBJECTS_LIST, newPersonList);
    }
    return mapping.findForward("success");
  }
Exemple #10
0
  public ActionForward editSubServiceLocation(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    // If user pressed 'Cancel' button,
    // return to home page

    CommonLogger.logDebug(log, "In PersonAction:editSubServiceLocation() ");

    if (isCancelled(request)) {
      return mapping.findForward("home");
    }

    try {

      String personId = request.getParameter(BSIConstants.PERSON_ID);
      String serviceId = request.getParameter(BSIConstants.SERVICE_ID);
      String serviceName = request.getParameter(BSIConstants.SERVICE_NAME);
      String personType = request.getParameter(BSIConstants.PERSON_TYPE);

      CommonLogger.logInfo(
          log,
          "Executing the editSubServiceLocation action for the person id:"
              + personId
              + ",serviceId = "
              + serviceId
              + ",serviceName = "
              + serviceName
              + " personType="
              + personType);

      PersonSrvsRegionManager ssrMgr = new PersonSrvsRegionManager();

      List regnList = ssrMgr.getSubscribedSrvsRegions(personId, serviceId, personType);

      /*			//Get the service properties.
      			ServiceManager svsMgr = new ServiceManager();
      			Set propertySet = svsMgr.getServiceProperties(serviceId);

      			//Get service propety values
      */

      SubscribeServiceForm subForm = (SubscribeServiceForm) form;
      /*
       * LocationForm locForm = null; ServiceRegion svsRegn = null; String
       * countryId = null; String countryName = null; String stateId =
       * null; String stateName = null; String locationId = null; String
       * locationName = null; List locnsList = new ArrayList();
       *
       * for (int z=0;z<serviceRegnList.size();z++) { locForm = new
       * LocationForm();
       *
       * svsRegn = (ServiceRegion)serviceRegnList.get(z); //Get the list
       * of all countries. countryId =
       * svsRegn.getCountry().getId().toString(); countryName =
       * svsRegn.getCountry().getName();
       *
       * stateId = svsRegn.getState().getId().toString(); stateName =
       * svsRegn.getState().getName(); locationId =
       * svsRegn.getLocation().getId().toString(); locationName =
       * svsRegn.getLocation().getName();
       *
       * locForm.setCountryId(countryId);
       * locForm.setCountryName(countryName); locForm.setStateId(stateId);
       * locForm.setStateName(stateName);
       * locForm.setLocationId(locationId);
       * locForm.setLocationName(locationName); locnsList.add(locForm); }
       */
      List locnsLit = prepareLocationFormList(regnList);
      subForm.populateForm(locnsLit);

      List countryList = getCountriesList();
      request.setAttribute(BSIConstants.COUNTRY_LIST, countryList);

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:edit() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    } finally {
      request.setAttribute(BSIConstants.ACTION_TYPE, BSIConstants.EDIT);
    }

    return mapping.findForward("success");
  }
Exemple #11
0
  public ActionForward listSubscribedServices(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:listSubscribedServices() ");

    ActionMessages msgs = new ActionMessages();
    Set srvs = null;

    try {

      // String personId = request.getParameter(BSIConstants.PERSON_ID);
      User user = (User) request.getSession().getAttribute(BSIConstants.USER);
      // String personId = user.getPerson().getId().toString();
      String personId = null;
      if (request.getParameter(BSIConstants.PERSON_ID) != null) {
        personId = request.getParameter(BSIConstants.PERSON_ID);
      } else {
        personId = user.getPerson().getId().toString();
      }
      String personType = request.getParameter(BSIConstants.PERSON_TYPE);

      CommonLogger.logDebug(log, "The person id is " + personId);

      PersonManager clientHandler = new PersonManager();
      Person personObj = clientHandler.getPerson(personId);

      // Get the service region for the person
      // TODO should support multiple service region, each for a service.
      Long serviceId = null;
      if (personType != null && personType.equalsIgnoreCase(BSIConstants.BUYER)) {
        srvs = personObj.getRequestedSevices();
      } else if (personType != null && personType.equalsIgnoreCase(BSIConstants.SUPPLIER)) {
        srvs = personObj.getOfferedServices();
      }

      // srvs = personObj.getServices();
      if (log.isDebugEnabled()) {
        if (srvs != null) {
          Object[] services = srvs.toArray();
          if (services.length > 0) serviceId = ((Service) services[0]).getNodeId();
          CommonLogger.logDebug(log, "The service id is " + serviceId);
        }
      }

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:subscribeService()  \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } finally {
      request.setAttribute(BSIConstants.SUBSCRIBED_SERVICES_LIST, srvs);
    }
    return mapping.findForward("success");
  }
Exemple #12
0
  public ActionForward listBuyersForService(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction.listBuyersForService()");

    String serviceId = request.getParameter(BSIConstants.SERVICE_ID);
    String ssrId = request.getParameter(BSIConstants.SERVICE_REGION_ID);
    List buyerList = null;

    CommonLogger.logDebug(
        log, "The request parameters are, serviceId=" + serviceId + ",ssrId=" + ssrId);
    try {

      // Get the service region
      SubscribeServiceForm ssform = (SubscribeServiceForm) form;
      ArrayList locns = ssform.getLocns();

      List regionIds = new ArrayList();
      HashMap locnMap = null;
      LocationForm locn = null;

      for (int x = 0; x < locns.size(); x++) {
        locn = (LocationForm) locns.get(x);
        regionIds.add(locn.getSubscribedRegionId());
        /*
         * locnMap = new HashMap();
         * locnMap.put("CountryId",locn.getCountryId());
         * locnMap.put("StateId",locn.getStateId());
         * locnMap.put("LocationId",locn.getLocationId());
         * locnList.add(locnMap);
         */
      }

      if (regionIds.size() == 0) throw new Exception("No regions selected");

      // LocationManager locMgr = new LocationManager();
      // List srvRegnIds = locMgr.getServiceRegions(locnList);

      PersonManager personMgr = new PersonManager();
      buyerList = personMgr.getBuyersForService(serviceId, regionIds);

      if (log.isDebugEnabled()) {
        Iterator iter = buyerList.iterator();
        while (iter.hasNext()) {
          Person person = (Person) iter.next();
          CommonLogger.logDebug(log, "The person name is " + person.getName());
        }
      }

      // request.getSession().setAttribute(BSIConstants.PERSONS_LIST,
      // buyerSet);
    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In PersonAction:listBuyersForService()  \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } finally {
      request.setAttribute(BSIConstants.PERSONS_LIST, buyerList);
    }
    return mapping.findForward("success");
  }
Exemple #13
0
  public ActionForward subscribeSrvs(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    CommonLogger.logDebug(log, "In PersonAction:subscribeSrvs() ");

    try {
      String personId = request.getParameter(BSIConstants.PERSON_ID);
      String serviceId = request.getParameter(BSIConstants.SERVICE_ID);
      String personType = request.getParameter(BSIConstants.PERSON_TYPE);

      CommonLogger.logDebug(
          log,
          "The personId is "
              + personId
              + ", the service id is "
              + serviceId
              + ",the personType is "
              + personType);

      SubscribeServiceForm ssform = (SubscribeServiceForm) form;
      ArrayList locns = ssform.getLocns();

      List regionIds = new ArrayList();
      HashMap locnMap = null;
      LocationForm locn = null;

      for (int x = 0; x < locns.size(); x++) {
        locn = (LocationForm) locns.get(x);
        CommonLogger.logDebug(log, "The regionId1:" + locn.getRegionId1());
        CommonLogger.logDebug(log, "The regionId2:" + locn.getRegionId2());
        CommonLogger.logDebug(log, "The regionId3:" + locn.getRegionId3());
        CommonLogger.logDebug(log, "The regionId4:" + locn.getRegionId4());
        CommonLogger.logDebug(log, "The regionId5:" + locn.getRegionId5());
        CommonLogger.logDebug(log, "The regionId16" + locn.getRegionId6());

        regionIds.add(locn.getSubscribedRegionId());
        /*
         * locnMap = new HashMap();
         * locnMap.put("CountryId",locn.getCountryId());
         * locnMap.put("StateId",locn.getStateId());
         * locnMap.put("LocationId",locn.getLocationId());
         * locnList.add(locnMap);
         */

      }

      if (regionIds.size() == 0) throw new Exception("No regions selected");

      // Get the buyer properties form, in case buyer.
      PersonManager clientHandler = new PersonManager();
      List buyerPropList = null;
      /*			if (personType.equalsIgnoreCase(BSIConstants.BUYER)) {
       */ buyerPropList = ((BuyerPropertiesForm) ssform).getPropertiesValues();
      //			}
      clientHandler.updateSubscribedServices(
          personId, serviceId, regionIds, personType, buyerPropList);
      // clientHandler.unSubscribeServiceLocation(personId,serviceId,personType);
      // clientHandler.subscribeService(personId,serviceId,locnList,personType);
      ActionMessages msgs = new ActionMessages();
      msgs.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("creation.action.succesfull"));
      saveMessages(request, msgs);

    } catch (BSIException ex1) {
      ActionErrors errors = new ActionErrors();
      CommonLogger.logDebug(
          log,
          "In SupplierAction:subscribeSrvs() \n exception occured. Exception message is "
              + ex1.getMessage());
      errors.add(
          ActionErrors.GLOBAL_MESSAGE, new ActionMessage(ex1.getErrorCode(), ex1.getMessage()));
      saveErrors(request, errors);
    } catch (Exception ex2) {
      throw ex2;
    }
    return mapping.findForward("success");
  }
Exemple #14
0
  /**
   * Creates an object of specified type from the request values.
   *
   * @param objClassName name of the class of the main object to be created.
   * @param reqParamMap values of the object in hash map
   * @return
   * @throws Exception
   */
  public Object createObject(String objClassName, HashMap reqParamMap) throws Exception {
    Object convertedObject = null;

    CommonLogger.logDebug(log, "In ObjectHandler.createObject()");

    try {
      Class classToLoad = Class.forName(objClassName);
      convertedObject = classToLoad.newInstance();

      // The name of the html field tha contains the set values should end
      // with "Set"
      // Map newMap = (HashMap) reqParamMap.clone();
      Map newMap = processParamNames(reqParamMap);
      Set mapKeysSet = newMap.keySet();
      Iterator keys = mapKeysSet.iterator();
      // To contain the parameter name values for the Set of specified
      // object type
      Map childPropertiesMap = new HashMap();
      while (keys.hasNext()) {
        // String keyName = (String) keys.next();
        RequestParamValue reqParam = (RequestParamValue) keys.next();
        // if (keyName.endsWith("Set")) {
        if (reqParam.getTypeOfParentClassVarible().equals("Set")) {
          // String setPropertyName =
          // keyName.substring(keyName.lastIndexOf(',') + 1);
          String setPropertyName = reqParam.getNameOfParentClassVariable() + "Set";
          // Check if the values needs to be set in different object
          // than the parent.
          if (setPropertyName != null && !childPropertiesMap.containsKey(setPropertyName)) {
            Map valueMap = new HashMap();
            valueMap.put(reqParam, newMap.get(reqParam));
            childPropertiesMap.put(setPropertyName, valueMap);
          } else {
            Map valueMap = (Map) childPropertiesMap.get(setPropertyName);
            valueMap.put(reqParam, newMap.get(reqParam));
            childPropertiesMap.put(setPropertyName, valueMap);
          }
        }
      }

      // Now further process the childPropertiesMap to generate the Set
      // object with specified object types.
      Iterator childIterator = childPropertiesMap.keySet().iterator();
      while (childIterator.hasNext()) {
        String keyName = (String) childIterator.next();
        // RequestParamValue reqParam = (RequestParamValue)
        // childIterator.next();

        if (keyName.endsWith("Set")) {
          // if (reqParam.getTypeOfParentClassVarible().equals("Set"))
          // {
          // String parentPropertyName = getPropertyName(keyName);

          Map valueMap = (Map) childPropertiesMap.get(keyName);
          ArrayToSetConverter converter = new ArrayToSetConverter();
          Set convertedSets = converter.convert(Set.class, valueMap);
          String parentClassPropertyName = null;
          Iterator iter = valueMap.keySet().iterator();
          while (iter.hasNext()) {
            parentClassPropertyName =
                ((RequestParamValue) iter.next()).getNameOfParentClassVariable();
            break;
          }
          // reqParamMap.put(reqParam.getNameOfParentClassVariable(),
          // convertedSets);
          reqParamMap.put(parentClassPropertyName, convertedSets);
        }
      }

      BeanUtils.populate(convertedObject, reqParamMap);
    } catch (BSIException ex1) {
      CommonLogger.logDebug(
          log, "In CreateObject \n exception occured. Exception message is " + ex1.getMessage());
    } catch (Exception ex2) {
      ex2.printStackTrace();
      throw ex2;
    }
    return convertedObject;
  }