Search in sources :

Example 1 with DataSourceQo

use of com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo 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 DataSourceQo

use of com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo in project Qualitis by WeBankFinTech.

the class PredicateTest method test.

@Test
@Transactional
public void test() {
    String user = "v_wblwyan_test1";
    /*
     * ProjectUserDao测试
     */
    DataSourceQo param = new DataSourceQo();
    param.setUser(user);
    param.setUserType(new Integer[] { ProjectUserPermissionEnum.CREATOR.getCode() });
    List<ProjectUser> projectUsers = dao.findByUsernameAndPermissionsIn(param);
    assertTrue(projectUsers.isEmpty());
    param.setUserType(new Integer[] { ProjectUserPermissionEnum.CREATOR.getCode() });
    projectUsers = dao.findByUsernameAndPermissionsIn(param);
    assertTrue(projectUsers.isEmpty());
    param.setUserType(null);
    projectUsers = dao.findByUsernameAndPermissionsIn(param);
    assertTrue(projectUsers.isEmpty());
    param.setUserType(new Integer[] {});
    projectUsers = dao.findByUsernameAndPermissionsIn(param);
    assertTrue(projectUsers.isEmpty());
    /*
     *TaskDataSourceDao 测试
     */
    List<TaskDataSource> taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, null, null, null, 0, 5);
    assertTrue(taskDataSources.isEmpty());
    taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", null, null, 0, 5);
    assertTrue(taskDataSources.isEmpty());
    taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", "databaseName_test", null, 0, 5);
    assertTrue(taskDataSources.isEmpty());
    taskDataSources = taskDataSourceDao.findByUserAndDataSource(user, "clusterName_test", "databaseName_test", "tableName_test", 0, 5);
    assertTrue(taskDataSources.isEmpty());
    long count = taskDataSourceDao.countByUserAndDataSource(user, "clusterName_test", "databaseName_test", null);
    assertEquals(0, count);
    /*
     *RuleDataSourceDao 测试
     */
    List<RuleDataSource> ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, null, null, null);
    assertTrue(ruleDataSources.isEmpty());
    ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, "clusterName_test", null, null);
    assertTrue(ruleDataSources.isEmpty());
    ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, "clusterName_test", "databaseName_test", null);
    assertTrue(ruleDataSources.isEmpty());
    ruleDataSources = ruleDataSourceDao.findByProjectUser((long) Integer.MAX_VALUE, "clusterName_test", "databaseName_test", "tableName_test");
    assertTrue(ruleDataSources.isEmpty());
}
Also used : ProjectUser(com.webank.wedatasphere.qualitis.project.entity.ProjectUser) RuleDataSource(com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource) TaskDataSource(com.webank.wedatasphere.qualitis.entity.TaskDataSource) DataSourceQo(com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

ProjectUser (com.webank.wedatasphere.qualitis.project.entity.ProjectUser)2 DataSourceQo (com.webank.wedatasphere.qualitis.query.queryqo.DataSourceQo)2 TaskDataSource (com.webank.wedatasphere.qualitis.entity.TaskDataSource)1 RuleQueryProject (com.webank.wedatasphere.qualitis.query.response.RuleQueryProject)1 RuleDataSource (com.webank.wedatasphere.qualitis.rule.entity.RuleDataSource)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 Transactional (org.springframework.transaction.annotation.Transactional)1