Search in sources :

Example 6 with DataMediaDO

use of com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO in project otter by alibaba.

the class DataMediaServiceImpl method create.

/**
     * 添加
     */
@Override
public void create(DataMedia dataMedia) {
    Assert.assertNotNull(dataMedia);
    try {
        DataMediaDO dataMediaDo = modelToDo(dataMedia);
        dataMediaDo.setId(0L);
        if (!dataMediaDao.checkUnique(dataMediaDo)) {
            String exceptionCause = "exist the same name dataMedia in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
        dataMediaDao.insert(dataMediaDo);
    } catch (RepeatConfigureException rce) {
        throw rce;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMedia has an exception!");
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) 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 7 with DataMediaDO

use of com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO in project otter by alibaba.

the class DataMediaServiceImpl method modelToDo.

/**
     * 用于Model对象转化为DO对象
     * 
     * @param dataMedia
     * @return DataMediaDO
     */
private DataMediaDO modelToDo(DataMedia dataMedia) {
    DataMediaDO dataMediaDo = new DataMediaDO();
    try {
        dataMediaDo.setId(dataMedia.getId());
        dataMediaDo.setName(dataMedia.getName());
        dataMediaDo.setNamespace(dataMedia.getNamespace());
        dataMediaDo.setDataMediaSourceId(dataMedia.getSource().getId());
        // if (dataMedia instanceof DbDataMedia) {
        // dataMediaDo.setProperties(JsonUtils.marshalToString((DbDataMedia) dataMedia));
        // }
        dataMediaDo.setProperties(JsonUtils.marshalToString(dataMedia));
        dataMediaDo.setGmtCreate(dataMedia.getGmtCreate());
        dataMediaDo.setGmtModified(dataMedia.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMedia Model to Do has an exception");
        throw new ManagerException(e);
    }
    return dataMediaDo;
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) 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)7 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)7 DataMediaDO (com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO)7 ArrayList (java.util.ArrayList)3 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)2 DbDataMedia (com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)2 MqDataMedia (com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia)2