Package com.sogou.qadev.service.cynthia.bean

Examples of com.sogou.qadev.service.cynthia.bean.TimerAction


    String hour = request.getParameter("hour[]");
    String minute = request.getParameter("minute[]");
    String recievers = request.getParameter("recievers");

    params = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>" + params;
    TimerAction timerAction = null;
    Timer timer = null;
    if (statId == null || statId.equals("")) {
      //新创建
      timerAction = das.createTimerAction();
      timerAction.setClassName("com.sogou.qadev.service.cynthia.service.StatisticerManager");
      timerAction.setMethod("execute");
      timerAction.setName(statName);
      timerAction.setCreateUser(key.getUsername());
      timerAction.setParam(params);
      if (isSendMail != null && isSendMail.equals("true") && recievers != null && !recievers.equals("")) {
        timer = das.createTimer(key.getUsername());
        timer.setActionId(timerAction.getId());
        timer.setActionParam(timerAction.getParam());
        timer.setName(timerAction.getName());
        timer.setRetry(true);
        timer.setRetryAccount(5);
        timer.setRetryDelay(50000);
        timer.setSendNull(true);
        timer.setStart(true);
        timer.setMonth(CommonUtil.arrayToStr(month));
        timer.setWeek(CommonUtil.arrayToStr(week));
        timer.setDay(CommonUtil.arrayToStr(date));
        timer.setHour(hour);
        timer.setMinute(minute);
        das.addTimer(timer);
      }

      return String.valueOf(das.addTimerAction(timerAction).equals(ErrorCode.success));
    }else {
      timerAction = das.queryTimerAction(DataAccessFactory.getInstance().createUUID(statId));
      //更新统计
      timerAction.setName(statName);
      timerAction.setParam(params);

      Timer[] timerArray = das.queryTimersByActionId(timerAction.getId());

      if (timerArray.length > 0) {
        //己存在定时器更新定时器
        for(int i = 0; i < timerArray.length; i++){
          if(timerArray[i].getActionId().toString().equals(timerAction.getId().toString())){
            timer = timerArray[i];
            timer.setActionParam(timerAction.getParam());
            timer.setName(timerAction.getName());

            if (isSendMail != null && isSendMail.equals("false")) {
              //时间为空则直接删除timer
              das.removeTimer(timer.getId());
            }else {
              //否则更新timer时间
              timer.setMonth(CommonUtil.arrayToStr(month));
              timer.setWeek(CommonUtil.arrayToStr(week));
              timer.setDay(CommonUtil.arrayToStr(date));
              timer.setHour(hour);
              timer.setMinute(minute);
              das.modifyTimer(timer);
            }
            break;
          }
        }
      }else {
        //不存在,创建定时器
        if (isSendMail != null && isSendMail.equals("true") && recievers != null && !recievers.equals("")) {
          timer = das.createTimer(key.getUsername());
          timer.setActionId(timerAction.getId());
          timer.setActionParam(timerAction.getParam());
          timer.setName(timerAction.getName());
          timer.setRetry(true);
          timer.setRetryAccount(5);
          timer.setRetryDelay(50000);
          timer.setSendNull(true);
          timer.setStart(true);
View Full Code Here


   * @param timerActionId
   * @return
   */
  public TimerAction queryTimerAction(UUID timerActionId)
  {
    TimerAction timerAction = null;

    Connection conn = null;
    PreparedStatement pstm = null;
    ResultSet rst = null;
    try
    {
      conn = DbPoolConnection.getInstance().getReadConnection();
      pstm = conn.prepareStatement("SELECT * FROM timer_action"
          + " WHERE id = ?");
      pstm.setLong(1, Long.parseLong(timerActionId.getValue()));

      rst = pstm.executeQuery();
      if(rst.next())
      {
        timerAction = new TimerActionImpl(timerActionId);

        timerAction.setName(rst.getString("name"));
        timerAction.setClassName(rst.getString("class_name"));
        timerAction.setMethod(rst.getString("method"));
        timerAction.setParam(rst.getString("param"));
        timerAction.setCreateUser(rst.getString("create_user"));
      }
    }
    catch(Exception e)
    {
      e.printStackTrace();
View Full Code Here

      rst = pstm.executeQuery();
      while(rst.next())
      {
        UUID id = DataAccessFactory.getInstance().createUUID(rst.getObject("id").toString());
        TimerAction timerAction = new TimerActionImpl(id);

        timerAction.setName(rst.getString("name"));
        timerAction.setClassName(rst.getString("class_name"));
        timerAction.setMethod(rst.getString("method"));
        timerAction.setParam(rst.getString("param"));
        timerAction.setCreateUser(rst.getString("create_user"));
        timerActionSet.add(timerAction);
      }
    }
    catch(Exception e)
    {
View Full Code Here

     
      rst = pstm.executeQuery();
      while(rst.next())
      {
        UUID id = DataAccessFactory.getInstance().createUUID(rst.getObject("id").toString());
        TimerAction timerAction = new TimerActionImpl(id);

        timerAction.setName(rst.getString("name"));
        timerAction.setClassName(rst.getString("class_name"));
        timerAction.setMethod(rst.getString("method"));
        timerAction.setParam(rst.getString("param"));
        timerAction.setCreateUser(rst.getString("create_user"));
        timerAction.setIsPublic(rst.getBoolean("is_public"));
        timerActionSet.add(timerAction);
      }
    }
    catch(Exception e)
    {
View Full Code Here

    private void doTimer(Timer timer) throws Exception {
      long timerStartTime = System.currentTimeMillis();
     
      System.out.println("start execute timer" + timer.getId());
     
      TimerAction timerAction = new TimerActionAccessSessionMySQL().queryTimerAction(timer.getActionId());
     
      if (timerAction == null) {
        return;
      }
View Full Code Here

   */
  public static Map<String, Object> getStatisticResultById(UUID statisticId,String userName){
    if (statisticId == null)
      return new HashMap<String, Object>();
   
    TimerAction timerAction = das.queryTimerAction(statisticId);
    if (timerAction == null) {
      return new HashMap<String, Object>();
    }else {
      Map<String, Object> result = getStatisticResultByXml(timerAction.getParam(), userName);
      result.put("statisticId", statisticId.getValue());
      return result;
    }
  }
View Full Code Here

  public static String getSqlOfStat(String statisticId, String statisticVal,String username){
    if (statisticId == null || statisticId.length() == 0 || statisticVal == null || statisticVal.length() == 0)  {
      return null;
    }
   
    TimerAction timerAction = das.queryTimerAction(DataAccessFactory.getInstance().createUUID(statisticId));
    if (timerAction == null) {
      return null;
    }
   
    Document doc = null;
    try {
      doc = XMLUtil.string2Document(timerAction.getParam(),"UTF-8");
    } catch (Exception e) {
      e.printStackTrace();
    }
    if (doc == null) {
      return null;
View Full Code Here

TOP

Related Classes of com.sogou.qadev.service.cynthia.bean.TimerAction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.