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());
}
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());
}
Aggregations