Search in sources :

Example 16 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class FullbuildWorkflowAction method doCreateNewTask.

/**
 * assemble 节点接收到来自console节点的触发任务,开始执行需要创建一个new的workflowbuildhistory记录
 *
 * @param context
 */
@Func(value = PermissionConstant.DATAFLOW_MANAGE, sideEffect = false)
public void doCreateNewTask(Context context) {
    final TriggerType triggerType = TriggerType.parse(this.getInt(IFullBuildContext.KEY_TRIGGER_TYPE));
    Application app = null;
    // appname 可以为空
    String appname = this.getString(IFullBuildContext.KEY_APP_NAME);
    if (StringUtils.isNotBlank(appname)) {
        app = this.getApplicationDAO().selectByName(appname);
        if (app == null) {
            throw new IllegalStateException("appname:" + appname + " relevant app pojo is not exist");
        }
    }
    WorkFlowBuildHistory task = new WorkFlowBuildHistory();
    task.setCreateTime(new Date());
    task.setStartTime(new Date());
    // task.setWorkFlowId(worflowid);
    task.setTriggerType(triggerType.getValue());
    task.setState((byte) ExecResult.DOING.getValue());
    // Integer buildHistoryId = null;
    // 从什么阶段开始执行
    FullbuildPhase fromPhase = FullbuildPhase.parse(getInt(IParamContext.COMPONENT_START, FullbuildPhase.FullDump.getValue()));
    FullbuildPhase endPhase = FullbuildPhase.parse(getInt(IParamContext.COMPONENT_END, FullbuildPhase.IndexBackFlow.getValue()));
    if (app == null) {
        if (endPhase.bigThan(FullbuildPhase.JOIN)) {
            endPhase = FullbuildPhase.JOIN;
        }
    }
    if (fromPhase.getValue() > FullbuildPhase.FullDump.getValue()) {
        // 如果是从非第一步开始执行的话,需要客户端提供依赖的history记录id
        task.setHistoryId(this.getInt(IFullBuildContext.KEY_BUILD_HISTORY_TASK_ID));
    }
    // 说明只有workflow的流程和索引没有关系,所以不可能执行到索引build阶段去
    // task.setEndPhase((app == null) ? FullbuildPhase.JOIN.getValue() : FullbuildPhase.IndexBackFlow.getValue());
    task.setEndPhase(endPhase.getValue());
    task.setStartPhase(fromPhase.getValue());
    if (app != null) {
        task.setAppId(app.getAppId());
        task.setAppName(app.getProjectName());
    }
    // 生成一个新的taskid
    this.setBizResult(context, new CreateNewTaskResult(getHistoryDAO().insertSelective(task), app));
}
Also used : TriggerType(com.qlangtech.tis.assemble.TriggerType) CreateNewTaskResult(com.qlangtech.tis.manage.common.CreateNewTaskResult) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) FullbuildPhase(com.qlangtech.tis.assemble.FullbuildPhase) Date(java.util.Date) Func(com.qlangtech.tis.manage.spring.aop.Func)

Example 17 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class TSearcherClusterInfoCollect method getBuAppMap.

/**
 */
