forked from apache/dolphinscheduler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProcessInstanceMapper.java
324 lines (290 loc) · 13.6 KB
/
ProcessInstanceMapper.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.dolphinscheduler.dao.mapper;
import org.apache.dolphinscheduler.common.enums.WorkflowExecutionStatus;
import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount;
import org.apache.dolphinscheduler.dao.entity.ProcessInstance;
import org.apache.dolphinscheduler.dao.model.WorkflowInstanceStatusCountDto;
import org.apache.ibatis.annotations.Param;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Set;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
/**
* process instance mapper interface
*/
public interface ProcessInstanceMapper extends BaseMapper<ProcessInstance> {
/**
* query process instance detail info by id
*
* @param processId processId
* @return process instance
*/
ProcessInstance queryDetailById(@Param("processId") int processId);
/**
* query process instance by host and stateArray
*
* @param host host
* @param stateArray stateArray
* @return process instance list
*/
List<ProcessInstance> queryByHostAndStatus(@Param("host") String host,
@Param("states") int[] stateArray);
/**
* query process instance host by stateArray
*
* @param stateArray
* @return
*/
List<String> queryNeedFailoverProcessInstanceHost(@Param("states") int[] stateArray);
/**
* query process instance by tenantCode and stateArray
*
* @param tenantCode tenantCode
* @param states states array
* @return process instance list
*/
List<ProcessInstance> queryByTenantCodeAndStatus(@Param("tenantCode") String tenantCode,
@Param("states") int[] states);
/**
* @param workerGroupName workerGroupName
* @param states states array
* @return process instance list
*/
List<ProcessInstance> queryByWorkerGroupNameAndStatus(@Param("workerGroupName") String workerGroupName,
@Param("states") int[] states);
/**
* process instance page
* @param page page
* @param projectId projectId
* @param processDefinitionId processDefinitionId
* @param searchVal searchVal
* @param executorId executorId
* @param statusArray statusArray
* @param host host
* @param startTime startTime
* @param endTime endTime
* @return process instance IPage
*/
/**
* process instance page
*
* @param page page
* @param projectCode projectCode
* @param processDefinitionCode processDefinitionCode
* @param searchVal searchVal
* @param executorName executorName
* @param statusArray statusArray
* @param host host
* @param startTime startTime
* @param endTime endTime
* @return process instance page
*/
IPage<ProcessInstance> queryProcessInstanceListPaging(Page<ProcessInstance> page,
@Param("projectCode") Long projectCode,
@Param("processDefinitionCode") Long processDefinitionCode,
@Param("searchVal") String searchVal,
@Param("executorName") String executorName,
@Param("states") int[] statusArray,
@Param("host") String host,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
/**
* set failover by host and state array
*
* @param host host
* @param stateArray stateArray
* @return set result
*/
int setFailoverByHostAndStateArray(@Param("host") String host,
@Param("states") int[] stateArray);
/**
* update process instance by state
*
* @param originState originState
* @param destState destState
* @return update result
*/
int updateProcessInstanceByState(@Param("originState") WorkflowExecutionStatus originState,
@Param("destState") WorkflowExecutionStatus destState);
/**
* update process instance by tenantCode
*
* @param originTenantCode originTenantCode
* @param destTenantCode destTenantCode
* @return update result
*/
int updateProcessInstanceByTenantCode(@Param("originTenantCode") String originTenantCode,
@Param("destTenantCode") String destTenantCode);
/**
* update process instance by worker groupId
*
* @param originWorkerGroupName originWorkerGroupName
* @param destWorkerGroupName destWorkerGroupName
* @return update result
*/
int updateProcessInstanceByWorkerGroupName(@Param("originWorkerGroupName") String originWorkerGroupName,
@Param("destWorkerGroupName") String destWorkerGroupName);
/**
* Statistics process instance state by given project codes list
* <p>
* We only need project codes to determine whether the process instance belongs to the user or not.
*
* @param startTime startTime
* @param endTime endTime
* @param projectCodes projectCodes
* @return ExecuteStatusCount list
*/
List<WorkflowInstanceStatusCountDto> countWorkflowInstanceStateByProjectCodes(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCodes") Collection<Long> projectCodes);
/**
* query process instance by processDefinitionCode
*
* @param processDefinitionCode processDefinitionCode
* @param size size
* @return process instance list
*/
List<ProcessInstance> queryByProcessDefineCode(@Param("processDefinitionCode") Long processDefinitionCode,
@Param("size") int size);
/**
* query last scheduler process instance
*
* @param definitionCode definitionCode
* @param startTime startTime
* @param endTime endTime
* @param testFlag testFlag
* @return process instance
*/
ProcessInstance queryLastSchedulerProcess(@Param("processDefinitionCode") Long definitionCode,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("testFlag") int testFlag);
/**
* query last manual process instance
*
* @param definitionCode definitionCode
* @param taskCode taskCode
* @param startTime startTime
* @param endTime endTime
* @param testFlag testFlag
* @return process instance
*/
ProcessInstance queryLastManualProcess(@Param("processDefinitionCode") Long definitionCode,
@Param("taskCode") Long taskCode,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("testFlag") int testFlag);
/**
* query first schedule process instance
*
* @param definitionCode definitionCode
* @return process instance
*/
ProcessInstance queryFirstScheduleProcessInstance(@Param("processDefinitionCode") Long definitionCode);
/**
* query first manual process instance
*
* @param definitionCode definitionCode
* @return process instance
*/
ProcessInstance queryFirstStartProcessInstance(@Param("processDefinitionCode") Long definitionCode);
/**
* query top n process instance order by running duration
*
* @param size size
* @param startTime start time
* @param startTime end time
* @param status process instance status
* @param projectCode project code
* @return ProcessInstance list
*/
List<ProcessInstance> queryTopNProcessInstance(@Param("size") int size,
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("status") WorkflowExecutionStatus status,
@Param("projectCode") long projectCode);
/**
* query process instance by processDefinitionCode and stateArray
*
* @param processDefinitionCode processDefinitionCode
* @param states states array
* @return process instance list
*/
List<ProcessInstance> queryByProcessDefineCodeAndStatus(@Param("processDefinitionCode") Long processDefinitionCode,
@Param("states") int[] states);
List<ProcessInstance> queryByProcessDefineCodeAndProcessDefinitionVersionAndStatusAndNextId(@Param("processDefinitionCode") Long processDefinitionCode,
@Param("processDefinitionVersion") int processDefinitionVersion,
@Param("states") int[] states,
@Param("id") Integer id);
int updateGlobalParamsById(@Param("globalParams") String globalParams,
@Param("id") int id);
boolean updateNextProcessIdById(@Param("thisInstanceId") int thisInstanceId,
@Param("runningInstanceId") int runningInstanceId);
ProcessInstance loadNextProcess4Serial(@Param("processDefinitionCode") Long processDefinitionCode,
@Param("state") int state, @Param("id") int id);
/**
* Filter process instance
*
* @param page page
* @param processDefinitionCode processDefinitionCode
* @param name name
* @param host host
* @param startTime startTime
* @param endTime endTime
* @return process instance IPage
*/
IPage<ProcessInstance> queryProcessInstanceListV2Paging(Page<ProcessInstance> page,
@Param("projectCode") Long projectCode,
@Param("processDefinitionCode") Long processDefinitionCode,
@Param("name") String name,
@Param("startTime") String startTime,
@Param("endTime") String endTime,
@Param("state") Integer state,
@Param("host") String host);
/**
* Statistics process instance state v2
* <p>
* We only need project codes to determine whether the process instance belongs to the user or not.
*
* @param startTime startTime
* @param endTime endTime
* @param projectCode projectCode
* @param workflowCode workflowCode
* @param model model
* @param projectIds projectIds
* @return ExecuteStatusCount list
*/
List<ExecuteStatusCount> countInstanceStateV2(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectCode") Long projectCode,
@Param("workflowCode") Long workflowCode,
@Param("model") Integer model,
@Param("projectIds") Set<Integer> projectIds);
/**
* query process list by triggerCode
*
* @param triggerCode
* @return
*/
List<ProcessInstance> queryByTriggerCode(@Param("triggerCode") Long triggerCode);
}