Search in sources :

Example 11 with DataMedia

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;
}
Also used : DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) MqDataMedia(com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 12 with 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;
}
Also used : DataMediaDO(com.alibaba.otter.manager.biz.config.datamedia.dal.dataobject.DataMediaDO) ArrayList(java.util.ArrayList) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) MqDataMedia(com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) DbDataMedia(com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 13 with DataMedia

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;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) ExtensionData(com.alibaba.otter.shared.common.model.config.data.ExtensionData)

Example 14 with DataMedia

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);
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) MqMediaSource(com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia)

Example 15 with DataMedia

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));
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) MqMediaSource(com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource) DataMediaSource(com.alibaba.otter.shared.common.model.config.data.DataMediaSource) DataMedia(com.alibaba.otter.shared.common.model.config.data.DataMedia)

Aggregations

DataMedia (com.alibaba.otter.shared.common.model.config.data.DataMedia)29 ArrayList (java.util.ArrayList)12 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)10 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)10 EventData (com.alibaba.otter.shared.etl.model.EventData)8 DbDialect (com.alibaba.otter.node.etl.common.db.dialect.DbDialect)7 DataMediaSource (com.alibaba.otter.shared.common.model.config.data.DataMediaSource)7 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)5 Table (org.apache.ddlutils.model.Table)4 Paginator (com.alibaba.citrus.util.Paginator)3 ExtractException (com.alibaba.otter.node.etl.extract.exceptions.ExtractException)3 ColumnPair (com.alibaba.otter.shared.common.model.config.data.ColumnPair)3 ExtensionData (com.alibaba.otter.shared.common.model.config.data.ExtensionData)3 DbDataMedia (com.alibaba.otter.shared.common.model.config.data.db.DbDataMedia)3 MqDataMedia (com.alibaba.otter.shared.common.model.config.data.mq.MqDataMedia)3 MqMediaSource (com.alibaba.otter.shared.common.model.config.data.mq.MqMediaSource)3 Pipeline (com.alibaba.otter.shared.common.model.config.pipeline.Pipeline)3 EventColumn (com.alibaba.otter.shared.etl.model.EventColumn)3 EventType (com.alibaba.otter.shared.etl.model.EventType)3 HashMap (java.util.HashMap)3