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;
}
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;
}
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();
}
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();
}
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();
}
Aggregations