use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class DataMediaPairServiceImpl method listByDataMediaId.
@Override
public List<DataMediaPair> listByDataMediaId(Long dataMediaId) {
Assert.assertNotNull(dataMediaId);
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
try {
List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByDataMediaId(dataMediaId);
if (dataMediaPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
return dataMediaPairs;
}
dataMediaPairs = doToModel(dataMediaPairDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMediaPairs by dataMediaId:" + dataMediaId + " has an exception!", e);
throw new ManagerException(e);
}
return dataMediaPairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class DataMediaPairServiceImpl method doToModel.
private List<DataMediaPair> doToModel(List<DataMediaPairDO> dataMediaPairDos) {
List<Long> dataMediaPairIds = new ArrayList<Long>();
for (DataMediaPairDO dataMediaPairDo : dataMediaPairDos) {
dataMediaPairIds.add(dataMediaPairDo.getId());
}
Map<Long, List<ColumnPair>> columnPairMap = dataColumnPairService.listByDataMediaPairIds(dataMediaPairIds.toArray(new Long[dataMediaPairIds.size()]));
Map<Long, List<ColumnGroup>> columnPairGroupMap = dataColumnPairGroupService.listByDataMediaPairIds(dataMediaPairIds.toArray(new Long[dataMediaPairIds.size()]));
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
for (DataMediaPairDO dataMediaPairDo : dataMediaPairDos) {
List<ColumnPair> columnPairs = columnPairMap.get(dataMediaPairDo.getId()) == null ? new ArrayList<ColumnPair>() : columnPairMap.get(dataMediaPairDo.getId());
List<ColumnGroup> columnGroups = columnPairGroupMap.get(dataMediaPairDo.getId()) == null ? new ArrayList<ColumnGroup>() : columnPairGroupMap.get(dataMediaPairDo.getId());
dataMediaPairs.add(doToModel(dataMediaPairDo, columnPairs, columnGroups));
}
return dataMediaPairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class DataMediaPairServiceImpl method listByPipelineId.
/**
* 根据PipelineId找到该枝干下的所有DataMediaPairs
*/
public List<DataMediaPair> listByPipelineId(Long pipelineId) {
Assert.assertNotNull(pipelineId);
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
try {
List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByPipelineId(pipelineId);
if (dataMediaPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
return dataMediaPairs;
}
dataMediaPairs = doToModel(dataMediaPairDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMediaPairs by pipelineId:" + pipelineId + " has an exception!", e);
throw new ManagerException(e);
}
return dataMediaPairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.
the class DataMediaPairServiceImpl method listByPipelineIdWithoutColumn.
@Override
public List<DataMediaPair> listByPipelineIdWithoutColumn(Long pipelineId) {
Assert.assertNotNull(pipelineId);
List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
try {
List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByPipelineId(pipelineId);
if (dataMediaPairDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
return dataMediaPairs;
}
dataMediaPairs = doToModelWithoutOther(dataMediaPairDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMediaPairs by pipelineId:" + pipelineId + " has an exception!", e);
throw new ManagerException(e);
}
return dataMediaPairs;
}
use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair 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;
}
Aggregations