use of org.olat.modules.vitero.model.GroupRole in project openolat by klemens.
the class ViteroManager method getGroupRoles.
/**
* @param id The group id
* @return
* @throws VmsNotAvailableException
*/
public ViteroGroupRoles getGroupRoles(int id) throws VmsNotAvailableException {
try {
Group groupWs = getGroupWebService();
Groupid groupId = new Groupid();
groupId.setGroupid(id);
Group_Type group = groupWs.getGroup(groupId);
Completegrouptype groupType = group.getGroup();
List<Completegrouptype.Participant> participants = groupType.getParticipant();
int numOfParticipants = participants == null ? 0 : participants.size();
ViteroGroupRoles groupRoles = new ViteroGroupRoles();
if (numOfParticipants > 0) {
Map<Integer, String> idToEmails = new HashMap<Integer, String>();
List<Usertype> vmsUsers = getVmsUsersByGroup(id);
if (vmsUsers != null) {
for (Usertype vmsUser : vmsUsers) {
Integer userId = new Integer(vmsUser.getId());
String email = vmsUser.getEmail();
groupRoles.getEmailsOfParticipants().add(email);
idToEmails.put(userId, email);
}
}
for (int i = 0; i < numOfParticipants; i++) {
Completegrouptype.Participant participant = participants.get(i);
Integer userId = new Integer(participant.getUserid());
String email = idToEmails.get(userId);
if (email != null) {
GroupRole role = GroupRole.valueOf(participant.getRole());
groupRoles.getEmailsToRole().put(email, role);
groupRoles.getEmailsToVmsUserId().put(email, userId);
}
}
}
return groupRoles;
} catch (SOAPFaultException f) {
ErrorCode code = handleAxisFault(f);
switch(code) {
default:
logAxisError("Cannot get group roles", f);
}
return null;
} catch (WebServiceException e) {
if (e.getCause() instanceof ConnectException) {
throw new VmsNotAvailableException();
}
return null;
}
}
use of org.olat.modules.vitero.model.GroupRole in project openolat by klemens.
the class ViteroBookingWebService method getMembers.
/**
* Returns the list of members of the booking.
*
* @response.representation.200.qname {http://www.example.com}viteroGroupMemberVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc This is the list of all bookings of a resource
* @response.representation.200.example {@link org.olat.modules.vitero.restapi.Examples#SAMPLE_ViteroGroupMemberVO}
* @param bookingId The id of the booking
* @return The list of members in the specified booking
*/
@GET
@Path("{bookingId}/members")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getMembers(@PathParam("bookingId") int bookingId) {
try {
ViteroBooking booking = viteroManager.getBookingById(null, ores, subIdentifier, bookingId);
if (booking == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
ViteroGroupRoles roles = viteroManager.getGroupRoles(booking.getGroupId());
if (roles == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
}
List<String> currentEmails = new ArrayList<>(roles.getEmailsOfParticipants());
List<ViteroGroupMemberVO> memberList = new ArrayList<>(currentEmails.size());
for (String email : currentEmails) {
SearchIdentityParams params = new SearchIdentityParams();
params.setUserProperties(Collections.singletonMap(UserConstants.EMAIL, email));
List<Identity> identities = securityManager.getIdentitiesByPowerSearch(params, 0, 1);
for (Identity identity : identities) {
GroupRole role = roles.getEmailsToRole().get(email);
memberList.add(new ViteroGroupMemberVO(identity.getKey(), role.name()));
}
}
ViteroGroupMemberVO[] members = memberList.toArray(new ViteroGroupMemberVO[memberList.size()]);
return Response.ok(members).build();
} catch (VmsNotAvailableException e) {
log.error("", e);
return handleNotAvailableException();
}
}
use of org.olat.modules.vitero.model.GroupRole in project openolat by klemens.
the class ViteroUserToGroupController method signIn.
private void signIn(List<Identity> identities) {
try {
ResourceMembers members = ((UserToGroupDataModel) tableCtr.getTableDataModel()).getMembers();
for (Identity identity : identities) {
boolean upgrade = members.getCoaches().contains(identity) || members.getOwners().contains(identity);
GroupRole role = upgrade ? GroupRole.teamleader : null;
ViteroStatus status = viteroManager.addToRoom(booking, identity, role);
if (status.isOk()) {
showInfo("signin.ok");
} else {
showInfo("signin.nok");
break;
}
}
loadModel();
} catch (VmsNotAvailableException e) {
showError(VmsNotAvailableException.I18N_KEY);
}
}
Aggregations