use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.
the class ICalendarController method importCalendar.
public void importCalendar(ActionRequest request, ActionResponse response) {
ICalendar cal = request.getContext().asType(ICalendar.class);
response.setView(ActionView.define(I18n.get(IExceptionMessage.IMPORT_CALENDAR)).model("com.axelor.apps.base.db.ImportConfiguration").add("form", "import-icalendar-form").param("popup", "reload").param("show-toolbar", "false").param("show-confirm", "false").param("popup-save", "false").context("_id", cal.getId()).map());
}
use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.
the class ICalendarController method testConnect.
public void testConnect(ActionRequest request, ActionResponse response) {
try {
ICalendar cal = request.getContext().asType(ICalendar.class);
Beans.get(ICalendarService.class).testConnect(cal);
response.setValue("isValid", true);
} catch (Exception e) {
TraceBackService.trace(e);
response.setFlash("Configuration error");
response.setValue("isValid", false);
}
}
use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.
the class ICalendarController method synchronizeCalendar.
public void synchronizeCalendar(ActionRequest request, ActionResponse response) throws MalformedURLException, ICalendarException {
ICalendar cal = request.getContext().asType(ICalendar.class);
cal = Beans.get(ICalendarRepository.class).find(cal.getId());
Beans.get(ICalendarService.class).sync(cal, false, 0);
response.setReload(true);
}
use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.
the class ICalendarService method export.
/**
* Export the calendar to the given output writer.
*
* @param calendar the source {@link ICalendar}
* @param writer the output writer
* @throws IOException
* @throws ParseException
* @throws ValidationException
*/
public void export(ICalendar calendar, Writer writer) throws IOException, ParseException, ValidationException {
Preconditions.checkNotNull(calendar, "calendar can't be null");
Preconditions.checkNotNull(writer, "writer can't be null");
Preconditions.checkNotNull(getICalendarEvents(calendar), "can't export empty calendar");
Calendar cal = newCalendar();
cal.getProperties().add(new XProperty(X_WR_CALNAME, calendar.getName()));
for (ICalendarEvent item : getICalendarEvents(calendar)) {
VEvent event = createVEvent(item);
cal.getComponents().add(event);
}
CalendarOutputter outputter = new CalendarOutputter();
outputter.output(cal, writer);
}
use of com.axelor.apps.base.db.ICalendar in project axelor-open-suite by axelor.
the class CalendarService method showSharedCalendars.
public List<Long> showSharedCalendars(User user) {
Team team = user.getActiveTeam();
Set<User> followedUsers = user.getFollowersCalUserSet();
List<Long> calendarIdlist = new ArrayList<Long>();
for (User userIt : followedUsers) {
for (CalendarManagement calendarManagement : userIt.getCalendarManagementList()) {
if ((user.equals(calendarManagement.getUser())) || (team != null && team.equals(calendarManagement.getTeam()))) {
List<ICalendar> icalList = icalRepo.all().filter("self.user.id = ?1", userIt.getId()).fetch();
calendarIdlist.addAll(Lists.transform(icalList, it -> it.getId()));
}
}
}
List<ICalendar> icalList = icalRepo.all().filter("self.user.id = ?1", user.getId()).fetch();
calendarIdlist.addAll(Lists.transform(icalList, it -> it.getId()));
return calendarIdlist;
}
Aggregations