Search in sources :

Example 56 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class SourceDbServiceImpl method updateBasic.

@Override
public boolean updateBasic(SourceDbBasicInfo basicInfo, String operator) {
    LOGGER.info("begin to update db data source basic={}", basicInfo);
    Preconditions.checkNotNull(basicInfo, "db data source basic is empty");
    // The groupId may be modified, it is necessary to determine whether the inlong group status of
    // the modified groupId supports modification
    this.checkGroupIsTempStatus(basicInfo.getInlongGroupId());
    // If id is empty, add
    if (basicInfo.getId() == null) {
        this.saveBasic(basicInfo, operator);
    } else {
        SourceDbBasicEntity basicEntity = dbBasicMapper.selectByPrimaryKey(basicInfo.getId());
        if (basicEntity == null) {
            LOGGER.error("db data source basic not found by id={}, update failed", basicInfo.getId());
            throw new BusinessException(ErrorCodeEnum.SOURCE_BASIC_NOT_FOUND);
        }
        BeanUtils.copyProperties(basicInfo, basicEntity);
        basicEntity.setModifier(operator);
        dbBasicMapper.updateByPrimaryKeySelective(basicEntity);
    }
    LOGGER.info("success to update db data source basic");
    return true;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) SourceDbBasicEntity(org.apache.inlong.manager.dao.entity.SourceDbBasicEntity)

Example 57 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class SourceFileServiceImpl method updateDetail.

@Transactional(rollbackFor = Throwable.class)
@Override
public boolean updateDetail(SourceFileDetailInfo detailInfo, String operator) {
    LOGGER.info("begin to update file data source detail={}", detailInfo);
    Preconditions.checkNotNull(detailInfo, "file data source detail is empty");
    Integer id = detailInfo.getId();
    Preconditions.checkNotNull(id, Constant.ID_IS_EMPTY);
    SourceFileDetailEntity entity = fileDetailMapper.selectByPrimaryKey(id);
    if (entity == null) {
        LOGGER.error("file data source detail not found by id=" + id);
        throw new BusinessException(ErrorCodeEnum.SOURCE_DETAIL_NOT_FOUND);
    }
    // After the approval is passed, the status needs to be revised to be revised to be issued: 205
    this.checkGroupIsTempStatus(detailInfo.getInlongGroupId());
    detailInfo.setStatus(EntityStatus.AGENT_ADD.getCode());
    SourceFileDetailEntity updateEntity = CommonBeanUtils.copyProperties(detailInfo, SourceFileDetailEntity::new);
    updateEntity.setModifier(operator);
    updateEntity.setModifyTime(new Date());
    fileDetailMapper.updateByPrimaryKeySelective(updateEntity);
    LOGGER.info("success to update file data source detail");
    return true;
}
Also used : BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) SourceFileDetailEntity(org.apache.inlong.manager.dao.entity.SourceFileDetailEntity) Date(java.util.Date) Transactional(org.springframework.transaction.annotation.Transactional)

Example 58 with BusinessException

use of org.apache.inlong.manager.common.exceptions.BusinessException in project incubator-inlong by apache.

the class SourceFileServiceImpl method saveBasic.

@Override
public Integer saveBasic(SourceFileBasicInfo basicInfo, String operator) {
    LOGGER.info("begin to save file data source basic={}", basicInfo);
    Preconditions.checkNotNull(basicInfo, "file data source basic is empty");
    String groupId = basicInfo.getInlongGroupId();
    String streamId = basicInfo.getInlongStreamId();
    Preconditions.checkNotNull(groupId, Constant.GROUP_ID_IS_EMPTY);
    Preconditions.checkNotNull(streamId, Constant.STREAM_ID_IS_EMPTY);
    // Check if it can be added
    this.checkGroupIsTempStatus(groupId);
    // Each groupId + streamId has only 1 valid basic information
    SourceFileBasicEntity exist = fileBasicMapper.selectByIdentifier(groupId, streamId);
    if (exist != null) {
        LOGGER.error("file data source basic already exists, please check");
        throw new BusinessException(ErrorCodeEnum.SOURCE_DUPLICATE);
    }
    SourceFileBasicEntity entity = CommonBeanUtils.copyProperties(basicInfo, SourceFileBasicEntity::new);
    entity.setCreator(operator);
    entity.setModifier(operator);
    entity.setCreateTime(new Date());
    fileBasicMapper.insertSelective(entity);
    LOGGER.info("success to save file data source basic");
    return entity.getId();
}
Also used : SourceFileBasicEntity(org.apache.inlong.manager.dao.entity.SourceFileBasicEntity) BusinessException(org.apache.inlong.manager.common.exceptions.BusinessException) Date(java.util.Date)

Aggregations

BusinessException (org.apache.inlong.manager.common.exceptions.BusinessException)58 Date (java.util.Date)20 Transactional (org.springframework.transaction.annotation.Transactional)18 InlongGroupEntity (org.apache.inlong.manager.dao.entity.InlongGroupEntity)14 StreamSinkEntity (org.apache.inlong.manager.dao.entity.StreamSinkEntity)8 InlongStreamEntity (org.apache.inlong.manager.dao.entity.InlongStreamEntity)7 InlongGroupInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupInfo)6 SourceFileDetailEntity (org.apache.inlong.manager.dao.entity.SourceFileDetailEntity)5 ThirdPartyClusterEntity (org.apache.inlong.manager.dao.entity.ThirdPartyClusterEntity)5 GroupState (org.apache.inlong.manager.common.enums.GroupState)4 InlongGroupPulsarEntity (org.apache.inlong.manager.dao.entity.InlongGroupPulsarEntity)4 SourceDbDetailEntity (org.apache.inlong.manager.dao.entity.SourceDbDetailEntity)4 PulsarClusterInfo (org.apache.inlong.common.pojo.dataproxy.PulsarClusterInfo)3 InlongGroupPulsarInfo (org.apache.inlong.manager.common.pojo.group.InlongGroupPulsarInfo)3 GroupResourceProcessForm (org.apache.inlong.manager.common.pojo.workflow.form.GroupResourceProcessForm)3 SourceDbBasicEntity (org.apache.inlong.manager.dao.entity.SourceDbBasicEntity)3 ColumnPositionMappingStrategy (com.opencsv.bean.ColumnPositionMappingStrategy)2 ApiOperation (io.swagger.annotations.ApiOperation)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2