use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class MembersPrintController method initFormMemberList.
private void initFormMemberList(String name, String label, List<Identity> members) {
List<Member> memberWrappers = members.stream().map(m -> createMember(m)).collect(Collectors.toList());
VelocityContainer listVC = createVelocityContainer("printList");
listVC.contextPut("label", label);
listVC.contextPut("avatarBaseURL", avatarBaseURL);
listVC.contextPut("members", memberWrappers);
listVC.contextPut("typecss", "o_" + name);
listVC.contextPut("userPropertyPrintHandlers", userPropertyPrintHandlers);
// add lookup table so the avatar properties can be read out from the member object that contains the full list of attributes
Map<String, Integer> handlerLookupMap = new HashMap<String, Integer>();
for (int i = userPropertyPrintHandlers.size(); i-- > 0; ) {
UserPropertyHandler handler = userPropertyPrintHandlers.get(i);
handlerLookupMap.put(handler.getName(), i);
}
listVC.contextPut("handlerLookupMap", handlerLookupMap);
mainVC.put(name, listVC);
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class MembersMailController method doSend.
private void doSend(UserRequest ureq) {
ContactList contactList = new ContactList("");
if (courseEnv == null) {
if (coachEl != null && coachEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(coachList.size());
for (Member coach : coachList) {
identityKeys.add(coach.getKey());
}
List<Identity> coaches = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(coaches);
}
if (participantEl != null && participantEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(participantList.size());
for (Member participant : participantList) {
identityKeys.add(participant.getKey());
}
List<Identity> participants = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(participants);
}
if (waitingEl != null && waitingEl.isAtLeastSelected(1)) {
List<Long> identityKeys = new ArrayList<>(waitingList.size());
for (Member waiter : waitingList) {
identityKeys.add(waiter.getKey());
}
List<Identity> waiters = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(waiters);
}
} else {
if (ownerEl != null && ownerEl.isAtLeastSelected(1)) {
RepositoryEntry courseRepositoryEntry = courseEnv.getCourseGroupManager().getCourseEntry();
List<Identity> owners = repositoryService.getMembers(courseRepositoryEntry, GroupRoles.owner.name());
contactList.addAllIdentites(owners);
}
if (coachEl != null && coachEl.isAtLeastSelected(1)) {
Set<Long> sendToWhatYouSee = new HashSet<>();
for (Member coach : coachList) {
sendToWhatYouSee.add(coach.getKey());
}
CourseGroupManager cgm = courseEnv.getCourseGroupManager();
avoidInvisibleMember(cgm.getCoachesFromBusinessGroups(), contactList, sendToWhatYouSee);
avoidInvisibleMember(cgm.getCoaches(), contactList, sendToWhatYouSee);
}
if (participantEl != null && participantEl.isAtLeastSelected(1)) {
Set<Long> sendToWhatYouSee = new HashSet<>();
for (Member participant : participantList) {
sendToWhatYouSee.add(participant.getKey());
}
CourseGroupManager cgm = courseEnv.getCourseGroupManager();
avoidInvisibleMember(cgm.getParticipantsFromBusinessGroups(), contactList, sendToWhatYouSee);
avoidInvisibleMember(cgm.getParticipants(), contactList, sendToWhatYouSee);
}
}
if (individualEl != null && individualEl.isAtLeastSelected(1) && selectedMembers != null && selectedMembers.size() > 0) {
List<Long> identityKeys = new ArrayList<>(selectedMembers.size());
for (Member member : selectedMembers) {
identityKeys.add(member.getKey());
}
List<Identity> selectedIdentities = securityManager.loadIdentityByKeys(identityKeys);
contactList.addAllIdentites(selectedIdentities);
}
if (externalEl != null && externalEl.isAtLeastSelected(1)) {
String value = externalAddressesEl.getValue();
if (StringHelper.containsNonWhitespace(value)) {
for (StringTokenizer tokenizer = new StringTokenizer(value, ",\r\n", false); tokenizer.hasMoreTokens(); ) {
String email = tokenizer.nextToken().trim();
contactList.add(new EMailIdentity(email, getLocale()));
}
}
}
doSendEmailToMember(ureq, contactList);
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class MembersTableController method doSendEmailToMember.
private void doSendEmailToMember(MemberView member, UserRequest ureq) {
if (!editable)
return;
ContactList memberList;
Identity identity = securityManager.loadIdentityByKey(member.getIdentityKey());
String fullName = userManager.getUserDisplayName(identity);
if (courseEnv == null) {
memberList = new ContactList(translate("members.to", new String[] { fullName, businessGroup.getName() }));
} else {
memberList = new ContactList(translate("members.to", new String[] { fullName, courseEnv.getCourseTitle() }));
}
memberList.add(identity);
doSendEmailToMember(memberList, ureq);
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class MembersTableController method getMembersFromIdentity.
private List<MemberView> getMembersFromIdentity(UserRequest ureq, List<Identity> identities, Map<Long, BusinessGroupMembership> groupmemberships, Map<Long, Date> recentLaunches, Map<Long, Date> initialLaunches) {
if (!deduplicateList) {
duplicateCatcher = new HashSet<>();
}
List<MemberView> memberList = new ArrayList<>();
for (Identity identity : identities) {
MemberView member = new MemberView(identity, userPropertyHandlers, getLocale());
if (userLastTimeVisible) {
if (repoEntry == null) {
BusinessGroupMembership groupmembership = groupmemberships.get(identity.getKey());
if (groupmembership != null) {
member.setFirstTime(groupmembership.getCreationDate());
member.setLastTime(groupmembership.getLastModified());
}
} else {
member.setFirstTime(initialLaunches.get(identity.getKey()));
member.setLastTime(recentLaunches.get(identity.getKey()));
}
}
if (!duplicateCatcher.contains(member)) {
memberList.add(member);
if (!identity.equals(ureq.getIdentity())) {
forgeChatLink(member);
}
}
duplicateCatcher.add(member);
}
return memberList;
}
use of org.olat.core.id.Identity in project OpenOLAT by OpenOLAT.
the class InfoMessagesWebService method createEmptyCourse.
/**
* Creates a new info message
* @response.representation.200.qname {http://www.example.com}infoMessageVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The info message
* @response.representation.200.example {@link org.olat.commons.info.restapi.Examples#SAMPLE_INFOMESSAGEVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @param resName The OLAT Resourceable name
* @param resId The OLAT Resourceable id
* @param resSubPath The resource sub path (optional)
* @param businessPath The business path
* @param authorKey The identity key of the author
* @param title The title
* @param message The message
* @param request The HTTP request
* @return It returns the id of the newly info message
*/
@PUT
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response createEmptyCourse(@QueryParam("resName") final String resName, @QueryParam("resId") final Long resId, @QueryParam("resSubPath") String resSubPath, @QueryParam("businessPath") String businessPath, @QueryParam("authorKey") Long authorKey, @QueryParam("title") String title, @QueryParam("message") String message, @Context HttpServletRequest request) {
if (!isAuthor(request)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
OLATResourceable ores = new OLATResourceable() {
@Override
public String getResourceableTypeName() {
return resName;
}
@Override
public Long getResourceableId() {
return resId;
}
};
Identity author;
UserRequest ureq = getUserRequest(request);
if (authorKey == null) {
author = ureq.getIdentity();
} else {
BaseSecurity securityManager = BaseSecurityManager.getInstance();
author = securityManager.loadIdentityByKey(authorKey, false);
if (author == null) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
}
InfoMessageFrontendManager messageManager = CoreSpringFactory.getImpl(InfoMessageFrontendManager.class);
InfoMessage msg = messageManager.createInfoMessage(ores, resSubPath, businessPath, author);
msg.setTitle(title);
msg.setMessage(message);
messageManager.sendInfoMessage(msg, null, ureq.getLocale(), ureq.getIdentity(), Collections.<Identity>emptyList());
InfoMessageVO infoVO = new InfoMessageVO(msg);
return Response.ok(infoVO).build();
}
Aggregations