Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@

package org.apache.dolphinscheduler.dao.entity;

import org.apache.dolphinscheduler.common.enums.CycleEnum;
import org.apache.dolphinscheduler.common.utils.JSONUtils;
import org.apache.dolphinscheduler.plugin.task.api.model.DependentItem;
import org.apache.dolphinscheduler.plugin.task.api.model.DependentTaskModel;
import org.apache.dolphinscheduler.plugin.task.api.parameters.DependentParameters;

import java.util.List;

import lombok.Data;

@Data
Expand All @@ -32,4 +40,46 @@ public class DependentWorkflowDefinition {

private String workerGroup;

public CycleEnum getDependentCycle(long upstreamProcessDefinitionCode) {
DependentParameters dependentParameters = this.getDependentParameters();
List<DependentTaskModel> dependentTaskModelList = dependentParameters.getDependence().getDependTaskList();

for (DependentTaskModel dependentTaskModel : dependentTaskModelList) {
List<DependentItem> dependentItemList = dependentTaskModel.getDependItemList();
for (DependentItem dependentItem : dependentItemList) {
if (upstreamProcessDefinitionCode == dependentItem.getDefinitionCode()) {
return cycle2CycleEnum(dependentItem.getCycle());
}
}
}

return CycleEnum.DAY;
}

public CycleEnum cycle2CycleEnum(String cycle) {
CycleEnum cycleEnum = null;

switch (cycle) {
case "day":
cycleEnum = CycleEnum.DAY;
break;
case "hour":
cycleEnum = CycleEnum.HOUR;
break;
case "week":
cycleEnum = CycleEnum.WEEK;
break;
case "month":
cycleEnum = CycleEnum.MONTH;
break;
default:
break;
}
return cycleEnum;
}

public DependentParameters getDependentParameters() {
return JSONUtils.parseObject(taskParams, DependentParameters.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@
*/
String queryAlertGroupInstanceIdsById(@Param("alertGroupId") int alertGroupId);

/**
* list authorized AlertGroup
* @param userId
* @param alertGroupsIds
* @return
*/
<T> List<AlertGroup> listAuthorizedAlertGroupList(@Param("userId") int userId,

Check warning on line 90 in dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/AlertGroupMapper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

T is not used in the method.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZ3hz5LsOywZVpvvqJrB&open=AZ3hz5LsOywZVpvvqJrB&pullRequest=18206
@Param("alertGroupsIds") List<Integer> alertGroupsIds);

/**
* queryAlertGroupPageByIds
* @param page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ IPage<DataSource> selectPaging(IPage<DataSource> page,
<T> List<DataSource> listAuthorizedDataSource(@Param("userId") int userId,
@Param("dataSourceIds") T[] dataSourceIds);

/**
* query datasource by name and user id
*
* @param userId userId
* @param name datasource name
* @return If the name does not exist or the user does not have permission, it will return null
*/
DataSource queryDataSourceByNameAndUserId(@Param("userId") int userId, @Param("name") String name);

/**
* selectPagingByIds
* @param dataSourcePage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ IPage<K8sNamespace> queryK8sNamespacePaging(IPage<K8sNamespace> page,
*/
Boolean existNamespace(@Param("namespace") String namespace, @Param("clusterCode") Long clusterCode);

/**
* query namespace except userId
*
* @param userId userId
* @return namespace list
*/
List<K8sNamespace> queryNamespaceExceptUserId(@Param("userId") int userId);

/**
* query authed namespace list by userId
*
Expand All @@ -58,4 +66,11 @@ IPage<K8sNamespace> queryK8sNamespacePaging(IPage<K8sNamespace> page,
*/
List<K8sNamespace> queryAuthedNamespaceListByUserId(@Param("userId") Integer userId);

/**
* check the target namespace
*
* @param namespaceCode namespaceCode
* @return true if exist else return null
*/
K8sNamespace queryByNamespaceCode(@Param("clusterCode") Long namespaceCode);
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,13 @@ public interface K8sNamespaceUserMapper extends BaseMapper<K8sNamespaceUser> {
int deleteNamespaceRelation(@Param("namespaceId") int namespaceId,
@Param("userId") int userId);

/**
* query namespace relation
*
* @param namespaceId namespaceId
* @param userId userId
* @return namespace user relation
*/
K8sNamespaceUser queryNamespaceRelation(@Param("namespaceId") int namespaceId,
@Param("userId") int userId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ public interface ProjectMapper extends BaseMapper<Project> {
*/
Project queryDetailById(@Param("projectId") int projectId);

/**
* query project detail by code
* @param projectCode projectCode
* @return project
*/
Project queryDetailByCode(@Param("projectCode") long projectCode);

/**
* query project by name
* @param projectName projectName
Expand Down Expand Up @@ -84,6 +91,13 @@ IPage<Project> queryProjectListPaging(IPage<Project> page,
*/
List<Project> queryAuthedProjectListByUserId(@Param("userId") int userId);

/**
* query relation project list by userId
* @param userId userId
* @return project list
*/
List<Project> queryRelationProjectListByUserId(@Param("userId") int userId);

/**
* query project except userId
* @param userId userId
Expand Down Expand Up @@ -116,6 +130,7 @@ IPage<Project> queryProjectListPaging(IPage<Project> page,
* list authorized Projects
* @param userId
* @param projectsIds
* @param <T>
* @return
*/
List<Project> listAuthorizedProjects(@Param("userId") int userId, @Param("projectsIds") List<Integer> projectsIds);
Expand All @@ -133,4 +148,10 @@ IPage<Project> queryProjectListPaging(IPage<Project> page,
*/
Project queryProjectByTaskInstanceId(@Param("taskInstanceId") int taskInstanceId);

/**
* query all workflow count
* @param projectsCodes projectsCodes
* @return workflow count
*/
int queryAllWorkflowCounts(@Param("projectsCodes") List<Long> projectsCodes);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ public interface RelationSubWorkflowMapper extends BaseMapper<RelationSubWorkflo
List<RelationSubWorkflow> queryAllSubWorkflowInstance(@Param("parentWorkflowInstanceId") Long parentWorkflowInstanceId,
@Param("parentTaskCode") Long parentTaskCode);

RelationSubWorkflow queryParentWorkflowInstance(@Param("subWorkflowInstanceId") Long subWorkflowInstanceId);

}
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ IPage<Schedule> queryByProjectAndWorkflowDefinitionCodePaging(IPage<Schedule> pa
@Param("workflowDefinitionCode") long workflowDefinitionCode,
@Param("searchVal") String searchVal);

/**
* Filter schedule
*
* @param page page
* @param schedule schedule
* @return schedule IPage
*/
IPage<Schedule> filterSchedules(IPage<Schedule> page,
@Param("schedule") Schedule schedule);

/**
* query schedule list by project name
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.dolphinscheduler.dao.entity.TaskDefinition;
import org.apache.dolphinscheduler.dao.entity.TaskDefinitionLog;
import org.apache.dolphinscheduler.dao.entity.TaskMainInfo;
import org.apache.dolphinscheduler.dao.model.WorkflowDefinitionCountDto;

import org.apache.ibatis.annotations.Param;
Expand All @@ -27,6 +28,7 @@
import java.util.List;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;

public interface TaskDefinitionMapper extends BaseMapper<TaskDefinition> {

Expand Down Expand Up @@ -82,6 +84,15 @@ TaskDefinition queryByName(@Param("projectCode") long projectCode,
*/
int batchInsert(@Param("taskDefinitions") List<TaskDefinitionLog> taskDefinitions);

/**
* task main info
* @param projectCode project code
* @param codeList code list
* @return task main info
*/
List<TaskMainInfo> queryDefineListByCodeList(@Param("projectCode") long projectCode,
@Param("codeList") List<Long> codeList);

/**
* query task definition by code list
*
Expand All @@ -90,6 +101,16 @@ TaskDefinition queryByName(@Param("projectCode") long projectCode,
*/
List<TaskDefinition> queryByCodeList(@Param("codes") Collection<Long> codes);

/**
* Filter task definition
*
* @param page page
* @param taskDefinition task definition
* @return task definition IPage
*/
IPage<TaskDefinition> filterTaskDefinition(IPage<TaskDefinition> page,
@Param("task") TaskDefinition taskDefinition);

/**
* batch delete task by task code
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,18 @@
*/
public interface TaskGroupQueueMapper extends BaseMapper<TaskGroupQueue> {

/**
* select task group queues by some conditions
*
* @param page page
* @param groupId group id
* @return task group queue list
*/
IPage<TaskGroupQueue> queryTaskGroupQueuePaging(IPage<TaskGroupQueue> page,
@Param("groupId") int groupId);

TaskGroupQueue queryByTaskId(@Param("taskId") int taskId);

/**
* query by status
*
Expand All @@ -61,6 +73,24 @@ public interface TaskGroupQueueMapper extends BaseMapper<TaskGroupQueue> {
*/
int updateStatusByTaskId(@Param("taskId") int taskId, @Param("status") int status);

/**
* Query the {@link TaskGroupQueue}, who's priority > the given <code>priority</code>
*/
List<TaskGroupQueue> queryHighPriorityTasks(@Param("groupId") int groupId, @Param("priority") int priority,
@Param("status") int status);

TaskGroupQueue queryTheHighestPriorityTasks(@Param("groupId") int groupId, @Param("status") int status,
@Param("forceStart") int forceStart, @Param("inQueue") int inQueue);

void updateInQueue(@Param("inQueue") int inQueue, @Param("id") int id);

void updateForceStart(@Param("queueId") int queueId, @Param("forceStart") int forceStart);

int updateInQueueLimit1(@Param("oldValue") int oldValue, @Param("newValue") int newValue, @Param("groupId") int id,
@Param("status") int status);

int updateInQueueCAS(@Param("oldValue") int oldValue, @Param("newValue") int newValue, @Param("id") int id);

void modifyPriority(@Param("queueId") int queueId, @Param("priority") int priority);

IPage<TaskGroupQueue> queryTaskGroupQueueByTaskGroupIdPaging(Page<TaskGroupQueue> page,
Expand All @@ -70,12 +100,17 @@ IPage<TaskGroupQueue> queryTaskGroupQueueByTaskGroupIdPaging(Page<TaskGroupQueue
@Param("groupId") int groupId,
@Param("projects") List<Project> projects);

void deleteByTaskInstanceIds(@Param("taskInstanceIds") List<Integer> taskInstanceIds);

void deleteByWorkflowInstanceId(@Param("workflowInstanceId") Integer workflowInstanceId);

void deleteByWorkflowInstanceIds(@Param("workflowInstanceIds") List<Integer> workflowInstanceIds);

void deleteByTaskGroupIds(@Param("taskGroupIds") List<Integer> taskGroupIds);

void updateTaskGroupPriorityByTaskInstanceId(@Param("taskInstanceId") Integer taskInstanceId,
@Param("priority") int taskGroupPriority);

List<TaskGroupQueue> queryAllInQueueTaskGroupQueueByGroupId(@Param("taskGroupId") Integer taskGroupId,
@Param("inQueue") int inQueue);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@

import org.apache.dolphinscheduler.common.enums.Flag;
import org.apache.dolphinscheduler.common.enums.TaskExecuteType;
import org.apache.dolphinscheduler.dao.entity.ExecuteStatusCount;
import org.apache.dolphinscheduler.dao.entity.TaskInstance;
import org.apache.dolphinscheduler.dao.model.TaskInstanceStatusCountDto;
import org.apache.dolphinscheduler.plugin.task.api.enums.TaskExecutionStatus;

import org.apache.ibatis.annotations.Param;

Expand Down Expand Up @@ -57,6 +59,41 @@
@Param("endTime") Date endTime,
@Param("projectCodes") Collection<Long> projectCodes);

/**
* Statistics task instance group by given project ids list by start time
* <p>
* We only need project ids to determine whether the task instance belongs to the user or not.
*
* @param startTime Statistics start time
* @param endTime Statistics end time
* @param projectIds Project ids list to filter
* @return List of ExecuteStatusCount
*/
List<ExecuteStatusCount> countTaskInstanceStateByProjectIdsV2(@Param("startTime") Date startTime,
@Param("endTime") Date endTime,
@Param("projectIds") Set<Integer> projectIds);

/**
* Statistics task instance group by given project codes list by submit time
* <p>
* We only need project codes to determine whether the task instance belongs to the user or not.
*
* @param startTime Statistics start time
* @param endTime Statistics end time
* @param projectCode projectCode
* @param model model
* @param projectIds projectIds
* @return List of ExecuteStatusCount
*/
List<ExecuteStatusCount> countTaskInstanceStateByProjectCodesAndStatesBySubmitTimeV2(@Param("startTime") Date startTime,

Check warning on line 88 in dolphinscheduler-dao/src/main/java/org/apache/dolphinscheduler/dao/mapper/TaskInstanceMapper.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Method has 8 parameters, which is greater than 7 authorized.

See more on https://sonarcloud.io/project/issues?id=apache-dolphinscheduler&issues=AZ3hz5LdOywZVpvvqJrA&open=AZ3hz5LdOywZVpvvqJrA&pullRequest=18206
@Param("endTime") Date endTime,
@Param("projectCode") Long projectCode,
@Param("workflowCode") Long workflowCode,
@Param("taskCode") Long taskCode,
@Param("model") Integer model,
@Param("projectIds") Set<Integer> projectIds,
@Param("states") List<TaskExecutionStatus> states);

IPage<TaskInstance> queryTaskInstanceListPaging(IPage<TaskInstance> page,
@Param("projectCode") Long projectCode,
@Param("workflowInstanceId") Integer workflowInstanceId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

public interface TenantMapper extends BaseMapper<Tenant> {

Expand Down Expand Up @@ -79,6 +80,16 @@ IPage<Tenant> queryTenantPaging(IPage<Tenant> page, @Param("ids") List<Integer>
*/
Boolean existTenant(@Param("tenantCode") String tenantCode);

/**
* queryTenantPagingByIds
* @param page
* @param ids
* @param searchVal
* @return
*/
IPage<Tenant> queryTenantPagingByIds(Page<Tenant> page, @Param("ids") List<Integer> ids,
@Param("searchVal") String searchVal);

/**
* queryAll
* @return
Expand Down
Loading
Loading