public // Map<String, List<App>>
BuAppMap getBuAppMap() {
    BuAppMap buAppMap = new BuAppMap();
    ApplicationCriteria query = new ApplicationCriteria();
    List<Application> apps = getApplicationDAO().selectByExample(query);
    List<App> applist = null;
    for (Application ap : apps) {
        App pp = new App();
        pp.setAppid(ap.getAppId());
        pp.setDpt(ap.getDptName());
        pp.setServiceName(ap.getProjectName());
        if ((applist = buAppMap.get(pp.getBu())) == null) {
            applist = new ArrayList<App>();
            buAppMap.put(pp.getBu(), applist);
        }
        applist.add(pp);
    }
    return buAppMap;
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 18 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class OfflineManager method deleteWorkflow.

// public WorkflowPojo getWorkflowConfig(String name, boolean isMaster) {
// return
// }
// public WorkflowPojo getWorkflowConfig(String name, String sha) {
// return GitUtils.$().getWorkflowSha(GitUtils.WORKFLOW_GIT_PROJECT_ID, sha,
// name);
// }
public void deleteWorkflow(int id, BasicModule action, Context context) {
    WorkFlow workFlow = workflowDAOFacade.getWorkFlowDAO().selectByPrimaryKey(id);
    if (workFlow == null) {
        action.addErrorMessage(context, "数据库没有这条记录");
        return;
    }
    if (workFlow.getInChange().intValue() != 0) {
        action.addErrorMessage(context, "该工作流在变更中,无法删除");
        return;
    }
    ApplicationCriteria applicationCriteria = new ApplicationCriteria();
    applicationCriteria.createCriteria().andWorkFlowIdEqualTo(id);
    List<Application> applications = action.getApplicationDAO().selectByExample(applicationCriteria);
    if (!CollectionUtils.isEmpty(applications)) {
        StringBuilder stringBuilder = new StringBuilder();
        for (Application application : applications) {
            stringBuilder.append(application.getProjectName()).append(", ");
        }
        action.addErrorMessage(context, "请先删除与该工作流相关的索引,相关索引为" + stringBuilder.toString());
        return;
    }
    try {
        GitUser user = GitUser.dft();
        // delete git
        GitUtils.$().deleteWorkflow(workFlow.getName(), user);
        // delete db
        workflowDAOFacade.getWorkFlowDAO().deleteByPrimaryKey(id);
        // TODO 删除线上db的数据,发送一个http请求
        action.addActionMessage(context, "工作流删除成功");
    } catch (Exception e) {
        action.addErrorMessage(context, "工作流删除失败");
        action.addErrorMessage(context, e.getMessage());
    }
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application) SQLException(java.sql.SQLException) GitUser(com.qlangtech.tis.git.GitUtils.GitUser)

Example 19 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class CheckAppDomainExistValve method getAppDomain.

public static AppDomainInfo getAppDomain(HttpServletRequest request, RunContext context) {
    // Assert.assertNotNull(applicationDAO);
    AppDomainInfo domain = (AppDomainInfo) request.getAttribute(ActionTool.REQUEST_DOMAIN_KEY);
    if (domain != null) {
        return domain;
    }
    // Integer bizid = null;
    // Integer appid = null;
    AppDomainInfo appDomain = null;
    // Cookie cookie = getCookie(request,
    // ChangeDomainAction.COOKIE_SELECT_APP);
    // if (cookie == null) {
    // // domain = new NullAppDomainInfo(applicationDAO);
    // domain = AppDomainInfo.createAppNotAware(getRuntime());
    // request.setAttribute(ActionTool.REQUEST_DOMAIN_KEY, domain);
    // return domain;
    // }
    // Matcher match = p2.matcher(cookie.getValue());
    // .getRuntime(request);
    AppAndRuntime environment = DefaultFilter.getAppAndRuntime();
    if (environment == null) {
        domain = AppDomainInfo.createAppNotAware(DefaultFilter.getRuntime());
        request.setAttribute(ActionTool.REQUEST_DOMAIN_KEY, domain);
        return domain;
    }
    try {
        if (StringUtils.isEmpty(environment.getAppName())) {
            // 只选择了环境 参数
            // appDomain = new AppDomainInfo(-1, -1, Integer
            // .parseInt(match.group(2)), context);
            appDomain = AppDomainInfo.createAppNotAware(environment.getRuntime());
        } else {
            appDomain = queryApplication(request, context, environment.getAppName(), environment.getRuntime());
            if (appDomain == null) {
                Application app = new Application();
                app.setProjectName(environment.getAppName());
                appDomain = new AppDomainInfo(0, 0, environment.getRuntime(), app);
            }
        }
    } catch (Exception e) {
        // return new NullAppDomainInfo(context.getApplicationDAO());
        throw new IllegalStateException(e);
    }
    if (appDomain == null) {
        appDomain = CheckAppDomainExistValve.createNull();
    }
    request.setAttribute(ActionTool.REQUEST_DOMAIN_KEY, appDomain);
    return appDomain;
}
Also used : AppAndRuntime(com.qlangtech.tis.manage.common.DefaultFilter.AppAndRuntime) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Example 20 with Application

use of com.qlangtech.tis.manage.biz.dal.pojo.Application in project tis by qlangtech.

the class CheckAppDomainExistValve method queryApplication.

public static AppDomainInfo queryApplication(HttpServletRequest request, RunContext context, final String appname, RunEnvironment runtime) {
    if (true) {
        ApplicationCriteria query = new ApplicationCriteria();
        query.createCriteria().andProjectNameEqualTo(appname);
        AppDomainInfo appDomain = null;
        for (Application app : context.getApplicationDAO().selectByExample(query)) {
            // Integer bizid, Integer appid, RunEnvironment runEnvironment, Application app
            appDomain = new // getRuntime(match),
            AppDomainInfo(// getRuntime(match),
            app.getDptId(), // getRuntime(match),
            app.getAppId(), runtime, app);
            // appDomain.setAppName(appname);
            break;
        }
        return appDomain;
    }
    return null;
// // ApplicationCriteria criteria = new ApplicationCriteria();
// // criteria.createCriteria().andProjectNameEqualTo(
// // // match.group(1)
// // appname);// .andNotDelete();
// AppDomainInfo appDomain = null;
// IAppsFetcher appFetcher = UserUtils.getAppsFetcher(request, context);
// 
// List<Application> applist = appFetcher.getApps(new CriteriaSetter() {
// @Override
// public void set(Criteria criteria) {
// criteria.andProjectNameEqualTo(appname);
// }
// });
// 
// // List<Application> applist = applicationDAO.selectByExample(criteria,
// // 1,
// // 100);
// 
// // AppsFetcher.create();
// 
// for (Application app : applist) {
// // appDomain = new AppDomainInfo(app, Integer
// // .parseInt(match.group(2)), applicationDAO);
// 
// // 如果应用的部门为空则说明不是一个合法的部门
// if (app.getDptId() == null || app.getDptId() < 1) {
// return CheckAppDomainExistValve.createNull();
// }
// 
// appDomain = new AppDomainInfo(app.getDptId(), app.getAppId(), runtime,
// // getRuntime(match),
// context);
// 
// appDomain.setAutoDeploy(app.getIsAutoDeploy());
// break;
// }
// return appDomain;
}
Also used : ApplicationCriteria(com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria) Application(com.qlangtech.tis.manage.biz.dal.pojo.Application)

Aggregations

Application (com.qlangtech.tis.manage.biz.dal.pojo.Application)26 ApplicationCriteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria)7 Func (com.qlangtech.tis.manage.spring.aop.Func)5 Department (com.qlangtech.tis.manage.biz.dal.pojo.Department)2 Nullable (com.qlangtech.tis.pubhook.common.Nullable)2 SchemaAction (com.qlangtech.tis.runtime.module.action.SchemaAction)2 File (java.io.File)2 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 JSONArray (org.json.JSONArray)2 JSONObject (org.json.JSONObject)2 JSONTokener (org.json.JSONTokener)2 JSONObject (com.alibaba.fastjson.JSONObject)1 Pager (com.koubei.web.tag.pager.Pager)1 FullbuildPhase (com.qlangtech.tis.assemble.FullbuildPhase)1 TriggerType (com.qlangtech.tis.assemble.TriggerType)1 DBConfigSuit (com.qlangtech.tis.db.parser.DBConfigSuit)1 GitUser (com.qlangtech.tis.git.GitUtils.GitUser)1 Criteria (com.qlangtech.tis.manage.biz.dal.pojo.ApplicationCriteria.Criteria)1 ServerGroup (com.qlangtech.tis.manage.biz.dal.pojo.ServerGroup)1