Skip to content

Commit

Permalink
Merge branch 'develop' into fix/form_scan_fail_independently
Browse files Browse the repository at this point in the history
  • Loading branch information
thoniTUB authored Feb 22, 2024
2 parents 47e1ae5 + b5e6216 commit 6ec79a2
Show file tree
Hide file tree
Showing 34 changed files with 566 additions and 237 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ public void addUser(User user) {
}

public User getUser(UserId userId) {
return authUser.get(userId);
final User user = authUser.get(userId);
if (user == null) {
log.warn("Requested unknown user '{}'", userId);
}
return user;
}

public Collection<User> getAllUsers() {
Expand All @@ -118,7 +122,11 @@ public void addRole(Role role) {
}

public Role getRole(RoleId roleId) {
return authRole.get(roleId);
final Role role = authRole.get(roleId);
if (role == null) {
log.warn("Requested unknown role '{}'", roleId);
}
return role;
}

public Collection<Role> getAllRoles() {
Expand All @@ -141,8 +149,12 @@ public void addGroup(Group group) {
authGroup.add(group);
}

public Group getGroup(GroupId id) {
return authGroup.get(id);
public Group getGroup(GroupId groupId) {
final Group group = authGroup.get(groupId);
if (group == null) {
log.warn("Requested unknown group '{}'", groupId);
}
return group;
}

public Collection<Group> getAllGroups() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.inject.Inject;
Expand Down Expand Up @@ -84,11 +86,18 @@ public FrontendAuthOverview getAuthOverview() {
Collection<FrontendAuthOverview.OverviewRow> overview = new TreeSet<>();
for (User user : getStorage().getAllUsers()) {
Collection<Group> userGroups = AuthorizationHelper.getGroupsOf(user, getStorage());
Set<Role> effectiveRoles = user.getRoles().stream().map(getStorage()::getRole).collect(Collectors.toSet());
userGroups.forEach(g -> effectiveRoles.addAll(g.getRoles().stream().map(getStorage()::getRole).sorted().collect(Collectors.toList())));
Set<Role> effectiveRoles = user.getRoles().stream()
.map(getStorage()::getRole)
// Filter role_ids that might not map TODO how do we handle those
.filter(Predicate.not(Objects::isNull))
.collect(Collectors.toCollection(HashSet::new));
userGroups.forEach(g -> effectiveRoles.addAll(g.getRoles().stream()
.map(getStorage()::getRole)
// Filter role_ids that might not map TODO how do we handle those
.filter(Predicate.not(Objects::isNull))
.sorted().toList()));
overview.add(FrontendAuthOverview.OverviewRow.builder().user(user).groups(userGroups).effectiveRoles(effectiveRoles).build());
}

return FrontendAuthOverview.builder().overview(overview).build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.bakdata.conquery.apiv1.query.concept.specific.CQAnd;
import com.bakdata.conquery.sql.conversion.NodeConverter;
import com.bakdata.conquery.sql.conversion.model.LogicalOperation;
import com.bakdata.conquery.sql.conversion.model.QueryStep;
import com.bakdata.conquery.sql.conversion.model.QueryStepJoiner;

public class CQAndConverter implements NodeConverter<CQAnd> {
Expand All @@ -17,12 +18,13 @@ public ConversionContext convert(CQAnd andNode, ConversionContext context) {
if (andNode.getChildren().size() == 1) {
return context.getNodeConversions().convert(andNode.getChildren().get(0), context);
}
return QueryStepJoiner.joinChildren(
QueryStep joined = QueryStepJoiner.joinChildren(
andNode.getChildren(),
context,
LogicalOperation.AND,
andNode.getDateAction()
);
return context.withQueryStep(joined);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.bakdata.conquery.apiv1.query.concept.specific.CQOr;
import com.bakdata.conquery.sql.conversion.NodeConverter;
import com.bakdata.conquery.sql.conversion.model.LogicalOperation;
import com.bakdata.conquery.sql.conversion.model.QueryStep;
import com.bakdata.conquery.sql.conversion.model.QueryStepJoiner;

public class CQOrConverter implements NodeConverter<CQOr> {
Expand All @@ -17,12 +18,13 @@ public ConversionContext convert(CQOr orNode, ConversionContext context) {
if (orNode.getChildren().size() == 1) {
return context.getNodeConversions().convert(orNode.getChildren().get(0), context);
}
return QueryStepJoiner.joinChildren(
QueryStep joined = QueryStepJoiner.joinChildren(
orNode.getChildren(),
context,
LogicalOperation.OR,
orNode.getDateAction()
);
return context.withQueryStep(joined);
}


Expand Down
Loading

0 comments on commit 6ec79a2

Please sign in to comment.