use of org.olat.commons.calendar.model.CalendarFileInfos in project OpenOLAT by OpenOLAT.
the class HomeCalendarManager method getListOfCalendarsFiles.
@Override
public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();
Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(identity);
// personal calendar
CalendarKey personalCalendarKey = new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
if (calendarModule.isEnablePersonalCalendar() && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
}
// reload every hour
List<CalendarFileInfos> importedCalendars = importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
aggregatedFiles.addAll(importedCalendars);
}
// group calendars
if (calendarModule.isEnableGroupCalendar()) {
SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
Set<BusinessGroup> resourceSet = new HashSet<>();
for (BusinessGroup group : groups) {
if (resourceSet.contains(group)) {
continue;
} else {
resourceSet.add(group);
}
String calendarId = group.getKey().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
}
}
}
}
if (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar()) {
List<Object[]> resources = getCourses(identity);
Set<RepositoryEntry> resourceSet = new HashSet<>();
for (Object[] resource : resources) {
RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
if (resourceSet.contains(courseEntry)) {
continue;
} else {
resourceSet.add(courseEntry);
}
String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
}
}
}
}
return aggregatedFiles;
}
use of org.olat.commons.calendar.model.CalendarFileInfos in project openolat by klemens.
the class ImportCalendarManager method getImportedCalendarInfosForIdentity.
public List<CalendarFileInfos> getImportedCalendarInfosForIdentity(Identity identity, boolean reload) {
List<CalendarFileInfos> calendars = new ArrayList<CalendarFileInfos>();
if (calendarModule.isEnabled() && calendarModule.isEnablePersonalCalendar()) {
long timestamp = System.currentTimeMillis();
List<ImportedCalendar> importedCalendars = importedCalendarDao.getImportedCalendars(identity);
KalendarEventFilter filter = new KalendarEventFilter(identity, importedCalendars);
for (ImportedCalendar importedCalendar : importedCalendars) {
if (reload) {
reloadImportCalendar(importedCalendar, timestamp, filter);
}
String calendarId = importedCalendar.getCalendarId();
File calendarFile = calendarManager.getCalendarFile(CalendarManager.TYPE_USER, calendarId);
CalendarFileInfos calendarInfos = new CalendarFileInfos(calendarId, CalendarManager.TYPE_USER, calendarFile);
calendars.add(calendarInfos);
}
}
return calendars;
}
use of org.olat.commons.calendar.model.CalendarFileInfos in project OpenOLAT by OpenOLAT.
the class ImportCalendarManager method getImportedCalendarInfosForIdentity.
public List<CalendarFileInfos> getImportedCalendarInfosForIdentity(Identity identity, boolean reload) {
List<CalendarFileInfos> calendars = new ArrayList<CalendarFileInfos>();
if (calendarModule.isEnabled() && calendarModule.isEnablePersonalCalendar()) {
long timestamp = System.currentTimeMillis();
List<ImportedCalendar> importedCalendars = importedCalendarDao.getImportedCalendars(identity);
KalendarEventFilter filter = new KalendarEventFilter(identity, importedCalendars);
for (ImportedCalendar importedCalendar : importedCalendars) {
if (reload) {
reloadImportCalendar(importedCalendar, timestamp, filter);
}
String calendarId = importedCalendar.getCalendarId();
File calendarFile = calendarManager.getCalendarFile(CalendarManager.TYPE_USER, calendarId);
CalendarFileInfos calendarInfos = new CalendarFileInfos(calendarId, CalendarManager.TYPE_USER, calendarFile);
calendars.add(calendarInfos);
}
}
return calendars;
}
use of org.olat.commons.calendar.model.CalendarFileInfos in project openolat by klemens.
the class HomeCalendarManager method getListOfCalendarsFiles.
@Override
public List<CalendarFileInfos> getListOfCalendarsFiles(Identity identity) {
List<CalendarFileInfos> aggregatedFiles = new ArrayList<>();
Map<CalendarKey, CalendarUserConfiguration> configMap = calendarManager.getCalendarUserConfigurationsMap(identity);
// personal calendar
CalendarKey personalCalendarKey = new CalendarKey(identity.getName(), CalendarManager.TYPE_USER);
CalendarUserConfiguration personalCalendarConfig = configMap.get(personalCalendarKey);
if (calendarModule.isEnablePersonalCalendar() && (personalCalendarConfig == null || personalCalendarConfig.isInAggregatedFeed())) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_USER, identity.getName());
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(identity.getName(), CalendarManager.TYPE_USER, iCalFile));
}
// reload every hour
List<CalendarFileInfos> importedCalendars = importCalendarManager.getImportedCalendarInfosForIdentity(identity, true);
aggregatedFiles.addAll(importedCalendars);
}
// group calendars
if (calendarModule.isEnableGroupCalendar()) {
SearchBusinessGroupParams groupParams = new SearchBusinessGroupParams(identity, true, true);
groupParams.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = businessGroupService.findBusinessGroups(groupParams, null, 0, -1);
Set<BusinessGroup> resourceSet = new HashSet<>();
for (BusinessGroup group : groups) {
if (resourceSet.contains(group)) {
continue;
} else {
resourceSet.add(group);
}
String calendarId = group.getKey().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_GROUP);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_GROUP, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_GROUP, iCalFile));
}
}
}
}
if (calendarModule.isEnableCourseElementCalendar() || calendarModule.isEnableCourseToolCalendar()) {
List<Object[]> resources = getCourses(identity);
Set<RepositoryEntry> resourceSet = new HashSet<>();
for (Object[] resource : resources) {
RepositoryEntry courseEntry = (RepositoryEntry) resource[0];
if (resourceSet.contains(courseEntry)) {
continue;
} else {
resourceSet.add(courseEntry);
}
String calendarId = courseEntry.getOlatResource().getResourceableId().toString();
CalendarKey key = new CalendarKey(calendarId, CalendarManager.TYPE_COURSE);
CalendarUserConfiguration calendarConfig = configMap.get(key);
if (calendarConfig == null || calendarConfig.isInAggregatedFeed()) {
File iCalFile = calendarManager.getCalendarICalFile(CalendarManager.TYPE_COURSE, calendarId);
if (iCalFile != null) {
aggregatedFiles.add(new CalendarFileInfos(calendarId, CalendarManager.TYPE_COURSE, iCalFile));
}
}
}
}
return aggregatedFiles;
}
use of org.olat.commons.calendar.model.CalendarFileInfos in project OpenOLAT by OpenOLAT.
the class ICalServlet method generateAggregatedCalendar.
/**
* Collect all the calendars, update the URL properties and the UUID.
*
* @param identity
* @param request
* @param response
* @throws IOException
*/
private void generateAggregatedCalendar(Identity identity, HttpServletRequest request, HttpServletResponse response) throws IOException {
PersonalCalendarManager homeCalendarManager = CoreSpringFactory.getImpl(PersonalCalendarManager.class);
if (identity == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND);
} else {
List<CalendarFileInfos> iCalFiles = homeCalendarManager.getListOfCalendarsFiles(identity);
DBFactory.getInstance().commitAndCloseSession();
Agent agent = getAgent(request);
Writer out = response.getWriter();
out.write(Calendar.BEGIN);
out.write(':');
out.write(Calendar.VCALENDAR);
out.write(Strings.LINE_SEPARATOR);
out.write(Version.VERSION_2_0.toString());
out.write(CalScale.GREGORIAN.toString());
outputTTL(agent, out);
Set<String> timezoneIds = new HashSet<>();
int numOfFiles = iCalFiles.size();
for (int i = 0; i < numOfFiles; i++) {
outputCalendar(iCalFiles.get(i), out, agent, timezoneIds);
}
if (agent == Agent.outlook) {
outputTimeZoneForOutlook(timezoneIds, out);
}
out.write(Calendar.END);
out.write(':');
out.write(Calendar.VCALENDAR);
}
}
Aggregations