use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.
the class DataMatrixServiceImpl method modify.
/**
* 修改
*/
public void modify(final DataMatrix matrix) {
Assert.assertNotNull(matrix);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
DataMatrixDO matrixDo = modelToDo(matrix);
if (dataMatrixDao.checkUnique(matrixDo)) {
dataMatrixDao.update(matrixDo);
} else {
String exceptionCause = "exist the same repeat matrix in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## modify canal(" + matrix.getId() + ") has an exception!");
throw new ManagerException(e);
}
}
});
}
use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.
the class DataMatrixServiceImpl method modelToDo.
/**
* 用于Model对象转化为DO对象
*/
private DataMatrixDO modelToDo(DataMatrix matrix) {
DataMatrixDO matrixDo = new DataMatrixDO();
try {
matrixDo.setId(matrix.getId());
matrixDo.setGroupKey(matrix.getGroupKey());
matrixDo.setDescription(matrix.getDescription());
matrixDo.setMaster(matrix.getMaster());
matrixDo.setSlave(matrix.getSlave());
matrixDo.setGmtCreate(matrix.getGmtCreate());
matrixDo.setGmtModified(matrix.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the matrix Model to Do has an exception");
throw new ManagerException(e);
}
return matrixDo;
}
use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.
the class DataMatrixServiceImpl method listByIds.
public List<DataMatrix> listByIds(Long... identities) {
List<DataMatrix> matrixs = new ArrayList<DataMatrix>();
try {
List<DataMatrixDO> matrixDos = null;
if (identities.length < 1) {
matrixDos = dataMatrixDao.listAll();
if (matrixDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any canal, maybe hasn't create any canal.");
return matrixs;
}
} else {
matrixDos = dataMatrixDao.listByMultiId(identities);
if (matrixDos.isEmpty()) {
String exceptionCause = "couldn't query any canal by matrixIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
matrixs = doToModel(matrixDos);
} catch (Exception e) {
logger.error("ERROR ## query channels has an exception!");
throw new ManagerException(e);
}
return matrixs;
}
use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.
the class DataMatrixServiceImpl method findByGroupKey.
public DataMatrix findByGroupKey(String groupKey) {
Assert.assertNotNull(groupKey);
DataMatrixDO matrixDo = dataMatrixDao.findByGroupKey(groupKey);
if (matrixDo == null) {
String exceptionCause = "query name:" + groupKey + " return null.";
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
return doToModel(matrixDo);
}
use of com.alibaba.otter.manager.biz.config.datamatrix.dal.dataobject.DataMatrixDO in project otter by alibaba.
the class DataMatrixServiceImpl method create.
/**
* 添加
*/
public void create(final DataMatrix matrix) {
Assert.assertNotNull(matrix);
transactionTemplate.execute(new TransactionCallbackWithoutResult() {
protected void doInTransactionWithoutResult(TransactionStatus status) {
try {
DataMatrixDO matrixlDO = modelToDo(matrix);
matrixlDO.setId(0L);
if (!dataMatrixDao.checkUnique(matrixlDO)) {
String exceptionCause = "exist the same repeat canal in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
dataMatrixDao.insert(matrixlDO);
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create canal has an exception!");
throw new ManagerException(e);
}
}
});
}
Aggregations