Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yanghaoyuan.sh
DolphinScheduler
提交
bc7a3f96
DolphinScheduler
项目概览
yanghaoyuan.sh
/
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,发现更多精彩内容 >>
未验证
提交
bc7a3f96
编写于
5月 06, 2020
作者:
X
xingchun-chen
提交者:
GitHub
5月 06, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into dev
上级
8fed430c
b08ba346
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
378 addition
and
148 deletion
+378
-148
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java
...scheduler/api/controller/ProcessDefinitionController.java
+12
-12
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
...in/java/org/apache/dolphinscheduler/api/enums/Status.java
+3
-2
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java
...olphinscheduler/api/service/ProcessDefinitionService.java
+193
-70
dolphinscheduler-api/src/main/resources/i18n/messages.properties
...scheduler-api/src/main/resources/i18n/messages.properties
+2
-0
dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties
...ler-api/src/main/resources/i18n/messages_en_US.properties
+2
-0
dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties
...ler-api/src/main/resources/i18n/messages_zh_CN.properties
+3
-0
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java
...duler/api/controller/ProcessDefinitionControllerTest.java
+62
-1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandlerTest.java
...phinscheduler/api/exceptions/ApiExceptionHandlerTest.java
+1
-1
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
...inscheduler/api/service/ProcessDefinitionServiceTest.java
+66
-46
dolphinscheduler-dao/src/main/resources/datasource.properties
...hinscheduler-dao/src/main/resources/datasource.properties
+3
-6
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue
...ges/projects/pages/definition/pages/list/_source/list.vue
+27
-7
dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
+4
-3
未找到文件。
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionController.java
浏览文件 @
bc7a3f96
...
@@ -449,30 +449,30 @@ public class ProcessDefinitionController extends BaseController {
...
@@ -449,30 +449,30 @@ public class ProcessDefinitionController extends BaseController {
}
}
/**
/**
*
export process definition by id
*
batch export process definition by ids
*
*
* @param loginUser login user
* @param loginUser login user
* @param projectName project name
* @param projectName project name
* @param processDefinitionId
process definition id
* @param processDefinitionId
s process definition ids
* @param response response
* @param response response
*/
*/
@ApiOperation
(
value
=
"
exportProcessDefinitionById"
,
notes
=
"EXPORT_PROCESS_DEFINITION_BY_ID
_NOTES"
)
@ApiOperation
(
value
=
"
batchExportProcessDefinitionByIds"
,
notes
=
"BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS
_NOTES"
)
@ApiImplicitParams
({
@ApiImplicitParams
({
@ApiImplicitParam
(
name
=
"processDefinitionId
"
,
value
=
"PROCESS_DEFINITION_ID"
,
required
=
true
,
dataType
=
"Int"
,
example
=
"100
"
)
@ApiImplicitParam
(
name
=
"processDefinitionId
s"
,
value
=
"PROCESS_DEFINITION_ID"
,
required
=
true
,
dataType
=
"String
"
)
})
})
@GetMapping
(
value
=
"/export"
)
@GetMapping
(
value
=
"/export"
)
@ResponseBody
@ResponseBody
public
void
exportProcessDefinitionById
(
@ApiIgnore
@RequestAttribute
(
value
=
Constants
.
SESSION_USER
)
User
loginUser
,
public
void
batchExportProcessDefinitionByIds
(
@ApiIgnore
@RequestAttribute
(
value
=
Constants
.
SESSION_USER
)
User
loginUser
,
@PathVariable
String
projectName
,
@ApiParam
(
name
=
"projectName"
,
value
=
"PROJECT_NAME"
,
required
=
true
)
@PathVariable
String
projectName
,
@RequestParam
(
"processDefinitionId"
)
Integer
processDefinitionId
,
@RequestParam
(
"processDefinitionIds"
)
String
processDefinitionIds
,
HttpServletResponse
response
)
{
HttpServletResponse
response
)
{
try
{
try
{
logger
.
info
(
"
export process definition by id, login user:{}, project name:{}, process definition id
:{}"
,
logger
.
info
(
"
batch export process definition by ids, login user:{}, project name:{}, process definition ids
:{}"
,
loginUser
.
getUserName
(),
projectName
,
processDefinitionId
);
loginUser
.
getUserName
(),
projectName
,
processDefinitionId
s
);
processDefinitionService
.
exportProcessDefinitionById
(
loginUser
,
projectName
,
processDefinitionId
,
response
);
processDefinitionService
.
batchExportProcessDefinitionByIds
(
loginUser
,
projectName
,
processDefinitionIds
,
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
Status
.
EXPORT_PROCESS_DEFINE_BY_ID
_ERROR
.
getMsg
(),
e
);
logger
.
error
(
Status
.
BATCH_EXPORT_PROCESS_DEFINE_BY_IDS
_ERROR
.
getMsg
(),
e
);
}
}
}
}
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/enums/Status.java
浏览文件 @
bc7a3f96
...
@@ -214,8 +214,8 @@ public enum Status {
...
@@ -214,8 +214,8 @@ public enum Status {
EXECUTE_PROCESS_INSTANCE_ERROR
(
50015
,
"execute process instance error"
,
"操作工作流实例错误"
),
EXECUTE_PROCESS_INSTANCE_ERROR
(
50015
,
"execute process instance error"
,
"操作工作流实例错误"
),
CHECK_PROCESS_DEFINITION_ERROR
(
50016
,
"check process definition error"
,
"检查工作流实例错误"
),
CHECK_PROCESS_DEFINITION_ERROR
(
50016
,
"check process definition error"
,
"检查工作流实例错误"
),
QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR
(
50017
,
"query recipients and copyers by process definition error"
,
"查询收件人和抄送人错误"
),
QUERY_RECIPIENTS_AND_COPYERS_BY_PROCESS_DEFINITION_ERROR
(
50017
,
"query recipients and copyers by process definition error"
,
"查询收件人和抄送人错误"
),
DATA_IS_NOT_VALID
(
50017
,
"data
%s not valid"
,
"数据[%s
]无效"
),
DATA_IS_NOT_VALID
(
50017
,
"data
{0} not valid"
,
"数据[{0}
]无效"
),
DATA_IS_NULL
(
50018
,
"data
%s is null"
,
"数据[%s
]不能为空"
),
DATA_IS_NULL
(
50018
,
"data
{0} is null"
,
"数据[{0}
]不能为空"
),
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"
,
"流程节点[%s]参数无效"
),
PROCESS_NODE_S_PARAMETER_INVALID
(
50020
,
"process node %s parameter invalid"
,
"流程节点[%s]参数无效"
),
PROCESS_DEFINE_STATE_ONLINE
(
50021
,
"process definition {0} is already on line"
,
"工作流定义[{0}]已上线"
),
PROCESS_DEFINE_STATE_ONLINE
(
50021
,
"process definition {0} is already on line"
,
"工作流定义[{0}]已上线"
),
...
@@ -226,6 +226,7 @@ public enum Status {
...
@@ -226,6 +226,7 @@ public enum Status {
BATCH_DELETE_PROCESS_DEFINE_BY_IDS_ERROR
(
50026
,
"batch delete process definition by ids {0} error"
,
"批量删除工作流定义[{0}]错误"
),
BATCH_DELETE_PROCESS_DEFINE_BY_IDS_ERROR
(
50026
,
"batch delete process definition by ids {0} error"
,
"批量删除工作流定义[{0}]错误"
),
TENANT_NOT_SUITABLE
(
50027
,
"there is not any tenant suitable, please choose a tenant available."
,
"没有合适的租户,请选择可用的租户"
),
TENANT_NOT_SUITABLE
(
50027
,
"there is not any tenant suitable, please choose a tenant available."
,
"没有合适的租户,请选择可用的租户"
),
EXPORT_PROCESS_DEFINE_BY_ID_ERROR
(
50028
,
"export process definition by id error"
,
"导出工作流定义错误"
),
EXPORT_PROCESS_DEFINE_BY_ID_ERROR
(
50028
,
"export process definition by id error"
,
"导出工作流定义错误"
),
BATCH_EXPORT_PROCESS_DEFINE_BY_IDS_ERROR
(
50028
,
"batch export process definition by ids error"
,
"批量导出工作流定义错误"
),
IMPORT_PROCESS_DEFINE_ERROR
(
50029
,
"import process definition error"
,
"导入工作流定义错误"
),
IMPORT_PROCESS_DEFINE_ERROR
(
50029
,
"import process definition error"
,
"导入工作流定义错误"
),
HDFS_NOT_STARTUP
(
60001
,
"hdfs not startup"
,
"hdfs未启用"
),
HDFS_NOT_STARTUP
(
60001
,
"hdfs not startup"
,
"hdfs未启用"
),
...
...
dolphinscheduler-api/src/main/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionService.java
浏览文件 @
bc7a3f96
...
@@ -563,14 +563,18 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -563,14 +563,18 @@ public class ProcessDefinitionService extends BaseDAGService {
}
}
/**
/**
* export process definition by id
* batch export process definition by ids
*
* @param loginUser
* @param loginUser login user
* @param projectName
* @param projectName project name
* @param processDefinitionIds
* @param processDefinitionId process definition id
* @param response
* @param response response
*/
*/
public
void
exportProcessDefinitionById
(
User
loginUser
,
String
projectName
,
Integer
processDefinitionId
,
HttpServletResponse
response
)
{
public
void
batchExportProcessDefinitionByIds
(
User
loginUser
,
String
projectName
,
String
processDefinitionIds
,
HttpServletResponse
response
){
if
(
StringUtils
.
isEmpty
(
processDefinitionIds
)){
return
;
}
//export project info
//export project info
Project
project
=
projectMapper
.
queryByName
(
projectName
);
Project
project
=
projectMapper
.
queryByName
(
projectName
);
...
@@ -578,20 +582,51 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -578,20 +582,51 @@ public class ProcessDefinitionService extends BaseDAGService {
Map
<
String
,
Object
>
checkResult
=
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
);
Map
<
String
,
Object
>
checkResult
=
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
);
Status
resultStatus
=
(
Status
)
checkResult
.
get
(
Constants
.
STATUS
);
Status
resultStatus
=
(
Status
)
checkResult
.
get
(
Constants
.
STATUS
);
if
(
resultStatus
==
Status
.
SUCCESS
)
{
if
(
resultStatus
!=
Status
.
SUCCESS
){
return
;
}
List
<
ProcessMeta
>
processDefinitionList
=
getProcessDefinitionList
(
processDefinitionIds
);
if
(
CollectionUtils
.
isNotEmpty
(
processDefinitionList
)){
downloadProcessDefinitionFile
(
response
,
processDefinitionList
);
}
}
/**
* get process definition list by ids
* @param processDefinitionIds
* @return
*/
private
List
<
ProcessMeta
>
getProcessDefinitionList
(
String
processDefinitionIds
){
List
<
ProcessMeta
>
processDefinitionList
=
new
ArrayList
<>();
String
[]
processDefinitionIdArray
=
processDefinitionIds
.
split
(
","
);
for
(
String
strProcessDefinitionId
:
processDefinitionIdArray
)
{
//get workflow info
//get workflow info
int
processDefinitionId
=
Integer
.
parseInt
(
strProcessDefinitionId
);
ProcessDefinition
processDefinition
=
processDefineMapper
.
queryByDefineId
(
processDefinitionId
);
ProcessDefinition
processDefinition
=
processDefineMapper
.
queryByDefineId
(
processDefinitionId
);
if
(
null
!=
processDefinition
)
{
if
(
null
!=
processDefinition
)
{
String
exportProcessJson
=
exportProcessMetaDataStr
(
processDefinitionId
,
processDefinition
);
processDefinitionList
.
add
(
exportProcessMetaData
(
processDefinitionId
,
processDefinition
));
}
}
return
processDefinitionList
;
}
/**
* download the process definition file
* @param response
* @param processDefinitionList
*/
private
void
downloadProcessDefinitionFile
(
HttpServletResponse
response
,
List
<
ProcessMeta
>
processDefinitionList
)
{
response
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
);
response
.
setContentType
(
MediaType
.
APPLICATION_JSON_UTF8_VALUE
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
processDefinition
.
getName
()+
".json"
);
BufferedOutputStream
buff
=
null
;
BufferedOutputStream
buff
=
null
;
ServletOutputStream
out
=
null
;
ServletOutputStream
out
=
null
;
try
{
try
{
out
=
response
.
getOutputStream
();
out
=
response
.
getOutputStream
();
buff
=
new
BufferedOutputStream
(
out
);
buff
=
new
BufferedOutputStream
(
out
);
buff
.
write
(
exportProcessJson
.
getBytes
(
StandardCharsets
.
UTF_8
));
buff
.
write
(
JSON
.
toJSONString
(
processDefinitionList
)
.
getBytes
(
StandardCharsets
.
UTF_8
));
buff
.
flush
();
buff
.
flush
();
buff
.
close
();
buff
.
close
();
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
...
@@ -613,8 +648,6 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -613,8 +648,6 @@ public class ProcessDefinitionService extends BaseDAGService {
}
}
}
}
}
}
}
}
/**
/**
* get export process metadata string
* get export process metadata string
...
@@ -623,6 +656,17 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -623,6 +656,17 @@ public class ProcessDefinitionService extends BaseDAGService {
* @return export process metadata string
* @return export process metadata string
*/
*/
public
String
exportProcessMetaDataStr
(
Integer
processDefinitionId
,
ProcessDefinition
processDefinition
)
{
public
String
exportProcessMetaDataStr
(
Integer
processDefinitionId
,
ProcessDefinition
processDefinition
)
{
//create workflow json file
return
JSONUtils
.
toJsonString
(
exportProcessMetaData
(
processDefinitionId
,
processDefinition
));
}
/**
* get export process metadata string
* @param processDefinitionId process definition id
* @param processDefinition process definition
* @return export process metadata string
*/
public
ProcessMeta
exportProcessMetaData
(
Integer
processDefinitionId
,
ProcessDefinition
processDefinition
)
{
//correct task param which has data source or dependent param
//correct task param which has data source or dependent param
String
correctProcessDefinitionJson
=
addExportTaskNodeSpecialParam
(
processDefinition
.
getProcessDefinitionJson
());
String
correctProcessDefinitionJson
=
addExportTaskNodeSpecialParam
(
processDefinition
.
getProcessDefinitionJson
());
processDefinition
.
setProcessDefinitionJson
(
correctProcessDefinitionJson
);
processDefinition
.
setProcessDefinitionJson
(
correctProcessDefinitionJson
);
...
@@ -639,14 +683,6 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -639,14 +683,6 @@ public class ProcessDefinitionService extends BaseDAGService {
List
<
Schedule
>
schedules
=
scheduleMapper
.
queryByProcessDefinitionId
(
processDefinitionId
);
List
<
Schedule
>
schedules
=
scheduleMapper
.
queryByProcessDefinitionId
(
processDefinitionId
);
if
(!
schedules
.
isEmpty
())
{
if
(!
schedules
.
isEmpty
())
{
Schedule
schedule
=
schedules
.
get
(
0
);
Schedule
schedule
=
schedules
.
get
(
0
);
/*WorkerGroup workerGroup = workerGroupMapper.selectById(schedule.getWorkerGroupId());
if (null == workerGroup && schedule.getWorkerGroupId() == -1) {
workerGroup = new WorkerGroup();
workerGroup.setId(-1);
workerGroup.setName("");
}*/
exportProcessMeta
.
setScheduleWarningType
(
schedule
.
getWarningType
().
toString
());
exportProcessMeta
.
setScheduleWarningType
(
schedule
.
getWarningType
().
toString
());
exportProcessMeta
.
setScheduleWarningGroupId
(
schedule
.
getWarningGroupId
());
exportProcessMeta
.
setScheduleWarningGroupId
(
schedule
.
getWarningGroupId
());
exportProcessMeta
.
setScheduleStartTime
(
DateUtils
.
dateToString
(
schedule
.
getStartTime
()));
exportProcessMeta
.
setScheduleStartTime
(
DateUtils
.
dateToString
(
schedule
.
getStartTime
()));
...
@@ -658,7 +694,7 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -658,7 +694,7 @@ public class ProcessDefinitionService extends BaseDAGService {
exportProcessMeta
.
setScheduleWorkerGroupName
(
schedule
.
getWorkerGroup
());
exportProcessMeta
.
setScheduleWorkerGroupName
(
schedule
.
getWorkerGroup
());
}
}
//create workflow json file
//create workflow json file
return
JSONUtils
.
toJsonString
(
exportProcessMeta
)
;
return
exportProcessMeta
;
}
}
/**
/**
...
@@ -705,26 +741,38 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -705,26 +741,38 @@ public class ProcessDefinitionService extends BaseDAGService {
public
Map
<
String
,
Object
>
importProcessDefinition
(
User
loginUser
,
MultipartFile
file
,
String
currentProjectName
)
{
public
Map
<
String
,
Object
>
importProcessDefinition
(
User
loginUser
,
MultipartFile
file
,
String
currentProjectName
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
String
processMetaJson
=
FileUtils
.
file2String
(
file
);
String
processMetaJson
=
FileUtils
.
file2String
(
file
);
ProcessMeta
processMeta
=
JSONUtils
.
parseObject
(
processMetaJson
,
ProcessMeta
.
class
);
List
<
ProcessMeta
>
processMetaList
=
JSON
.
parseArray
(
processMetaJson
,
ProcessMeta
.
class
);
//check file content
//check file content
if
(
null
==
processMeta
)
{
if
(
CollectionUtils
.
isEmpty
(
processMetaList
)
)
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"fileContent"
);
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"fileContent"
);
return
result
;
return
result
;
}
}
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProjectName
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"projectName"
);
for
(
ProcessMeta
processMeta:
processMetaList
){
if
(!
checkAndImportProcessDefinition
(
loginUser
,
currentProjectName
,
result
,
processMeta
)){
return
result
;
return
result
;
}
}
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProcessDefinitionName
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"processDefinitionName"
);
return
result
;
}
}
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProcessDefinitionJson
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"processDefinitionJson"
);
return
result
;
return
result
;
}
}
/**
* check and import process definition
* @param loginUser
* @param currentProjectName
* @param result
* @param processMeta
* @return
*/
private
boolean
checkAndImportProcessDefinition
(
User
loginUser
,
String
currentProjectName
,
Map
<
String
,
Object
>
result
,
ProcessMeta
processMeta
)
{
if
(!
checkImportanceParams
(
processMeta
,
result
)){
return
false
;
}
//deal with process name
//deal with process name
String
processDefinitionName
=
processMeta
.
getProcessDefinitionName
();
String
processDefinitionName
=
processMeta
.
getProcessDefinitionName
();
//use currentProjectName to query
//use currentProjectName to query
...
@@ -734,31 +782,84 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -734,31 +782,84 @@ public class ProcessDefinitionService extends BaseDAGService {
processDefinitionName
,
1
);
processDefinitionName
,
1
);
}
}
//add special task param
// get create process result
String
importProcessParam
=
addImportTaskNodeParam
(
loginUser
,
processMeta
.
getProcessDefinitionJson
(),
targetProject
);
Map
<
String
,
Object
>
createProcessResult
=
getCreateProcessResult
(
loginUser
,
currentProjectName
,
result
,
processMeta
,
processDefinitionName
,
addImportTaskNodeParam
(
loginUser
,
processMeta
.
getProcessDefinitionJson
(),
targetProject
));
if
(
createProcessResult
==
null
){
return
false
;
}
//create process definition
Integer
processDefinitionId
=
Objects
.
isNull
(
createProcessResult
.
get
(
"processDefinitionId"
))?
null
:
Integer
.
parseInt
(
createProcessResult
.
get
(
"processDefinitionId"
).
toString
());
//scheduler param
return
getImportProcessScheduleResult
(
loginUser
,
currentProjectName
,
result
,
processMeta
,
processDefinitionName
,
processDefinitionId
);
}
Map
<
String
,
Object
>
createProcessResult
;
/**
* get create process result
* @param loginUser
* @param currentProjectName
* @param result
* @param processMeta
* @param processDefinitionName
* @param importProcessParam
* @return
*/
private
Map
<
String
,
Object
>
getCreateProcessResult
(
User
loginUser
,
String
currentProjectName
,
Map
<
String
,
Object
>
result
,
ProcessMeta
processMeta
,
String
processDefinitionName
,
String
importProcessParam
){
Map
<
String
,
Object
>
createProcessResult
=
null
;
try
{
try
{
createProcessResult
=
createProcessDefinition
(
loginUser
createProcessResult
=
createProcessDefinition
(
loginUser
,
currentProjectName
,
,
currentProjectName
,
processDefinitionName
,
processDefinitionName
+
"_import_"
+
System
.
currentTimeMillis
()
,
importProcessParam
,
importProcessParam
,
processMeta
.
getProcessDefinitionDescription
(),
processMeta
.
getProcessDefinitionDescription
(),
processMeta
.
getProcessDefinitionLocations
(),
processMeta
.
getProcessDefinitionLocations
(),
processMeta
.
getProcessDefinitionConnects
());
processMeta
.
getProcessDefinitionConnects
());
putMsg
(
result
,
Status
.
SUCCESS
);
}
catch
(
JsonProcessingException
e
)
{
}
catch
(
JsonProcessingException
e
)
{
logger
.
error
(
"import process meta json data: {}"
,
e
.
getMessage
(),
e
);
logger
.
error
(
"import process meta json data: {}"
,
e
.
getMessage
(),
e
);
putMsg
(
result
,
Status
.
IMPORT_PROCESS_DEFINE_ERROR
);
putMsg
(
result
,
Status
.
IMPORT_PROCESS_DEFINE_ERROR
);
return
result
;
}
}
putMsg
(
result
,
Status
.
SUCCESS
);
return
createProcessResult
;
//create process definition
Integer
processDefinitionId
=
null
;
if
(
null
!=
createProcessResult
&&
Objects
.
nonNull
(
createProcessResult
.
get
(
"processDefinitionId"
)))
{
processDefinitionId
=
Integer
.
parseInt
(
createProcessResult
.
get
(
"processDefinitionId"
).
toString
());
}
}
//scheduler param
/**
* get import process schedule result
* @param loginUser
* @param currentProjectName
* @param result
* @param processMeta
* @param processDefinitionName
* @param processDefinitionId
* @return
*/
private
boolean
getImportProcessScheduleResult
(
User
loginUser
,
String
currentProjectName
,
Map
<
String
,
Object
>
result
,
ProcessMeta
processMeta
,
String
processDefinitionName
,
Integer
processDefinitionId
)
{
if
(
null
!=
processMeta
.
getScheduleCrontab
()
&&
null
!=
processDefinitionId
)
{
if
(
null
!=
processMeta
.
getScheduleCrontab
()
&&
null
!=
processDefinitionId
)
{
int
scheduleInsert
=
importProcessSchedule
(
loginUser
,
int
scheduleInsert
=
importProcessSchedule
(
loginUser
,
currentProjectName
,
currentProjectName
,
...
@@ -768,11 +869,33 @@ public class ProcessDefinitionService extends BaseDAGService {
...
@@ -768,11 +869,33 @@ public class ProcessDefinitionService extends BaseDAGService {
if
(
0
==
scheduleInsert
)
{
if
(
0
==
scheduleInsert
)
{
putMsg
(
result
,
Status
.
IMPORT_PROCESS_DEFINE_ERROR
);
putMsg
(
result
,
Status
.
IMPORT_PROCESS_DEFINE_ERROR
);
return
result
;
return
false
;
}
}
}
return
true
;
}
}
return
result
;
/**
* check importance params
* @param processMeta
* @param result
* @return
*/
private
boolean
checkImportanceParams
(
ProcessMeta
processMeta
,
Map
<
String
,
Object
>
result
){
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProjectName
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"projectName"
);
return
false
;
}
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProcessDefinitionName
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"processDefinitionName"
);
return
false
;
}
if
(
StringUtils
.
isEmpty
(
processMeta
.
getProcessDefinitionJson
()))
{
putMsg
(
result
,
Status
.
DATA_IS_NULL
,
"processDefinitionJson"
);
return
false
;
}
return
true
;
}
}
/**
/**
...
...
dolphinscheduler-api/src/main/resources/i18n/messages.properties
浏览文件 @
bc7a3f96
...
@@ -252,3 +252,5 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source
...
@@ -252,3 +252,5 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source
AUTHORIZED_DATA_SOURCE_NOTES
=
authorized data source
AUTHORIZED_DATA_SOURCE_NOTES
=
authorized data source
DELETE_SCHEDULER_BY_ID_NOTES
=
delete scheduler by id
DELETE_SCHEDULER_BY_ID_NOTES
=
delete scheduler by id
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
query alert group list paging
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
query alert group list paging
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES
=
export process definition by id
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES
=
batch export process definition by ids
\ No newline at end of file
dolphinscheduler-api/src/main/resources/i18n/messages_en_US.properties
浏览文件 @
bc7a3f96
...
@@ -252,3 +252,5 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source
...
@@ -252,3 +252,5 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=unauthorized data source
AUTHORIZED_DATA_SOURCE_NOTES
=
authorized data source
AUTHORIZED_DATA_SOURCE_NOTES
=
authorized data source
DELETE_SCHEDULER_BY_ID_NOTES
=
delete scheduler by id
DELETE_SCHEDULER_BY_ID_NOTES
=
delete scheduler by id
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
query alert group list paging
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
query alert group list paging
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES
=
export process definition by id
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES
=
batch export process definition by ids
dolphinscheduler-api/src/main/resources/i18n/messages_zh_CN.properties
浏览文件 @
bc7a3f96
...
@@ -250,3 +250,6 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=未授权的数据源
...
@@ -250,3 +250,6 @@ UNAUTHORIZED_DATA_SOURCE_NOTES=未授权的数据源
AUTHORIZED_DATA_SOURCE_NOTES
=
授权的数据源
AUTHORIZED_DATA_SOURCE_NOTES
=
授权的数据源
DELETE_SCHEDULER_BY_ID_NOTES
=
根据定时id删除定时数据
DELETE_SCHEDULER_BY_ID_NOTES
=
根据定时id删除定时数据
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
分页查询告警组列表
QUERY_ALERT_GROUP_LIST_PAGING_NOTES
=
分页查询告警组列表
EXPORT_PROCESS_DEFINITION_BY_ID_NOTES
=
通过工作流ID导出工作流定义
BATCH_EXPORT_PROCESS_DEFINITION_BY_IDS_NOTES
=
批量导出工作流定义
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/controller/ProcessDefinitionControllerTest.java
浏览文件 @
bc7a3f96
...
@@ -18,12 +18,14 @@ package org.apache.dolphinscheduler.api.controller;
...
@@ -18,12 +18,14 @@ package org.apache.dolphinscheduler.api.controller;
import
org.apache.dolphinscheduler.api.enums.Status
;
import
org.apache.dolphinscheduler.api.enums.Status
;
import
org.apache.dolphinscheduler.api.service.ProcessDefinitionService
;
import
org.apache.dolphinscheduler.api.service.ProcessDefinitionService
;
import
org.apache.dolphinscheduler.api.utils.PageInfo
;
import
org.apache.dolphinscheduler.api.utils.Result
;
import
org.apache.dolphinscheduler.api.utils.Result
;
import
org.apache.dolphinscheduler.common.Constants
;
import
org.apache.dolphinscheduler.common.Constants
;
import
org.apache.dolphinscheduler.common.enums.ReleaseState
;
import
org.apache.dolphinscheduler.common.enums.ReleaseState
;
import
org.apache.dolphinscheduler.common.enums.UserType
;
import
org.apache.dolphinscheduler.common.enums.UserType
;
import
org.apache.dolphinscheduler.common.model.TaskNode
;
import
org.apache.dolphinscheduler.common.model.TaskNode
;
import
org.apache.dolphinscheduler.dao.entity.ProcessDefinition
;
import
org.apache.dolphinscheduler.dao.entity.ProcessDefinition
;
import
org.apache.dolphinscheduler.dao.entity.Resource
;
import
org.apache.dolphinscheduler.dao.entity.User
;
import
org.apache.dolphinscheduler.dao.entity.User
;
import
org.junit.*
;
import
org.junit.*
;
import
org.junit.runner.RunWith
;
import
org.junit.runner.RunWith
;
...
@@ -33,6 +35,8 @@ import org.mockito.Mockito;
...
@@ -33,6 +35,8 @@ import org.mockito.Mockito;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.mock.web.MockHttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.text.MessageFormat
;
import
java.text.MessageFormat
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashMap
;
...
@@ -111,7 +115,7 @@ public class ProcessDefinitionControllerTest{
...
@@ -111,7 +115,7 @@ public class ProcessDefinitionControllerTest{
}
}
@Test
@Test
public
void
U
pdateProcessDefinition
()
throws
Exception
{
public
void
u
pdateProcessDefinition
()
throws
Exception
{
String
json
=
"{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"
;
String
json
=
"{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"
;
String
locations
=
"{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"
;
String
locations
=
"{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"
;
...
@@ -287,4 +291,61 @@ public class ProcessDefinitionControllerTest{
...
@@ -287,4 +291,61 @@ public class ProcessDefinitionControllerTest{
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
response
.
getCode
().
intValue
());
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
response
.
getCode
().
intValue
());
}
}
@Test
public
void
testQueryProcessDefinitionAllByProjectId
()
throws
Exception
{
int
projectId
=
1
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
putMsg
(
result
,
Status
.
SUCCESS
);
Mockito
.
when
(
processDefinitionService
.
queryProcessDefinitionAllByProjectId
(
projectId
)).
thenReturn
(
result
);
Result
response
=
processDefinitionController
.
queryProcessDefinitionAllByProjectId
(
user
,
projectId
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
response
.
getCode
().
intValue
());
}
@Test
public
void
testViewTree
()
throws
Exception
{
String
projectName
=
"test"
;
int
processId
=
1
;
int
limit
=
2
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
putMsg
(
result
,
Status
.
SUCCESS
);
Mockito
.
when
(
processDefinitionService
.
viewTree
(
processId
,
limit
)).
thenReturn
(
result
);
Result
response
=
processDefinitionController
.
viewTree
(
user
,
projectName
,
processId
,
limit
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
response
.
getCode
().
intValue
());
}
@Test
public
void
testQueryProcessDefinitionListPaging
()
throws
Exception
{
String
projectName
=
"test"
;
int
pageNo
=
1
;
int
pageSize
=
10
;
String
searchVal
=
""
;
int
userId
=
1
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
putMsg
(
result
,
Status
.
SUCCESS
);
result
.
put
(
Constants
.
DATA_LIST
,
new
PageInfo
<
Resource
>(
1
,
10
));
Mockito
.
when
(
processDefinitionService
.
queryProcessDefinitionListPaging
(
user
,
projectName
,
searchVal
,
pageNo
,
pageSize
,
userId
)).
thenReturn
(
result
);
Result
response
=
processDefinitionController
.
queryProcessDefinitionListPaging
(
user
,
projectName
,
pageNo
,
searchVal
,
userId
,
pageSize
);
Assert
.
assertEquals
(
Status
.
SUCCESS
.
getCode
(),
response
.
getCode
().
intValue
());
}
@Test
public
void
testBatchExportProcessDefinitionByIds
()
throws
Exception
{
String
processDefinitionIds
=
"1,2"
;
String
projectName
=
"test"
;
HttpServletResponse
response
=
new
MockHttpServletResponse
();
ProcessDefinitionService
service
=
new
ProcessDefinitionService
();
ProcessDefinitionService
spy
=
Mockito
.
spy
(
service
);
Mockito
.
doNothing
().
when
(
spy
).
batchExportProcessDefinitionByIds
(
user
,
projectName
,
processDefinitionIds
,
response
);
processDefinitionController
.
batchExportProcessDefinitionByIds
(
user
,
projectName
,
processDefinitionIds
,
response
);
}
}
}
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/exceptions/ApiExceptionHandlerTest.java
浏览文件 @
bc7a3f96
...
@@ -46,7 +46,7 @@ public class ApiExceptionHandlerTest {
...
@@ -46,7 +46,7 @@ public class ApiExceptionHandlerTest {
public
void
exceptionHandlerRuntime
()
throws
NoSuchMethodException
{
public
void
exceptionHandlerRuntime
()
throws
NoSuchMethodException
{
ApiExceptionHandler
handler
=
new
ApiExceptionHandler
();
ApiExceptionHandler
handler
=
new
ApiExceptionHandler
();
ProcessDefinitionController
controller
=
new
ProcessDefinitionController
();
ProcessDefinitionController
controller
=
new
ProcessDefinitionController
();
Method
method
=
controller
.
getClass
().
getMethod
(
"
exportProcessDefinitionById"
,
User
.
class
,
String
.
class
,
Integer
.
class
,
HttpServletResponse
.
class
);
Method
method
=
controller
.
getClass
().
getMethod
(
"
batchExportProcessDefinitionByIds"
,
User
.
class
,
String
.
class
,
String
.
class
,
HttpServletResponse
.
class
);
HandlerMethod
hm
=
new
HandlerMethod
(
controller
,
method
);
HandlerMethod
hm
=
new
HandlerMethod
(
controller
,
method
);
Result
result
=
handler
.
exceptionHandler
(
new
RuntimeException
(
"test exception"
),
hm
);
Result
result
=
handler
.
exceptionHandler
(
new
RuntimeException
(
"test exception"
),
hm
);
Assert
.
assertEquals
(
Status
.
INTERNAL_SERVER_ERROR_ARGS
.
getCode
(),
result
.
getCode
().
intValue
());
Assert
.
assertEquals
(
Status
.
INTERNAL_SERVER_ERROR_ARGS
.
getCode
(),
result
.
getCode
().
intValue
());
...
...
dolphinscheduler-api/src/test/java/org/apache/dolphinscheduler/api/service/ProcessDefinitionServiceTest.java
浏览文件 @
bc7a3f96
...
@@ -667,32 +667,60 @@ public class ProcessDefinitionServiceTest {
...
@@ -667,32 +667,60 @@ public class ProcessDefinitionServiceTest {
}
}
@Test
public
void
testCreateProcess
()
throws
IOException
{
String
json
=
"{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"
;
String
locations
=
"{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"
;
String
projectName
=
"test"
;
String
name
=
"dag_test"
;
String
description
=
"desc test"
;
String
connects
=
"[]"
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
putMsg
(
result
,
Status
.
SUCCESS
);
result
.
put
(
"processDefinitionId"
,
1
);
Mockito
.
when
(
projectMapper
.
queryByName
(
projectName
)).
thenReturn
(
getProject
(
projectName
));
User
loginUser
=
new
User
();
loginUser
.
setId
(
1
);
loginUser
.
setUserType
(
UserType
.
ADMIN_USER
);
Project
project
=
getProject
(
projectName
);
//project not found
Mockito
.
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
)).
thenReturn
(
result
);
Mockito
.
when
(
processDefineMapper
.
insert
(
getProcessDefinition
())).
thenReturn
(
1
);
Map
<
String
,
Object
>
result1
=
processDefinitionService
.
createProcessDefinition
(
loginUser
,
projectName
,
name
,
json
,
description
,
locations
,
connects
);
Assert
.
assertEquals
(
Status
.
SUCCESS
,
result1
.
get
(
Constants
.
STATUS
));
}
@Test
@Test
public
void
testImportProcessDefinitionById
()
throws
IOException
{
public
void
testImportProcessDefinitionById
()
throws
IOException
{
String
processJson
=
"{\"projectName\":\"testProject\",\"processDefinitionName\":\"shell-4\","
+
String
json
=
"{\"globalParams\":[],\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-36196\",\"name\":\"ssh_test1\",\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"aa=\\\"1234\\\"\\necho ${aa}\"},\"desc\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,\"preTasks\":[]}],\"tenantId\":-1,\"timeout\":0}"
;
"\"processDefinitionJson\":\"{\\\"tenantId\\\":1,\\\"globalParams\\\":[],"
+
String
locations
=
"{\"tasks-36196\":{\"name\":\"ssh_test1\",\"targetarr\":\"\",\"x\":141,\"y\":70}}"
;
"\\\"tasks\\\":[{\\\"workerGroupId\\\":-1,\\\"description\\\":\\\"\\\",\\\"runFlag\\\":\\\"NORMAL\\\","
+
"\\\"type\\\":\\\"SHELL\\\",\\\"params\\\":{\\\"rawScript\\\":\\\"#!/bin/bash\\\\necho \\\\\\\"shell-4\\\\\\\"\\\","
+
String
projectName
=
"test"
;
"\\\"localParams\\\":[],\\\"resourceList\\\":[]},\\\"timeout\\\":{\\\"enable\\\":false,\\\"strategy\\\":\\\"\\\"},"
+
String
name
=
"dag_test"
;
"\\\"maxRetryTimes\\\":\\\"0\\\",\\\"taskInstancePriority\\\":\\\"MEDIUM\\\",\\\"name\\\":\\\"shell-4\\\","
+
String
description
=
"desc test"
;
"\\\"dependence\\\":{},\\\"retryInterval\\\":\\\"1\\\",\\\"preTasks\\\":[],\\\"id\\\":\\\"tasks-84090\\\"},"
+
String
connects
=
"[]"
;
"{\\\"taskInstancePriority\\\":\\\"MEDIUM\\\",\\\"name\\\":\\\"shell-5\\\",\\\"workerGroupId\\\":-1,"
+
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
"\\\"description\\\":\\\"\\\",\\\"dependence\\\":{},\\\"preTasks\\\":[\\\"shell-4\\\"],\\\"id\\\":\\\"tasks-87364\\\","
+
putMsg
(
result
,
Status
.
SUCCESS
);
"\\\"runFlag\\\":\\\"NORMAL\\\",\\\"type\\\":\\\"SUB_PROCESS\\\",\\\"params\\\":{\\\"processDefinitionId\\\":46},"
+
result
.
put
(
"processDefinitionId"
,
1
);
"\\\"timeout\\\":{\\\"enable\\\":false,\\\"strategy\\\":\\\"\\\"}}],\\\"timeout\\\":0}\","
+
"\"processDefinitionDescription\":\"\",\"processDefinitionLocations\":\"{\\\"tasks-84090\\\":{\\\"name\\\":\\\"shell-4\\\","
+
Mockito
.
when
(
projectMapper
.
queryByName
(
projectName
)).
thenReturn
(
getProject
(
projectName
));
"\\\"targetarr\\\":\\\"\\\",\\\"x\\\":128,\\\"y\\\":114},\\\"tasks-87364\\\":{\\\"name\\\":\\\"shell-5\\\","
+
User
loginUser
=
new
User
();
"\\\"targetarr\\\":\\\"tasks-84090\\\",\\\"x\\\":266,\\\"y\\\":115}}\","
+
loginUser
.
setId
(
1
);
"\"processDefinitionConnects\":\"[{\\\"endPointSourceId\\\":\\\"tasks-84090\\\","
+
loginUser
.
setUserType
(
UserType
.
ADMIN_USER
);
"\\\"endPointTargetId\\\":\\\"tasks-87364\\\"}]\"}"
;
Project
project
=
getProject
(
projectName
)
;
String
subProcessJson
=
"{\"globalParams\":[],"
+
//project not found
"\"tasks\":[{\"type\":\"SHELL\",\"id\":\"tasks-52423\",\"name\":\"shell-5\","
+
Mockito
.
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
project
,
projectName
)).
thenReturn
(
result
);
"\"params\":{\"resourceList\":[],\"localParams\":[],\"rawScript\":\"echo \\\"shell-5\\\"\"},\"description\":\"\","
+
Mockito
.
when
(
processDefineMapper
.
insert
(
getProcessDefinition
())).
thenReturn
(
1
);
"\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\",\"retryInterval\":\"1\","
+
Map
<
String
,
Object
>
result1
=
processDefinitionService
.
createProcessDefinition
(
loginUser
,
projectName
,
name
,
json
,
description
,
locations
,
connects
);
"\"timeout\":{\"strategy\":\"\",\"interval\":null,\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1,"
+
"\"preTasks\":[]}],\"tenantId\":1,\"timeout\":0}
"
;
String
processJson
=
"[{\"processDefinitionConnects\":\"[]\",\"processDefinitionJson\":\"{\\\"tenantId\\\":-1,\\\"globalParams\\\":[],\\\"tasks\\\":[{\\\"workerGroupId\\\":-1,\\\"runFlag\\\":\\\"NORMAL\\\",\\\"type\\\":\\\"SHELL\\\",\\\"params\\\":{\\\"rawScript\\\":\\\"aa=\\\\\\\"1234\\\\\\\"\\\\necho ${aa}\\\",\\\"localParams\\\":[],\\\"resourceList\\\":[]},\\\"timeout\\\":{\\\"enable\\\":false,\\\"strategy\\\":\\\"\\\"},\\\"maxRetryTimes\\\":\\\"0\\\",\\\"taskInstancePriority\\\":\\\"MEDIUM\\\",\\\"name\\\":\\\"ssh_test1\\\",\\\"dependence\\\":{},\\\"retryInterval\\\":\\\"1\\\",\\\"preTasks\\\":[],\\\"id\\\":\\\"tasks-36196\\\",\\\"desc\\\":\\\"\\\"}],\\\"timeout\\\":0}\",\"processDefinitionLocations\":\"{\\\"tasks-36196\\\":{\\\"name\\\":\\\"ssh_test1\\\",\\\"targetarr\\\":\\\"\\\",\\\"x\\\":141,\\\"y\\\":70}}\",\"processDefinitionName\":\"dag_test\",\"projectName\":\"test\"}]
"
;
FileUtils
.
writeStringToFile
(
new
File
(
"/tmp/task.json"
),
processJson
);
FileUtils
.
writeStringToFile
(
new
File
(
"/tmp/task.json"
),
processJson
);
...
@@ -703,23 +731,16 @@ public class ProcessDefinitionServiceTest {
...
@@ -703,23 +731,16 @@ public class ProcessDefinitionServiceTest {
MultipartFile
multipartFile
=
new
MockMultipartFile
(
file
.
getName
(),
file
.
getName
(),
MultipartFile
multipartFile
=
new
MockMultipartFile
(
file
.
getName
(),
file
.
getName
(),
ContentType
.
APPLICATION_OCTET_STREAM
.
toString
(),
fileInputStream
);
ContentType
.
APPLICATION_OCTET_STREAM
.
toString
(),
fileInputStream
);
User
loginUser
=
new
User
();
String
currentProjectName
=
"test"
;
loginUser
.
setId
(
1
);
loginUser
.
setUserType
(
UserType
.
ADMIN_USER
);
String
currentProjectName
=
"testProject"
;
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
5
);
putMsg
(
result
,
Status
.
SUCCESS
,
currentProjectName
);
ProcessDefinition
shellDefinition2
=
new
ProcessDefinition
();
ProcessDefinition
shellDefinition2
=
new
ProcessDefinition
();
shellDefinition2
.
setId
(
46
);
shellDefinition2
.
setId
(
25
);
shellDefinition2
.
setName
(
"shell-5"
);
shellDefinition2
.
setName
(
"B"
);
shellDefinition2
.
setProjectId
(
2
);
shellDefinition2
.
setProjectId
(
1
);
shellDefinition2
.
setProcessDefinitionJson
(
subProcessJson
);
Mockito
.
when
(
projectMapper
.
queryByName
(
currentProjectName
)).
thenReturn
(
getProject
(
currentProjectName
));
Mockito
.
when
(
projectMapper
.
queryByName
(
currentProjectName
)).
thenReturn
(
getProject
(
currentProjectName
));
Mockito
.
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
getProject
(
currentProjectName
),
currentProjectName
)).
thenReturn
(
result
);
Mockito
.
when
(
projectService
.
checkProjectAndAuth
(
loginUser
,
getProject
(
currentProjectName
),
currentProjectName
)).
thenReturn
(
result
);
Mockito
.
when
(
processDefineMapper
.
queryByDefineId
(
46
)).
thenReturn
(
shellDefinition2
);
Mockito
.
when
(
processDefineMapper
.
queryByDefineId
(
25
)).
thenReturn
(
shellDefinition2
);
//import process
//import process
Map
<
String
,
Object
>
importProcessResult
=
processDefinitionService
.
importProcessDefinition
(
loginUser
,
multipartFile
,
currentProjectName
);
Map
<
String
,
Object
>
importProcessResult
=
processDefinitionService
.
importProcessDefinition
(
loginUser
,
multipartFile
,
currentProjectName
);
...
@@ -730,18 +751,17 @@ public class ProcessDefinitionServiceTest {
...
@@ -730,18 +751,17 @@ public class ProcessDefinitionServiceTest {
Assert
.
assertTrue
(
delete
);
Assert
.
assertTrue
(
delete
);
String
processMetaJson
=
""
;
String
processMetaJson
=
"[]"
;
improssProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
importProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
//
processMetaJson
=
"{\"scheduleWorkerGroupId\":-1}"
;
processMetaJson
=
"[{\"scheduleWorkerGroupId\":-1}]"
;
improssProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
importProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
processMetaJson
=
"{\"scheduleWorkerGroupId\":-1,\"projectName\":\"test\"}"
;
improssProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
processMetaJson
=
"
{\"scheduleWorkerGroupId\":-1,\"projectName\":\"test\",\"processDefinitionName\":\"test_definition\"}
"
;
processMetaJson
=
"
[{\"scheduleWorkerGroupId\":-1,\"projectName\":\"test\"}]
"
;
imp
ross
ProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
imp
ort
ProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
processMetaJson
=
"[{\"scheduleWorkerGroupId\":-1,\"projectName\":\"test\",\"processDefinitionName\":\"test_definition\"}]"
;
importProcessCheckData
(
file
,
loginUser
,
currentProjectName
,
processMetaJson
);
}
}
...
@@ -753,7 +773,7 @@ public class ProcessDefinitionServiceTest {
...
@@ -753,7 +773,7 @@ public class ProcessDefinitionServiceTest {
* @param processMetaJson process meta json
* @param processMetaJson process meta json
* @throws IOException IO exception
* @throws IOException IO exception
*/
*/
private
void
imp
ross
ProcessCheckData
(
File
file
,
User
loginUser
,
String
currentProjectName
,
String
processMetaJson
)
throws
IOException
{
private
void
imp
ort
ProcessCheckData
(
File
file
,
User
loginUser
,
String
currentProjectName
,
String
processMetaJson
)
throws
IOException
{
//check null
//check null
FileUtils
.
writeStringToFile
(
new
File
(
"/tmp/task.json"
),
processMetaJson
);
FileUtils
.
writeStringToFile
(
new
File
(
"/tmp/task.json"
),
processMetaJson
);
...
...
dolphinscheduler-dao/src/main/resources/datasource.properties
浏览文件 @
bc7a3f96
...
@@ -15,16 +15,13 @@
...
@@ -15,16 +15,13 @@
# limitations under the License.
# limitations under the License.
#
#
# postgresql
# postgre
#spring.datasource.driver-class-name=org.postgresql.Driver
#spring.datasource.url=jdbc:postgresql://localhost:5432/dolphinscheduler
# mysql
spring.datasource.driver-class-name
=
org.postgresql.Driver
spring.datasource.driver-class-name
=
org.postgresql.Driver
spring.datasource.url
=
jdbc:postgresql://localhost:5432/dolphinscheduler
spring.datasource.url
=
jdbc:postgresql://localhost:5432/dolphinscheduler
spring.datasource.username
=
test
spring.datasource.username
=
test
spring.datasource.password
=
test
spring.datasource.password
=
test
# mysql
# connection configuration
# connection configuration
#spring.datasource.initialSize=5
#spring.datasource.initialSize=5
# min connection number
# min connection number
...
...
dolphinscheduler-ui/src/js/conf/home/pages/projects/pages/definition/pages/list/_source/list.vue
浏览文件 @
bc7a3f96
...
@@ -123,7 +123,7 @@
...
@@ -123,7 +123,7 @@
</table>
</table>
</div>
</div>
<x-poptip
<x-poptip
v-show=
"str
Delete
!== ''"
v-show=
"str
SelectIds
!== ''"
ref=
"poptipDeleteAll"
ref=
"poptipDeleteAll"
placement=
"bottom-start"
placement=
"bottom-start"
width=
"90"
>
width=
"90"
>
...
@@ -137,6 +137,10 @@
...
@@ -137,6 +137,10 @@
</
template
>
</
template
>
</x-poptip>
</x-poptip>
<
template
v-if=
"strSelectIds !== ''"
>
<x-button
size=
"xsmall"
style=
"position: absolute; bottom: -48px; left: 80px;"
@
click=
"_batchExport(item)"
>
{{
$t
(
'
Export
'
)
}}
</x-button>
</
template
>
</div>
</div>
</template>
</template>
<
script
>
<
script
>
...
@@ -151,7 +155,7 @@
...
@@ -151,7 +155,7 @@
data
()
{
data
()
{
return
{
return
{
list
:
[],
list
:
[],
str
Delete
:
''
,
str
SelectIds
:
''
,
checkAll
:
false
checkAll
:
false
}
}
},
},
...
@@ -326,12 +330,28 @@
...
@@ -326,12 +330,28 @@
_export
(
item
)
{
_export
(
item
)
{
this
.
exportDefinition
({
this
.
exportDefinition
({
processDefinitionId
:
item
.
id
,
processDefinitionId
s
:
item
.
id
,
processDefinition
Name
:
item
.
name
file
Name
:
item
.
name
}).
catch
(
e
=>
{
}).
catch
(
e
=>
{
this
.
$message
.
error
(
e
.
msg
||
''
)
this
.
$message
.
error
(
e
.
msg
||
''
)
})
})
},
},
_batchExport
()
{
this
.
exportDefinition
({
processDefinitionIds
:
this
.
strSelectIds
,
fileName
:
"
process_
"
+
new
Date
().
getTime
()
}).
then
(
res
=>
{
this
.
_onUpdate
()
this
.
checkAll
=
false
this
.
strSelectIds
=
''
}).
catch
(
e
=>
{
this
.
strSelectIds
=
''
this
.
checkAll
=
false
this
.
$message
.
error
(
e
.
msg
)
})
},
/**
/**
* Edit state
* Edit state
*/
*/
...
@@ -364,7 +384,7 @@
...
@@ -364,7 +384,7 @@
arr
.
push
(
item
.
id
)
arr
.
push
(
item
.
id
)
}
}
})
})
this
.
str
Delete
=
_
.
join
(
arr
,
'
,
'
)
this
.
str
SelectIds
=
_
.
join
(
arr
,
'
,
'
)
if
(
v
===
false
)
{
if
(
v
===
false
)
{
this
.
checkAll
=
false
this
.
checkAll
=
false
}
}
...
@@ -375,7 +395,7 @@
...
@@ -375,7 +395,7 @@
_batchDelete
()
{
_batchDelete
()
{
this
.
$refs
[
'
poptipDeleteAll
'
].
doClose
()
this
.
$refs
[
'
poptipDeleteAll
'
].
doClose
()
this
.
batchDeleteDefinition
({
this
.
batchDeleteDefinition
({
processDefinitionIds
:
this
.
str
Delete
processDefinitionIds
:
this
.
str
SelectIds
}).
then
(
res
=>
{
}).
then
(
res
=>
{
this
.
_onUpdate
()
this
.
_onUpdate
()
this
.
checkAll
=
false
this
.
checkAll
=
false
...
@@ -399,7 +419,7 @@
...
@@ -399,7 +419,7 @@
deep
:
true
deep
:
true
},
},
pageNo
()
{
pageNo
()
{
this
.
str
Delete
=
''
this
.
str
SelectIds
=
''
}
}
},
},
created
()
{
created
()
{
...
...
dolphinscheduler-ui/src/js/conf/home/store/dag/actions.js
浏览文件 @
bc7a3f96
...
@@ -596,14 +596,15 @@ export default {
...
@@ -596,14 +596,15 @@ export default {
}
}
}
}
io
.
get
(
`projects/
${
state
.
projectName
}
/process/export`
,{
processDefinitionId
:
payload
.
processDefinitionId
,
},
res
=>
{
io
.
get
(
`projects/
${
state
.
projectName
}
/process/export`
,{
processDefinitionId
s
:
payload
.
processDefinitionIds
},
res
=>
{
downloadBlob
(
res
,
payload
.
processDefinition
Name
)
downloadBlob
(
res
,
payload
.
file
Name
)
},
e
=>
{
},
e
=>
{
},
{
},
{
responseType
:
'
blob
'
responseType
:
'
blob
'
})
})
},
},
/**
/**
* Process instance get variable
* Process instance get variable
*/
*/
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录