use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.
the class GTAReminderRuleTest method addEnrollmentDate.
private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
rel.getGroup();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(field, amount);
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(cal.getTime());
membership.setLastModified(cal.getTime());
membership.setGroup(rel.getGroup());
membership.setIdentity(id);
membership.setRole(role.name());
dbInstance.getCurrentEntityManager().persist(membership);
dbInstance.commit();
}
use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.
the class ReminderRuleEngineTest method addEnrollmentDate.
private void addEnrollmentDate(RepositoryEntry entry, Identity id, GroupRoles role, int amount, int field) {
RepositoryEntryToGroupRelation rel = entry.getGroups().iterator().next();
rel.getGroup();
Calendar cal = Calendar.getInstance();
cal.setTime(new Date());
cal.add(field, amount);
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(cal.getTime());
membership.setLastModified(cal.getTime());
membership.setGroup(rel.getGroup());
membership.setIdentity(id);
membership.setRole(role.name());
dbInstance.getCurrentEntityManager().persist(membership);
dbInstance.commit();
}
use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_10_0_0 method processSecurityGroup.
private void processSecurityGroup(Group group, String role, SecurityGroup secGroup) {
if (secGroup == null)
return;
List<SecurityGroupMembershipImpl> oldMemberships = getMembershipsOfSecurityGroup(secGroup);
for (SecurityGroupMembershipImpl oldMembership : oldMemberships) {
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(oldMembership.getCreationDate());
membership.setLastModified(oldMembership.getLastModified());
membership.setGroup(group);
membership.setIdentity(oldMembership.getIdentity());
membership.setRole(role);
dbInstance.getCurrentEntityManager().persist(membership);
Set<GroupMembership> members = ((GroupImpl) group).getMembers();
if (members == null) {
members = new HashSet<>();
((GroupImpl) group).setMembers(members);
}
members.add(membership);
}
}
use of org.olat.basesecurity.model.GroupMembershipImpl in project OpenOLAT by OpenOLAT.
the class BusinessGroupRelationDAO method touchMembership.
public void touchMembership(IdentityRef identity, BusinessGroupRef group) {
StringBuilder sb = new StringBuilder();
sb.append("select membership from businessgroup as bgroup ").append(" inner join bgroup.baseGroup as baseGroup").append(" inner join baseGroup.members as membership").append(" where bgroup.key=:businessGroupKey and membership.identity.key=:identityKey");
List<GroupMembershipImpl> memberships = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), GroupMembershipImpl.class).setParameter("businessGroupKey", group.getKey()).setParameter("identityKey", identity.getKey()).getResultList();
for (GroupMembershipImpl membership : memberships) {
membership.setLastModified(new Date());
}
}
use of org.olat.basesecurity.model.GroupMembershipImpl in project openolat by klemens.
the class GroupDAO method addMembershipOneWay.
/**
* Create a membership without updating the set in the group.
*/
public void addMembershipOneWay(Group group, Identity identity, String role) {
GroupMembershipImpl membership = new GroupMembershipImpl();
membership.setCreationDate(new Date());
membership.setLastModified(new Date());
membership.setGroup(group);
membership.setIdentity(identity);
membership.setRole(role);
dbInstance.getCurrentEntityManager().persist(membership);
}
Aggregations