Search in sources :

Example 1 with InlongGroupApproveForm

use of org.apache.inlong.manager.common.pojo.workflow.form.InlongGroupApproveForm in project incubator-inlong by apache.

the class GroupPassTaskListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    // Save the data format selected at the time of approval and the cluster information of the inlong stream
    InlongGroupApproveForm form = (InlongGroupApproveForm) context.getActionContext().getForm();
    InlongGroupApproveRequest approveInfo = form.getGroupApproveInfo();
    // Only the [Wait approval] status allowed the passing operation
    String groupId = approveInfo.getInlongGroupId();
    InlongGroupEntity entity = groupMapper.selectByGroupId(groupId);
    if (entity == null) {
        throw new WorkflowListenerException("inlong group not found with group id=" + groupId);
    }
    if (!Objects.equals(GroupState.TO_BE_APPROVAL.getCode(), entity.getStatus())) {
        throw new WorkflowListenerException("inlong group status is [wait_approval], not allowed to approve again");
    }
    // Save the inlong group information after approval
    groupService.updateAfterApprove(approveInfo, context.getApplicant());
    // Save inlong stream information after approval
    List<InlongStreamApproveRequest> streamApproveInfoList = form.getStreamApproveInfoList();
    streamService.updateAfterApprove(streamApproveInfoList, context.getApplicant());
    return ListenerResult.success();
}
Also used : InlongGroupApproveForm(org.apache.inlong.manager.common.pojo.workflow.form.InlongGroupApproveForm) InlongStreamApproveRequest(org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest) InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException) InlongGroupApproveRequest(org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)

Aggregations

WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)1 InlongGroupApproveRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupApproveRequest)1 InlongStreamApproveRequest (org.apache.inlong.manager.common.pojo.stream.InlongStreamApproveRequest)1 InlongGroupApproveForm (org.apache.inlong.manager.common.pojo.workflow.form.InlongGroupApproveForm)1 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)1