use of com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO in project otter by alibaba.
the class CanalServiceImpl method listByIds.
public List<Canal> listByIds(Long... identities) {
List<Canal> canals = new ArrayList<Canal>();
try {
List<CanalDO> canalDos = null;
if (identities.length < 1) {
canalDos = canalDao.listAll();
if (canalDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any canal, maybe hasn't create any canal.");
return canals;
}
} else {
canalDos = canalDao.listByMultiId(identities);
if (canalDos.isEmpty()) {
String exceptionCause = "couldn't query any canal by canalIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
canals = doToModel(canalDos);
} catch (Exception e) {
logger.error("ERROR ## query channels has an exception!");
throw new ManagerException(e);
}
return canals;
}
use of com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO in project otter by alibaba.
the class CanalServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*
* @param canal
* @return CanalDO
*/
private CanalDO modelToDo(Canal canal) {
CanalDO canalDo = new CanalDO();
try {
canalDo.setId(canal.getId());
canalDo.setName(canal.getName());
canalDo.setStatus(canal.getStatus());
canalDo.setDescription(canal.getDesc());
canalDo.setParameters(canal.getCanalParameter());
canalDo.setGmtCreate(canal.getGmtCreate());
canalDo.setGmtModified(canal.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the canal Model to Do has an exception");
throw new ManagerException(e);
}
return canalDo;
}
use of com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO in project otter by alibaba.
the class CanalServiceImpl method modify.
/**
* 修改
*/
public void modify(final Canal canal) {
Assert.assertNotNull(canal);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
CanalDO canalDo = modelToDo(canal);
if (canalDao.checkUnique(canalDo)) {
canalDao.update(canalDo);
} else {
String exceptionCause = "exist the same repeat canal in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## modify canal(" + canal.getId() + ") has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO in project otter by alibaba.
the class CanalServiceImpl method findByName.
public Canal findByName(String name) {
Assert.assertNotNull(name);
CanalDO canalDo = canalDao.findByName(name);
if (canalDo == null) {
String exceptionCause = "query name:" + name + " return null.";
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
return doToModel(canalDo);
}
use of com.alibaba.otter.manager.biz.config.canal.dal.dataobject.CanalDO in project otter by alibaba.
the class CanalServiceImpl method create.
/**
* 添加
*/
public void create(final Canal canal) {
Assert.assertNotNull(canal);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
CanalDO canalDO = modelToDo(canal);
canalDO.setId(0L);
if (!canalDao.checkUnique(canalDO)) {
String exceptionCause = "exist the same repeat canal in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
canalDao.insert(canalDO);
canal.setId(canalDO.getId());
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create canal has an exception!");
throw new ManagerException(e);
}
}
});
}
Aggregations