use of com.dtstack.taier.dao.domain.Tenant in project Taier by DTStack.
the class TenantService method addTenant.
public void addTenant(String tenantName, Long createUserId) {
Tenant tenant = new Tenant();
tenant.setTenantName(tenantName);
tenant.setCreateUserId(createUserId);
tenant.setGmtCreate(Timestamp.from(Instant.now()));
tenantMapper.insert(tenant);
}
use of com.dtstack.taier.dao.domain.Tenant in project Taier by DTStack.
the class BatchTaskService method allProductGlobalSearch.
/**
* 查找所有产品提交的任务
*
* @param searchVO
* @return
*/
public List<BatchAllProductGlobalReturnVO> allProductGlobalSearch(AllProductGlobalSearchVO searchVO) {
BatchTask batchTask = developTaskDao.getOne(searchVO.getTaskId());
if (batchTask == null) {
throw new RdosDefineException(ErrorCode.CAN_NOT_FIND_TASK);
}
if (batchTask.getTaskType().intValue() == EScheduleJobType.VIRTUAL.getVal().intValue()) {
throw new RdosDefineException(ErrorCode.VIRTUAL_TASK_UNSUPPORTED_OPERATION);
}
// 过滤掉已经依赖的任务
final List<BatchTaskTask> taskTasks = this.batchTaskTaskService.getByParentTaskId(searchVO.getTaskId());
final List<Long> excludeIds = new ArrayList<>(taskTasks.size());
excludeIds.add(searchVO.getTaskId());
taskTasks.forEach(taskTask -> excludeIds.add(taskTask.getTaskId()));
List<ScheduleTaskShade> scheduleTaskShadeList = taskService.findTaskByTaskName(searchVO.getTaskName(), searchVO.getSelectTenantId(), searchVO.getUserId());
List<ScheduleTaskShade> filterTask = scheduleTaskShadeList.stream().filter(scheduleTask -> !excludeIds.contains(scheduleTask.getTaskId())).collect(Collectors.toList());
Map<Long, Tenant> tenantMap = tenantService.listAllTenant().stream().collect(Collectors.toMap(Tenant::getId, g -> (g)));
List<BatchAllProductGlobalReturnVO> voList = Lists.newArrayList();
for (ScheduleTaskShade scheduleTaskShade : filterTask) {
BatchAllProductGlobalReturnVO vo = new BatchAllProductGlobalReturnVO();
vo.setTaskId(scheduleTaskShade.getTaskId());
vo.setTaskName(scheduleTaskShade.getName());
Tenant tenant = tenantMap.get(scheduleTaskShade.getTenantId());
if (tenant != null) {
vo.setTenantId(tenant.getId());
vo.setTenantName(tenant.getTenantName());
}
voList.add(vo);
}
return voList;
}
use of com.dtstack.taier.dao.domain.Tenant in project Taier by DTStack.
the class TenantController method addTenant.
@PostMapping(value = "/addTenant")
public R<Void> addTenant(@RequestParam("tenantName") String tenantName, @CookieValue(Cookies.USER_ID) Long userId) throws Exception {
if (StringUtils.isBlank(tenantName)) {
throw new RdosDefineException(ErrorCode.INVALID_PARAMETERS);
}
Tenant tenant = tenantService.findByName(tenantName.trim());
if (null != tenant) {
throw new RdosDefineException("tenant has exist");
}
tenantService.addTenant(tenantName, userId);
return R.empty();
}
use of com.dtstack.taier.dao.domain.Tenant in project Taier by DTStack.
the class UserController method switchTenant.
@PostMapping(value = "/switchTenant")
public R<String> switchTenant(@RequestParam(value = "tenantId") Long tenantId, HttpServletRequest request, HttpServletResponse response) {
String token = cookieService.token(request);
if (StringUtils.isBlank(token)) {
throw new RdosDefineException(ErrorCode.TOKEN_IS_NULL);
}
DTToken decryption = tokenService.decryption(token);
Long userId = decryption.getUserId();
User user = userService.getById(userId);
if (null == user) {
throw new RdosDefineException(ErrorCode.USER_IS_NULL);
}
Tenant tenant = tenantService.getTenantById(tenantId);
if (null == tenant) {
throw new RdosDefineException(ErrorCode.TENANT_IS_NULL);
}
DtUser dtUser = new DtUser();
dtUser.setUserId(user.getId());
dtUser.setUserName(user.getUserName());
dtUser.setEmail(user.getEmail());
dtUser.setPhone(user.getPhoneNumber());
dtUser.setTenantId(tenantId);
dtUser.setTenantName(tenant.getTenantName());
loginService.onAuthenticationSuccess(request, response, dtUser);
return R.ok(user.getUserName());
}
use of com.dtstack.taier.dao.domain.Tenant in project Taier by DTStack.
the class TenantService method bindingTenant.
@Transactional(rollbackFor = Exception.class)
public void bindingTenant(Long tenantId, Long clusterId, Long queueId, String clusterName, List<ComponentBindDBVO> bindDBDTOList) throws Exception {
Tenant tenant = getTenant(tenantId);
checkTenantBindStatus(tenantId);
checkClusterCanUse(clusterName);
addClusterTenant(tenant.getId(), clusterId);
if (queueId != null) {
// hadoop
updateTenantQueue(tenantId, clusterId, queueId);
}
List<ComponentBindDBDTO> bindDTOList = ClusterTransfer.INSTANCE.bindDBtoDTOList(bindDBDTOList);
initDataDevelop(clusterId, tenantId, tenant.getCreateUserId(), tenant.getTenantName(), tenant.getTenantDesc(), bindDTOList);
}
Aggregations