use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method deleteCatalogue.
/**
* 删除目录
*/
public void deleteCatalogue(BatchCatalogue catalogueInput) {
BatchCatalogue catalogue = developCatalogueDao.getOne(catalogueInput.getId());
catalogueOneNotUpdate(catalogue);
if (catalogue == null || catalogue.getIsDeleted() == 1) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_CATALOGUE);
}
// 判断文件夹下任务
List<BatchTask> taskList = batchTaskService.listBatchTaskByNodePid(catalogueInput.getTenantId(), catalogue.getId());
List<BatchResource> resourceList = batchResourceService.listByPidAndTenantId(catalogueInput.getTenantId(), catalogue.getId());
if (taskList.size() > 0 || resourceList.size() > 0) {
throw new RdosDefineException(ErrorCode.CATALOGUE_NO_EMPTY);
}
// 判断文件夹下子目录
if (CollectionUtils.isNotEmpty(developCatalogueDao.listByPidAndTenantId(catalogue.getId(), catalogueInput.getTenantId()))) {
throw new RdosDefineException(ErrorCode.CATALOGUE_NO_EMPTY);
}
catalogue.setIsDeleted(Deleted.DELETED.getStatus());
catalogue.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
developCatalogueDao.deleteById(catalogue.getId());
}
use of com.dtstack.taier.dao.domain.BatchCatalogue in project Taier by DTStack.
the class BatchCatalogueService method addCatalogue.
/**
* 新增 and 修改目录
* @param catalogue
* @return
*/
public CatalogueVO addCatalogue(BatchCatalogue catalogue) {
if (Objects.isNull(catalogue)) {
throw new RdosDefineException(ErrorCode.CATALOGUE_NOT_EMPTY);
}
if (StringUtils.isBlank(catalogue.getNodeName())) {
throw new RdosDefineException(ErrorCode.CATALOGUE_NAME_NOT_EMPTY);
}
catalogue.setNodeName(catalogue.getNodeName().trim());
// 校验文件夹中是否含有空格
if (catalogue.getNodeName().contains(" ")) {
throw new RdosDefineException(ErrorCode.CATALOGUE_NAME_CANNOT_CONTAIN_SPACES);
}
BatchCatalogue dbCatalogue = developCatalogueDao.getByPidAndName(catalogue.getTenantId(), catalogue.getNodePid(), catalogue.getNodeName());
if (dbCatalogue != null) {
throw new RdosDefineException(ErrorCode.CATALOGUE_EXISTS);
}
// 校验当前父级直接一层的子目录或者任务的个数总数不可超过SUB_AMOUNTS_LIMIT(2000)
Integer subAmountsByNodePid = developCatalogueDao.getSubAmountsByNodePid(catalogue.getNodePid(), catalogue.getTenantId());
if (subAmountsByNodePid >= SUB_AMOUNTS_LIMIT) {
throw new RdosDefineException(ErrorCode.SUBDIRECTORY_OR_FILE_AMOUNT_RESTRICTIONS);
}
int parentCatalogueLevel = catalogue.getNodePid() == 0L ? 0 : this.isOverLevelLimit(catalogue.getNodePid());
catalogue.setLevel(parentCatalogueLevel + 1);
catalogue.setCreateUserId(catalogue.getCreateUserId());
catalogue.setGmtModified(Timestamp.valueOf(LocalDateTime.now()));
catalogue.setGmtCreate(Timestamp.valueOf(LocalDateTime.now()));
if (null == catalogue.getCatalogueType()) {
catalogue.setCatalogueType(RdosBatchCatalogueTypeEnum.NORAML.getType());
}
if (RdosBatchCatalogueTypeEnum.TENANT.getType().equals(catalogue.getCatalogueType())) {
if (catalogue.getLevel() > 3) {
throw new RdosDefineException(ErrorCode.CREATE_TENANT_CATALOGUE_LEVE);
}
}
addOrUpdate(catalogue);
CatalogueVO cv = CatalogueVO.toVO(catalogue);
cv.setType(BatchCatalogueService.FILE_TYPE_FOLDER);
return cv;
}
Aggregations