Esempio n. 1
0
  @Override
  public ResultDTO executeCommand(
      String screenName,
      String querynodeXpath,
      JSONObject jsonRecord,
      InputDTO inputDTO,
      ResultDTO resultDTO) {
    ResultDTO resDTO = new ResultDTO();
    try {
      Element rootXml = ScreenMapRepo.findMapXMLRoot(screenName);
      Element processorElm =
          (Element) rootXml.selectSingleNode("/root/screen/bl/" + querynodeXpath + " ");
      String methodName = processorElm.attributeValue("method");

      if ("testMethod1".equals(methodName)) {
        testMethod1();
        System.out.println(ServletActionContext.getContext().getSession());
        System.out.println(
            "Session var retreived:"
                + ServletActionContext.getContext().getSession().get("mysessionkey"));
      } else {
        System.out.println("ProgramSetup BL methodname is not defined");
      }

      List<String> errors = new ArrayList<String>();
      errors.add("business.logic.unimplemented");
      resDTO.setMessages(errors);
    } catch (FrontendException e) {
      resDTO.addError("error.accessxml");
    }
    return resDTO;
  }
  @SuppressWarnings("unchecked")
  public void getAll() {

    // servletActionContext class
    requestMap = (Map) ServletActionContext.getContext().get("request");
    sessionMap = (Map<String, Object>) ServletActionContext.getContext().getSession();
    applicationMap = (Map<String, Object>) ServletActionContext.getContext().getApplication();

    request = ServletActionContext.getRequest();
    session = request.getSession();
    context = session.getServletContext();
  }
 /** 用户自己创建的班级购 */
 @Action(
     value = "myGroupon",
     interceptorRefs = {@InterceptorRef(value = "userActionStack")},
     results = {@Result(name = SUCCESS, location = "/userPages/groupon.jsp")})
 public String myGroupon() {
   User sessionUser = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
   // 获得这个学校所有的团购项目
   List<Groupon> groupons = grouponService.userGrounpons(sessionUser.getId());
   ServletActionContext.getContext().getValueStack().set("search", 1);
   ServletActionContext.getContext().getValueStack().set("groupons", groupons);
   return SUCCESS;
 }
 /** 编辑策略 */
 public void updateTactics() throws Exception {
   HttpServletRequest request = ServletActionContext.getRequest();
   PrintWriter out = ServletActionContext.getResponse().getWriter();
   ServletActionContext.getResponse().setCharacterEncoding("UTF-8");
   String vcTaskOrder = (String) ServletActionContext.getContext().getSession().get("baseUserId");
   String dtOrderTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.s").format(new Date());
   String dtStartTime = ReqUtils.getReqString(request, "dtStartTime");
   String dtEndTime = ReqUtils.getReqString(request, "dtEndTime");
   String intStartHour = ReqUtils.getReqString(request, "intStartHour");
   String intEndHour = ReqUtils.getReqString(request, "intEndHour");
   String vcContents = ReqUtils.getReqString(request, "vcContents");
   //		vcContents = new String(vcContents.getBytes("ISO-8859-1"),"UTF-8");
   vcContents = new String(vcContents.getBytes("ISO-8859-1"), "GBK");
   String nmDataGetterTaskId = ReqUtils.getReqString(request, "id");
   String productArray = ReqUtils.getReqString(request, "product");
   keywordsTacticsImpl.deleteKeyValueGetterFilter(nmDataGetterTaskId);
   keywordsTacticsImpl.updateTactics(
       nmDataGetterTaskId,
       vcTaskOrder,
       dtStartTime,
       dtEndTime,
       intStartHour,
       intEndHour,
       vcContents);
   String[] nmSoTypeIds = productArray.split(",");
   String isExactMarkValuearray = ReqUtils.getReqString(request, "iskey");
   // isExactMarkValuearray = new
   // String(isExactMarkValuearray.getBytes("ISO-8859-1"),"UTF-8");
   isExactMarkValuearray = new String(isExactMarkValuearray.getBytes("ISO-8859-1"), "GBK");
   if (isExactMarkValuearray != "" || isExactMarkValuearray != null) {
     String[] isExactMarkValues = isExactMarkValuearray.split(",");
     for (int i = 0; i < nmSoTypeIds.length; i++) {
       String nmSoTypeId = nmSoTypeIds[i];
       for (int j = 0; j < isExactMarkValues.length; j++) {
         String isExactMarkValue = isExactMarkValues[j];
         // keywordsTacticsImpl.insertIsExactMark(nmDataGetterTaskId, nmSoTypeId,
         // isExactMarkValue);
       }
     }
   }
   String unExactMarkValuearray = ReqUtils.getReqString(request, "unkey");
   // unExactMarkValuearray = new
   // String(unExactMarkValuearray.getBytes("ISO-8859-1"),"UTF-8");
   unExactMarkValuearray = new String(unExactMarkValuearray.getBytes("ISO-8859-1"), "GBK");
   if (unExactMarkValuearray != "" || unExactMarkValuearray != null) {
     String[] unExactMarkValues = unExactMarkValuearray.split(",");
     for (int i = 0; i < nmSoTypeIds.length; i++) {
       String nmSoTypeId = nmSoTypeIds[i];
       for (int j = 0; j < unExactMarkValues.length; j++) {
         String unExactMarkValue = unExactMarkValues[j];
         keywordsTacticsImpl.insertUnExactMark(nmDataGetterTaskId, nmSoTypeId, unExactMarkValue);
       }
     }
   }
   out.write("1");
 }
