public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    logger.debug(
        "========================="
            + request.getParameter("password")
            + "-------------------------"
            + request.getParameter("hospitalRetypePassword"));
    String password = request.getParameter("password");
    String rePassword = request.getParameter("rePassword");
    String contactName = request.getParameter("contactName");
    String name = request.getParameter("name");
    int country = Integer.parseInt(request.getParameter("country"));
    int type = Integer.parseInt(request.getParameter("type"));
    contactName += " " + request.getParameter("contactSurName");
    String phone = request.getParameter("phone1");
    phone += request.getParameter("phone2");
    int cityId = Integer.parseInt(request.getParameter("city"));

    logger.debug(
        "====================contactName== "
            + contactName
            + " -----------contactName--------------");

    String username = request.getParameter("username");
    InetAddress thisIp = InetAddress.getLocalHost();
    String i = thisIp.getHostAddress();

    logger.debug(
        "====================thisIp==" + thisIp.getAddress() + "-----------thisIp--------------");
    if (!password.equals(rePassword)) {
      ActionErrors errors = new ActionErrors();
      logger.debug(
          "+++++++++++++++++++++"
              + request.getParameter("rePassword")
              + "-------------------------"
              + request.getParameter("hospitalRetypePassword"));
      errors.add("hospitalPassword", new ActionMessage("applicationForm.hospital.error.password"));
      logger.debug("yes");
      saveErrors(request, errors);
      return mapping.getInputForward();
    }
    if (type == 0) {
      ActionErrors errors = new ActionErrors();
      errors.add("hospitalPassword", new ActionMessage("applicationForm.hospital.error.type"));
      saveErrors(request, errors);
      return mapping.getInputForward();
    }

    // check Country
    if (country == 0) {
      ActionErrors errors = new ActionErrors();
      errors.add("hospitalPassword", new ActionMessage("applicationForm.hospital.error.country"));
      saveErrors(request, errors);
      return mapping.getInputForward();
    }

    // check City
    if (cityId == 0) {
      ActionErrors errors = new ActionErrors();
      errors.add("hospitalPassword", new ActionMessage("applicationForm.hospital.error.city"));
      saveErrors(request, errors);
      return mapping.getInputForward();
    }

    DynaActionForm dynaActionForm = (DynaActionForm) form;

    Provider register = new Provider();
    ProviderStaff providerStaff = new ProviderStaff();
    // .setHospitalDateRegister(new Date());
    providerStaff.setCreatedOn(new Date());
    register.setIpAddress(i);

    BeanUtils.copyProperties(register, dynaActionForm);
    BeanUtils.copyProperties(providerStaff, dynaActionForm);
    providerStaff.setContactName(contactName);
    register.setStatus(0);
    register.setPhone(phone);
    /*String encryptPass = com.omb.onlineclub.encrypt.OneWayEncrypt.getInstance().encrypt(register.getPassword());
    user.setPassword(encryptPass);
    */

    Session session = null;
    Transaction tx = null;
    try {
      // Begin Unit of work
      ProviderStaff user = null;
      Provider userName = null;

      session = HibernateUtil.getSessionFactory().openSession();
      tx = session.beginTransaction();
      Query query1 = session.createQuery("from Provider p where p.name=:name");
      query1.setString("name", name);
      userName = (Provider) query1.uniqueResult();
      logger.debug("+++++++++++++++++++++userName " + userName + "-------------------------");
      if (userName != null) {
        ActionErrors errors = new ActionErrors();
        logger.debug("+++++++++++++++++++++name " + user + "-------------------------");
        errors.add("hospitalUserName", new ActionMessage("applicationForm.hospital.error.Name"));
        saveErrors(request, errors);
        return mapping.getInputForward();
      }
      // check username
      Query query = session.createQuery("from ProviderStaff ps where ps.username=:username");
      query.setString("username", username);
      user = (ProviderStaff) query.uniqueResult();
      if (user != null) {
        ActionErrors errors = new ActionErrors();
        logger.debug("+++++++++++++++++++++testUser" + user + "-------------------------");
        errors.add(
            "hospitalUserName", new ActionMessage("applicationForm.hospital.error.UserName"));
        saveErrors(request, errors);
        return mapping.getInputForward();
      }

      logger.debug("+++++++++++++++++++++city" + cityId + "------city------------------");
      HashPassword pass = new HashPassword();
      providerStaff.setPassword(pass.hashPassword(password));
      providerStaff.setMaster(1);

      // 1 true
      City city = (City) session.load(City.class, cityId);
      register.setCity(city);
      register.setNumberStaff(1);
      session.save(register);
      providerStaff.setStatus(0);
      providerStaff.setProvider(register);
      session.save(providerStaff);
      tx.commit();
    } catch (Exception ex) {
      if (tx != null) {
        tx.rollback();
      }
      throw new WebActionException(ex);
    } finally {
      if (session != null) {
        session.close();
      }
    }

    return (mapping.findForward("success"));
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String serviceId = null;
    serviceId = request.getParameter("id");
    ProviderService providerService;
    Long providerSerId = Long.parseLong(request.getParameter("id"));
    ProviderStaff providerStaff = (ProviderStaff) request.getSession().getAttribute("User");
    // Long providerId=provider.getId();
    long providerSessiongId = providerStaff.getProvider().getId();

    Session session = null;
    Transaction tx = null;
    try {
      session = HibernateUtil.getSessionFactory().openSession();
      tx = session.beginTransaction();

      Provider provider = (Provider) session.get(Provider.class, providerSessiongId);
      Provider providerTwo = (Provider) session.get(Provider.class, providerSerId);
      Query queryId =
          session.createQuery(
              "select ps.id,ps.createdOn from ProviderService ps join "
                  + "ps.provider pr  join ps.providerTwo pt "
                  + "where ps.provider.id=:id and ps.providerTwo.id=:idSes and ps.status=0");
      queryId.setLong("id", providerSerId);
      queryId.setLong("idSes", providerSessiongId);
      Object[] providerServiceSelect = (Object[]) queryId.uniqueResult();
      if (providerServiceSelect != null) {
        long providerServiceId = (Long) providerServiceSelect[0];
        providerService = (ProviderService) session.get(ProviderService.class, providerServiceId);
        providerService.setStatus(1);
        logger.debug(
            "==========================================))providerServiceSelect======="
                + providerServiceSelect);
      } else {
        providerService = new ProviderService();
        providerService.setProvider(provider);
        providerService.setProviderTwo(providerTwo);
        providerService.setStatus(0);
        providerService.setCreatedOn(new Date());
      }
      logger.debug("==============ssssssssssssssss============================");
      if (provider.getServiceId() == null || (provider.getServiceId().equals(""))) {
        logger.debug("==============xxxxxxxxxxxxxxxxxxxxxxxxxx============================");
        provider.setServiceId(serviceId);
      } else if (provider.getServiceId() != null) {
        logger.debug(
            "==============yttyyyyyyyyyyyyyyyyyyyyyy=======provider.getServiceId()====================="
                + provider.getServiceId());
        provider.setServiceId(serviceId = provider.getServiceId() + "," + serviceId);
      }
      session.save(providerService);
      session.save(provider);
      tx.commit();
    } catch (Exception ex) {
      if (tx != null) {
        tx.rollback();
      }
      throw new WebActionException(ex);
    } finally {
      if (session != null) {
        session.close();
      }
    }

    return (mapping.findForward("success"));
  }