use of org.olat.group.model.BGRepositoryEntryRelation in project OpenOLAT by OpenOLAT.
the class GroupSearchController method doSearchGroups.
/**
* Perform a search for the given search value in the search result providers
* and clear any GUI errors that might be on the page
*
* @param searchValue
* @param ureq
*/
private void doSearchGroups(String searchValue) {
if (StringHelper.containsNonWhitespace(searchValue)) {
SearchBusinessGroupParams param1s = new SearchBusinessGroupParams();
param1s.setNameOrDesc(searchValue);
Set<BusinessGroup> dedupGroups = new HashSet<>();
List<BusinessGroup> group1s = businessGroupService.findBusinessGroups(param1s, null, 0, -1);
filterGroups(group1s, dedupGroups);
SearchBusinessGroupParams param2s = new SearchBusinessGroupParams();
param2s.setCourseTitle(searchValue);
List<BusinessGroup> group2s = businessGroupService.findBusinessGroups(param2s, null, 0, -1);
filterGroups(group2s, dedupGroups);
List<BusinessGroup> groups = new ArrayList<BusinessGroup>(group1s.size() + group2s.size());
groups.addAll(group1s);
groups.addAll(group2s);
List<Long> groupKeysWithRelations = PersistenceHelper.toKeys(groups);
List<BGRepositoryEntryRelation> resources = businessGroupService.findRelationToRepositoryEntries(groupKeysWithRelations, 0, -1);
List<GroupWrapper> groupWrappers = new ArrayList<GroupWrapper>();
for (BusinessGroup group : groups) {
StringBuilder sb = new StringBuilder();
for (BGRepositoryEntryRelation resource : resources) {
if (resource.getGroupKey().equals(group.getKey())) {
if (sb.length() > 0)
sb.append(", ");
sb.append(resource.getRepositoryEntryDisplayName());
}
}
GroupWrapper wrapper = new GroupWrapper(group, sb.toString());
wrapper.setTutor(createSelection("tutor_" + group.getKey()));
wrapper.setParticipant(createSelection("participant_" + group.getKey()));
groupWrappers.add(wrapper);
}
table.reset();
tableDataModel.setObjects(groupWrappers);
errorComp.clearError();
}
}
use of org.olat.group.model.BGRepositoryEntryRelation in project OpenOLAT by OpenOLAT.
the class BusinessGroupMembershipProcessor method processIdentityRemoved.
private void processIdentityRemoved(Long groupKey, Long identityKey) {
IdentityRef identityRef = new IdentityRefImpl(identityKey);
BusinessGroupRef groupRef = new BusinessGroupRefImpl(groupKey);
if (!businessGroupRelationDao.hasAnyRole(identityRef, groupRef)) {
infoMessageManager.updateInfoMessagesOfIdentity(groupRef, identityRef);
notificationsManager.unsubscribeAllForIdentityAndResId(identityRef, groupRef.getKey());
List<BGRepositoryEntryRelation> relations = businessGroupRelationDao.findRelationToRepositoryEntries(Collections.singletonList(groupKey), 0, -1);
for (BGRepositoryEntryRelation relation : relations) {
Long repositoryEntryKey = relation.getRepositoryEntryKey();
RepositoryEntryRef entryRef = new RepositoryEntryRefImpl(repositoryEntryKey);
List<String> remaingRoles = repositoryEntryRelationDao.getRoles(identityRef, entryRef);
if (remaingRoles.isEmpty()) {
OLATResource resource = repositoryManager.lookupRepositoryEntryResource(entryRef.getKey());
notificationsManager.unsubscribeAllForIdentityAndResId(identityRef, resource.getResourceableId());
}
}
}
}
use of org.olat.group.model.BGRepositoryEntryRelation in project openolat by klemens.
the class BusinessGroupRelationDAOTest method findRelationToRepositoryEntries.
@Test
public void findRelationToRepositoryEntries() {
// create 3 entries and 1 group
RepositoryEntry re1 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re2 = JunitTestHelper.createAndPersistRepositoryEntry();
RepositoryEntry re3 = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group = businessGroupDao.createAndPersist(null, "rel-repo", "rel-repo-desc", 0, 10, true, false, false, false, false);
dbInstance.commitAndCloseSession();
businessGroupRelationDao.addRelationToResource(group, re1);
businessGroupRelationDao.addRelationToResource(group, re2);
businessGroupRelationDao.addRelationToResource(group, re3);
dbInstance.commitAndCloseSession();
// check with empty list of groups
List<BGRepositoryEntryRelation> emptyRelations = businessGroupRelationDao.findRelationToRepositoryEntries(Collections.<Long>emptyList(), 0, -1);
Assert.assertNotNull(emptyRelations);
Assert.assertEquals(0, emptyRelations.size());
// check with the group
List<BGRepositoryEntryRelation> relations = businessGroupRelationDao.findRelationToRepositoryEntries(Collections.singletonList(group.getKey()), 0, -1);
Assert.assertNotNull(relations);
Assert.assertEquals(3, relations.size());
int count = 0;
for (BGRepositoryEntryRelation relation : relations) {
if (relation.getRepositoryEntryKey().equals(re1.getKey()) || relation.getRepositoryEntryKey().equals(re2.getKey()) || relation.getRepositoryEntryKey().equals(re3.getKey())) {
count++;
}
}
Assert.assertEquals(3, count);
}
Aggregations