Search in sources :

Example 31 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairAction method doEdit.

public void doEdit(@Param("submitKey") String submitKey, @Param("channelId") Long channelId, @FormGroup("dataMediaPairInfo") Group dataMediaPairInfo, @FormField(name = "formDataMediaPairError", group = "dataMediaPairInfo") CustomErrors err, Navigator nav) throws Exception {
    DataMediaPair dataMediaPair = new DataMediaPair();
    DataMedia sourceDataMedia = new DataMedia();
    DataMedia targetDataMedia = new DataMedia();
    dataMediaPairInfo.setProperties(dataMediaPair);
    // filter解析
    ExtensionDataType filterType = ExtensionDataType.valueOf(dataMediaPairInfo.getField("filterType").getStringValue());
    ExtensionData filterData = new ExtensionData();
    filterData.setExtensionDataType(filterType);
    if (filterType.isClazz()) {
        filterData.setClazzPath(dataMediaPairInfo.getField("filterText").getStringValue());
    } else if (filterType.isSource()) {
        filterData.setSourceText(dataMediaPairInfo.getField("filterText").getStringValue());
    }
    dataMediaPair.setFilterData(filterData);
    // fileresovler解析
    ExtensionDataType resolverType = ExtensionDataType.valueOf(dataMediaPairInfo.getField("resolverType").getStringValue());
    ExtensionData resolverData = new ExtensionData();
    resolverData.setExtensionDataType(resolverType);
    if (resolverType.isClazz()) {
        resolverData.setClazzPath(dataMediaPairInfo.getField("resolverText").getStringValue());
    } else if (resolverType.isSource()) {
        resolverData.setSourceText(dataMediaPairInfo.getField("resolverText").getStringValue());
    }
    dataMediaPair.setResolverData(resolverData);
    sourceDataMedia.setId(dataMediaPairInfo.getField("sourceDataMediaId").getLongValue());
    dataMediaPair.setSource(sourceDataMedia);
    targetDataMedia.setId(dataMediaPairInfo.getField("targetDataMediaId").getLongValue());
    dataMediaPair.setTarget(targetDataMedia);
    try {
        dataMediaPairService.modify(dataMediaPair);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidDataMediaPair");
        return;
    }
    if (submitKey.equals("保存")) {
        nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + dataMediaPair.getPipelineId());
    } else if (submitKey.equals("下一步")) {
        nav.redirectToLocation("addColumnPair.htm?pipelineId=" + dataMediaPair.getPipelineId() + "&channelId=" + channelId + "&dataMediaPairId=" + dataMediaPair.getId() + "&sourceMediaId=" + sourceDataMedia.getId() + "&targetMediaId=" + targetDataMedia.getId());
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ExtensionDataType(com.alibaba.otter.shared.common.model.config.data.ExtensionDataType) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) ExtensionData(com.alibaba.otter.shared.common.model.config.data.ExtensionData)

Example 32 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaPairAction method doAdd.

/**
     * 添加DataMediaPair
     * 
     * @param channelInfo
     * @param channelParameterInfo
     * @throws Exception
     */
public void doAdd(@Param("submitKey") String submitKey, @FormGroup("dataMediaPairInfo") Group dataMediaPairInfo, @FormField(name = "formDataMediaPairError", group = "dataMediaPairInfo") CustomErrors err, Navigator nav) throws Exception {
    DataMediaPair dataMediaPair = new DataMediaPair();
    DataMedia sourceDataMedia = new DataMedia();
    DataMedia targetDataMedia = new DataMedia();
    dataMediaPairInfo.setProperties(dataMediaPair);
    // filter解析
    ExtensionDataType filterType = ExtensionDataType.valueOf(dataMediaPairInfo.getField("filterType").getStringValue());
    ExtensionData filterData = new ExtensionData();
    filterData.setExtensionDataType(filterType);
    if (filterType.isClazz()) {
        filterData.setClazzPath(dataMediaPairInfo.getField("filterText").getStringValue());
    } else if (filterType.isSource()) {
        filterData.setSourceText(dataMediaPairInfo.getField("filterText").getStringValue());
    }
    dataMediaPair.setFilterData(filterData);
    // fileresovler解析
    ExtensionDataType resolverType = ExtensionDataType.valueOf(dataMediaPairInfo.getField("resolverType").getStringValue());
    ExtensionData resolverData = new ExtensionData();
    resolverData.setExtensionDataType(resolverType);
    if (resolverType.isClazz()) {
        resolverData.setClazzPath(dataMediaPairInfo.getField("resolverText").getStringValue());
    } else if (resolverType.isSource()) {
        resolverData.setSourceText(dataMediaPairInfo.getField("resolverText").getStringValue());
    }
    dataMediaPair.setResolverData(resolverData);
    sourceDataMedia.setId(dataMediaPairInfo.getField("sourceDataMediaId").getLongValue());
    dataMediaPair.setSource(sourceDataMedia);
    targetDataMedia.setId(dataMediaPairInfo.getField("targetDataMediaId").getLongValue());
    dataMediaPair.setTarget(targetDataMedia);
    Long id = 0L;
    try {
        id = dataMediaPairService.createAndReturnId(dataMediaPair);
    } catch (RepeatConfigureException rce) {
        err.setMessage("invalidDataMediaPair");
        return;
    }
    if (submitKey.equals("保存")) {
        nav.redirectToLocation("dataMediaPairList.htm?pipelineId=" + dataMediaPair.getPipelineId());
    } else if (submitKey.equals("下一步")) {
        nav.redirectToLocation("addColumnPair.htm?dataMediaPairId=" + id + "&pipelineId=" + dataMediaPair.getPipelineId() + "&dataMediaPairId=" + id + "&sourceMediaId=" + sourceDataMedia.getId() + "&targetMediaId=" + targetDataMedia.getId());
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ExtensionDataType(com.alibaba.otter.shared.common.model.config.data.ExtensionDataType) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) ExtensionData(com.alibaba.otter.shared.common.model.config.data.ExtensionData)

Example 33 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair 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 34 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaInfo method execute.

public void execute(@Param("dataMediaId") Long dataMediaId, Context context) throws Exception {
    DataMedia dataMedia = dataMediaService.findById(dataMediaId);
    List<DataMediaPair> dataMediaPairs = dataMediaPairService.listByDataMediaId(dataMediaId);
    List<SeniorDataMediaPair> seniorDataMediapairs = new ArrayList<SeniorDataMediaPair>();
    for (DataMediaPair dataMediaPair : dataMediaPairs) {
        SeniorDataMediaPair seniorDataMediaPair = new SeniorDataMediaPair();
        seniorDataMediaPair.setChannel(channelService.findByPipelineId(dataMediaPair.getPipelineId()));
        seniorDataMediaPair.setDataMediaPair(dataMediaPair);
        seniorDataMediapairs.add(seniorDataMediaPair);
    }
    context.put("dataMedia", dataMedia);
    context.put("seniorDataMediapairs", seniorDataMediapairs);
}
Also used : SeniorDataMediaPair(com.alibaba.otter.manager.web.common.model.SeniorDataMediaPair) DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) SeniorDataMediaPair(com.alibaba.otter.manager.web.common.model.SeniorDataMediaPair)

