use of org.olat.group.model.ContactViewExtended in project OpenOLAT by OpenOLAT.
the class InstantMessagingServiceImpl method getBuddyGroups.
@Override
public List<BuddyGroup> getBuddyGroups(Identity me, boolean offlineUsers) {
List<BuddyGroup> groups = new ArrayList<BuddyGroup>(25);
Map<Long, BuddyGroup> groupMap = new HashMap<Long, BuddyGroup>();
Map<Long, String> identityKeyToStatus = new HashMap<Long, String>();
List<ContactViewExtended> contactList = contactDao.getContactWithExtendedInfos(me);
collectMembersStatus(contactList, identityKeyToStatus);
for (ContactViewExtended contact : contactList) {
addBuddyToGroupList(contact, me, groupMap, groups, identityKeyToStatus, offlineUsers);
}
return groups;
}
use of org.olat.group.model.ContactViewExtended in project openolat by klemens.
the class ContactDAOTest method testGroupOwners.
@Test
public void testGroupOwners() {
// 5 identities
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-3-" + UUID.randomUUID().toString());
Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-4-" + UUID.randomUUID().toString());
Identity id5 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-5-" + UUID.randomUUID().toString());
// create 3 groups
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gfoo", "gfoo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gfpo", "gfpo-desc", 0, 5, true, false, false, true, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "gfqo", "gfqo-desc", 0, 5, true, false, false, false, false);
dbInstance.commitAndCloseSession();
// id1 -> group 1 and 2
// visible
businessGroupRelationDao.addRole(id1, group1, GroupRoles.coach.name());
// visible
businessGroupRelationDao.addRole(id1, group2, GroupRoles.participant.name());
// id2 -> group 1 and 2
// not
businessGroupRelationDao.addRole(id2, group1, GroupRoles.participant.name());
// not
businessGroupRelationDao.addRole(id2, group2, GroupRoles.coach.name());
// id3 -> group 1 and 3
// not
businessGroupRelationDao.addRole(id3, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
// id4 -> group 2
// not
businessGroupRelationDao.addRole(id4, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id4, group3, GroupRoles.coach.name());
// id5 -> group 3
// not
businessGroupRelationDao.addRole(id5, group3, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check identity1 : no contact
Collection<ContactViewExtended> contacts1 = contactDao.getGroupOwners(id1);
Assert.assertNotNull(contacts1);
Assert.assertEquals(1, contacts1.size());
Assert.assertTrue(contacts1.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity2 : contact to id1 and id3
Collection<ContactViewExtended> contacts2 = contactDao.getGroupOwners(id2);
Assert.assertNotNull(contacts2);
Assert.assertEquals(1, contacts2.size());
Assert.assertTrue(contacts2.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity3 : contact to id1 and id2
Collection<ContactViewExtended> contacts3 = contactDao.getGroupOwners(id3);
Assert.assertNotNull(contacts3);
Assert.assertEquals(0, contacts3.size());
// check identity4 : contact to id1
Collection<ContactViewExtended> contacts4 = contactDao.getGroupOwners(id4);
Assert.assertNotNull(contacts4);
Assert.assertEquals(0, contacts4.size());
// check identity5 : contact to id2
Collection<ContactViewExtended> contacts5 = contactDao.getGroupOwners(id5);
Assert.assertNotNull(contacts5);
Assert.assertEquals(0, contacts5.size());
}
use of org.olat.group.model.ContactViewExtended in project openolat by klemens.
the class ContactDAOTest method testGroupParticipants.
@Test
public void testGroupParticipants() {
// 5 identities
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-3-" + UUID.randomUUID().toString());
Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-4-" + UUID.randomUUID().toString());
Identity id5 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-5-" + UUID.randomUUID().toString());
// create 3 groups
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gfoo", "gfoo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gfpo", "gfpo-desc", 0, 5, true, false, false, true, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "gfqo", "gfqo-desc", 0, 5, true, false, false, false, false);
dbInstance.commitAndCloseSession();
// id1 -> group 1 and 2
// visible
businessGroupRelationDao.addRole(id1, group1, GroupRoles.coach.name());
// visible
businessGroupRelationDao.addRole(id1, group2, GroupRoles.participant.name());
// id2 -> group 1 and 2
// not
businessGroupRelationDao.addRole(id2, group1, GroupRoles.participant.name());
// not
businessGroupRelationDao.addRole(id2, group2, GroupRoles.coach.name());
// id3 -> group 1 and 3
// not
businessGroupRelationDao.addRole(id3, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
// id4 -> group 2
// not
businessGroupRelationDao.addRole(id4, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id4, group3, GroupRoles.coach.name());
// id5 -> group 3
// not
businessGroupRelationDao.addRole(id5, group3, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check identity1 : no contact
Collection<ContactViewExtended> contacts1 = contactDao.getParticipants(id1);
Assert.assertNotNull(contacts1);
Assert.assertEquals(1, contacts1.size());
Assert.assertTrue(contacts1.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity2 : contact to id1 and id3
Collection<ContactViewExtended> contacts2 = contactDao.getParticipants(id2);
Assert.assertNotNull(contacts2);
Assert.assertEquals(1, contacts2.size());
Assert.assertTrue(contacts2.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity3 : contact to id1 and id2
Collection<ContactViewExtended> contacts3 = contactDao.getParticipants(id3);
Assert.assertNotNull(contacts3);
Assert.assertEquals(1, contacts3.size());
Assert.assertTrue(contacts3.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity4 : contact to id1
Collection<ContactViewExtended> contacts4 = contactDao.getParticipants(id4);
Assert.assertNotNull(contacts4);
Assert.assertEquals(1, contacts4.size());
Assert.assertTrue(contacts4.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity5 : contact to id2
Collection<ContactViewExtended> contacts5 = contactDao.getParticipants(id5);
Assert.assertNotNull(contacts5);
Assert.assertEquals(0, contacts5.size());
}
use of org.olat.group.model.ContactViewExtended in project OpenOLAT by OpenOLAT.
the class ContactDAOTest method testGroupParticipants.
@Test
public void testGroupParticipants() {
// 5 identities
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-3-" + UUID.randomUUID().toString());
Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-4-" + UUID.randomUUID().toString());
Identity id5 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-5-" + UUID.randomUUID().toString());
// create 3 groups
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gfoo", "gfoo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gfpo", "gfpo-desc", 0, 5, true, false, false, true, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "gfqo", "gfqo-desc", 0, 5, true, false, false, false, false);
dbInstance.commitAndCloseSession();
// id1 -> group 1 and 2
// visible
businessGroupRelationDao.addRole(id1, group1, GroupRoles.coach.name());
// visible
businessGroupRelationDao.addRole(id1, group2, GroupRoles.participant.name());
// id2 -> group 1 and 2
// not
businessGroupRelationDao.addRole(id2, group1, GroupRoles.participant.name());
// not
businessGroupRelationDao.addRole(id2, group2, GroupRoles.coach.name());
// id3 -> group 1 and 3
// not
businessGroupRelationDao.addRole(id3, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
// id4 -> group 2
// not
businessGroupRelationDao.addRole(id4, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id4, group3, GroupRoles.coach.name());
// id5 -> group 3
// not
businessGroupRelationDao.addRole(id5, group3, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check identity1 : no contact
Collection<ContactViewExtended> contacts1 = contactDao.getParticipants(id1);
Assert.assertNotNull(contacts1);
Assert.assertEquals(1, contacts1.size());
Assert.assertTrue(contacts1.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity2 : contact to id1 and id3
Collection<ContactViewExtended> contacts2 = contactDao.getParticipants(id2);
Assert.assertNotNull(contacts2);
Assert.assertEquals(1, contacts2.size());
Assert.assertTrue(contacts2.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity3 : contact to id1 and id2
Collection<ContactViewExtended> contacts3 = contactDao.getParticipants(id3);
Assert.assertNotNull(contacts3);
Assert.assertEquals(1, contacts3.size());
Assert.assertTrue(contacts3.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity4 : contact to id1
Collection<ContactViewExtended> contacts4 = contactDao.getParticipants(id4);
Assert.assertNotNull(contacts4);
Assert.assertEquals(1, contacts4.size());
Assert.assertTrue(contacts4.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity5 : contact to id2
Collection<ContactViewExtended> contacts5 = contactDao.getParticipants(id5);
Assert.assertNotNull(contacts5);
Assert.assertEquals(0, contacts5.size());
}
use of org.olat.group.model.ContactViewExtended in project OpenOLAT by OpenOLAT.
the class ContactDAOTest method testGroupOwners.
@Test
public void testGroupOwners() {
// 5 identities
Identity id1 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-1-" + UUID.randomUUID().toString());
Identity id2 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-2-" + UUID.randomUUID().toString());
Identity id3 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-3-" + UUID.randomUUID().toString());
Identity id4 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-4-" + UUID.randomUUID().toString());
Identity id5 = JunitTestHelper.createAndPersistIdentityAsUser("fdao-5-" + UUID.randomUUID().toString());
// create 3 groups
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "gfoo", "gfoo-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "gfpo", "gfpo-desc", 0, 5, true, false, false, true, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "gfqo", "gfqo-desc", 0, 5, true, false, false, false, false);
dbInstance.commitAndCloseSession();
// id1 -> group 1 and 2
// visible
businessGroupRelationDao.addRole(id1, group1, GroupRoles.coach.name());
// visible
businessGroupRelationDao.addRole(id1, group2, GroupRoles.participant.name());
// id2 -> group 1 and 2
// not
businessGroupRelationDao.addRole(id2, group1, GroupRoles.participant.name());
// not
businessGroupRelationDao.addRole(id2, group2, GroupRoles.coach.name());
// id3 -> group 1 and 3
// not
businessGroupRelationDao.addRole(id3, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id3, group3, GroupRoles.participant.name());
// id4 -> group 2
// not
businessGroupRelationDao.addRole(id4, group2, GroupRoles.coach.name());
// not
businessGroupRelationDao.addRole(id4, group3, GroupRoles.coach.name());
// id5 -> group 3
// not
businessGroupRelationDao.addRole(id5, group3, GroupRoles.coach.name());
dbInstance.commitAndCloseSession();
// check identity1 : no contact
Collection<ContactViewExtended> contacts1 = contactDao.getGroupOwners(id1);
Assert.assertNotNull(contacts1);
Assert.assertEquals(1, contacts1.size());
Assert.assertTrue(contacts1.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity2 : contact to id1 and id3
Collection<ContactViewExtended> contacts2 = contactDao.getGroupOwners(id2);
Assert.assertNotNull(contacts2);
Assert.assertEquals(1, contacts2.size());
Assert.assertTrue(contacts2.iterator().next().getIdentityKey().equals(id1.getKey()));
// check identity3 : contact to id1 and id2
Collection<ContactViewExtended> contacts3 = contactDao.getGroupOwners(id3);
Assert.assertNotNull(contacts3);
Assert.assertEquals(0, contacts3.size());
// check identity4 : contact to id1
Collection<ContactViewExtended> contacts4 = contactDao.getGroupOwners(id4);
Assert.assertNotNull(contacts4);
Assert.assertEquals(0, contacts4.size());
// check identity5 : contact to id2
Collection<ContactViewExtended> contacts5 = contactDao.getGroupOwners(id5);
Assert.assertNotNull(contacts5);
Assert.assertEquals(0, contacts5.size());
}
Aggregations