Esempio n. 5
0
 @InputConfig(resultName = "login")
 public String oauth2Login() throws Exception {
   logger.debug("checkLogin code:  " + code);
   Employee employee = oauth2LoginService.accessEmployee(code);
   if (employee != null) {
     ServletActionContext.getContext().getSession().put(LOGIN_USER, employee);
     return MAIN;
   }
   return LOGIN;
 }
Esempio n. 6
0
  @InputConfig(resultName = "login")
  public String checkLogin() throws Exception {
    logger.debug("checkLogin name:  " + name + " password:  " + password);
    Employee employee = employeeService.findByLogin(name, password);
    System.out.println(employee);

    if (employee != null) {
      ServletActionContext.getContext().getSession().put(LOGIN_USER, employee);
      return MAIN;
    }
    return LOGIN;
  }
Esempio n. 7
0
  // 实现退出当前帐号
  public String Logout() {
    System.out.println("LogoutAction---Logout()");
    // 获取request对象和response对象
    HttpServletRequest request = ServletActionContext.getRequest();
    HttpServletResponse response = ServletActionContext.getResponse();
    ApplicationContext otx = new ClassPathXmlApplicationContext("applicationContext.xml");
    // Spring调用相应DAO
    MembRegiDAO mDao = (MembRegiDAO) otx.getBean("MembRegiDAO");
    // Spring调用相应DAO
    ExpeRegiDAO eDao = (ExpeRegiDAO) otx.getBean("ExpeRegiDAO");
    // 获取session对象
    Map<String, Object> session = ServletActionContext.getContext().getSession();
    String forward = "error";
    System.out.println("forward---");
    String name = "";
    try {
      request.setCharacterEncoding("utf-8");
      response.setContentType("text/html;charset=utf-8");
      name = request.getParameter("name");
      System.out.println("会员编号:" + name);
    } catch (UnsupportedEncodingException e) {
      System.out.println("会员编号:" + 4444);
      e.printStackTrace();
    }

    System.out.println("专家编号:" + name);
    ExpeRegi expert = eDao.getExpeinfoById(name);
    // 调用getMembinfoById方法,通过id查看用户注册信息
    MembRegi member = mDao.getMembinfoById(name);

    if (expert != null) {
      System.out.println("专家--" + expert.getExpeId() + "退出");
      expert.setState(false);
      eDao.UpdateExpeRegi(expert);
      session.clear();
      forward = "success";

    } else if (member != null) {
      System.out.println("会员--" + member.getMembId() + "退出");
      member.setState(false);
      mDao.UpdateMembRegi(member);
      session.clear();
      forward = "success";
    } else {
      forward = "error";
    }
    return forward;
  }
 // 1 团购增删改查
 @Action(
     value = "grouponOpePage",
     interceptorRefs = {@InterceptorRef(value = "userActionStack")},
     results = {@Result(name = SUCCESS, location = "/userPages/grouponindex.jsp")})
 public String grouponOpePage() {
   User sessionUser = (User) ServletActionContext.getRequest().getSession().getAttribute("user");
   Groupon findGroupon = null;
   if (groupon.getId() != null && groupon.getId() != 0) {
     findGroupon = grouponService.getGrouponDetail(groupon.getId());
     if (findGroupon == null && !findGroupon.getUser().getId().equals(sessionUser.getId())) {
       findGroupon = null;
     }
   }
   ServletActionContext.getContext().getValueStack().set("groupon", findGroupon);
   return SUCCESS;
 }
Esempio n. 9
0
 public String updateUI() {
   department = departmentService.get(department.getID());
   Map<Department, Integer> treeData = departmentService.listTree(department.getID());
   ServletActionContext.getContext().put("departmentTreeData", treeData);
   return "updateUI";
 }
Esempio n. 10
0
 public String addUI() {
   Map<Department, Integer> treeData = departmentService.listTree(0);
   ServletActionContext.getContext().put("departmentTreeData", treeData);
   return "addUI";
 }
Esempio n. 11
0
 public String list() {
   List<Department> list = departmentService.list();
   ServletActionContext.getContext().put("DepartmentList", list);
   return "list";
 }
