Search in sources :

Example 1 with Tenant

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);
}
Also used : Tenant(com.dtstack.taier.dao.domain.Tenant) ClusterTenant(com.dtstack.taier.dao.domain.ClusterTenant)

Example 2 with 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;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) SourceDTOType(com.dtstack.taier.develop.enums.develop.SourceDTOType) DependencyType(com.dtstack.taier.common.enums.DependencyType) TaskParamTemplate(com.dtstack.taier.dao.domain.TaskParamTemplate) ISourceDTO(com.dtstack.dtcenter.loader.dto.source.ISourceDTO) CatalogueType(com.dtstack.taier.common.enums.CatalogueType) Autowired(org.springframework.beans.factory.annotation.Autowired) KerberosConfigVerify(com.dtstack.taier.common.kerberos.KerberosConfigVerify) JSONPath(com.alibaba.fastjson.JSONPath) BooleanUtils(org.apache.commons.lang.BooleanUtils) SyncModel(com.dtstack.taier.develop.enums.develop.SyncModel) Matcher(java.util.regex.Matcher) ComponentService(com.dtstack.taier.scheduler.service.ComponentService) Pair(org.apache.commons.lang3.tuple.Pair) BatchReadWriteLock(com.dtstack.taier.dao.domain.BatchReadWriteLock) Map(java.util.Map) TaskCatalogueVO(com.dtstack.taier.develop.dto.devlop.TaskCatalogueVO) TaskGetNotDeleteVO(com.dtstack.taier.develop.dto.devlop.TaskGetNotDeleteVO) DevelopTaskDao(com.dtstack.taier.dao.mapper.DevelopTaskDao) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) DictType(com.dtstack.taier.common.enums.DictType) Strings(com.dtstack.taier.common.util.Strings) BatchTaskVersionDetailDTO(com.dtstack.taier.dao.dto.BatchTaskVersionDetailDTO) Resource(javax.annotation.Resource) PublishTaskStatusEnum(com.dtstack.taier.common.enums.PublishTaskStatusEnum) AllProductGlobalSearchVO(com.dtstack.taier.develop.vo.develop.query.AllProductGlobalSearchVO) Set(java.util.Set) DatasourceService(com.dtstack.taier.develop.service.datasource.impl.DatasourceService) BatchTaskVersion(com.dtstack.taier.dao.domain.BatchTaskVersion) BatchResource(com.dtstack.taier.dao.domain.BatchResource) SyncJobCheck(com.dtstack.taier.develop.utils.develop.sync.job.SyncJobCheck) ScheduleTaskVO(com.dtstack.taier.scheduler.vo.ScheduleTaskVO) TypeReference(com.alibaba.fastjson.TypeReference) SqlQueryDTO(com.dtstack.dtcenter.loader.dto.SqlQueryDTO) PageQuery(com.dtstack.taier.dao.pager.PageQuery) BatchTaskBatchVO(com.dtstack.taier.develop.dto.devlop.BatchTaskBatchVO) EScheduleStatus(com.dtstack.taier.common.enums.EScheduleStatus) ScheduleFactory(com.dtstack.taier.develop.parser.ScheduleFactory) CheckSyntaxResult(com.dtstack.taier.develop.dto.devlop.CheckSyntaxResult) LocalDateTime(java.time.LocalDateTime) EnvironmentContext(com.dtstack.taier.common.env.EnvironmentContext) TenantService(com.dtstack.taier.develop.service.console.TenantService) SimpleDateFormat(java.text.SimpleDateFormat) IClient(com.dtstack.dtcenter.loader.client.IClient) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) MathUtil(com.dtstack.taier.pluginapi.util.MathUtil) ArrayList(java.util.ArrayList) UserDTO(com.dtstack.taier.dao.dto.UserDTO) JSONArray(com.alibaba.fastjson.JSONArray) Dict(com.dtstack.taier.dao.domain.Dict) FuncType(com.dtstack.taier.common.enums.FuncType) Tenant(com.dtstack.taier.dao.domain.Tenant) Lists(com.google.common.collect.Lists) Service(org.springframework.stereotype.Service) ClusterService(com.dtstack.taier.scheduler.service.ClusterService) DataSourceType(com.dtstack.dtcenter.loader.source.DataSourceType) TaskLockStatus(com.dtstack.taier.common.enums.TaskLockStatus) ErrorCode(com.dtstack.taier.common.exception.ErrorCode) TaskOperateType(com.dtstack.taier.develop.enums.develop.TaskOperateType) ScheduleTaskShadeDTO(com.dtstack.taier.scheduler.dto.schedule.ScheduleTaskShadeDTO) User(com.dtstack.taier.dao.domain.User) IOException(java.io.IOException) Sort(com.dtstack.taier.dao.pager.Sort) ScheduleDictService(com.dtstack.taier.scheduler.service.ScheduleDictService) File(java.io.File) BatchTaskResource(com.dtstack.taier.dao.domain.BatchTaskResource) JSON(com.alibaba.fastjson.JSON) PublicUtil(com.dtstack.taier.common.util.PublicUtil) BatchDataSource(com.dtstack.taier.dao.domain.BatchDataSource) ResourceRefType(com.dtstack.taier.common.enums.ResourceRefType) Preconditions(com.google.common.base.Preconditions) EScheduleJobType(com.dtstack.taier.common.enums.EScheduleJobType) SavaTaskDTO(com.dtstack.taier.scheduler.dto.schedule.SavaTaskDTO) UserService(com.dtstack.taier.develop.service.user.UserService) Date(java.util.Date) ListUtils(org.apache.commons.collections.ListUtils) LoggerFactory(org.slf4j.LoggerFactory) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) BatchTaskGetComponentVersionResultVO(com.dtstack.taier.develop.vo.develop.result.BatchTaskGetComponentVersionResultVO) ColumnMetaDTO(com.dtstack.dtcenter.loader.dto.ColumnMetaDTO) Base64Util(com.dtstack.taier.common.util.Base64Util) Component(com.dtstack.taier.dao.domain.Component) ScheduleCron(com.dtstack.taier.develop.parser.ScheduleCron) DateFormat(java.text.DateFormat) EDeployType(com.dtstack.taier.common.enums.EDeployType) PatternConstant(com.dtstack.taier.common.constant.PatternConstant) ESchedulePeriodType(com.dtstack.taier.develop.parser.ESchedulePeriodType) Timestamp(java.sql.Timestamp) Collection(java.util.Collection) IKerberos(com.dtstack.dtcenter.loader.client.IKerberos) ClientCache(com.dtstack.dtcenter.loader.client.ClientCache) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TaskCheckResultVO(com.dtstack.taier.develop.dto.devlop.TaskCheckResultVO) TaskResourceParam(com.dtstack.taier.develop.dto.devlop.TaskResourceParam) Objects(java.util.Objects) List(java.util.List) BatchSysParameter(com.dtstack.taier.dao.domain.BatchSysParameter) DevelopReadWriteLockDao(com.dtstack.taier.dao.mapper.DevelopReadWriteLockDao) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) JSONObject(com.alibaba.fastjson.JSONObject) PluginName(com.dtstack.taier.develop.utils.develop.sync.job.PluginName) Pattern(java.util.regex.Pattern) BatchAllProductGlobalReturnVO(com.dtstack.taier.develop.vo.develop.result.BatchAllProductGlobalReturnVO) Deleted(com.dtstack.taier.common.enums.Deleted) BeanUtils(org.springframework.beans.BeanUtils) HashMap(java.util.HashMap) BatchCatalogue(com.dtstack.taier.dao.domain.BatchCatalogue) HashSet(java.util.HashSet) TaskCreateModelType(com.dtstack.taier.develop.enums.develop.TaskCreateModelType) CollectionUtils(org.apache.commons.collections.CollectionUtils) TaskParamTemplateService(com.dtstack.taier.develop.service.task.TaskParamTemplateService) Constant(com.dtstack.taier.develop.utils.develop.common.enums.Constant) DtCenterDefException(com.dtstack.taier.common.exception.DtCenterDefException) BatchTask(com.dtstack.taier.dao.domain.BatchTask) TaskService(com.dtstack.taier.develop.service.schedule.TaskService) Logger(org.slf4j.Logger) MapUtils(org.apache.commons.collections.MapUtils) DataFilter(com.dtstack.taier.common.util.DataFilter) ReadWriteLockType(com.dtstack.taier.common.enums.ReadWriteLockType) BatchTaskDTO(com.dtstack.taier.dao.dto.BatchTaskDTO) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Maps(com.google.common.collect.Maps) EComponentType(com.dtstack.taier.common.enums.EComponentType) ReadWriteLockVO(com.dtstack.taier.develop.dto.devlop.ReadWriteLockVO) BatchTaskParam(com.dtstack.taier.dao.domain.BatchTaskParam) Comparator(java.util.Comparator) ESubmitStatus(com.dtstack.taier.common.enums.ESubmitStatus) JsonUtils(com.dtstack.taier.common.util.JsonUtils) Transactional(org.springframework.transaction.annotation.Transactional) BatchTask(com.dtstack.taier.dao.domain.BatchTask) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) ArrayList(java.util.ArrayList) BatchAllProductGlobalReturnVO(com.dtstack.taier.develop.vo.develop.result.BatchAllProductGlobalReturnVO) ScheduleTaskShade(com.dtstack.taier.dao.domain.ScheduleTaskShade) BatchTaskTask(com.dtstack.taier.dao.domain.BatchTaskTask) Tenant(com.dtstack.taier.dao.domain.Tenant)

