Search in sources :

Example 1 with InlongGroupEntity

use of org.apache.inlong.manager.dao.entity.InlongGroupEntity in project incubator-inlong by apache.

the class CommonOperateService method checkGroupStatus.

/**
 * Check whether the inlong group status is temporary
 *
 * @param groupId Inlong group id
 * @return Inlong group entity, for caller reuse
 */
public InlongGroupEntity checkGroupStatus(String groupId, String operator) {
    InlongGroupEntity inlongGroupEntity = groupMapper.selectByGroupId(groupId);
    Preconditions.checkNotNull(inlongGroupEntity, "groupId is invalid");
    List<String> managers = Arrays.asList(inlongGroupEntity.getInCharges().split(","));
    Preconditions.checkTrue(managers.contains(operator), String.format(ErrorCodeEnum.USER_IS_NOT_MANAGER.getMessage(), operator, managers));
    GroupState state = GroupState.forCode(inlongGroupEntity.getStatus());
    // Add/modify/delete is not allowed under certain group state
    if (GroupState.notAllowedUpdate(state)) {
        LOGGER.error("inlong group status was not allowed to add/update/delete related info");
        throw new BusinessException(ErrorCodeEnum.OPT_NOT_ALLOWED_BY_STATUS);
    }
    return inlongGroupEntity;
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) GroupState(org.apache.inlong.manager.common.enums.GroupState)

Example 2 with InlongGroupEntity

use of org.apache.inlong.manager.dao.entity.InlongGroupEntity in project incubator-inlong by apache.

the class StreamSourceServiceImpl method logicDeleteAll.

@Override
@Transactional(rollbackFor = Throwable.class)
public boolean logicDeleteAll(String groupId, String streamId, String operator) {
    LOGGER.info("begin to logic delete all source info by groupId={}, streamId={}", groupId, streamId);
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
    // Check if it can be deleted
    InlongGroupEntity groupEntity = commonOperateService.checkGroupStatus(groupId, operator);
    Integer nextStatus;
    if (GroupState.CONFIG_SUCCESSFUL.getCode().equals(groupEntity.getStatus())) {
        nextStatus = SourceState.TO_BE_ISSUED_DELETE.getCode();
    } else {
        nextStatus = SourceState.SOURCE_DISABLE.getCode();
    }
    Date now = new Date();
    List<StreamSourceEntity> entityList = sourceMapper.selectByRelatedId(groupId, streamId);
    if (CollectionUtils.isNotEmpty(entityList)) {
        for (StreamSourceEntity entity : entityList) {
            Integer id = entity.getId();
            entity.setPreviousStatus(entity.getStatus());
            entity.setStatus(nextStatus);
            entity.setIsDeleted(id);
            entity.setModifier(operator);
            entity.setModifyTime(now);
            sourceMapper.updateByPrimaryKeySelective(entity);
        }
    }
    LOGGER.info("success to logic delete all source by groupId={}, streamId={}", groupId, streamId);
    return true;
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) StreamSourceEntity(org.apache.inlong.manager.dao.entity.StreamSourceEntity) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with InlongGroupEntity

use of org.apache.inlong.manager.dao.entity.InlongGroupEntity in project incubator-inlong by apache.

the class GroupCancelProcessListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewGroupProcessForm form = (NewGroupProcessForm) context.getProcessForm();
    // After canceling the approval, the status becomes [Waiting to submit]
    String groupId = form.getInlongGroupId();
    // Only the [Wait approval] status allowed the canceling operation
    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("current status was not allowed to cancel business");
    }
    // After canceling the approval, the status becomes [Waiting to submit]
    String username = context.getApplicant();
    groupMapper.updateStatus(groupId, GroupState.TO_BE_SUBMIT.getCode(), username);
    return ListenerResult.success();
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) NewGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Example 4 with InlongGroupEntity

use of org.apache.inlong.manager.dao.entity.InlongGroupEntity 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)

Example 5 with InlongGroupEntity

use of org.apache.inlong.manager.dao.entity.InlongGroupEntity in project incubator-inlong by apache.

the class GroupRejectProcessListener method listen.

@Override
public ListenerResult listen(WorkflowContext context) throws WorkflowListenerException {
    NewGroupProcessForm form = (NewGroupProcessForm) context.getProcessForm();
    // Only the [Wait approval] status allowed the rejecting operation
    String groupId = form.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("current status was not allowed to reject inlong group");
    }
    // After reject, update inlong group status to [GROUP_APPROVE_REJECT]
    String username = context.getApplicant();
    groupService.updateStatus(groupId, GroupState.APPROVE_REJECTED.getCode(), username);
    return ListenerResult.success();
}
Also used : InlongGroupEntity(org.apache.inlong.manager.dao.entity.InlongGroupEntity) NewGroupProcessForm(org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm) WorkflowListenerException(org.apache.inlong.manager.common.exceptions.WorkflowListenerException)

Aggregations

InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)26 BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)14 Transactional (org.springframework.transaction.annotation.Transactional)11 Date (java.util.Date)5 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)5 InlongGroupPulsarEntity (org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity)4 ArrayList (java.util.ArrayList)3 GroupState (org.apache.inlong.manager.common.enums.GroupState)3 WorkflowListenerException (org.apache.inlong.manager.common.exceptions.WorkflowListenerException)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)3 DataProxyConfig (org.apache.inlong.common.pojo.dataproxy.DataProxyConfig)2 InlongGroupRequest (org.apache.inlong.manager.common.pojo.group.InlongGroupRequest)2 NewGroupProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.NewGroupProcessForm)2 SourceFileDetailEntity (org.apache.inlong.manager.dao.entity.SourceFileDetailEntity)2 Test (org.junit.Test)2 Page (com.github.pagehelper.Page)1 PageInfo (com.github.pagehelper.PageInfo)1 List (java.util.List)1 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)1 ThirdPartyClusterDTO (org.apache.inlong.common.pojo.dataproxy.ThirdPartyClusterDTO)1