Esempio n. 12
0
 public void setRequest(HttpServletRequest request) {
   this.request = request;
   urlHelper = ServletActionContext.getContext().getInstance(DefaultUrlHelper.class);
 }
Esempio n. 13
0
 /**
  * 获得Application范围参数的名值对Map集合
  *
  * @return
  */
 protected Map getApplicationMap() {
   return ServletActionContext.getContext().getApplication();
 }
Esempio n. 14
0
 /**
  * 获得请求参数的名值对Map集合
  *
  * @return
  */
 protected Map getParameterMap() {
   return ServletActionContext.getContext().getParameters();
 }
Esempio n. 15
0
  public String save() throws Exception {

    String resultHtml = "";
    String formname = "";
    ResultDTO result = new ResultDTO();
    logger.debug("submitdata:" + submitdata);
    JSONObject jobj1 = JSONObject.fromObject(submitdata);
    InputDTO inputDTO = new InputDTO();
    inputDTO.setData((JSONObject) jobj1);
    ActionContext.getContext().getValueStack().getContext().put("inputDTO", inputDTO);
    ServletActionContext.getContext().getSession().put("mysessionkey", "MY session val");
    System.out.println(ServletActionContext.getContext().getSession().get("mysessionkey"));
    ResultDTO resDTO = null;

    try {
      FEValidator validator = new FEValidator();
      ResultDTO validatorDTO = validator.validate(screenName, jobj1);
      if (validatorDTO != null && validatorDTO.getErrors() != null) {
        if (validatorDTO.getErrors().size() > 0) {
          throw new ValidationException();
        }
      }
      CommandProcessor cmdpr = new CommandProcessor();
      resDTO = cmdpr.commandProcessor(jobj1, screenName);
      //			if(resDTO!=null && resDTO.getErrors() != null){
      //				if(resDTO.getErrors().size() >0){
      //					throw new ValidationException();
      //				}
      //			}
      JSONObject resObj = JSONObject.fromObject(resDTO);
      resultHtml = resObj.toString();
    } catch (ValidationException e) {
      throw new FrontendException("error.pagefailed", e);
    } catch (Exception e) {
      throw new Exception("error.global");
    }

    PageReturnType pg = null;
    try {
      pg = new ReturnCommandProcessor().getReturnType(screenName, jobj1, resDTO);
      screenName = pg.nextScreenName;
      resultPage = pg.resultPage;

      if ("ajax".equals(pg.resultName)) {
        inputStream = new StringBufferInputStream(resultHtml);
      }
    } catch (FrontendException e) {
      throw new FrontendException("error.nextpagenotfound");
    } catch (Exception e) {
      throw new Exception("error.global");
    }
    System.out.println("resultName = " + pg.resultName);
    System.out.println("screenName = " + pg.nextScreenName);
    System.out.println("resultPage = " + pg.resultPage);

    return pg.resultName;

    /*for (Iterator itr = jobj1.keys();itr.hasNext();) {
    	String name = (String) itr.next();
    	formname = name;
    	logger.debug(name);
    	JSONArray jobj = jobj1.getJSONArray(formname);
    	Gson gson = new Gson();
    	JsonElement jelm = gson.toJsonTree(submitdata);

    	for (int i = 0; i < jobj.size(); i++) {

    		if(jobj.getJSONObject(i).getString("txtstatus").equalsIgnoreCase("Modify")){

    				logger.debug("Going to Modify Block");
    				UpdateData upd = new UpdateData();
    				result =	upd.update(screenName,formname,jobj.getJSONObject(i));
    				if(result.getMessages().size() > 0)
    					resultHtml += "Records("+result.getMessages().size()+") Modified Successfully<br/>";
    				else
    					resultHtml += "Request failed "+ result.getErrors().size()+"\n";
    		}
    		if(jobj.getJSONObject(i).getString("txtstatus").equalsIgnoreCase("new")){
    				logger.debug("Going to Modify Block");
    				InsertData ins = new InsertData();
    				result = ins.insert(screenName,formname,jobj.getJSONObject(i));
    				if(result.getMessages().size() > 0)
    					resultHtml += "Records("+result.getMessages().size()+") Created Successfully<br/>";
    				else
    					resultHtml += "Request failed "+result.getErrors().size()+"\n";
    		}
    		if(jobj.getJSONObject(i).getString("txtstatus").equalsIgnoreCase("close")){
    				logger.debug("Going to Modify Block");
    				UpdateData upd = new UpdateData();
    				result = upd.update(screenName,formname,jobj.getJSONObject(i));
    				if(result.getMessages().size() > 0)
    					resultHtml += "Records("+result.getMessages().size()+") Closed Successfully<br/>";
    				else
    					resultHtml += "Request failed "+result.getErrors().size()+"\n";
    		}


    	}

    }*/
  }
 public Map<String, Object> getSession() {
   return ServletActionContext.getContext().getSession();
 }