Example 3 with Tenant

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();
}
Also used : Tenant(com.dtstack.taier.dao.domain.Tenant) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 4 with Tenant

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());
}
Also used : DtUser(com.dtstack.taier.develop.dto.user.DtUser) User(com.dtstack.taier.dao.domain.User) Tenant(com.dtstack.taier.dao.domain.Tenant) RdosDefineException(com.dtstack.taier.common.exception.RdosDefineException) DTToken(com.dtstack.taier.develop.dto.user.DTToken) DtUser(com.dtstack.taier.develop.dto.user.DtUser) PostMapping(org.springframework.web.bind.annotation.PostMapping)

Example 5 with Tenant

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);
}
Also used : Tenant(com.dtstack.taier.dao.domain.Tenant) ClusterTenant(com.dtstack.taier.dao.domain.ClusterTenant) ComponentBindDBDTO(com.dtstack.taier.develop.dto.devlop.ComponentBindDBDTO) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

Tenant (com.dtstack.taier.dao.domain.Tenant)6 RdosDefineException (com.dtstack.taier.common.exception.RdosDefineException)3 PostMapping (org.springframework.web.bind.annotation.PostMapping)2 JSON (com.alibaba.fastjson.JSON)1 JSONArray (com.alibaba.fastjson.JSONArray)1 JSONObject (com.alibaba.fastjson.JSONObject)1 JSONPath (com.alibaba.fastjson.JSONPath)1 TypeReference (com.alibaba.fastjson.TypeReference)1 ClientCache (com.dtstack.dtcenter.loader.client.ClientCache)1 IClient (com.dtstack.dtcenter.loader.client.IClient)1 IKerberos (com.dtstack.dtcenter.loader.client.IKerberos)1 ColumnMetaDTO (com.dtstack.dtcenter.loader.dto.ColumnMetaDTO)1 SqlQueryDTO (com.dtstack.dtcenter.loader.dto.SqlQueryDTO)1 ISourceDTO (com.dtstack.dtcenter.loader.dto.source.ISourceDTO)1 DataSourceType (com.dtstack.dtcenter.loader.source.DataSourceType)1 PatternConstant (com.dtstack.taier.common.constant.PatternConstant)1 CatalogueType (com.dtstack.taier.common.enums.CatalogueType)1 Deleted (com.dtstack.taier.common.enums.Deleted)1 DependencyType (com.dtstack.taier.common.enums.DependencyType)1 DictType (com.dtstack.taier.common.enums.DictType)1