Search in sources :

Example 11 with ColumnPair

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;
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)

Example 12 with ColumnPair

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);
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) Column(com.alibaba.otter.shared.common.model.config.data.Column) ArrayList(java.util.ArrayList) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup)

Example 13 with ColumnPair

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);
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) ArrayList(java.util.ArrayList) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia)

Example 14 with ColumnPair

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);
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup)

Example 15 with ColumnPair

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());
}
Also used : ColumnPair(com.alibaba.otter.shared.common.model.config.data.ColumnPair) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) Channel(com.alibaba.otter.shared.common.model.config.channel.Channel) ColumnGroup(com.alibaba.otter.shared.common.model.config.data.ColumnGroup)

Aggregations

ColumnPair (com.alibaba.otter.shared.common.model.config.data.ColumnPair)16 ArrayList (java.util.ArrayList)13 ColumnGroup (com.alibaba.otter.shared.common.model.config.data.ColumnGroup)5 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)5 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)3 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)3 DataColumnPairDO (com.alibaba.otter.manager.biz.config.datacolumnpair.dal.dataobject.DataColumnPairDO)3 Column (com.alibaba.otter.shared.common.model.config.data.Column)3 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)3 EventColumn (com.alibaba.otter.shared.etl.model.EventColumn)3 HashMap (java.util.HashMap)3 List (java.util.List)3 EventData (com.alibaba.otter.shared.etl.model.EventData)2 HashSet (java.util.HashSet)2 TypeReference (com.alibaba.fastjson.TypeReference)1 DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)1 DbDialect (com.alibaba.otter.node.etl.common.db.dialect.DbDialect)1 ExtractException (com.alibaba.otter.node.etl.extract.exceptions.ExtractException)1 TransformException (com.alibaba.otter.node.etl.transform.exception.TransformException)1 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)1