use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method initCatalogue.
/**
* 绑定租户时,初始化目录信息
* @param tenantId
* @param userId
* @param componentVOS 根据控制台配置的组件信息,初始化相应的目录
*/
@Transactional(rollbackFor = Exception.class)
public void initCatalogue(Long tenantId, Long userId, List<ComponentVO> componentVOS) {
// 离线各模块的 0 级目录,任务管理、函数管理、资源管理
List<Dict> zeroBatchCatalogueDictList = dictService.listByDictType(DictType.DATA_DEVELOP_CATALOGUE);
List<Integer> componentTypes = componentVOS.stream().map(ComponentVO::getComponentTypeCode).collect(Collectors.toList());
// 根据控制台配置的组件信息,获取需要初始化的 1 级目录,任务开发、SparkSQL、资源管理 等
List<Dict> oneBatchCatalogueDictList = this.initCatalogueDictLevelByEngineType(componentTypes);
Map<String, Set<String>> oneCatalogueValueAndNameMapping = oneBatchCatalogueDictList.stream().collect(Collectors.groupingBy(Dict::getDictValue, Collectors.mapping(Dict::getDictDesc, Collectors.toSet())));
for (Dict zeroDict : zeroBatchCatalogueDictList) {
// 初始化 0 级目录
BatchCatalogue zeroBatchCatalogue = new BatchCatalogue();
zeroBatchCatalogue.setNodeName(zeroDict.getDictDesc());
zeroBatchCatalogue.setNodePid(DEFAULT_NODE_PID);
zeroBatchCatalogue.setOrderVal(zeroDict.getSort());
zeroBatchCatalogue.setLevel(CatalogueLevel.ONE.getLevel());
zeroBatchCatalogue.setTenantId(tenantId);
zeroBatchCatalogue.setCreateUserId(userId);
zeroBatchCatalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
zeroBatchCatalogue = addOrUpdate(zeroBatchCatalogue);
if (CollectionUtils.isNotEmpty(oneCatalogueValueAndNameMapping.get(zeroDict.getDictValue()))) {
for (String oneCatalogueName : oneCatalogueValueAndNameMapping.get(zeroDict.getDictValue())) {
// 初始化 1 级目录
BatchCatalogue oneBatchCatalogue = new BatchCatalogue();
oneBatchCatalogue.setNodeName(oneCatalogueName);
oneBatchCatalogue.setLevel(CatalogueLevel.SECOND.getLevel());
oneBatchCatalogue.setNodePid(zeroBatchCatalogue.getId());
oneBatchCatalogue.setTenantId(tenantId);
oneBatchCatalogue.setCreateUserId(userId);
oneBatchCatalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
addOrUpdate(oneBatchCatalogue);
if (TASK_DEVELOPE.equals(oneCatalogueName)) {
// 初始化任务模版
initTemplateCatalogue(oneBatchCatalogue, tenantId, userId);
}
this.initEngineCatalogue(tenantId, userId, oneCatalogueName, oneBatchCatalogue);
}
}
}
}
use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method replaceSystemFunction.
/**
* 根据目录类型查询对应的函数根目录
* @param catalogueId
* @param catalogueType
* @param childCatalogues
*/
private void replaceSystemFunction(Long catalogueId, String catalogueType, List<BatchCatalogue> childCatalogues) {
if (CatalogueType.SPARKSQL_FUNCTION.getType().equals(catalogueType)) {
BatchCatalogue one = developCatalogueDao.getOne(catalogueId);
EngineCatalogueType systemEngineType = EngineCatalogueType.getByeName(one == null ? null : one.getNodeName());
// 需要将系统函数替换对应 引擎的函数模板
BatchCatalogue systemFuncCatalogue = developCatalogueDao.getSystemFunctionCatalogueOne(systemEngineType.getType());
if (systemFuncCatalogue == null) {
return;
}
for (BatchCatalogue childCatalogue : childCatalogues) {
if ("系统函数".equals(childCatalogue.getNodeName())) {
childCatalogue.setNodePid(systemFuncCatalogue.getNodePid());
childCatalogue.setId(systemFuncCatalogue.getId());
}
}
}
}
use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method getGrandCatalogueId.
/**
* 根据当前节点递归查询所有父节点列表
* @param currentId
* @param ids
* @return 父节点列表
*/
private void getGrandCatalogueId(Long currentId, List<Long> ids) {
BatchCatalogue catalogue = developCatalogueDao.getOne(currentId);
if (catalogue != null && catalogue.getLevel() >= 1) {
ids.add(catalogue.getNodePid());
getGrandCatalogueId(catalogue.getNodePid(), ids);
}
}
use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method getCatalogueOne.
/**
* 获取 租户 下的 0 级目录极其子目录
* @param tenantId
* @return
*/
public List<CatalogueVO> getCatalogueOne(Long tenantId) {
// 查询 0 级目录
List<BatchCatalogue> zeroCatalogues = developCatalogueDao.listByLevelAndTenantId(0, tenantId);
// 从字典表中查询出初始化的 0 级目录
List<Dict> zeroCatalogueDictList = dictService.listByDictType(DictType.DATA_DEVELOP_CATALOGUE);
// 从字典表中查询出初始化的 1 级目录
List<Dict> oneCatalogueDictList = dictService.listByDictType(DictType.DATA_DEVELOP_CATALOGUE_L1);
// 0 级目录的中文和英文名称
Map<String, String> zeroCatalogueType = zeroCatalogueDictList.stream().collect(Collectors.toMap(Dict::getDictDesc, Dict::getDictName, (key1, key2) -> key1));
// 1 级目录的中文和英文名称
Map<String, String> oneCatalogueType = oneCatalogueDictList.stream().collect(Collectors.toMap(Dict::getDictDesc, Dict::getDictName, (key1, key2) -> key1));
List<CatalogueVO> zeroCatalogueVOList = new ArrayList<>(zeroCatalogues.size());
for (BatchCatalogue zeroCatalogue : zeroCatalogues) {
CatalogueVO zeroCatalogueVO = CatalogueVO.toVO(zeroCatalogue);
zeroCatalogueVO.setCatalogueType(zeroCatalogueType.get(zeroCatalogue.getNodeName()));
zeroCatalogueVO.setType(FILE_TYPE_FOLDER);
zeroCatalogueVOList.add(zeroCatalogueVO);
// 查询一级目录下的子目录
List<BatchCatalogue> oneChildCatalogues = developCatalogueDao.listByPidAndTenantId(zeroCatalogue.getId(), tenantId);
if (FUNCTION_MANAGER_NAME.equals(zeroCatalogue.getNodeName())) {
// 如果是函数目录,默认添加上系统函数目录
BatchCatalogue systemFuncCatalogue = developCatalogueDao.getSystemFunctionCatalogueOne(EngineCatalogueType.SPARK.getType());
if (systemFuncCatalogue != null) {
oneChildCatalogues.add(systemFuncCatalogue);
}
}
List<CatalogueVO> oneChildCatalogueVOList = new ArrayList<>(oneChildCatalogues.size());
for (BatchCatalogue oneChildCatalogue : oneChildCatalogues) {
CatalogueVO oneChildCatalogueVO = CatalogueVO.toVO(oneChildCatalogue);
if (EngineCatalogueType.SPARK.getDesc().equals(oneChildCatalogueVO.getName())) {
// spark 函数管理 不是目录
oneChildCatalogueVO.setType("catalogue");
} else {
oneChildCatalogueVO.setType("folder");
}
oneChildCatalogueVO.setCatalogueType(oneCatalogueType.get(oneChildCatalogue.getNodeName()));
oneChildCatalogueVOList.add(oneChildCatalogueVO);
}
zeroCatalogueVO.setChildren(oneChildCatalogueVOList);
}
return zeroCatalogueVOList;
}
use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method updateCatalogue.
/**
* 更新目录(移动和重命名)
*/
public void updateCatalogue(BatchCatalogueVO catalogueInput) {
BatchCatalogue catalogue = developCatalogueDao.getOne(catalogueInput.getId());
catalogueOneNotUpdate(catalogue);
if (catalogue == null || catalogue.getIsDeleted() == 1) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_CATALOGUE);
}
if (canNotMoveCatalogue(catalogueInput.getId(), catalogueInput.getNodePid())) {
throw new RdosDefineException(ErrorCode.CAN_NOT_MOVE_CATALOGUE);
}
BatchCatalogue updateCatalogue = new BatchCatalogue();
updateCatalogue.setId(catalogueInput.getId());
// 重命名
if (catalogueInput.getNodeName() != null) {
updateCatalogue.setNodeName(catalogueInput.getNodeName());
}
// 移动
if (catalogueInput.getNodePid() != null && catalogueInput.getNodePid() != 0) {
int parentLevel = this.isOverLevelLimit(catalogueInput.getNodePid());
updateCatalogue.setLevel(parentLevel + 1);
updateCatalogue.setNodePid(catalogueInput.getNodePid());
} else {
updateCatalogue.setNodePid(catalogue.getNodePid());
}
// 判断移动的目录下 有没有相同名称的文件夹
BatchCatalogue byLevelAndPIdAndTenantIdAndName = developCatalogueDao.getBeanByTenantIdAndNameAndParentId(catalogue.getTenantId(), updateCatalogue.getNodeName(), updateCatalogue.getNodePid());
if (byLevelAndPIdAndTenantIdAndName != null && (!byLevelAndPIdAndTenantIdAndName.getId().equals(catalogue.getId()))) {
throw new RdosDefineException(ErrorCode.FILE_NAME_REPETITION);
}
updateCatalogue.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
addOrUpdate(updateCatalogue);
}
Aggregations