Skip to content

Commit

Permalink
[KNOWAGE-6095] Do not show unshared datasets in list
Browse files Browse the repository at this point in the history
In the "All Data Set" tab we must show datasets with category = null ONLY IF current user is owner.
  • Loading branch information
Marco Balestri committed Jul 28, 2021
1 parent 11d4588 commit b50c6c2
Showing 1 changed file with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ private static void initialize(List<SbiDataSet> datasets) {
}

@Override
public List<SbiDataSet> list(int offset, int fetchSize, String owner, String sortByColumn, boolean reverse, List<Integer> tagIds, List<SbiDataSetFilter> filter) {
public List<SbiDataSet> list(int offset, int fetchSize, String owner, String sortByColumn, boolean reverse, List<Integer> tagIds,
List<SbiDataSetFilter> filter) {

Session session = null;
List<SbiDataSet> ret = Collections.emptyList();
Expand All @@ -417,9 +418,10 @@ public List<SbiDataSet> list(int offset, int fetchSize, String owner, String sor

ret = cr.list();

} catch(Exception ex) {
LogMF.error(logger, "Error getting list of dataset with offset {0}, limit {1}, owner {2}, sorting column {3}, reverse {4} and tags {5}", new Object[] { offset, fetchSize, owner, sortByColumn, reverse, tagIds });
}finally {
} catch (Exception ex) {
LogMF.error(logger, "Error getting list of dataset with offset {0}, limit {1}, owner {2}, sorting column {3}, reverse {4} and tags {5}",
new Object[] { offset, fetchSize, owner, sortByColumn, reverse, tagIds });
} finally {
if (session != null) {
session.close();
}
Expand All @@ -429,7 +431,8 @@ public List<SbiDataSet> list(int offset, int fetchSize, String owner, String sor
}

@Override
public List<SbiDataSet> workspaceList(int offset, int fetchSize, String owner, boolean includeOwned, boolean includePublic, String scope, String type, Set<Domain> categoryList, String implementation, boolean showDerivedDatasets) {
public List<SbiDataSet> workspaceList(int offset, int fetchSize, String owner, boolean includeOwned, boolean includePublic, String scope, String type,
Set<Domain> categoryList, String implementation, boolean showDerivedDatasets) {

List<SbiDataSet> results = Collections.emptyList();
Session session = null;
Expand Down Expand Up @@ -505,15 +508,13 @@ public List<SbiDataSet> loadMyDataSets(int offset, int fetchSize, UserProfile us
statement.append("from SbiDataSet ds where ds.active = :active and (ds.owner = :owner or (");
session = getSession();
categoryList = UserUtilities.getDataSetCategoriesByUser(userProfile);
if (categoryList.isEmpty()) {
statement.append("ds.category.valueId is null ");
} else {
if (!categoryList.isEmpty()) {
categoryIds = extractCategoryIds(categoryList);
statement.append("(ds.category.valueId is null or ds.category.valueId in (:categories)) ");
statement.append("ds.category.valueId in (:categories) and ");
}

statement.append(
"and ds.scope.valueId in (select dom.valueId from SbiDomains dom where dom.valueCd in ('USER', 'ENTERPRISE') and dom.domainCd = 'DS_SCOPE')))");
"ds.scope.valueId in (select dom.valueId from SbiDomains dom where dom.valueCd in ('USER', 'ENTERPRISE') and dom.domainCd = 'DS_SCOPE')))");

Query query = session.createQuery(statement.toString());
query.setBoolean("active", true);
Expand Down Expand Up @@ -546,7 +547,6 @@ private List<Integer> extractCategoryIds(Set<Domain> categoryList) {
return toReturn;
}


private void withImplementation(Criteria cr, String implementation) {
if (StringUtils.isNotEmpty(implementation)) {
cr.add(Restrictions.eq("type", implementation));
Expand Down Expand Up @@ -655,8 +655,6 @@ private void filterOn(Criteria cr, List<SbiDataSetFilter> filters) {
}
}



private Criterion onlyActiveRestriction() {
return Restrictions.eq("active", true);
}
Expand All @@ -674,5 +672,4 @@ private Criterion ownedByRestriction(IEngUserProfile userProfile) {
return Restrictions.eq("owner", owner);
}


}

0 comments on commit b50c6c2

Please sign in to comment.