コード例 #1
0
ファイル: PersonAction.java プロジェクト: nmsgit1234/bsip
  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");
  }
コード例 #2
0
ファイル: PersonAction.java プロジェクト: nmsgit1234/bsip
  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");
  }
コード例 #3
0
ファイル: PersonAction.java プロジェクト: nmsgit1234/bsip
  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");
  }
コード例 #4
0
ファイル: PersonAction.java プロジェクト: nmsgit1234/bsip
  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");
  }