use of com.alibaba.otter.shared.common.model.config.data.DataMedia in project otter by alibaba.
the class DataMediaServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*
* @param dataMediaDo
* @return DataMedia
*/
private DataMedia doToModel(DataMediaDO dataMediaDo) {
DataMedia dataMedia = null;
try {
DataMediaSource dataMediaSource = dataMediaSourceService.findById(dataMediaDo.getDataMediaSourceId());
if (dataMediaSource.getType().isMysql() || dataMediaSource.getType().isOracle()) {
dataMedia = JsonUtils.unmarshalFromString(dataMediaDo.getProperties(), DbDataMedia.class);
dataMedia.setSource(dataMediaSource);
} else if (dataMediaSource.getType().isNapoli() || dataMediaSource.getType().isMq()) {
dataMedia = JsonUtils.unmarshalFromString(dataMediaDo.getProperties(), MqDataMedia.class);
dataMedia.setSource(dataMediaSource);
}
dataMedia.setId(dataMediaDo.getId());
dataMedia.setGmtCreate(dataMediaDo.getGmtCreate());
dataMedia.setGmtModified(dataMediaDo.getGmtModified());
} catch (Exception e) {
logger.error("ERROR ## change the dataMedia Do to Model has an exception");
throw new ManagerException(e);
}
return dataMedia;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMedia in project otter by alibaba.
the class DataMediaServiceImpl method listByIds.
@Override
public List<DataMedia> listByIds(Long... identities) {
List<DataMedia> dataMedias = new ArrayList<DataMedia>();
try {
List<DataMediaDO> dataMediaDos = null;
if (identities.length < 1) {
dataMediaDos = dataMediaDao.listAll();
if (dataMediaDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMedia, maybe hasn't create any dataMedia.");
return dataMedias;
}
} else {
dataMediaDos = dataMediaDao.listByMultiId(identities);
if (dataMediaDos.isEmpty()) {
String exceptionCause = "couldn't query any dataMedia by dataMediaIds:" + Arrays.toString(identities);
logger.error("ERROR ## " + exceptionCause);
throw new ManagerException(exceptionCause);
}
}
dataMedias = doToModel(dataMediaDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMedias has an exception!");
throw new ManagerException(e);
}
return dataMedias;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMedia 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.shared.common.model.config.data.DataMedia in project otter by alibaba.
the class DataMediaAction method doAdd.
/**
* 添加Channel
*
* @param channelInfo
* @param channelParameterInfo
* @throws Exception
*/
public void doAdd(@FormGroup("dataMediaInfo") Group dataMediaInfo, @FormField(name = "formDataMediaError", group = "dataMediaInfo") CustomErrors err, Navigator nav) throws Exception {
DataMedia dataMedia = new DataMedia();
dataMediaInfo.setProperties(dataMedia);
DataMediaSource dataMediaSource = dataMediaSourceService.findById(dataMediaInfo.getField("sourceId").getLongValue());
if (dataMediaSource.getType().isMysql() || dataMediaSource.getType().isOracle()) {
dataMedia.setSource((DbMediaSource) dataMediaSource);
} else if (dataMediaSource.getType().isNapoli() || dataMediaSource.getType().isMq()) {
dataMedia.setSource((MqMediaSource) dataMediaSource);
}
try {
dataMediaService.create(dataMedia);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidDataMedia");
return;
}
nav.redirectTo(WebConstant.DATA_MEDIA_LIST_LINK);
}
use of com.alibaba.otter.shared.common.model.config.data.DataMedia in project otter by alibaba.
the class DataMediaAction method doEdit.
public void doEdit(@FormGroup("dataMediaInfo") Group dataMediaInfo, @Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, @FormField(name = "formDataMediaError", group = "dataMediaInfo") CustomErrors err, Navigator nav) throws Exception {
DataMedia dataMedia = new DataMedia();
dataMediaInfo.setProperties(dataMedia);
DataMediaSource dataMediaSource = dataMediaSourceService.findById(dataMediaInfo.getField("sourceId").getLongValue());
if (dataMediaSource.getType().isMysql() || dataMediaSource.getType().isOracle()) {
dataMedia.setSource((DbMediaSource) dataMediaSource);
} else if (dataMediaSource.getType().isNapoli() || dataMediaSource.getType().isMq()) {
dataMedia.setSource((MqMediaSource) dataMediaSource);
}
try {
dataMediaService.modify(dataMedia);
} catch (RepeatConfigureException rce) {
err.setMessage("invalidDataMedia");
return;
}
nav.redirectToLocation("dataMediaList.htm?pageIndex=" + pageIndex + "&searchKey=" + urlEncode(searchKey));
}
Aggregations