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