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));
}
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;
}
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());
}
}
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;
}
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;
}
Aggregations