use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.
the class FormConfig method fullRepresentation.
/**
* Return the full representation of the configuration with the configured form fields and meta data.
*/
public FormConfigFullRepresentation fullRepresentation(MetaStorage storage, Subject requestingUser) {
String ownerName = Optional.ofNullable(owner).map(User::getLabel).orElse(null);
/* Calculate which groups can see this query.
* This is usually not done very often and should be reasonable fast, so don't cache this.
*/
List<GroupId> permittedGroups = new ArrayList<>();
for (Group group : storage.getAllGroups()) {
for (Permission perm : group.getPermissions()) {
if (perm.implies(createPermission(Ability.READ.asSet()))) {
permittedGroups.add(group.getId());
continue;
}
}
}
return FormConfigFullRepresentation.builder().id(getId()).formType(formType).label(label).tags(tags).ownerName(ownerName).own(requestingUser.isOwner(this)).createdAt(getCreationTime().atZone(ZoneId.systemDefault())).shared(shared).groups(permittedGroups).values(values).build();
}
use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.
the class ManagedExecution method setAdditionalFieldsForStatusWithGroups.
private void setAdditionalFieldsForStatusWithGroups(@NonNull MetaStorage storage, FullExecutionStatus status) {
/* Calculate which groups can see this query.
* This usually is usually not done very often and should be reasonable fast, so don't cache this.
*/
List<GroupId> permittedGroups = new ArrayList<>();
for (Group group : storage.getAllGroups()) {
for (Permission perm : group.getPermissions()) {
if (perm.implies(createPermission(Ability.READ.asSet()))) {
permittedGroups.add(group.getId());
continue;
}
}
}
status.setGroups(permittedGroups);
}
use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.
the class GroupHandlingTest method execute.
@Override
public void execute(StandaloneSupport conquery) throws Exception {
MetaStorage storage = conquery.getMetaStorage();
Group group1 = new Group("company", "company", storage);
User user1 = new User("user", "user", storage);
User user1copy = new User("user", "user", storage);
User user2 = new User("user2", "user2", storage);
try {
storage.addGroup(group1);
storage.addUser(user1);
group1.addMember(user1);
group1.addMember(user1copy);
assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId());
group1.addMember(user2);
assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId(), user2.getId());
group1.removeMember(user2);
assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId());
} finally {
storage.removeUser(user1.getId());
storage.removeUser(user2.getId());
storage.removeGroup(group1.getId());
}
}
use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.
the class AdminProcessor method deleteUser.
public synchronized void deleteUser(User user) {
for (Group group : storage.getAllGroups()) {
group.removeMember(user);
}
storage.removeUser(user.getId());
log.trace("Removed user {} from the storage.", user.getId());
}
use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.
the class AdminProcessor method deleteRole.
/**
* Deletes the mandator, that is identified by the id. Its references are
* removed from the users, the groups, and from the storage.
*
* @param role the role to delete
*/
public void deleteRole(Role role) {
log.info("Deleting {}", role);
for (User user : storage.getAllUsers()) {
user.removeRole(role);
}
for (Group group : storage.getAllGroups()) {
group.removeRole(role);
}
storage.removeRole(role.getId());
}
Aggregations