Search in sources :

Example 1 with RuleQueryProject

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

the class RuleQueryServiceImpl method query.

/**
 * Query rule by creator
 *
 * @param queryParam
 * @return List<RuleQueryProject>
 */
@Override
public List<RuleQueryProject> query(RuleQueryRequest queryParam) {
    DataSourceQo param = new DataSourceQo(queryParam);
    // Query project user by creator
    List<ProjectUser> projectUsers = projectUserDao.findByUsernameAndPermissionsIn(param);
    boolean projectUsersNull = (projectUsers == null || projectUsers.isEmpty());
    if (projectUsersNull) {
        LOGGER.info("[My DataSource] Find no projects of user:{},", queryParam.getUser());
        return null;
    }
    Map<Long, RuleQueryProject> projectMap = new HashMap<>(4);
    getProjectsByUserPerm(param, projectUsers, projectMap);
    if (projectMap.values().isEmpty()) {
        LOGGER.info("[My DataSource] Find no datasources/rules of user, user: {}", queryParam.getUser());
        return null;
    }
    return new ArrayList<>(projectMap.values());
}
Also used : ProjectUser(com.webank.wedatasphere.qualitis.project.entity.ProjectUser) RuleQueryProject(com.webank.wedatasphere.qualitis.query.response.RuleQueryProject) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DataSourceQo(com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo)

Example 2 with RuleQueryProject

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

the class RuleQueryServiceImpl method putIntoProject.

private void putIntoProject(RuleDataSource ds, Map<Long, RuleQueryProject> projectMap, Project project) {
    Rule rule = ds.getRule();
    Long projectId = ds.getProjectId();
    // If contains
    if (projectMap.containsKey(projectId)) {
        RuleQueryProject queryProject = projectMap.get(projectId);
        putIntoRuleOfProject(ds, queryProject);
        return;
    }
    // If not contain
    RuleQueryProject queryProject = newRuleQueryProject(project, rule, ds);
    projectMap.put(projectId, queryProject);
}
Also used : RuleQueryProject(com.webank.wedatasphere.qualitis.query.response.RuleQueryProject) Rule(com.webank.wedatasphere.qualitis.rule.entity.Rule) RuleQueryRule(com.webank.wedatasphere.qualitis.query.response.RuleQueryRule)

Aggregations

RuleQueryProject (com.webank.wedatasphere.qualitis.query.response.RuleQueryProject)2 ProjectUser (com.webank.wedatasphere.qualitis.project.entity.ProjectUser)1 DataSourceQo (com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo)1 RuleQueryRule (com.webank.wedatasphere.qualitis.query.response.RuleQueryRule)1 Rule (com.webank.wedatasphere.qualitis.rule.entity.Rule)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1