/**
   * Method execute
   *
   * @param ActionMapping mapping
   * @param ActionForm form
   * @param HttpServletRequest request
   * @param HttpServletResponse response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();
    // clientXML = (XMLClient) session.getAttribute("client");
    clientXML = XMLClient.getInstance();
    sessionLogin = (String) session.getAttribute("login");

    ajoutsuppressionForm ajoutForm = (ajoutsuppressionForm) form;

    String idperm = ajoutForm.getId1();
    String idrole = ajoutForm.getId2();

    response.setContentType("text/html");

    boolean ajout = clientXML.ajouterPermissionRole(sessionLogin, idperm, idrole);

    if (ajout) {
      String result = "INFO: Permission ajoutée au role";

      session.setAttribute("Resultat", result);
      return mapping.findForward("ok");
    } else {
      String erreur = "ERREUR: Permission non ajoutée au role";

      session.setAttribute("Resultat", erreur);
      return mapping.findForward("failed");
    }
  }
Beispiel #2
0
  public ActionForward execute(
      ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
    try {
      GpsImportForm gpsForm = (GpsImportForm) form;
      User user = (User) req.getSession().getAttribute("user");
      int entryId = gpsForm.getEntryId();
      String fileName = gpsForm.getFileName();
      String title = gpsForm.getTitle();
      String activityId = gpsForm.getActivityId();
      String xml = gpsForm.getXml();
      log.debug(xml);

      List<GpsTrack> tracks = new TcxParser().parse(xml.getBytes());
      GpsTrack track = tracks.get(0); // Horrible hack.
      createAttachment(user, entryId, fileName, title, activityId, track);
      createGeotag(fileName, track);

      req.setAttribute("status", "success");
      req.setAttribute("message", "");
      log.debug("Returning status: success.");
      return mapping.findForward("results");
    } catch (Exception e) {
      log.fatal("Error processing incoming Garmin XML", e);
      req.setAttribute("status", "failure");
      req.setAttribute("message", e.toString());
      return mapping.findForward("results");
    }
  }
  /**
   * Method 'execute'
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @throws Exception
   * @return ActionForward
   */
  public ActionForward handle(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    try {
      // parse parameters
      // create the DAO class
      TelesalesCallSourceDao dao = TelesalesCallSourceDaoFactory.create();

      // execute the finder
      TelesalesCallSource dto[] = dao.findAll();

      // store the results
      request.setAttribute("result", dto);

      return mapping.findForward("success");
    } catch (Exception e) {
      ActionErrors _errors = new ActionErrors();
      _errors.add(
          ActionErrors.GLOBAL_ERROR,
          new ActionError("internal.error", e.getClass().getName() + ": " + e.getMessage()));
      saveErrors(request, _errors);
      return mapping.findForward("failure");
    }
  }
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String forward = FWD_SUCCESS;

    DynaActionForm dynaForm = (DynaActionForm) form;
    // get selected qaEvents
    String[] selectedIDs = (String[]) dynaForm.get("selectedIDs");

    // get sysUserId from login module
    UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
    String sysUserId = String.valueOf(usd.getSystemUserId());

    List qaEvents = new ArrayList();

    for (int i = 0; i < selectedIDs.length; i++) {
      QaEvent qaEvent = new QaEvent();
      qaEvent.setId(selectedIDs[i]);
      qaEvent.setSysUserId(sysUserId);
      qaEvents.add(qaEvent);
    }
    ActionMessages errors = null;
    try {

      QaEventDAO qaEventDAO = new QaEventDAOImpl();
      qaEventDAO.deleteData(qaEvents);
      // System.out.println("Just deleted QaEvent");
      // initialize the form
      dynaForm.initialize(mapping);

    } catch (LIMSRuntimeException lre) {
      // bugzilla 2154
      LogEvent.logError("QaEventDeleteAction", "performAction()", lre.toString());
      request.setAttribute(IActionConstants.REQUEST_FAILED, true);

      errors = new ActionMessages();
      ActionError error = null;
      if (lre.getException() instanceof org.hibernate.StaleObjectStateException) {
        error = new ActionError("errors.OptimisticLockException", null, null);
      } else {
        error = new ActionError("errors.DeleteException", null, null);
      }
      errors.add(ActionMessages.GLOBAL_MESSAGE, error);
      saveErrors(request, errors);
      request.setAttribute(Globals.ERROR_KEY, errors);
      forward = FWD_FAIL;
    }
    if (forward.equals(FWD_FAIL)) return mapping.findForward(forward);

    if ("true".equalsIgnoreCase(request.getParameter("close"))) {
      forward = FWD_CLOSE;
    }

    request.setAttribute("menuDefinition", "QaEventMenuDefinition");
    return mapping.findForward(forward);
  }
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse reponse)
      throws Exception {
    BeanEcrireCommentaire bean = (BeanEcrireCommentaire) actionForm;
    String contenu = bean.getContenu();
    BeanCommentaire beanCommentaire = new BeanCommentaire();
    beanCommentaire.setContenu(contenu);
    Abonne abonne =
        (Abonne)
            bdutil.getUtilisateur(((Integer) request.getSession().getAttribute("id")).intValue());
    beanCommentaire.setIdRedacteur(abonne.getId());

    Article article = bdart.getArticle(Integer.parseInt(request.getParameter("idArticle")));
    beanCommentaire.setIdArticle(article.getId());

    // beanCommentaire.setId(bdart.getIdLibre());

    if (contenu.equals("")) return mapping.findForward("echec");
    else {

      bdcom.addCommentaire(beanCommentaire.getCommentaire());

      //        bdart.addArticle(beanArticle.getArticle());

      //	beanCommentaire.setIdRedacteur(request.getSession(true));
      //	beanCommentaire.setIdArticle(((Article)request.getAttribute("article")).getId());
      //	bean.setId(BDArticles.getIdLibre())
      /// bdart.addArticle(beanCommentaire.getCommentaire());     // /!\ omg!!!

      return mapping.findForward("succes");
    }
  }
 public ActionForward execute(
     ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
     throws Exception {
   ProductLoaderForm obj = (ProductLoaderForm) form;
   String productName = obj.getProductName();
   String productId = obj.getProductId();
   String store = obj.getStore();
   String notes = obj.getNotes();
   String productDesc = obj.getProductDesc();
   String price = obj.getPrice();
   Connection con = null;
   Class.forName(ConnectionStats.DRIVER);
   String url = ConnectionStats.DB_URL;
   String usr = ConnectionStats.DB_USER;
   String pwd = ConnectionStats.DB_PASSWORD;
   con = DriverManager.getConnection(url, usr, pwd);
   Statement stmt = con.createStatement();
   try {
     ResultSet rs =
         stmt.executeQuery("select * from service2_main where productId = '" + productId + "'");
     if (!(rs.next())) {
       stmt.executeUpdate(
           "insert into service2_main values('"
               + productId
               + "','"
               + productName
               + "','"
               + productDesc
               + "',)");
     }
     stmt.executeUpdate(
         "delete from service2_tbl where productId = '"
             + productId
             + "' and store = '"
             + store
             + "'");
     stmt.executeUpdate(
         "insert into service2_tbl values('"
             + productId
             + "','"
             + store
             + "',"
             + Float.parseFloat(price)
             + ",'"
             + notes
             + "')");
     req.setAttribute("msg", "Succeeded");
     System.out.println("succeded");
     return mapping.findForward("success");
   } catch (Exception ex) {
     System.out.println("failure");
     req.setAttribute("msg", "Data updating failed");
     return mapping.findForward("failure");
   }
 }
Beispiel #7
0
  /**
   * Process the specified HTTP request, and create the corresponding HTTP response (or forward to
   * another web component that will create it). 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 form
   * @param req
   * @param res
   * @param mapping The ActionMapping used to select this instance
   * @exception IOException if an input/output error occurs
   * @exception ServletException if a servlet exception occurs
   * @return destination
   */
  public ActionForward execute(
      ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
      throws IOException, ServletException {
    ActionMessages errors = new ActionMessages();
    ActionForward destination = null;

    if (!this.checkLogon(req)) {
      return mapping.findForward("logon");
    }
    Integer action;

    try {
      action = Integer.parseInt(req.getParameter("action"));
    } catch (Exception e) {
      action = BlacklistAction.ACTION_LIST;
    }

    AgnUtils.logger().info("Action: " + action);

    try {
      destination = executeIntern(mapping, req, errors, destination, action);
    } catch (Exception e) {
      AgnUtils.logger().error("execute: " + e + "\n" + AgnUtils.getStackTrace(e));
      errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.exception"));
    }

    // Report any errors we have discovered back to the original form
    if (!errors.isEmpty()) {
      saveErrors(req, errors);
    }
    return destination;
  }
Beispiel #8
0
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ListForm aWebForm = (ListForm) actionForm;

    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.doList(aWebForm, request, response); // 查询处理
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      if (aWebForm.getMethod().equals("jgys_submit")) { // 修改
        Deal.doList(aWebForm, request, response); // 查询处理
        Deal.doJgys_submit(aWebForm, request, response);
        sMessage = "确定竣工验收报告,并提交到工程结算处理成功";
      }

      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      String[] button = {"关闭"}; // 按钮数组
      String[] onclick = {"parent.window.close()"}; // 按钮响应事件
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest req, HttpServletResponse resp ){
		
		if("GET".equals(req.getMethod())){
			JSONObject json = AndroidHelper.DoGetForbiddenException();
			req.setAttribute("json", json.toString());
			return mapping.findForward("succes");
		
		}else if("POST".equals(req.getMethod())){
			
			String email = request.getParameter("mail");
			String mdp = req.getParameter("mdp");
			org.json.JSONObject json = new JSONObject();
			PersonneDAO persDAO = new PersonneDAO();
			
			// check the login and the pwd
			if( mail != null && mdp != null){
				Personne p = persDAO.getmailPersonne(mail);
				// managing the misfound exceptions
				if(p == null) {
					json = AndroidHelper.UserNotFoundException();
				// Uncorrect password
				}else if(!mdp.equals(p.getmdpPersonne())){
					json = AndroidHelper.PassIncorrectException()
				} else {
					p.setmailPersonne("");
					p.setmdpPersonne("");
					json = new JSONObject(p);
				}
			
			} else{
Beispiel #10
0
 public ActionForward execute(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws IOException, ServletException {
   if (true) throw new java.io.IOException();
   return (mapping.findForward("success"));
 }
  /**
   * 增加主机服务
   *
   * @param mapping .
   * @param form .
   * @param request .
   * @param response .
   * @return .
   * @throws Exception .
   */
  public ActionForward addMonitorService(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ActionMessages errors = new ActionMessages();
    MonitorService monitorService = (MonitorService) ((DynaActionForm) form).get("monitorService");
    String type = (String) ((DynaActionForm) form).get("type");
    DependencyUtil.clearDependencyProperty(monitorService);
    monitorHostserviceService.saveMonitorService(monitorService);

    if (!errors.isEmpty()) {
      saveErrors(request, errors);
      return mapping.findForward("input");
    } else {
      return mapping.findForward("success");
    }
  }
 public ActionForward updateMonitorService(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   MonitorService monitorService = (MonitorService) ((DynaActionForm) form).get("monitorService");
   DependencyUtil.clearDependencyProperty(monitorService);
   monitorHostserviceService.updateMonitorService(monitorService);
   return mapping.findForward("success");
 }
  /**
   * Method execute
   *
   * @param ActionMapping mapping
   * @param ActionForm form
   * @param HttpServletRequest request
   * @param HttpServletResponse response
   * @return ActionForward
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    HttpSession session = request.getSession();
    // clientXML = (XMLClient) session.getAttribute("client");
    clientXML = XMLClient.getInstance();
    sessionLogin = (String) session.getAttribute("login");

    planifProgForm planifForm = (planifProgForm) form;

    String idprog = planifForm.getIdprog();
    String idcanal = planifForm.getIdcanal();
    String jour = planifForm.getJour();
    String mois = planifForm.getMois();
    String annee = planifForm.getAnnee();
    String heure = planifForm.getHeure();
    String minute = planifForm.getMinute();
    String seconde = planifForm.getSeconde();

    response.setContentType("text/html");

    boolean planifie =
        clientXML.planifierProgramme(
            sessionLogin, idprog, idcanal, jour, mois, annee, heure, minute, seconde);

    if (planifie) {
      String result = "INFO: Programme planifié sur le canal";

      session.setAttribute("Resultat", result);
      return mapping.findForward("ok");
    } else {
      String erreur = "ERREUR: Programme non planifié";

      session.setAttribute("Resultat", erreur);
      return mapping.findForward("failed");
    }
  }
 public ActionForward execute(
     ActionMapping mapping, ActionForm form, HttpServletRequest req, HttpServletResponse res)
     throws Exception {
   ServiceDataForm obj = (ServiceDataForm) form;
   String serviceId = obj.getServiceId();
   CalculateService obj2 = new CalculateService();
   obj2.calculate(serviceId);
   Connection con = null;
   Class.forName(ConnectionStats.DRIVER);
   String url = ConnectionStats.DB_URL;
   String usr = ConnectionStats.DB_USER;
   String pwd = ConnectionStats.DB_PASSWORD;
   con = DriverManager.getConnection(url, usr, pwd);
   Statement stmt = con.createStatement();
   ResultSet rs = null;
   rs = stmt.executeQuery("select * from " + serviceId + "_main");
   ResultSetMetaData rsmd = rs.getMetaData();
   int col = rsmd.getColumnCount();
   String[] mainHeader = new String[col];
   for (int i = 0; i < col; i++) {
     mainHeader[i] = rsmd.getColumnLabel(i + 1);
   }
   ArrayList<String[]> serviceDataMain = new ArrayList<String[]>();
   while (rs.next()) {
     String[] str = new String[col];
     for (int i = 0; i < col; i++) {
       str[i] = rs.getString(i + 1);
     }
     serviceDataMain.add(str);
   }
   req.setAttribute("mainHeader", mainHeader);
   req.setAttribute("serviceDataMain", serviceDataMain);
   rs = stmt.executeQuery("select * from " + serviceId + "_tbl");
   rsmd = rs.getMetaData();
   col = rsmd.getColumnCount();
   String[] tblHeader = new String[col];
   for (int i = 0; i < col; i++) {
     tblHeader[i] = rsmd.getColumnLabel(i + 1);
   }
   ArrayList<String[]> serviceDatatbl = new ArrayList<String[]>();
   while (rs.next()) {
     String[] str = new String[col];
     for (int i = 0; i < col; i++) {
       str[i] = rs.getString(i + 1);
     }
     serviceDatatbl.add(str);
   }
   req.setAttribute("tblHeader", tblHeader);
   req.setAttribute("serviceDatatbl", serviceDatatbl);
   rs.close();
   con.close();
   return mapping.findForward("success");
 }
 public ActionForward viewMonitorServiceTemplate(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String templateId = request.getParameter("templateId");
   MonitorServiceTemplate monitorServiceTemplate =
       templateService.findMonitorServiceTemplateById(Integer.valueOf(templateId));
   DependencyUtil.initDependencyProperty(monitorServiceTemplate);
   ((DynaActionForm) form).set("monitorServiceTemplate", monitorServiceTemplate);
   return mapping.findForward("view");
 }
 public ActionForward viewMonitorService(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String id = request.getParameter("id");
   MonitorService monitorService =
       monitorHostserviceService.getMonitorService(Integer.valueOf(id));
   DependencyUtil.initDependencyProperty(monitorService);
   ((DynaActionForm) form).set("monitorService", monitorService);
   return mapping.findForward("view");
 }
Beispiel #17
0
  protected ActionForward executeIntern(
      ActionMapping mapping,
      HttpServletRequest req,
      ActionMessages errors,
      ActionForward destination,
      Integer action) {

    BlacklistDao dao = (BlacklistDao) getBean("BlacklistDao");
    String email = null;

    switch (action) {
      case BlacklistAction.ACTION_LIST:
        if (allowed("settings.show", req)) {
          destination = mapping.findForward("list");
        } else {
          errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("error.permissionDenied"));
        }
        break;
      case BlacklistAction.ACTION_SAVE:
        email = req.getParameter("newemail");
        if (dao.insert(getCompanyID(req), email)) {
          updateUserStatus(email.trim(), req);
        }
        destination = mapping.findForward("list");
        break;
      case ACTION_CONFIRM_DELETE:
        destination = mapping.findForward("delete");
        break;
      case BlacklistAction.ACTION_DELETE:
        email = req.getParameter("delete");
        dao.delete(getCompanyID(req), email);
        destination = mapping.findForward("list");
        break;
      default:
        destination = mapping.findForward("list");
    }
    return destination;
  }
  /**
   * 增加服务模板
   *
   * @param mapping .
   * @param form .
   * @param request .
   * @param response .
   * @return .
   * @throws Exception .
   */
  public ActionForward addMonitorServiceTemplate(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    ActionMessages errors = new ActionMessages();
    try {
      MonitorServiceTemplate monitorServiceTemplate =
          (MonitorServiceTemplate) ((DynaActionForm) form).get("monitorServiceTemplate");
      DependencyUtil.clearDependencyProperty(monitorServiceTemplate);
      templateService.saveMonitorServiceTemplate(monitorServiceTemplate);
    } catch (TemplateAlreadyExistException e) {
      errors.add("addMonitorServiceTemplate", new ActionMessage("errors.TemplateExist"));
    }

    if (!errors.isEmpty()) {
      saveErrors(request, errors);
      return mapping.findForward("input");
    } else {
      return mapping.findForward("success");
    }
  }
 protected ActionForward findSuccess(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response) {
   String parameter = request.getParameter("parameter");
   if (parameter == null) {
     parameter = mapping.getParameter();
   }
   String value =
       ServletParameterHelper.replaceDynamicParameters(parameter, request.getParameterMap());
   ActionForward forward = null;
   if (StringUtil.asNull(value) != null) {
     forward = mapping.findForward("success-" + value);
   } else {
     forward = mapping.findForward("success-null");
   }
   if (forward != null) {
     return forward;
   } else {
     return super.findSuccess(mapping, form, request, response);
   }
 }
Beispiel #20
0
 /**
  * 响应页面提交
  *
  * @param actionMapping ActionMapping这个 Action 的配置信息
  * @param actionForm ActionForm 用户提交的表单数据
  * @param request HttpServletRequest当前的 HTTP 请求对象
  * @param response HttpServletResponse当前的 HTTP 响应对象
  * @return ActionForward 提交到查询页面
  * @throws Exception
  */
 public ActionForward execute(
     ActionMapping actionMapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   EditForm aWebForm = (EditForm) actionForm;
   Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值
   if (request.getParameter("print") == null) {
     return actionMapping.getInputForward();
   } else {
     return actionMapping.findForward("print");
   }
 }
 public ActionForward update(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   EmployeeService service = new EmployeeService();
   DynaActionForm employeeForm = (DynaActionForm) form;
   EmployeeDTO employeeDTO = new EmployeeDTO();
   BeanUtils.copyProperties(employeeDTO, employeeForm);
   service.updateEmployee(employeeDTO);
   ActionMessages messages = new ActionMessages();
   ActionMessage message = new ActionMessage("message.employee.update.success");
   messages.add(ActionMessages.GLOBAL_MESSAGE, message);
   saveMessages(request, messages);
   return (mapping.findForward("updateSuccess"));
 }
 public ActionForward selectMonitorServiceTemplate(
     ActionMapping mapping,
     ActionForm form,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   String templateId = request.getParameter("templateId");
   if (StringUtils.isNotBlank(templateId)) {
     MonitorServiceTemplate monitorServiceTemplate =
         templateService.findMonitorServiceTemplateById(Integer.valueOf(templateId));
     request.setAttribute("monitorServiceTemplate", monitorServiceTemplate);
   }
   List list = templateService.findAllMonitorServiceTemplate();
   request.setAttribute("list", list);
   request.setAttribute("templateId", templateId);
   return mapping.findForward("selectServiceTemplate");
 }
  public ActionForward inputMonitorServiceTemplate(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    MonitorServiceTemplate monitorServiceTemplate = new MonitorServiceTemplate();
    List monitorTimePeriods = templateService.findAllMonitorTimePeriods();
    List monitorContactgroups = monitorSupportService.findAllMonitorContactgroups();
    List serviceCommands = monitorSupportService.findMonitorCommands(Integer.valueOf(2));
    ((DynaActionForm) form).set("monitorServiceTemplate", monitorServiceTemplate);
    ((DynaActionForm) form).set("type", "add");
    request.getSession().setAttribute("monitorTimePeriods", monitorTimePeriods);
    request.getSession().setAttribute("monitorContactgroups", monitorContactgroups);
    request.getSession().setAttribute("serviceCommands", serviceCommands);

    return mapping.findForward("input");
  }
  public ActionForward listMonitorService(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // query condition
    MonitorService monitorService = (MonitorService) ((DynaActionForm) form).get("monitorService");

    DBPaginatedList page = new DBPaginatedList();
    PaginationUtil.pageInfoPopulate("row", request, page);
    monitorHostserviceService.findMonitorServiceByPage(page, monitorService);

    request.setAttribute("hostserviceList", page);
    ((DynaActionForm) form).set("monitorService", monitorService);

    return mapping.findForward("list");
  }
Beispiel #25
0
  /**
   * 响应页面提交
   *
   * @param actionMapping ActionMapping这个 Action 的配置信息
   * @param actionForm ActionForm 用户提交的表单数据
   * @param request HttpServletRequest当前的 HTTP 请求对象
   * @param response HttpServletResponse当前的 HTTP 响应对象
   * @return ActionForward 提交到查询页面
   * @throws Exception
   */
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    EditForm aWebForm = (EditForm) actionForm;
    if (aWebForm.getMethod() == null) { // 初次进行页面,需要取初始值
      Deal.setEditDefault(aWebForm, request, response); // 设置进入增加页面的初始值
      return actionMapping.getInputForward();
    } else {
      String sMessage = "未能找到 " + aWebForm.getMethod() + " 对应的处理方法";
      String[] button; // 按钮数组
      String[] onclick; // 按钮响应事件

      if (aWebForm.getMethod().equals("edit")) { // 修改
        Deal.doDHHFEdit(aWebForm, request, response); // 处理修改
        sMessage = mModuleName + "修改处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else if (aWebForm.getMethod().equals("add")) { // 修改
        Deal.doDHHFAdd(aWebForm, request, response); // 处理修改
        sMessage = mModuleName + "增加处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else if (aWebForm.getMethod().equals("del")) { // 删除
        Deal.doDHHFDelete(aWebForm, request, response); // 处理删除
        sMessage = mModuleName + "删除处理成功";
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      } else { // 未能找到 " + aWebForm.getMethod() + " 对应的处理方法
        button = new String[] {"关闭"}; // 按钮数组
        onclick = new String[] {"parent.window.close()"}; // 按钮响应事件
      }
      CCommonMessage mMessage = new CCommonMessage(); // 统一提示页面
      mMessage.setMessage(sMessage); // 默认为"处理成功!"
      mMessage.setButtonName(button);
      mMessage.setOnClickFunc(onclick);
      request.setAttribute(CConstants.MESSAGE_OBJECT, mMessage);
      // 在处理页面最后调用(事先要配置名字为success的forward,在全局配置里有 message)
      return actionMapping.findForward("message");
    }
  }
  public ActionForward editMonitorServiceTemplate(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    String templateId = request.getParameter("templateId");
    MonitorServiceTemplate monitorServiceTemplate =
        templateService.findMonitorServiceTemplateById(Integer.valueOf(templateId));
    DependencyUtil.initDependencyProperty(monitorServiceTemplate);
    List monitorTimePeriods = templateService.findAllMonitorTimePeriods();
    List monitorContactgroups = monitorSupportService.findAllMonitorContactgroups();
    List serviceCommands = monitorSupportService.findMonitorCommands(Integer.valueOf(2));
    ((DynaActionForm) form).set("monitorServiceTemplate", monitorServiceTemplate);
    ((DynaActionForm) form).set("type", "edit");
    request.getSession().setAttribute("monitorTimePeriods", monitorTimePeriods);
    request.getSession().setAttribute("monitorContactgroups", monitorContactgroups);
    request.getSession().setAttribute("serviceCommands", serviceCommands);

    return mapping.findForward("input");
  }
  public ActionForward listMonitorServiceTemplate(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    // query condition
    MonitorServiceTemplate monitorServiceTemplate =
        (MonitorServiceTemplate) ((DynaActionForm) form).get("monitorServiceTemplate");
    List monitorContactgroups = monitorSupportService.findAllMonitorContactgroups();

    DBPaginatedList page = new DBPaginatedList();
    PaginationUtil.pageInfoPopulate("row", request, page);
    templateService.findMonitorServiceTemplateByPage(page, monitorServiceTemplate);

    request.setAttribute("serviceTemplates", page);
    request.getSession().setAttribute("monitorContactgroups", monitorContactgroups);
    ((DynaActionForm) form).set("monitorServiceTemplate", monitorServiceTemplate);

    return mapping.findForward("list");
  }
Beispiel #28
0
  public ActionForward execute(
      ActionMapping actionMapping,
      ActionForm actionForm,
      HttpServletRequest httpServletRequest,
      HttpServletResponse httpServletResponse) {
    LazyValidatorForm frm = (LazyValidatorForm) actionForm;

    if (formCanceled(frm)) {
      return actionMapping.findForward(SUCCESS);
    }

    resetFocusControl(frm, CANCEL);
    ActionMessages msgs = new ActionMessages();
    if (!formSaved(frm)) {
      setFormMode(frm, ((String) httpServletRequest.getParameter(BROWSE_ACTION)));
      setFormId(frm, (String) httpServletRequest.getParameter(BROWSE_ID));
      try {
        httpServletRequest
            .getSession()
            .setAttribute("hozehKindList", Misc.listHardCode(Constants.TableId.HOZEH_KIND));

        LoginInfo loginInfo = getLoginInfo(httpServletRequest);
        if (!loginInfo.userHasAccess(getFormId(frm), getFormMode(frm))) {
          if (isFormInModifyMode(frm)
              && loginInfo.userHasAccess(getFormId(frm), Constants.ActionType.ENQUERY)) {
            setFormMode(frm, Constants.ActionType.ENQUERY);
          } else {
            throw new Exception(INVALID_ACCESS);
          }
        }
        if (!isFormInAddMode(frm)) {
          String formKey = (String) httpServletRequest.getParameter(BROWSE_KEY);
          frm.set("formKey", formKey);
          String key[] = formKey.split(Constants.DATA_SEPARATOR_SPLIT);
          short officeCode = Short.parseShort(key[0]);
          short hozehCode = Short.parseShort(key[1]);
          String hozehKind = key[2];

          HozehInfo inf = Place.getHozehDetails(officeCode, hozehCode, hozehKind);
          frm.set(OFFICE_CODE, Short.toString(inf.getOfficeCode()));
          frm.set(HOZEH_CODE, Short.toString(inf.getHozehCode()));
          frm.set(HOZEH_KIND, inf.getHozehKind());
          frm.set(HOZEH_DESC, inf.getHozehDesc());
          if (inf.isInactive()) {
            frm.set(CODE_ACTIVE_FLAG, "on");
          }
        }
        String officeCode = (String) frm.get(OFFICE_CODE);
        if (Utils.isEmpty(officeCode)) {
          officeCode = "0";
          frm.set(OFFICE_CODE, officeCode);
        }
        frm.set(OFFICE_NAME, Place.getOfficeName(Short.parseShort(officeCode)));

        if (isFormInAddMode(frm)) {
          resetFocusControl(frm, HOZEH_CODE);
        } else if (isFormInModifyMode(frm)) {
          resetFocusControl(frm, HOZEH_DESC);
        }
      } catch (Exception ex) {
        addError(msgs, ex.getMessage());
        saveErrors(httpServletRequest, msgs);
      }
      return actionMapping.findForward(EDIT);
    } else {
      HozehInfo inf = new HozehInfo();
      resetFocusControl(frm, "");

      if (isFormInAddMode(frm)) {

        String officeCode = ((String) frm.get(OFFICE_CODE)).trim();
        resetFocusControl(frm, "");
        if (Utils.isEmpty(officeCode)) {
          addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "اداره");
          setFocusControl(frm, OFFICE_CODE);
        } else if (!Utils.isValidNotZeroNumber(officeCode, 3)) {
          addError(msgs, FIELD_INVALID, "اداره");
          setFocusControl(frm, OFFICE_CODE);
        } else {
          inf.setOfficeCode(Short.parseShort(officeCode));
        }

        String hozehCode = ((String) frm.get(HOZEH_CODE)).trim();
        if (Utils.isEmpty(hozehCode)) {
          addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "كد");
          setFocusControl(frm, HOZEH_CODE);
        } else if (!Utils.isValidNotZeroNumber(hozehCode, 3)) {
          addError(msgs, FIELD_INVALID, "كد");
          setFocusControl(frm, HOZEH_CODE);
        } else {
          inf.setHozehCode(Short.parseShort(hozehCode));
        }

        String hozehKind = ((String) frm.get(HOZEH_KIND)).trim();
        if (Utils.isEmpty(hozehKind)) {
          addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "نوع");
          setFocusControl(frm, HOZEH_KIND);
        } else if (hozehKind.length() > 1) {
          addError(msgs, FIELD_INVALID, "نوع");
          setFocusControl(frm, HOZEH_KIND);
        } else {
          inf.setHozehKind(hozehKind);
        }

      } else {
        String formKey = (String) frm.get("formKey");
        String key[] = formKey.split(Constants.DATA_SEPARATOR_SPLIT);

        inf.setOfficeCode(Short.parseShort(key[0]));
        inf.setHozehCode(Short.parseShort(key[1]));
        inf.setHozehKind(key[2]);
      }

      if (!isFormInDeleteMode(frm)) {
        String hozehDesc = Utils.charVal((String) frm.get(HOZEH_DESC));
        frm.set(HOZEH_DESC, hozehDesc);
        if (Utils.isEmpty(hozehDesc)) {
          addError(msgs, FIELD_CAN_NOT_BE_EMPTY, "شرح");
          setFocusControl(frm, HOZEH_DESC);
        } else if (hozehDesc.length() > 50) {
          addError(msgs, FIELD_INVALID, "شرح");
          setFocusControl(frm, HOZEH_DESC);
        } else {
          inf.setHozehDesc(hozehDesc);
        }

        if (frm.get(CODE_ACTIVE_FLAG) == null) {
          inf.setCodeActiveFlag(Constants.CodeActiveFlag.ACTIVE);
        } else {
          inf.setCodeActiveFlag(Constants.CodeActiveFlag.INACTIVE);
        }
      }

      if (!msgs.isEmpty()) {
        saveErrors(httpServletRequest, msgs);
        return actionMapping.findForward(EDIT);
      }

      resetFocusControl(frm, CANCEL);
      try {
        Place.saveHozeh(getFormMode(frm), inf);
        httpServletRequest.setAttribute(BROWSE_KEY, inf.getKey());
        return actionMapping.findForward(SUCCESS);
      } catch (Exception ex) {
        resetFocusControl(frm, CANCEL);
        addError(msgs, ex.getMessage());
        saveErrors(httpServletRequest, msgs);
        return actionMapping.findForward(EDIT);
      }
    }
  }
  protected ActionForward performAction(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    String forward = FWD_SUCCESS;
    request.setAttribute(ALLOW_EDITS_KEY, "true");

    BaseActionForm dynaForm = (BaseActionForm) form;
    // server-side validation (validation.xml)
    ActionMessages errors = dynaForm.validate(mapping, request);

    // bugzilla 2614 allow for NB domain samples
    String selectedTestId = "";

    String referenceTableId = SystemConfiguration.getInstance().getResultReferenceTableId();
    String refId = (String) dynaForm.get("noteRefId");

    String noteIds = (String) dynaForm.get("noteIds");
    String noteSubjects = (String) dynaForm.get("noteSubjects");
    String noteTexts = (String) dynaForm.get("noteTexts");
    String noteTypes = (String) dynaForm.get("noteTypes");
    String noteLastupdateds = (String) dynaForm.get("noteLastupdateds");

    List noteIdList = new ArrayList();
    List noteSubjectList = new ArrayList();
    List noteTextList = new ArrayList();
    List noteTypeList = new ArrayList();
    List noteLastupdatedList = new ArrayList();

    String textSeparator = SystemConfiguration.getInstance().getDefaultTextSeparator();

    NoteDAO noteDAO = new NoteDAOImpl();
    SystemUserDAO systemUserDAO = new SystemUserDAOImpl();
    // bugzilla 2571 go through ReferenceTablesDAO to get reference tables info
    ReferenceTablesDAO referenceTablesDAO = new ReferenceTablesDAOImpl();

    // get sysUserId from login module
    UserSessionData usd = (UserSessionData) request.getSession().getAttribute(USER_SESSION_DATA);
    String sysUserId = String.valueOf(usd.getSystemUserId());
    org.hibernate.Transaction tx = HibernateUtil.getSession().beginTransaction();

    try {

      textSeparator = StringUtil.convertStringToRegEx(textSeparator);

      SystemUser systemUser = new SystemUser();
      systemUser.setId(sysUserId);
      systemUserDAO.getData(systemUser);

      // get all the data required to forward to correct page

      // get analysis id from result
      ResultDAO resultDAO = new ResultDAOImpl();
      Result result = new Result();
      result.setId(refId);
      resultDAO.getData(result);

      String analysisId = result.getAnalysis().getId();

      AnalysisDAO analysisDAO = new AnalysisDAOImpl();
      Analysis analysis = new Analysis();
      analysis.setId(analysisId);
      analysisDAO.getData(analysis);

      // get test id from analysis
      selectedTestId = analysis.getTest().getId();

      // get domain from sample
      SampleItemDAO sampleItemDAO = new SampleItemDAOImpl();
      SampleItem sampleItem = new SampleItem();
      sampleItem.setId(analysis.getSampleItem().getId());
      sampleItemDAO.getData(sampleItem);

      SampleDAO sampleDAO = new SampleDAOImpl();
      Sample sample = new Sample();
      // bugzilla 1773 need to store sample not sampleId for use in sorting
      sample.setId(sampleItem.getSample().getId());
      sampleDAO.getData(sample);

      // bugzilla 2614 allow for NB domain samples
      // now that we have the domain (for forwarding to correct fail page)
      // validate note popup form data!
      try {
        // bugzilla 2254 moved loadListFromStringOfElements to StringUtil
        noteIdList = StringUtil.loadListFromStringOfElements(noteIds, textSeparator, false);
        noteLastupdatedList =
            StringUtil.loadListFromStringOfElements(noteLastupdateds, textSeparator, false);
        // these three need to be validated for empty strings
        noteSubjectList =
            StringUtil.loadListFromStringOfElements(noteSubjects, textSeparator, true);
        noteTextList = StringUtil.loadListFromStringOfElements(noteTexts, textSeparator, true);
        noteTypeList = StringUtil.loadListFromStringOfElements(noteTypes, textSeparator, true);

      } catch (Exception e) {
        // bugzilla 2154
        LogEvent.logError("ResultsEntryNotesUpdateAction", "performAction()", e.toString());
        String messageKey = "note.note";
        ActionError error = new ActionError("errors.invalid", getMessageForKey(messageKey), null);
        errors.add(ActionMessages.GLOBAL_MESSAGE, error);
        saveErrors(request, errors);
        forward = FWD_FAIL;

        return mapping.findForward(forward);
      }

      for (int i = 0; i < noteIdList.size(); i++) {
        Note note = new Note();

        String noteId = (String) noteIdList.get(i);
        note.setReferenceId(refId);
        // bugzilla 1922
        // bugzilla 2571 go through ReferenceTablesDAO to get reference tables info
        ReferenceTables referenceTables = new ReferenceTables();
        referenceTables.setId(referenceTableId);
        // bugzilla 2571
        referenceTablesDAO.getData(referenceTables);
        note.setReferenceTables(referenceTables);
        note.setSystemUser(systemUser);
        note.setSystemUserId(sysUserId);
        // 1926 for audit trail
        note.setSysUserId(sysUserId);

        if (noteId != null && !noteId.equals("0")) {
          note.setId((String) noteIdList.get(i));
          note.setSubject((String) noteSubjectList.get(i));
          note.setText((String) noteTextList.get(i));
          note.setNoteType((String) noteTypeList.get(i));

          Timestamp noteTimestamp = null;
          if (!StringUtil.isNullorNill((String) noteLastupdatedList.get(i))) {

            noteTimestamp = DateUtil.formatStringToTimestamp((String) noteLastupdatedList.get(i));
          }

          note.setLastupdated(noteTimestamp);

          // UPDATE
          noteDAO.updateData(note);
          // }

        } else {
          // this is a new note
          note.setSubject((String) noteSubjectList.get(i));
          note.setText((String) noteTextList.get(i));
          note.setNoteType((String) noteTypeList.get(i));
          // INSERT
          noteDAO.insertData(note);
        }
      }

      tx.commit();

      return getForward(mapping.findForward(forward), selectedTestId, analysisId);

    } catch (LIMSRuntimeException lre) {
      // bugzilla 2154
      LogEvent.logError("ResultsEntryNotesUpdateAction", "performAction()", lre.toString());
      tx.rollback();
      errors = new ActionMessages();
      ActionError error = null;
      if (lre.getException() instanceof org.hibernate.StaleObjectStateException) {
        error = new ActionError("errors.OptimisticLockException", null, null);
      } else {
        if (lre.getException() instanceof LIMSDuplicateRecordException) {
          java.util.Locale locale =
              (java.util.Locale)
                  request.getSession().getAttribute("org.apache.struts.action.LOCALE");
          String messageKey = "note.note";
          String msg =
              ResourceLocator.getInstance().getMessageResources().getMessage(locale, messageKey);
          error = new ActionError("errors.DuplicateRecord", msg, null);

        } else {
          error = new ActionError("errors.UpdateException", null, null);
        }
      }
      errors.add(ActionMessages.GLOBAL_MESSAGE, error);
      saveErrors(request, errors);
      request.setAttribute(Globals.ERROR_KEY, errors);

      // disable previous and next
      request.setAttribute(PREVIOUS_DISABLED, "true");
      request.setAttribute(NEXT_DISABLED, "true");

      // default forward fail
      forward = FWD_FAIL;

    } finally {
      HibernateUtil.closeSession();
    }
    if (forward.equals(FWD_FAIL)
        || forward.equals(FWD_FAIL_HUMAN)
        || forward.equals(FWD_FAIL_ANIMAL)) return mapping.findForward(forward);

    // initialize the form
    dynaForm.initialize(mapping);

    // we need this for subsequent actions to
    // get data related to note parent for forwarding to next page
    request.setAttribute("refId", refId);
    request.setAttribute(SELECTED_TEST_ID, selectedTestId);

    return mapping.findForward(forward);
  }
  /**
   * Edit
   *
   * @param mapping
   * @param form
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward edit(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    log.debug("<TargetedModificationAction> Entering edit");
    if (!isTokenValid(request)) {
      return mapping.findForward("failure");
    }

    // Grab the current modelID from the session
    String modelID = (String) request.getSession().getAttribute(Constants.MODELID);

    TargetedModificationForm targetedModificationForm = (TargetedModificationForm) form;

    // Grab the current SpontaneousMutation we are working with related to
    // this
    String aTargetedModificationID = targetedModificationForm.getModificationId();

    log.debug(
        "<TargetedModificationAction save> following Characteristics:"
            + "\n\t getName: "
            + targetedModificationForm.getName()
            + "\n\t getModificationType: "
            + targetedModificationForm.getModificationType()
            + "\n\t getOtherModificationType: "
            + targetedModificationForm.getOtherModificationType()
            + "\n\t getGeneIdentifier: "
            + targetedModificationForm.getGeneIdentifier()
            + "\n\t getEsCellLineName: "
            + targetedModificationForm.getEsCellLineName()
            + "\n\t getBlastocystName: "
            + targetedModificationForm.getBlastocystName()
            + "\n\t getConditionedBy: "
            + targetedModificationForm.getConditionedBy()
            + "\n\t getDescription: "
            + targetedModificationForm.getDescription()
            + "\n\t getComments: "
            + targetedModificationForm.getComments()
            + "\n\t getMgiId: "
            + targetedModificationForm.getMgiId()
            + "\n\t getZfinId: "
            + targetedModificationForm.getZfinId()
            + "\n\t getRgdId: "
            + targetedModificationForm.getRgdId()
            + "\n\t getUrl: "
            + targetedModificationForm.getUrl()
            + "\n\t getTitle: "
            + targetedModificationForm.getTitle()
            + "\n\t getDescriptionOfConstruct: "
            + targetedModificationForm.getDescriptionOfConstruct()
            + "\n\t getConstructSequence(): "
            + targetedModificationForm.getConstructSequence()
            + (String) request.getSession().getAttribute("camod.loggedon.username"));

    TargetedModificationManager targetedModificationManager =
        (TargetedModificationManager) getBean("targetedModificationManager");
    String theAction = (String) request.getParameter(Constants.Parameters.ACTION);

    String theForward = "AnimalModelTreePopulateAction";
    try {
      // retrieve animal model by it's id
      AnimalModelManager theAnimalModelManager = (AnimalModelManager) getBean("animalModelManager");
      AnimalModel theAnimalModel = theAnimalModelManager.get(modelID);

      if ("Delete".equals(theAction)) {

        targetedModificationManager.remove(aTargetedModificationID, theAnimalModel);

        ActionMessages msg = new ActionMessages();
        msg.add(
            ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("targetedmodification.delete.successful"));
        saveErrors(request, msg);

      } else {
        TargetedModification theTargetedModification =
            targetedModificationManager.get(aTargetedModificationID);
        targetedModificationManager.update(
            theAnimalModel, targetedModificationForm, theTargetedModification, request);

        log.debug("TargetedModification edited");

        ActionMessages msg = new ActionMessages();
        msg.add(
            ActionMessages.GLOBAL_MESSAGE,
            new ActionMessage("targetedmodification.edit.successful"));
        saveErrors(request, msg);
      }
    } catch (IllegalArgumentException e) {
      log.error("Exception ocurred editing a TargetedModification", e);

      theForward = "input";

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.image.unsupportedfiletype"));
      saveErrors(request, msg);

    } catch (Exception e) {
      log.error("Exception occurred creating a TargetedModification", e);

      // Encountered an error saving the model.
      ActionMessages msg = new ActionMessages();
      msg.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("errors.admin.message"));
      saveErrors(request, msg);
    }

    log.debug("< TargetedModificationAction> Exiting edit");
    resetToken(request);

    return mapping.findForward(theForward);
  }