Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
三久
DolphinScheduler
提交
079a7ed8
DolphinScheduler
项目概览
三久
/
DolphinScheduler
与 Fork 源项目一致
Fork自
apache / DolphinScheduler
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
DolphinScheduler
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
079a7ed8
编写于
5月 10, 2019
作者:
L
lgcareer
提交者:
GitHub
5月 10, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #270 from lgcareer/branch-1.0.2
add delete process definition by id
上级
45886e46
995706f0
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
123 addition
and
1 deletion
+123
-1
escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java
...scheduler/api/controller/ProcessDefinitionController.java
+25
-0
escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
...ler-api/src/main/java/cn/escheduler/api/enums/Status.java
+3
-0
escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java
...a/cn/escheduler/api/service/ProcessDefinitionService.java
+59
-0
escheduler-api/src/test/java/cn/escheduler/api/service/ProcessDefinitionServiceTest.java
.../escheduler/api/service/ProcessDefinitionServiceTest.java
+12
-0
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapper.java
...rc/main/java/cn/escheduler/dao/mapper/ScheduleMapper.java
+7
-1
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapperProvider.java
...java/cn/escheduler/dao/mapper/ScheduleMapperProvider.java
+17
-0
未找到文件。
escheduler-api/src/main/java/cn/escheduler/api/controller/ProcessDefinitionController.java
浏览文件 @
079a7ed8
...
@@ -323,4 +323,29 @@ public class ProcessDefinitionController extends BaseController{
...
@@ -323,4 +323,29 @@ public class ProcessDefinitionController extends BaseController{
}
}
}
}
/**
* delete process definition by id
*
* @param loginUser
* @param projectName
* @param processDefinitionId
* @return
*/
@GetMapping
(
value
=
"/delete"
)
@ResponseStatus
(
HttpStatus
.
OK
)
public
Result
deleteProcessDefinitionById
(
@RequestAttribute
(
value
=
Constants
.
SESSION_USER
)
User
loginUser
,
@PathVariable
String
projectName
,
@RequestParam
(
"processDefinitionId"
)
Integer
processDefinitionId
){
try
{
logger
.
info
(
"delete process definition by id, login user:{}, project name:{}, process definition id:{}"
,
loginUser
.
getUserName
(),
projectName
,
processDefinitionId
);
Map
<
String
,
Object
>
result
=
processDefinitionService
.
deleteProcessDefinitionById
(
loginUser
,
projectName
,
processDefinitionId
);
return
returnDataList
(
result
);
}
catch
(
Exception
e
){
logger
.
error
(
DELETE_PROCESS_DEFINE_BY_ID_ERROR
.
getMsg
(),
e
);
return
error
(
Status
.
DELETE_PROCESS_DEFINE_BY_ID_ERROR
.
getCode
(),
Status
.
DELETE_PROCESS_DEFINE_BY_ID_ERROR
.
getMsg
());
}
}
}
}
escheduler-api/src/main/java/cn/escheduler/api/enums/Status.java
浏览文件 @
079a7ed8
...
@@ -200,6 +200,9 @@ public enum Status {
...
@@ -200,6 +200,9 @@ public enum Status {
DATA_IS_NULL
(
50018
,
"data %s is null"
),
DATA_IS_NULL
(
50018
,
"data %s is null"
),
PROCESS_NODE_HAS_CYCLE
(
50019
,
"process node has cycle"
),
PROCESS_NODE_HAS_CYCLE
(
50019
,
"process node has cycle"
),
PROCESS_NODE_S_PARAMETER_INVALID
(
50020
,
"process node %s parameter invalid"
),
PROCESS_NODE_S_PARAMETER_INVALID
(
50020
,
"process node %s parameter invalid"
),
PROCESS_DEFINE_STATE_ONLINE
(
50021
,
"process definition {0} is already on line"
),
DELETE_PROCESS_DEFINE_BY_ID_ERROR
(
50022
,
"delete process definition by id error"
),
SCHEDULE_CRON_STATE_ONLINE
(
50023
,
"the status of schedule {0} is already on line"
),
HDFS_NOT_STARTUP
(
60001
,
"hdfs not startup"
),
HDFS_NOT_STARTUP
(
60001
,
"hdfs not startup"
),
...
...
escheduler-api/src/main/java/cn/escheduler/api/service/ProcessDefinitionService.java
浏览文件 @
079a7ed8
...
@@ -336,6 +336,65 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -336,6 +336,65 @@ public class ProcessDefinitionService extends BaseDAGService {
return
result
;
return
result
;
}
}
/**
* delete process definition by id
*
* @param loginUser
* @param projectName
* @param processDefinitionId
* @return
*/
@Transactional
(
value
=
"TransactionManager"
,
rollbackFor
=
Exception
.
class
)
public
Map
<
String
,
Object
>
deleteProcessDefinitionById
(
User
loginUser
,
String
projectName
,
Integer
processDefinitionId
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
Project
project
=
projectMapper
.
queryByName
(
projectName
);
Map
<
String
,
Object
>
checkResult
=
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
);
Status
resultEnum
=
(
Status
)
checkResult
.
get
(
Constants
.
STATUS
);
if
(
resultEnum
!=
Status
.
SUCCESS
)
{
return
checkResult
;
}
ProcessDefinition
processDefinition
=
processDefineMapper
.
queryByDefineId
(
processDefinitionId
);
if
(
processDefinition
==
null
)
{
putMsg
(
result
,
Status
.
PROCESS_DEFINE_NOT_EXIST
,
processDefinitionId
);
return
result
;
}
// check process definition is already online
if
(
processDefinition
.
getReleaseState
()
==
ReleaseState
.
ONLINE
)
{
putMsg
(
result
,
Status
.
PROCESS_DEFINE_STATE_ONLINE
,
processDefinitionId
);
return
result
;
}
// get the timing according to the process definition
List
<
Schedule
>
schedules
=
scheduleMapper
.
selectAllByProcessDefineArray
(
new
int
[
processDefinitionId
]);
if
(!
schedules
.
isEmpty
()
&&
schedules
.
size
()
>
1
)
{
logger
.
warn
(
"scheduler num is {},Greater than 1"
,
schedules
.
size
());
putMsg
(
result
,
Status
.
DELETE_PROCESS_DEFINE_BY_ID_ERROR
);
return
result
;
}
else
if
(
schedules
.
size
()
==
1
){
Schedule
schedule
=
schedules
.
get
(
0
);
if
(
schedule
.
getReleaseState
()
==
ReleaseState
.
OFFLINE
){
scheduleMapper
.
delete
(
schedule
.
getId
());
}
else
if
(
schedule
.
getReleaseState
()
==
ReleaseState
.
ONLINE
){
putMsg
(
result
,
Status
.
SCHEDULE_CRON_STATE_ONLINE
,
schedule
.
getId
());
return
result
;
}
}
int
delete
=
processDefineMapper
.
delete
(
processDefinitionId
);
if
(
delete
>
0
)
{
putMsg
(
result
,
Status
.
SUCCESS
);
}
else
{
putMsg
(
result
,
Status
.
DELETE_PROCESS_DEFINE_BY_ID_ERROR
);
}
return
result
;
}
/**
/**
* release process definition: online / offline
* release process definition: online / offline
*
*
...
...
escheduler-api/src/test/java/cn/escheduler/api/service/ProcessDefinitionServiceTest.java
浏览文件 @
079a7ed8
...
@@ -63,4 +63,16 @@ public class ProcessDefinitionServiceTest {
...
@@ -63,4 +63,16 @@ public class ProcessDefinitionServiceTest {
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
}
}
@Test
public
void
deleteProcessDefinitionByIdTest
()
throws
Exception
{
User
loginUser
=
new
User
();
loginUser
.
setId
(
2
);
loginUser
.
setUserType
(
UserType
.
GENERAL_USER
);
Map
<
String
,
Object
>
map
=
processDefinitionService
.
deleteProcessDefinitionById
(
loginUser
,
"li_sql_test"
,
6
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
map
.
get
(
Constants
.
STATUS
));
logger
.
info
(
JSON
.
toJSONString
(
map
));
}
}
}
\ No newline at end of file
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapper.java
浏览文件 @
079a7ed8
...
@@ -173,6 +173,12 @@ public interface ScheduleMapper {
...
@@ -173,6 +173,12 @@ public interface ScheduleMapper {
@SelectProvider
(
type
=
ScheduleMapperProvider
.
class
,
method
=
"selectAllByProcessDefineArray"
)
@SelectProvider
(
type
=
ScheduleMapperProvider
.
class
,
method
=
"selectAllByProcessDefineArray"
)
List
<
Schedule
>
selectAllByProcessDefineArray
(
@Param
(
"processDefineIds"
)
int
[]
processDefineIds
);
List
<
Schedule
>
selectAllByProcessDefineArray
(
@Param
(
"processDefineIds"
)
int
[]
processDefineIds
);
/**
* delete schedule by id
* @param scheduleId
* @return
*/
@DeleteProvider
(
type
=
ScheduleMapperProvider
.
class
,
method
=
"delete"
)
int
delete
(
@Param
(
"scheduleId"
)
int
scheduleId
);
}
}
escheduler-dao/src/main/java/cn/escheduler/dao/mapper/ScheduleMapperProvider.java
浏览文件 @
079a7ed8
...
@@ -180,4 +180,21 @@ public class ScheduleMapperProvider {
...
@@ -180,4 +180,21 @@ public class ScheduleMapperProvider {
WHERE
(
"release_state = 1"
);
WHERE
(
"release_state = 1"
);
}}.
toString
();
}}.
toString
();
}
}
/**
* delete schedule by id
*
* @param parameter
* @return
*/
public
String
delete
(
Map
<
String
,
Object
>
parameter
)
{
return
new
SQL
()
{
{
DELETE_FROM
(
DB_NAME
);
WHERE
(
"`id`=#{scheduleId}"
);
}
}.
toString
();
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录