use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method doToModel.
/**
* 用于DO对象转化为Model对象
*
* @param pipelineDO
* @return Pipeline
*/
private Pipeline doToModel(PipelineDO pipelineDo) {
Pipeline pipeline = new Pipeline();
try {
pipeline.setId(pipelineDo.getId());
pipeline.setName(pipelineDo.getName());
pipeline.setParameters(pipelineDo.getParameters());
pipeline.setDescription(pipelineDo.getDescription());
pipeline.setGmtCreate(pipelineDo.getGmtCreate());
pipeline.setGmtModified(pipelineDo.getGmtModified());
pipeline.setChannelId(pipelineDo.getChannelId());
pipeline.getParameters().setMainstemClientId(pipeline.getId().shortValue());
// 组装DatamediaPair
List<DataMediaPair> pairs = dataMediaPairService.listByPipelineId(pipelineDo.getId());
Collections.sort(pairs, new DataMediaPairComparable());
pipeline.setPairs(pairs);
// 组装Node
List<PipelineNodeRelationDO> relations = pipelineNodeRelationDao.listByPipelineIds(pipelineDo.getId());
List<Long> totalNodeIds = new ArrayList<Long>();
for (PipelineNodeRelationDO relation : relations) {
Long nodeId = relation.getNodeId();
if (!totalNodeIds.contains(nodeId)) {
totalNodeIds.add(nodeId);
}
}
List<Node> totalNodes = nodeService.listByIds(totalNodeIds.toArray(new Long[totalNodeIds.size()]));
List<Node> selectNodes = new ArrayList<Node>();
List<Node> extractNodes = new ArrayList<Node>();
List<Node> loadNodes = new ArrayList<Node>();
for (Node node : totalNodes) {
for (PipelineNodeRelationDO relation : relations) {
if (node.getId().equals(relation.getNodeId())) {
if (relation.getLocation().isSelect()) {
selectNodes.add(node);
} else if (relation.getLocation().isExtract()) {
extractNodes.add(node);
} else if (relation.getLocation().isLoad()) {
loadNodes.add(node);
}
}
}
}
pipeline.setSelectNodes(selectNodes);
pipeline.setExtractNodes(extractNodes);
pipeline.setLoadNodes(loadNodes);
} catch (Exception e) {
logger.error("ERROR ## change the pipeline Do to Model has an exception");
throw new ManagerException(e);
}
return pipeline;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class PipelineServiceImpl method doToModelWithoutOther.
private Pipeline doToModelWithoutOther(PipelineDO pipelineDo) {
Pipeline pipeline = new Pipeline();
try {
pipeline.setId(pipelineDo.getId());
pipeline.setName(pipelineDo.getName());
pipeline.setParameters(pipelineDo.getParameters());
pipeline.setDescription(pipelineDo.getDescription());
pipeline.setGmtCreate(pipelineDo.getGmtCreate());
pipeline.setGmtModified(pipelineDo.getGmtModified());
pipeline.setChannelId(pipelineDo.getChannelId());
pipeline.getParameters().setMainstemClientId(pipeline.getId().shortValue());
} catch (Exception e) {
logger.error("ERROR ## change the pipeline Do to Model has an exception");
throw new ManagerException(e);
}
return pipeline;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method createReturnId.
/**
* 添加
*/
@Override
public Long createReturnId(DataMedia dataMedia) {
Assert.assertNotNull(dataMedia);
try {
DataMediaDO dataMediaDo = modelToDo(dataMedia);
dataMediaDo.setId(0L);
DataMediaDO dataMediaDoInDb = dataMediaDao.checkUniqueAndReturnExist(dataMediaDo);
if (dataMediaDoInDb == null) {
dataMediaDo = dataMediaDao.insert(dataMediaDo);
} else {
dataMediaDo = dataMediaDoInDb;
}
return dataMediaDo.getId();
} catch (RepeatConfigureException rce) {
throw rce;
} catch (Exception e) {
logger.error("ERROR ## create dataMedia has an exception!");
throw new ManagerException(e);
}
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method listByCondition.
@Override
public List<DataMedia> listByCondition(Map condition) {
List<DataMedia> dataMedias = new ArrayList<DataMedia>();
try {
List<DataMediaDO> dataMediaDos = dataMediaDao.listByCondition(condition);
if (dataMediaDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMedias by the condition:" + JsonUtils.marshalToString(condition));
return dataMedias;
}
dataMedias = doToModel(dataMediaDos);
} catch (Exception e) {
logger.error("ERROR ## query dataMedias by condition has an exception!");
throw new ManagerException(e);
}
return dataMedias;
}
use of com.alibaba.otter.manager.biz.common.exceptions.ManagerException in project otter by alibaba.
the class DataMediaServiceImpl method listByDataMediaSourceId.
@Override
public List<DataMedia> listByDataMediaSourceId(Long dataMediaSourceId) {
Assert.assertNotNull(dataMediaSourceId);
List<DataMediaDO> dataMediaDos = null;
try {
dataMediaDos = dataMediaDao.listByDataMediaSourceId(dataMediaSourceId);
if (dataMediaDos.isEmpty()) {
logger.debug("DEBUG ## couldn't query any dataMedia, maybe hasn't create any dataMedia.");
return new ArrayList<DataMedia>();
}
} catch (Exception e) {
logger.error("ERROR ## query dataMedias by sourceId:" + dataMediaSourceId + " has an exception!");
throw new ManagerException(e);
}
return doToModel(dataMediaDos);
}
Aggregations