use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataColumnPairGroupServiceImpl method listByDataMediaPairIds.
@Override
public Map<Long, List<ColumnGroup>> listByDataMediaPairIds(Long... dataMediaPairIds) {
Assert.assertNotNull(dataMediaPairIds);
Map<Long, List<ColumnGroup>> dataColumnGroups = new HashMap<Long, List<ColumnGroup>>();
try {
List<DataColumnPairGroupDO> dataColumnPairGroupDos = dataColumnPairGroupDao.ListByDataMediaPairIds(dataMediaPairIds);
if (CollectionUtils.isEmpty(dataColumnPairGroupDos)) {
logger.debug("DEBUG ## couldn't query any dataColumnPairGroup, maybe hasn't create any dataColumnPairGroup.");
return dataColumnGroups;
}
for (DataColumnPairGroupDO dataColumnPairGroupDo : dataColumnPairGroupDos) {
List<ColumnGroup> columnGroups = dataColumnGroups.get(dataColumnPairGroupDo.getDataMediaPairId());
if (columnGroups != null) {
if (!columnGroups.contains(doToModel(dataColumnPairGroupDo))) {
columnGroups.add(doToModel(dataColumnPairGroupDo));
}
} else {
columnGroups = new ArrayList<ColumnGroup>();
columnGroups.add(doToModel(dataColumnPairGroupDo));
dataColumnGroups.put(dataColumnPairGroupDo.getDataMediaPairId(), columnGroups);
}
}
} catch (Exception e) {
logger.error("ERROR ## query dataColumnPairGroup by dataMediaId:" + dataMediaPairIds + " has an exception!");
throw new ManagerException(e);
}
return dataColumnGroups;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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.common.exceptions.ManagerException in project otter by alibaba.
the class DataMatrixServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*/
private DataMatrix doToModel(DataMatrixDO matrixDo) {
DataMatrix matrix = new DataMatrix();
try {
matrix.setId(matrixDo.getId());
matrix.setGroupKey(matrixDo.getGroupKey());
matrix.setDescription(matrixDo.getDescription());
matrix.setMaster(matrixDo.getMaster());
matrix.setSlave(matrixDo.getSlave());
matrix.setGmtCreate(matrixDo.getGmtCreate());
matrix.setGmtModified(matrixDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the canal Do to Model has an exception");
throw new ManagerException(e);
}
return matrix;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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.common.exceptions.ManagerException 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);
}
}
});
}
Aggregations