Пример #1
0
  public List prepareLocationFormList(List regnList) throws BSIException {
    CommonLogger.logDebug(
        log, "In PersonAction.prepareLocationFormList(): the regn list size is " + regnList.size());
    System.out.println(
        "In PersonAction.prepareLocationFormList(): the regn list size is " + regnList.size());
    List locnList = new ArrayList();
    LocationForm locForm = null;
    Region region = null;
    String[] ids;
    String[] names;

    for (int z = 0; z < regnList.size(); z++) {
      ids = new String[6];
      names = new String[6];

      locForm = new LocationForm();
      int arrayPos = 0;

      region = (Region) regnList.get(z);
      ids[arrayPos] = region.getRegionId().toString();
      names[arrayPos] = region.getName();

      // Extract parent region name/ids for the given region
      RegionManager regMgr = new RegionManager();

      while (true) {
        region = regMgr.getParentRegion(region.getRegionId());
        CommonLogger.logDebug(log, "The region id is " + region.getRegionId().toString());
        System.out.println("The region id is " + region.getRegionId().toString());

        if (region == null
            || region.getRegionId().toString().equalsIgnoreCase(BSIConstants.ROOT_REGION_ID)) break;
        else {
          arrayPos = arrayPos + 1;
          ids[arrayPos] = region.getRegionId().toString();
          names[arrayPos] = region.getName();
        }
      }

      for (int m = 0; m < 6; m++) {
        System.out.println("The id [] :" + m + "=" + ids[m]);
        System.out.println("The names [] :" + m + "=" + names[m]);
      }
      // Populate the location form
      locForm.setRegionIdAndName(arrayPos + 1, ids, names);
      locnList.add(locForm);
    }
    return locnList;
  }
Пример #2
0
 public static void main(String[] args) {
   try {
     PersonSrvsRegionManager ssrMgr = new PersonSrvsRegionManager();
     List regnList = ssrMgr.getSubscribedSrvsRegions("1", "2", "B");
     PersonAction action = new PersonAction();
     List locnsList = action.prepareLocationFormList(regnList);
     SubscribeServiceForm form = new SubscribeServiceForm();
     form.populateForm(locnsList);
     List locnForms = form.getLocns();
     System.out.println("Getting the results from the form : ");
     for (int x = 0; x < locnForms.size(); x++) {
       LocationForm form1 = (LocationForm) locnForms.get(x);
       System.out.println(form1.getRegionId1());
       System.out.println(form1.getRegionId2());
       System.out.println(form1.getRegionName1());
       System.out.println(form1.getRegionName2());
     }
   } catch (Exception ex) {
     ex.printStackTrace();
   }
 }
Пример #3
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");
  }
Пример #4
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");
  }
Пример #5
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");
  }