use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaPairServiceImpl method doToModel.
/*-------------------------------------------------------------*/
private DataMediaPair doToModel(DataMediaPairDO dataMediaPairDo, List<ColumnPair> columnPairs, List<ColumnGroup> columnGroups) {
DataMediaPair dataMediaPair = new DataMediaPair();
try {
dataMediaPair.setId(dataMediaPairDo.getId());
dataMediaPair.setPipelineId(dataMediaPairDo.getPipelineId());
dataMediaPair.setPullWeight(dataMediaPairDo.getPullWeight());
dataMediaPair.setPushWeight(dataMediaPairDo.getPushWeight());
if (StringUtils.isNotBlank(dataMediaPairDo.getFilter())) {
dataMediaPair.setFilterData(JsonUtils.unmarshalFromString(dataMediaPairDo.getFilter(), ExtensionData.class));
}
if (StringUtils.isNotBlank(dataMediaPairDo.getResolver())) {
dataMediaPair.setResolverData(JsonUtils.unmarshalFromString(dataMediaPairDo.getResolver(), ExtensionData.class));
}
dataMediaPair.setColumnPairs(columnPairs);
dataMediaPair.setColumnGroups(columnGroups);
dataMediaPair.setColumnPairMode(dataMediaPairDo.getColumnPairMode());
dataMediaPair.setGmtCreate(dataMediaPairDo.getGmtCreate());
dataMediaPair.setGmtModified(dataMediaPairDo.getGmtModified());
// 组装DataMedia
List<DataMedia> dataMedias = dataMediaService.listByIds(dataMediaPairDo.getSourceDataMediaId(), dataMediaPairDo.getTargetDataMediaId());
if (null == dataMedias || dataMedias.size() != 2) {
// 抛出异常
return dataMediaPair;
}
for (DataMedia dataMedia : dataMedias) {
if (dataMedia.getId().equals(dataMediaPairDo.getSourceDataMediaId())) {
dataMediaPair.setSource(dataMedia);
} else if (dataMedia.getId().equals(dataMediaPairDo.getTargetDataMediaId())) {
dataMediaPair.setTarget(dataMedia);
}
}
} catch (Exception e) {
logger.error("ERROR ## change the dataMediaPair Do to Model has an exception", e);
throw new ManagerException(e);
}
return dataMediaPair;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaPairServiceImpl method modify.
/**
* 修改
*/
public void modify(DataMediaPair dataMediaPair) {
Assert.assertNotNull(dataMediaPair);
try {
DataMediaPairDO dataMediaPairDo = modelToDo(dataMediaPair);
if (dataMediaPairDao.checkUnique(dataMediaPairDo)) {
dataMediaPairDao.update(dataMediaPairDo);
} else {
String exceptionCause = "exist the same pair in the database.";
logger.warn("WARN ## " + exceptionCause);
throw new RepeatConfigureException(exceptionCause);
}
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## modify dataMediaPair has an exception!", e);
throw new ManagerException(e);
}
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaSourceServiceImpl method doToModel.
/**
* 类型:数据库类型 Mysql和Oracle 用于DO对象转化为Model对象
*
* @param dataMediaSourceDo
* @return DataMediaSource
*/
private DataMediaSource doToModel(DataMediaSourceDO dataMediaSourceDo) {
DataMediaSource dataMediaSource = new DbMediaSource();
try {
if (dataMediaSourceDo.getType().isMysql() || dataMediaSourceDo.getType().isOracle()) {
dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), DbMediaSource.class);
} else if (dataMediaSourceDo.getType().isNapoli() || dataMediaSourceDo.getType().isMq()) {
dataMediaSource = JsonUtils.unmarshalFromString(dataMediaSourceDo.getProperties(), MqMediaSource.class);
}
dataMediaSource.setId(dataMediaSourceDo.getId());
dataMediaSource.setGmtCreate(dataMediaSourceDo.getGmtCreate());
dataMediaSource.setGmtModified(dataMediaSourceDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the dataMediaSource Do to Model has an exception");
throw new ManagerException(e);
}
return dataMediaSource;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException 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.common.exceptions.ManagerException 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