use of com.alibaba.otter.shared.common.model.config.data.ColumnPair 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.ColumnPair in project otter by alibaba.
the class ColumnPairGroupAction method doSave.
public void doSave(@Param("dataMediaPairId") Long dataMediaPairId, @Param("submitKey") String submitKey, @Param("pipelineId") Long pipelineId, @FormGroup("columnPairGroupInfo") Group columnPairGroupInfo, @FormField(name = "formColumnPairGroupError", group = "columnPairGroupInfo") CustomErrors err, Navigator nav) throws Exception {
String[] columnPairStrings = columnPairGroupInfo.getField("groupResult").getStringValues();
ColumnGroup columnGroup = new ColumnGroup();
List<ColumnPair> columnPairs = new ArrayList<ColumnPair>();
for (String columnPairString : columnPairStrings) {
ColumnPair columnPair = new ColumnPair();
String[] temp = columnPairString.split(COLON);
columnPair.setSourceColumn(new Column(temp[0]));
columnPair.setTargetColumn(new Column(temp[1]));
columnPair.setDataMediaPairId(dataMediaPairId);
columnPairs.add(columnPair);
}
columnGroup.setColumnPairs(columnPairs);
columnGroup.setDataMediaPairId(dataMediaPairId);
dataColumnPairGroupService.removeByDataMediaPairId(dataMediaPairId);
dataColumnPairGroupService.create(columnGroup);
nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.data.ColumnPair in project otter by alibaba.
the class AddColumnPair method execute.
public void execute(@Param("dataMediaPairId") Long dataMediaPairId, @Param("channelId") Long channelId, @Param("pipelineId") Long pipelineId, @Param("sourceMediaId") Long sourceMediaId, @Param("targetMediaId") Long targetMediaId, Context context) throws Exception {
@SuppressWarnings("unchecked") DataMedia sourcedataMedia = dataMediaService.findById(sourceMediaId);
DataMedia targetdataMedia = dataMediaService.findById(targetMediaId);
List<String> sourceColumns = dataMediaService.queryColumnByMedia(sourcedataMedia);
List<String> targetColumns = dataMediaService.queryColumnByMedia(targetdataMedia);
List<String> underSourceColumns = new ArrayList<String>();
List<String> underTargetColumns = new ArrayList<String>();
List<ColumnPair> columnPairs = dataColumnPairService.listByDataMediaPairId(dataMediaPairId);
if (columnPairs != null && !columnPairs.isEmpty()) {
for (ColumnPair columnPair : columnPairs) {
if (columnPair.getSourceColumn() != null) {
underSourceColumns.add(columnPair.getSourceColumn().getName());
}
if (columnPair.getTargetColumn() != null) {
underTargetColumns.add(columnPair.getTargetColumn().getName());
}
}
}
sourceColumns.removeAll(underSourceColumns);
targetColumns.removeAll(underTargetColumns);
context.put("sourceMediaId", sourceMediaId);
context.put("targetMediaId", targetMediaId);
context.put("sourceColumns", sourceColumns);
context.put("targetColumns", targetColumns);
context.put("underSourceColumns", underSourceColumns);
context.put("underTargetColumns", underTargetColumns);
context.put("dataMediaPairId", dataMediaPairId);
context.put("channelId", channelId);
context.put("pipelineId", pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.data.ColumnPair in project otter by alibaba.
the class AddColumnPairGroup method execute.
public void execute(@Param("dataMediaPairId") Long dataMediaPairId, @Param("pipelineId") Long pipelineId, @Param("channelId") Long channelId, @Param("sourceMediaId") Long sourceMediaId, @Param("targetMediaId") Long targetMediaId, Context context) throws Exception {
List<ColumnPair> columnPairs = dataColumnPairService.listByDataMediaPairId(dataMediaPairId);
if (CollectionUtils.isEmpty(columnPairs)) {
columnPairs.addAll(buildColumnPairFromDataMedia(dataMediaPairId, sourceMediaId, targetMediaId));
} else {
DataMediaPair dataMediaPair = dataMediaPairService.findById(dataMediaPairId);
if (dataMediaPair.getColumnPairMode().isExclude()) {
List<ColumnPair> allColumnPairs = buildColumnPairFromDataMedia(dataMediaPairId, sourceMediaId, targetMediaId);
// 如果是exclude模式,排除掉
allColumnPairs.removeAll(columnPairs);
columnPairs = allColumnPairs;
}
}
List<ColumnGroup> columnGroups = dataColumnPairGroupService.listByDataMediaPairId(dataMediaPairId);
List<ColumnPair> columnPairGroup = new ArrayList<ColumnPair>();
if (CollectionUtils.isNotEmpty(columnGroups)) {
for (ColumnGroup columnGroup : columnGroups) {
List<ColumnPair> columnPairTemp = new ArrayList<ColumnPair>();
columnPairGroup = columnGroup.getColumnPairs();
for (ColumnPair columnPair : columnPairGroup) {
for (ColumnPair subColumnPair : columnPairs) {
if (columnPair.equals(subColumnPair)) {
columnPairTemp.add(subColumnPair);
}
}
}
// 如果是多个Group,需要深度复制columnPair,每个Group需要复制一个
columnPairs.removeAll(columnPairTemp);
}
}
// 未加入group的columnPair定义
context.put("preColumnPairs", columnPairs);
// 当前group的columnPair定义
context.put("columnPairs", columnPairGroup);
context.put("dataMediaPairId", dataMediaPairId);
context.put("channelId", channelId);
context.put("pipelineId", pipelineId);
}
use of com.alibaba.otter.shared.common.model.config.data.ColumnPair in project otter by alibaba.
the class DataMediaPairInfo method execute.
public void execute(@Param("dataMediaPairId") Long dataMediaPairId, Context context) throws Exception {
DataMediaPair dataMediaPair = dataMediaPairService.findById(dataMediaPairId);
Channel channel = channelService.findByPipelineId(dataMediaPair.getPipelineId());
List<ColumnPair> columnPairs = dataMediaPair.getColumnPairs();
List<ColumnGroup> columnGroups = dataMediaPair.getColumnGroups();
// 暂时策略,只拿出list的第一个Group
ColumnGroup columnGroup = new ColumnGroup();
if (!CollectionUtils.isEmpty(columnGroups)) {
columnGroup = columnGroups.get(0);
}
context.put("dataMediaPair", dataMediaPair);
context.put("columnGroup", columnGroup);
context.put("columnPairs", columnPairs);
context.put("channelId", channel.getId());
}
Aggregations