Search in sources :

Example 1 with DataMediaPairDO

use of com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO in project otter by alibaba.

the class DataMediaPairServiceImpl method listByIds.

/*-----------------------------------查询方法,整合-----------------------------------------*/
public List<DataMediaPair> listByIds(Long... identities) {
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = null;
        if (identities.length < 1) {
            dataMediaPairDos = dataMediaPairDao.listAll();
            if (dataMediaPairDos.isEmpty()) {
                logger.debug("DEBUG ## couldn't query any dataMediaPair, maybe hasn't create any dataMediaPair.");
                return dataMediaPairs;
            }
        } else {
            dataMediaPairDos = dataMediaPairDao.listByMultiId(identities);
            if (dataMediaPairDos.isEmpty()) {
                String exceptionCause = "couldn't query any dataMediaPair by dataMediaPairIds:" + Arrays.toString(identities);
                logger.error("ERROR ## " + exceptionCause);
                throw new ManagerException(exceptionCause);
            }
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs has an exception!", e);
        throw new ManagerException(e);
    }
    return dataMediaPairs;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 2 with DataMediaPairDO

use of com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO in project otter by alibaba.

the class DataMediaPairServiceImpl method listByCondition.

@Override
public List<DataMediaPair> listByCondition(Map condition) {
    List<DataMediaPair> dataMediaPairs = new ArrayList<DataMediaPair>();
    try {
        List<DataMediaPairDO> dataMediaPairDos = dataMediaPairDao.listByCondition(condition);
        if (dataMediaPairDos.isEmpty()) {
            logger.debug("DEBUG ## couldn't query any DataMediaPairs by the condition:" + JsonUtils.marshalToString(condition));
            return dataMediaPairs;
        }
        dataMediaPairs = doToModel(dataMediaPairDos);
    } catch (Exception e) {
        logger.error("ERROR ## query dataMediaPairs by condition has an exception!", e);
        throw new ManagerException(e);
    }
    return dataMediaPairs;
}
Also used : DataMediaPair(com.alibaba.otter.shared.common.model.config.data.DataMediaPair) ArrayList(java.util.ArrayList) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 3 with DataMediaPairDO

use of com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO in project otter by alibaba.

the class DataMediaPairServiceImpl method modelToDo.

/**
     * 用于Model对象转化为DO对象
     * 
     * @param dataMediaPair
     * @return DataMediaPairDO
     */
private DataMediaPairDO modelToDo(DataMediaPair dataMediaPair) {
    DataMediaPairDO dataMediaPairDo = new DataMediaPairDO();
    try {
        dataMediaPairDo.setId(dataMediaPair.getId());
        dataMediaPairDo.setPipelineId(dataMediaPair.getPipelineId());
        dataMediaPairDo.setSourceDataMediaId(dataMediaPair.getSource().getId());
        dataMediaPairDo.setTargetDataMediaId(dataMediaPair.getTarget().getId());
        dataMediaPairDo.setFilter(JsonUtils.marshalToString(dataMediaPair.getFilterData()));
        dataMediaPairDo.setResolver(JsonUtils.marshalToString(dataMediaPair.getResolverData()));
        dataMediaPairDo.setPullWeight(dataMediaPair.getPullWeight());
        dataMediaPairDo.setPushWeight(dataMediaPair.getPushWeight());
        dataMediaPairDo.setColumnPairMode(dataMediaPair.getColumnPairMode());
        dataMediaPairDo.setGmtCreate(dataMediaPair.getGmtCreate());
        dataMediaPairDo.setGmtModified(dataMediaPair.getGmtModified());
    } catch (Exception e) {
        logger.error("ERROR ## change the dataMediaPair Model to Do has an exception", e);
        throw new ManagerException(e);
    }
    return dataMediaPairDo;
}
Also used : DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 4 with DataMediaPairDO

use of com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO in project otter by alibaba.

the class DataMediaPairServiceImpl method createAndReturnId.

/**
     * 添加并返回插入的id
     */
public Long createAndReturnId(DataMediaPair dataMediaPair) {
    Assert.assertNotNull(dataMediaPair);
    try {
        DataMediaPairDO dataMediaPairDo = modelToDo(dataMediaPair);
        dataMediaPairDo.setId(0L);
        if (!dataMediaPairDao.checkUnique(dataMediaPairDo)) {
            String exceptionCause = "exist the same pair in the database.";
            logger.warn("WARN ## " + exceptionCause);
            throw new RepeatConfigureException(exceptionCause);
        }
        dataMediaPairDao.insert(dataMediaPairDo);
        return dataMediaPairDo.getId();
    } catch (RepeatConfigureException rcf) {
        throw rcf;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMediaPair has an exception!", e);
        throw new ManagerException(e);
    }
}
Also used : RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException) DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Example 5 with DataMediaPairDO

use of com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO in project otter by alibaba.

the class DataMediaPairServiceImpl method createIfNotExist.

/**
     * 添加并返回插入的id
     */
public boolean createIfNotExist(DataMediaPair dataMediaPair) {
    Assert.assertNotNull(dataMediaPair);
    try {
        DataMediaPairDO dataMediaPairDo = modelToDo(dataMediaPair);
        dataMediaPairDo.setId(0L);
        if (!dataMediaPairDao.checkUnique(dataMediaPairDo)) {
            return false;
        }
        dataMediaPairDao.insert(dataMediaPairDo);
        return true;
    } catch (Exception e) {
        logger.error("ERROR ## create dataMediaPair has an exception!", e);
        throw new ManagerException(e);
    }
}
Also used : DataMediaPairDO(com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) ManagerException(com.alibaba.otter.manager.biz.common.exceptions.ManagerException) RepeatConfigureException(com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)

Aggregations

DataMediaPairDO (com.alibaba.otter.manager.biz.config.datamediapair.dal.dataobject.DataMediaPairDO)10 ManagerException (com.alibaba.otter.manager.biz.common.exceptions.ManagerException)9 RepeatConfigureException (com.alibaba.otter.manager.biz.common.exceptions.RepeatConfigureException)9 DataMediaPair (com.alibaba.otter.shared.common.model.config.data.DataMediaPair)6 ArrayList (java.util.ArrayList)6 ColumnGroup (com.alibaba.otter.shared.common.model.config.data.ColumnGroup)1 ColumnPair (com.alibaba.otter.shared.common.model.config.data.ColumnPair)1 List (java.util.List)1