Example 35 with DataMediaPair

use of com.alibaba.otter.shared.common.model.config.data.DataMediaPair in project otter by alibaba.

the class DataMediaList method execute.

public void execute(@Param("pageIndex") int pageIndex, @Param("searchKey") String searchKey, Context context) throws Exception {
    @SuppressWarnings("unchecked") Map<String, Object> condition = new HashMap<String, Object>();
    if ("请输入关键字(目前支持DataMedia的ID、名字搜索)".equals(searchKey)) {
        searchKey = "";
    }
    condition.put("searchKey", searchKey);
    int count = dataMediaService.getCount(condition);
    Paginator paginator = new Paginator();
    paginator.setItems(count);
    paginator.setPage(pageIndex);
    condition.put("offset", paginator.getOffset());
    condition.put("length", paginator.getLength());
    List<DataMedia> dataMedias = dataMediaService.listByCondition(condition);
    List<SeniorDataMedia> seniorDataMedias = new ArrayList<SeniorDataMedia>();
    for (DataMedia dataMedia : dataMedias) {
        SeniorDataMedia seniorDataMedia = new SeniorDataMedia();
        seniorDataMedia.setId(dataMedia.getId());
        seniorDataMedia.setEncode(dataMedia.getEncode());
        seniorDataMedia.setGmtCreate(dataMedia.getGmtCreate());
        seniorDataMedia.setGmtModified(dataMedia.getGmtModified());
        seniorDataMedia.setName(dataMedia.getName());
        seniorDataMedia.setNamespace(dataMedia.getNamespace());
        seniorDataMedia.setSource(dataMedia.getSource());
        List<DataMediaPair> pairs = dataMediaPairService.listByDataMediaId(dataMedia.getId());
        seniorDataMedia.setPairs(pairs);
        if (pairs.size() < 1) {
            seniorDataMedia.setUsed(false);
        } else {
            seniorDataMedia.setUsed(true);
        }
        seniorDataMedias.add(seniorDataMedia);
    }
    context.put("dataMedias", seniorDataMedias);
    context.put("paginator", paginator);
    context.put("searchKey", searchKey);
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Paginator(com.alibaba.citrus.util.Paginator) SeniorDataMedia(com.alibaba.otter.manager.web.common.model.SeniorDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) SeniorDataMedia(com.alibaba.otter.manager.web.common.model.SeniorDataMedia)

Aggregations

DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)51 ArrayList (java.util.ArrayList)26 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)19 EventData (com.alibaba.otter.shared.etl.model.EventData)16 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)12 DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)11 DbDataMedia (com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)10 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)9 BaseDbTest (com.alibaba.otter.node.etl.BaseDbTest)9 RowBatch (com.alibaba.otter.shared.etl.model.RowBatch)9 Test (org.testng.annotations.Test)9 Identity (com.alibaba.otter.shared.etl.model.Identity)8 DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)6 Channel (com.alibaba.otter.shared.common.model.config.channel.Channel)6 HashMap (java.util.HashMap)6 ColumnPair (com.alibaba.otter.shared.common.model.config.data.ColumnPair)5 BatchObject (com.alibaba.otter.shared.etl.model.BatchObject)5 ColumnGroup (com.alibaba.otter.shared.common.model.config.data.ColumnGroup)4 Node (com.alibaba.otter.shared.common.model.config.node.Node)4 DbBatch (com.alibaba.otter.shared.etl.model.DbBatch)4