Search in sources :

Example 1 with DataMediaSourceDO

use of com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO in project otter by alibaba.

the class DataMediaSourceServiceImpl method modify.

/**
 * 修改
 */
public void modify(DataMediaSource dataMediaSource) {
    Assert.assertNotNull(dataMediaSource);
    try {
        DataMediaSourceDO dataMediaSourceDo = modelToDo(dataMediaSource);
        if (dataMediaSourceDao.checkUnique(dataMediaSourceDo)) {
            dataMediaSourceDao.update(dataMediaSourceDo);
        } else {
            String exceptionCause = "exist the same name source in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## modify dataMediaSource has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 2 with DataMediaSourceDO

use of com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO in project otter by alibaba.

the class DataMediaSourceServiceImpl method create.

/**
 * 添加
 */
public void create(DataMediaSource dataMediaSource) {
    Assert.assertNotNull(dataMediaSource);
    try {
        DataMediaSourceDO dataMediaSourceDo = modelToDo(dataMediaSource);
        dataMediaSourceDo.setId(0L);
        if (!dataMediaSourceDao.checkUnique(dataMediaSourceDo)) {
            String exceptionCause = "exist the same name source in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
        dataMediaSourceDao.insert(dataMediaSourceDo);
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMediaSource has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 3 with DataMediaSourceDO

use of com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO in project otter by alibaba.

the class DataMediaSourceServiceImpl method modelToDo.

/**
 * 类型:数据库类型 Mysql和Oracle 用于Model对象转化为DO对象
 *
 * @param dataMediaSource
 * @return DataMediaSourceDO
 */
private DataMediaSourceDO modelToDo(DataMediaSource dataMediaSource) {
    DataMediaSourceDO dataMediaSourceDo = new DataMediaSourceDO();
    try {
        dataMediaSourceDo.setId(dataMediaSource.getId());
        dataMediaSourceDo.setName(dataMediaSource.getName());
        dataMediaSourceDo.setType(dataMediaSource.getType());
        if (dataMediaSource instanceof DbMediaSource) {
            dataMediaSourceDo.setProperties(JsonUtils.marshalToString((DbMediaSource) dataMediaSource));
        } else if (dataMediaSource instanceof MqMediaSource) {
            dataMediaSourceDo.setProperties(JsonUtils.marshalToString((MqMediaSource) dataMediaSource));
        }
        dataMediaSourceDo.setGmtCreate(dataMediaSource.getGmtCreate());
        dataMediaSourceDo.setGmtModified(dataMediaSource.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaSource Model to Do has an exception");
        throw new ManagerException(e);
    }
    return dataMediaSourceDo;
}
Also used : MqMediaSource(com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource) DbMediaSource(com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 4 with DataMediaSourceDO

use of com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO in project otter by alibaba.

the class DataMediaSourceServiceImpl method listByCondition.

@Override
public List<DataMediaSource> listByCondition(Map condition) {
    List<DataMediaSource> dataMediaSources = new ArrayList<DataMediaSource>();
    try {
        List<DataMediaSourceDO> dataMediaSourceDos = dataMediaSourceDao.listByCondition(condition);
        if (dataMediaSourceDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any DataMediaSources by the condition:" + JsonUtils.marshalToString(condition));
            return dataMediaSources;
        }
        dataMediaSources = doToModel(dataMediaSourceDos);
    } catch (Exception e) {
        logger.error("ERROR ## query DataMediaSources by condition has an exception!");
        throw new ManagerException(e);
    }
    return dataMediaSources;
}
Also used : ArrayList(java.util.ArrayList) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DataMediaSourceDO(com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Aggregations

ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)4 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)4 DataMediaSourceDO (com.alibaba.otter.manager.biz.config.datamediasource.dal.dataobject.DataMediaSourceDO)4 DataMediaSource (com.alibaba.otter.shared.common.model.config.data.DataMediaSource)1 DbMediaSource (com.alibaba.otter.shared.common.model.config.data.db.DbMediaSource)1 MqMediaSource (com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource)1 ArrayList (java.util.ArrayList)1