use of org.olat.modules.openmeetings.model.OpenMeetingsRoomReference in project openolat by klemens.
the class OpenMeetingsManagerImpl method getResourceNames.
private Map<Long, String> getResourceNames(List<OpenMeetingsRoomReference> properties) {
Map<Long, String> roomIdToResourceName = new HashMap<Long, String>();
Map<Long, List<Long>> resourceIdToRoomIds = new HashMap<Long, List<Long>>();
for (OpenMeetingsRoomReference prop : properties) {
long roomId = prop.getRoomId();
if (prop.getGroup() != null) {
roomIdToResourceName.put(roomId, prop.getGroup().getName());
} else if ("CourseModule".equals(prop.getResourceTypeName())) {
if (!resourceIdToRoomIds.containsKey(prop.getResourceTypeId())) {
resourceIdToRoomIds.put(prop.getResourceTypeId(), new ArrayList<Long>());
}
resourceIdToRoomIds.get(prop.getResourceTypeId()).add(roomId);
}
}
if (!resourceIdToRoomIds.isEmpty()) {
List<RepositoryEntryShortImpl> shortRepos = repositoryManager.loadRepositoryEntryShortsByResource(resourceIdToRoomIds.keySet(), "CourseModule");
for (RepositoryEntryShortImpl repoEntry : shortRepos) {
List<Long> roomIds = resourceIdToRoomIds.get(repoEntry.getOlatResource().getResourceableId());
for (Long roomId : roomIds) {
roomIdToResourceName.put(roomId, repoEntry.getDisplayname());
}
}
}
return roomIdToResourceName;
}
use of org.olat.modules.openmeetings.model.OpenMeetingsRoomReference in project openolat by klemens.
the class OpenMeetingsManagerImpl method addRoom.
@Override
public OpenMeetingsRoom addRoom(BusinessGroup group, OLATResourceable ores, String subIdentifier, OpenMeetingsRoom room) {
if (room.getRoomId() < 0) {
updateRoom(group, ores, subIdentifier, room);
}
try {
String sid = adminLogin();
RoomServicePortType roomWs = getRoomWebService();
long returned = roomWs.addRoomWithModerationAndRecordingFlags(sid, room.getName(), room.getType(), room.getComment(), room.getSize(), false, false, false, 0, room.isModerated(), getOpenOLATExternalType(), true, room.isAudioOnly(), false, true);
if (returned >= 0) {
room.setRoomId(returned);
log.audit("Room created");
OpenMeetingsRoomReference ref = openMeetingsDao.createReference(group, ores, subIdentifier, room);
room.setReference(ref);
return room;
}
return null;
} catch (Exception e) {
log.error("", e);
return null;
}
}
use of org.olat.modules.openmeetings.model.OpenMeetingsRoomReference in project openolat by klemens.
the class OpenMeetingsManagerImpl method getRoom.
@Override
public OpenMeetingsRoom getRoom(BusinessGroup group, OLATResourceable ores, String subIdentifier) throws OpenMeetingsException {
OpenMeetingsRoomReference prop = openMeetingsDao.getReference(group, ores, subIdentifier);
if (prop == null) {
return null;
}
Long roomId = prop.getRoomId();
if (roomId != null && roomId.longValue() > 0) {
try {
String sessionId = adminLogin();
OpenMeetingsRoom room = openMeetingsDao.deserializeRoom(prop.getConfig());
getRoomById(sessionId, room, roomId.longValue());
return room;
} catch (OpenMeetingsException e) {
throw e;
} catch (Exception e) {
log.error("", e);
throw translateException(e, 0);
}
}
return null;
}
use of org.olat.modules.openmeetings.model.OpenMeetingsRoomReference in project openolat by klemens.
the class OpenMeetingsManagerImpl method getLocalRoom.
@Override
public OpenMeetingsRoom getLocalRoom(BusinessGroup group, OLATResourceable ores, String subIdentifier) {
OpenMeetingsRoomReference ref = openMeetingsDao.getReference(group, ores, subIdentifier);
if (ref == null) {
return null;
}
OpenMeetingsRoom room = openMeetingsDao.deserializeRoom(ref.getConfig());
room.setReference(ref);
return room;
}
use of org.olat.modules.openmeetings.model.OpenMeetingsRoomReference in project openolat by klemens.
the class OpenMeetingsManagerImpl method getOpenOLATRooms.
@Override
public List<OpenMeetingsRoom> getOpenOLATRooms() {
try {
String adminSID = adminLogin();
RoomServicePortType roomWs = getRoomWebService();
GetRoomsWithCurrentUsersByListAndType getRooms = new GetRoomsWithCurrentUsersByListAndType();
getRooms.setAsc(true);
getRooms.setExternalRoomType(getOpenOLATExternalType());
getRooms.setOrderby("name");
getRooms.setStart(0);
getRooms.setMax(2000);
getRooms.setSID(adminSID);
Map<Long, RoomReturnInfo> realRooms = new HashMap<Long, RoomReturnInfo>();
// get rooms on openmeetings
List<RoomReturn> roomsRet = roomWs.getRoomsWithCurrentUsersByListAndType(adminSID, 0, 2000, "name", true, getOpenOLATExternalType());
if (roomsRet != null) {
for (RoomReturn roomRet : roomsRet) {
RoomReturnInfo info = new RoomReturnInfo();
info.setName(roomRet.getName());
info.setRoomId(roomRet.getRoomId());
int numOfUsers = 0;
if (roomRet.getRoomUser() != null) {
for (RoomUser user : roomRet.getRoomUser()) {
if (user != null) {
numOfUsers++;
}
}
}
info.setNumOfUsers(numOfUsers);
realRooms.put(new Long(roomRet.getRoomId()), info);
}
}
// get properties saved
List<OpenMeetingsRoomReference> props = openMeetingsDao.getReferences();
Map<Long, String> roomIdToResources = getResourceNames(props);
List<OpenMeetingsRoom> rooms = new ArrayList<OpenMeetingsRoom>();
for (OpenMeetingsRoomReference prop : props) {
Long roomId = new Long(prop.getRoomId());
RoomReturnInfo infos = realRooms.get(roomId);
if (infos != null) {
OpenMeetingsRoom room = openMeetingsDao.deserializeRoom(prop.getConfig());
room.setReference(prop);
room.setName(infos.getName());
room.setNumOfUsers(infos.getNumOfUsers());
String resourceName = roomIdToResources.get(roomId);
if (resourceName != null) {
room.setResourceName(resourceName);
}
rooms.add(room);
}
}
return rooms;
} catch (Exception e) {
log.error("", e);
return null;
}
}
Aggregations