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

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


  protected Object execute_i(Interpreter bsh)
  {
    String content = "";
    try
    {
      Script script = (Script) bsh.get("script");
      if (script == null)
        return null;

      content = script.getScript();
      if (content == null)
        return null;
      return bsh.eval(content);
    }
    catch (EvalError e)
View Full Code Here


        interpreter = ScriptExecuteManager.allDeamonScript.remove(0);
      }

      if (interpreter != null) {
        try {
          Script script = (Script) interpreter.get("script");
          if (script == null)
            continue;

          String content = script.getScript();
          if (content == null)
            continue;
          interpreter.eval(content);
        } catch (EvalError e) {
          e.printStackTrace();
View Full Code Here

 
  @ResponseBody
  @RequestMapping("/unMountScriptTemplate.do")
  public String unMountScriptTemplate(@RequestParam("scriptId") String scriptId, @RequestParam("templateId") String templateId) throws Exception {
   
    Script script     = das.queryScript(DataAccessFactory.getInstance().createUUID(scriptId));
   
    UUID[] oldTemplateIds = script.getTemplateIds();
    List<UUID> newTemplateIds = new ArrayList<UUID>();
    for(UUID oldTemplateId : oldTemplateIds)
    {
      if(!oldTemplateId.toString().equals(templateId))
      {
        newTemplateIds.add(oldTemplateId);
      }
    }
    script.setTemplateIds(newTemplateIds.toArray(new UUID[newTemplateIds.size()]));
   
    UUID[] oldStatIds = script.getEndStatIds();
    UUID[] oldActionIds = script.getActionIds();
    List<UUID> oldStatIdsList = new ArrayList<UUID>();
    List<UUID> oldActionIdsList =new ArrayList<UUID>();
   
    if(oldStatIds != null)
    {
      for(UUID oldStatId : oldStatIds)
      {
        oldStatIdsList.add(oldStatId);
      }
    }
   
    if(oldActionIds!=null)
    {
      for(UUID oldActionId : oldActionIds)
      {
        oldActionIdsList.add(oldActionId);
      }
    }
   
    List<UUID> newFlowIds = new ArrayList<UUID>();
    for(UUID tempId : newTemplateIds)
    {
      Template template = das.queryTemplate(tempId);
      if(template!=null)
        newFlowIds.add(template.getFlowId());
    }
    Template removedTemplate = das.queryTemplate(DataAccessFactory.getInstance().createUUID(templateId));
    if(!newFlowIds.contains(removedTemplate.getFlowId()))
    {
      Flow removedFlow = das.queryFlow(removedTemplate.getFlowId());
      Stat[] removedFlowStats = removedFlow.getStats();
      for(Stat stat : removedFlowStats)
      {
        if(oldStatIdsList.contains(stat.getId()))
          oldStatIdsList.remove(stat.getId());
      }
     
      Action[] removedFlowActions = removedFlow.getActions();
      for(Action action : removedFlowActions)
      {
        if(oldActionIdsList.contains(action.getId()))
        {
          oldActionIdsList.remove(action.getId());
        }
      }
    }
    script.setEndStatIds(oldStatIdsList.toArray(new UUID[oldStatIdsList.size()]));
    script.setActionIds(oldActionIdsList.toArray(new UUID[oldActionIdsList.size()]));
    das.updateScript(script);
    StringBuffer result = new StringBuffer(this.baseXml);
    result.append("<root>");
    result.append("<id>").append(script.getId()).append("</id>");
    result.append("</root>");
    return result.toString();
  }
View Full Code Here

    String isValidStr        = request.getParameter("isValid");
    String allowedTemplates  = request.getParameter("allowedTemplates");
   
    //TODO
    String userName  = ((Key)httpSession.getAttribute("key")).getUsername();
    Script script = null;
    if(scriptId==null||"".equals(scriptId)){
      script = das.createScript(userName);
    }else{
      script = das.queryScript(DataAccessFactory.getInstance().createUUID(scriptId));
    }
   
    script.setScript(scriptCode);
    script.setName(scriptName);
    script.setAfterFail(Boolean.valueOf(isAfterFailStr));
    script.setAsync(Boolean.valueOf(isAsyncStr));
    script.setBeforeCommit(Boolean.valueOf(isBeforeCommitStr));
    script.setAfterSuccess(Boolean.valueOf(isAfterSuccessStr));
    script.setStatEdit(Boolean.valueOf(isStatEditStr));
    script.setActionEdit(Boolean.valueOf(isActionEditStr));
    script.setValid(Boolean.valueOf(isValidStr));
   
    if(allowedTemplates!=null&&!"null".equals(allowedTemplates)&&!"".equals(allowedTemplates))
    {
      String[] allowedTemplateIdsStr = allowedTemplates.split(",");
      List<UUID> allowedTemplateIdsList = new ArrayList<UUID>();
      for(String allowedTemplateIdStr : allowedTemplateIdsStr)
      {
        allowedTemplateIdsList.add(DataAccessFactory.getInstance().createUUID(allowedTemplateIdStr));
      }
      script.setAllowedTemplateIds(allowedTemplateIdsList.toArray(new UUID[0]));
    }
    if(scriptId==null||"".equals(scriptId))
    {
      das.addScript(script);
    }else
View Full Code Here

  public String mountScriptTemplate(HttpServletRequest request,HttpServletResponse response) throws Exception {
    String scriptId   = request.getParameter("scriptId");
    String templateId = request.getParameter("templateId");
    String actions    = request.getParameter("actions");
    String stats      = request.getParameter("stats");
    Script script     = das.queryScript(DataAccessFactory.getInstance().createUUID(scriptId));

    UUID[] oldTemplateIds = script.getTemplateIds();
    if(!CynthiaUtil.idInArray(oldTemplateIds,templateId))
    {
      List<UUID> oldTemplateIdsList = new ArrayList<UUID>();
      if(oldTemplateIds!=null)
      {
        for(UUID oldTemplateId : oldTemplateIds)
        {
          oldTemplateIdsList.add(oldTemplateId);
        }
      }
      if(templateId!=null&&!templateId.equals("")&&!"null".equals(templateId))
        oldTemplateIdsList.add(DataAccessFactory.getInstance().createUUID(templateId));
      script.setTemplateIds(oldTemplateIdsList.toArray(new UUID[oldTemplateIdsList.size()]));
    }
   
    Template newTemplate = das.queryTemplate(DataAccessFactory.getInstance().createUUID(templateId));
    Flow     newFlow     = das.queryFlow(newTemplate.getFlowId());
    Stat[]   newFlowStats= newFlow.getStats();
    Action[] newFlowActions=newFlow.getActions();
    List<UUID> newFlowStatIds = new ArrayList<UUID>();
    List<UUID> newFlowActionIds = new ArrayList<UUID>();
    for(Stat stat : newFlowStats)
    {
      newFlowStatIds.add(stat.getId());
    }
    for(Action action : newFlowActions)
    {
      newFlowActionIds.add(action.getId());
    }
   
    if(actions!=null)
    {
      UUID[] oldActionIds = script.getActionIds();
      List<UUID> oldActionIdsList = new ArrayList<UUID>();
      if(oldActionIds != null)
      {
        for(UUID oldActionId : oldActionIds)
        {
          oldActionIdsList.add(oldActionId);
        }
      }
      UUID[] newActionIds = CynthiaUtil.stringToIdArray(actions);
      for(UUID actionId : newActionIds)
      {
        if(!oldActionIdsList.contains(actionId))
        {
          oldActionIdsList.add(actionId);
        }
        newFlowActionIds.remove(actionId);
      }
     
      for(UUID actionId : newFlowActionIds)
      {
        if(oldActionIdsList.contains(actionId))
          oldActionIdsList.remove(actionId);
      }
      script.setActionIds(oldActionIdsList.toArray(new UUID[oldActionIdsList.size()]));
    }
   
    if(stats != null)
    {
      UUID[] oldStatIds = script.getEndStatIds();
      List<UUID> oldStatIdsList = new ArrayList<UUID>();
      if(oldStatIds != null)
      {
        for(UUID oldStatId : oldStatIds)
        {
          oldStatIdsList.add(oldStatId);
        }
      }
      UUID[] newStatIds = CynthiaUtil.stringToIdArray(stats);
      for(UUID statId : newStatIds)
      {
        if(!oldStatIdsList.contains(statId))
        {
          oldStatIdsList.add(statId);
        }
        newFlowStatIds.remove(statId);
      }
     
      for(UUID statId : newFlowStatIds)
      {
        if(oldStatIdsList.contains(statId))
          oldStatIdsList.remove(statId);
      }
     
      script.setEndStatIds(oldStatIdsList.toArray(new UUID[oldStatIdsList.size()]));
    }
    das.updateScript(script);
    StringBuffer result = new StringBuffer(this.baseXml);
    result.append("<root>");
    result.append("<id>").append(script.getId()).append("</id>");
    result.append("</root>");
    return result.toString();
  }
View Full Code Here

  @RequestMapping("/initScript.do")
  @ResponseBody
  public String initScript(@RequestParam("scriptId")String scriptId) throws Exception {
   
    DataAccessSession das = DataAccessFactory.getInstance().getSysDas();
    Script script = das.queryScriptNoImport(DataAccessFactory.getInstance().createUUID(scriptId));
    ScriptVO scriptVO = new ScriptVO();
    scriptVO.setId(script.getId().toString());
    scriptVO.setAfterFail(script.isAfterFail());
    scriptVO.setAfterQuery(script.isAfterQuery());
    scriptVO.setAfterSuccess(script.isAfterSuccess());
    scriptVO.setAsync(script.isAsync());
    scriptVO.setCreateTime(script.getCreateTime());
    scriptVO.setCreateUser(script.getCreateUser());
    scriptVO.setName(script.getName());
    scriptVO.setScript(script.getScript());
    scriptVO.setActionEdit(script.isActionEdit());
    scriptVO.setStatEdit(script.isStatEdit());
    scriptVO.setValid(script.isValid());
   
    UUID[] templateIds = script.getTemplateIds();
    Map<String,String> mountTemplatesMap = new HashMap<String,String>();
    if(templateIds!=null)
    { 
      for(UUID templateId : templateIds)
      {
        Template template = das.queryTemplate(templateId);
        if(template!=null)
          mountTemplatesMap.put(templateId.toString(), template.getName());
      }
    }
    Map<String,String> allTemplateMap = new HashMap<String,String>();
    Template[] allTemplates = das.queryAllTemplates();
    if(allTemplates!=null)
    {
      for(Template template: allTemplates)
      {
        allTemplateMap.put(template.getId().toString(), template.getName());
      }
    }
    scriptVO.setAllTemplates(allTemplateMap);
    scriptVO.setMountTemplates(mountTemplatesMap);
   
    UUID[] statIds = script.getEndStatIds();
    List<String> statIdsList = new ArrayList<String>();
    if(statIds != null)
    {
      for(UUID statId : statIds)
      {
        statIdsList.add(statId.toString());
      }
    }
    UUID[] actionIds = script.getActionIds();
    List<String> actionIdsList = new ArrayList<String>();
    if(actionIds != null)
    {
      for(UUID actionId : actionIds)
      {
        actionIdsList.add(actionId.toString());
      }
    }
   
    UUID[] allowedTemplateIds = script.getAllowedTemplateIds();
    List<String> allowedTemplateIdsList = new ArrayList<String>();
    if(allowedTemplateIds != null)
    {
      for(UUID allowedTemplateId : allowedTemplateIds)
      {
View Full Code Here

  public String initTemplateActionAndStat(@RequestParam("templateId") String templateId, @RequestParam("scriptId") String scriptId) throws Exception {
    StringBuffer result = new StringBuffer(this.baseXml);
   
    Template template = das.queryTemplate(DataAccessFactory.getInstance().createUUID(templateId));
    Flow flow       = das.queryFlow(template.getFlowId());
    Script script     = null;
    UUID[] actionIds  = null;
    UUID[] endStatIds = null;
    if(scriptId!=null&&!"".equals(scriptId))
    {
      script = das.queryScript(DataAccessFactory.getInstance().createUUID(scriptId));
    }
    if(script != null)
    {
      actionIds  = script.getActionIds();
      endStatIds = script.getEndStatIds();
    }
   
    Action[] flowActions = flow.getActions();
    Stat[]   flowStats   = flow.getStats();
    result.append("<template>");
View Full Code Here

        String scriptImportStr = getScriptImportStr();
       
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");
       
        Script script = new ScriptImpl(scriptId, createUser, createTime);
       
        script.setName(rs.getString("name"));
        script.setTemplateTypeIds(ArrayUtil.string2IdArray(rs.getString("template_type_ids")));
        script.setTemplateIds(ArrayUtil.string2IdArray(rs.getString("template_ids")));
        script.setFlowIds(ArrayUtil.string2IdArray(rs.getString("flow_ids")));
        script.setBeginStatIds(ArrayUtil.string2IdArray(rs.getString("begin_stat_ids")));
        script.setEndStatIds(ArrayUtil.string2IdArray(rs.getString("end_stat_ids")));
        script.setActionIds(ArrayUtil.string2IdArray(rs.getString("action_ids")));
        script.setAsync(rs.getBoolean("is_async"));
        script.setBeforeCommit(rs.getBoolean("is_before_commit"));
        script.setAfterSuccess(rs.getBoolean("is_after_success"));
        script.setAfterFail(rs.getBoolean("is_after_fail"));
        script.setAfterQuery(rs.getBoolean("is_after_query"));
        script.setScript(scriptImportStr + rs.getString("xml"));
        script.setStatEdit(rs.getBoolean("is_stat_edit"));
        script.setActionEdit(rs.getBoolean("is_action_edit"));
        script.setValid(rs.getBoolean("is_valid"));
        script.setAllowedTemplateIds(ArrayUtil.string2IdArray(rs.getString("allowed_template_ids")));
       
        return script;
      }
    }
    catch(Exception e)
View Full Code Here

      while(rs.next())
      {
        String createUser = rs.getString("create_user");
        Timestamp createTime = rs.getTimestamp("create_time");
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("id").toString());
        Script script = new ScriptImpl(id, createUser, createTime);
       
        script.setName(rs.getString("name"));
        script.setTemplateTypeIds(ArrayUtil.string2IdArray(rs.getString("template_type_ids")));
        script.setTemplateIds(ArrayUtil.string2IdArray(rs.getString("template_ids")));
        script.setFlowIds(ArrayUtil.string2IdArray(rs.getString("flow_ids")));
        script.setBeginStatIds(ArrayUtil.string2IdArray(rs.getString("begin_stat_ids")));
        script.setEndStatIds(ArrayUtil.string2IdArray(rs.getString("end_stat_ids")));
        script.setActionIds(ArrayUtil.string2IdArray(rs.getString("action_ids")));
        script.setAsync(rs.getBoolean("is_async"));
        script.setBeforeCommit(rs.getBoolean("is_before_commit"));
        script.setAfterSuccess(rs.getBoolean("is_after_success"));
        script.setAfterFail(rs.getBoolean("is_after_fail"));
        script.setAfterQuery(rs.getBoolean("is_after_query"));
        script.setScript(scriptImportStr + rs.getString("xml"));
        script.setStatEdit(rs.getBoolean("is_stat_edit"));
        script.setActionEdit(rs.getBoolean("is_action_edit"));
        script.setValid(rs.getBoolean("is_valid"));
        script.setAllowedTemplateIds(ArrayUtil.string2IdArray(rs.getString("allowed_template_ids")));
       
        result.add(script);
       
      }
    }
View Full Code Here

      String scriptImportStr = getScriptImportStr();
      while(rs.next())
      {
        UUID id = DataAccessFactory.getInstance().createUUID(rs.getObject("id").toString());
        Timestamp createTime = rs.getTimestamp("create_time");
        Script script = new ScriptImpl(id, rs.getString("create_user"), createTime);
        script.setName(rs.getString("name"));
        script.setTemplateTypeIds(ArrayUtil.string2IdArray(rs.getString("template_type_ids")));
        script.setTemplateIds(ArrayUtil.string2IdArray(rs.getString("template_ids")));
        script.setFlowIds(ArrayUtil.string2IdArray(rs.getString("flow_ids")));
        script.setBeginStatIds(ArrayUtil.string2IdArray(rs.getString("begin_stat_ids")));
        script.setEndStatIds(ArrayUtil.string2IdArray(rs.getString("end_stat_ids")));
        script.setActionIds(ArrayUtil.string2IdArray(rs.getString("action_ids")));
        script.setAsync(rs.getBoolean("is_async"));
        script.setBeforeCommit(rs.getBoolean("is_before_commit"));
        script.setAfterSuccess(rs.getBoolean("is_after_success"));
        script.setAfterFail(rs.getBoolean("is_after_fail"));
        script.setAfterQuery(rs.getBoolean("is_after_query"));
        script.setScript(scriptImportStr + rs.getString("xml"));
        script.setStatEdit(rs.getBoolean("is_stat_edit"));
        script.setActionEdit(rs.getBoolean("is_action_edit"));
        script.setValid(rs.getBoolean("is_valid"));
        script.setAllowedTemplateIds(ArrayUtil.string2IdArray(rs.getString("allowed_template_ids")));
        scriptSet.add(script);
      }
    }catch(Exception e)
    {
      logger.error("",e);
View Full Code Here

TOP

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

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.