Search in sources :

Example 16 with GeneralResponse

use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.

the class RuleServiceImpl method getRuleDetail.

@Override
public GeneralResponse<RuleDetailResponse> getRuleDetail(Long ruleId) throws UnExpectedRequestException {
    // Check existence of rule
    Rule ruleInDb = ruleDao.findById(ruleId);
    if (ruleInDb == null) {
        throw new UnExpectedRequestException("rule_id [" + ruleId + "] {&DOES_NOT_EXIST}");
    }
    if (!ruleInDb.getRuleType().equals(RuleTypeEnum.SINGLE_TEMPLATE_RULE.getCode())) {
        throw new UnExpectedRequestException("rule(id: [" + ruleId + "]) {&IS_NOT_A_RULE_WITH_TEMPLATE}");
    }
    Long projectInDbId = ruleInDb.getProject().getId();
    String loginUser = HttpUtils.getUserName(httpServletRequest);
    projectService.checkProjectExistence(projectInDbId, loginUser);
    LOGGER.info("Succeed to find rule. rule_id: {}", ruleInDb.getId());
    RuleDetailResponse response = new RuleDetailResponse(ruleInDb);
    LOGGER.info("Succeed to get rule detail. rule_id: {}", ruleId);
    return new GeneralResponse<>("200", "{&GET_RULE_DETAIL_SUCCESSFULLY}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) RuleDetailResponse(com.webank.wedatasphere.qualitis.rule.response.RuleDetailResponse)

Example 17 with GeneralResponse

use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.

the class RuleTemplateServiceImpl method getMultiSourceTemplateMeta.

@Override
public GeneralResponse<?> getMultiSourceTemplateMeta(Long templateId) throws UnExpectedRequestException {
    // Check existence of template and if multi-table rule template
    Template templateInDb = checkRuleTemplate(templateId);
    if (!templateInDb.getTemplateType().equals(RuleTemplateTypeEnum.MULTI_SOURCE_TEMPLATE.getCode())) {
        throw new UnExpectedRequestException("Template : [" + templateId + "] {&IS_NOT_A_MULTI_TEMPLATE}");
    }
    // return show_sql of template and template output
    TemplateInputDemandResponse templateInputDemandResponse = new TemplateInputDemandResponse(templateInDb, RuleTemplateTypeEnum.MULTI_SOURCE_TEMPLATE.getCode());
    LOGGER.info("Succeed to get the meta of multi_rule_template. rule_template_id: {}", templateId);
    return new GeneralResponse<>("200", "{&GET_META_OF_MULTI_RULE_TEMPLATE_SUCCESSFULLY}", templateInputDemandResponse);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) TemplateInputDemandResponse(com.webank.wedatasphere.qualitis.rule.response.TemplateInputDemandResponse) Template(com.webank.wedatasphere.qualitis.rule.entity.Template)

Example 18 with GeneralResponse

use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.

the class RuleTemplateServiceImpl method getRuleMultiTemplateMeta.

/**
 * Get meta data information by template_id
 * @param ruleTemplateId
 * @return
 * @throws UnExpectedRequestException
 */
@Override
public GeneralResponse<TemplateMetaResponse> getRuleMultiTemplateMeta(Long ruleTemplateId) throws UnExpectedRequestException {
    // Find rule template by rule template id
    Template templateInDb = ruleTemplateDao.findById(ruleTemplateId);
    if (null == templateInDb) {
        throw new UnExpectedRequestException("rule_template_id {&CAN_NOT_BE_NULL_OR_EMPTY}");
    }
    // Find meta data of template
    List<TemplateOutputMeta> templateOutputMetas = templateOutputMetaDao.findByRuleTemplate(templateInDb);
    // Add child template
    if (templateInDb.getChildTemplate() != null) {
        templateOutputMetas.addAll(templateOutputMetaDao.findByRuleTemplate(templateInDb.getChildTemplate()));
    }
    List<Integer> types = templateDataSourceTypeDao.findByTemplate(templateInDb).stream().map(TemplateDataSourceType::getDataSourceTypeId).collect(Collectors.toList());
    TemplateMetaResponse response = new TemplateMetaResponse(templateInDb, templateOutputMetas, types);
    LOGGER.info("Succeed to get rule_template, rule template id: {}", ruleTemplateId);
    return new GeneralResponse<>("200", "{&GET_RULE_TEMPLATE_META_SUCCESSFULLY}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) TemplateOutputMeta(com.webank.wedatasphere.qualitis.rule.entity.TemplateOutputMeta) Template(com.webank.wedatasphere.qualitis.rule.entity.Template) TemplateMetaResponse(com.webank.wedatasphere.qualitis.rule.response.TemplateMetaResponse)

Example 19 with GeneralResponse

use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method getApplicationStatus.

@Override
public GeneralResponse<?> getApplicationStatus(String applicationId) throws UnExpectedRequestException {
    // Find application by applicationId
    Application application = applicationDao.findById(applicationId);
    if (application == null) {
        throw new UnExpectedRequestException("Application_id {&DOES_NOT_EXIST}");
    }
    LOGGER.info("Succeed to find application. application: {}", application);
    List<Task> tasks = taskDao.findByApplication(application);
    ApplicationTaskResponse response = new ApplicationTaskResponse(application, tasks);
    LOGGER.info("Succeed to get application status. response: {}", response);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATION_STATUS}", response);
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) Task(com.webank.wedatasphere.qualitis.entity.Task) ApplicationTaskResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskResponse) Application(com.webank.wedatasphere.qualitis.entity.Application)

Example 20 with GeneralResponse

use of com.webank.wedatasphere.qualitis.response.GeneralResponse in project Qualitis by WeBankFinTech.

the class OuterExecutionServiceImpl method getApplicationDynamicStatus.

@Override
public GeneralResponse<?> getApplicationDynamicStatus(String applicationId) throws UnExpectedRequestException {
    // Find application by applicationId
    Application application = applicationDao.findById(applicationId);
    if (application == null) {
        throw new UnExpectedRequestException("Application_id {&DOES_NOT_EXIST}");
    }
    LOGGER.info("Succeed to find application. application: {}", application);
    return new GeneralResponse<>("200", "{&SUCCEED_TO_GET_APPLICATION_STATUS}", new ApplicationTaskResponse(application));
}
Also used : GeneralResponse(com.webank.wedatasphere.qualitis.response.GeneralResponse) UnExpectedRequestException(com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException) ApplicationTaskResponse(com.webank.wedatasphere.qualitis.response.ApplicationTaskResponse) Application(com.webank.wedatasphere.qualitis.entity.Application)

Aggregations

GeneralResponse (com.webank.wedatasphere.qualitis.response.GeneralResponse)146 UnExpectedRequestException (com.webank.wedatasphere.qualitis.exception.UnExpectedRequestException)96 Transactional (org.springframework.transaction.annotation.Transactional)49 ArrayList (java.util.ArrayList)48 User (com.webank.wedatasphere.qualitis.entity.User)40 GetAllResponse (com.webank.wedatasphere.qualitis.response.GetAllResponse)30 Project (com.webank.wedatasphere.qualitis.project.entity.Project)28 Map (java.util.Map)27 ClusterInfo (com.webank.wedatasphere.qualitis.entity.ClusterInfo)26 MetaDataAcquireFailedException (com.webank.wedatasphere.qualitis.metadata.exception.MetaDataAcquireFailedException)24 List (java.util.List)22 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)21 PermissionDeniedRequestException (com.webank.wedatasphere.qualitis.exception.PermissionDeniedRequestException)17 IOException (java.io.IOException)16 UserRole (com.webank.wedatasphere.qualitis.entity.UserRole)15 Date (java.util.Date)15 Task (com.webank.wedatasphere.qualitis.entity.Task)14 JSONObject (org.json.JSONObject)14 HttpEntity (org.springframework.http.HttpEntity)14 HttpHeaders (org.springframework.http.HttpHeaders)14