Search in sources :

Example 6 with ICalendar

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());
}
Also used : ICalendar(com.axelor.apps.base.db.ICalendar)

Example 7 with ICalendar

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);
    }
}
Also used : ICalendar(com.axelor.apps.base.db.ICalendar) ICalendarService(com.axelor.apps.base.ical.ICalendarService) MalformedURLException(java.net.MalformedURLException) ParserException(net.fortuna.ical4j.data.ParserException) IOException(java.io.IOException) ParseException(java.text.ParseException) ICalendarException(com.axelor.apps.base.ical.ICalendarException)

Example 8 with ICalendar

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);
}
Also used : ICalendar(com.axelor.apps.base.db.ICalendar) ICalendarService(com.axelor.apps.base.ical.ICalendarService)

Example 9 with ICalendar

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);
}
Also used : ICalendarEvent(com.axelor.apps.base.db.ICalendarEvent) VEvent(net.fortuna.ical4j.model.component.VEvent) XProperty(net.fortuna.ical4j.model.property.XProperty) Calendar(net.fortuna.ical4j.model.Calendar) ICalendar(com.axelor.apps.base.db.ICalendar) CalendarOutputter(net.fortuna.ical4j.data.CalendarOutputter)

Example 10 with ICalendar

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;
}
Also used : ICalendarEvent(com.axelor.apps.base.db.ICalendarEvent) CalendarManagement(com.axelor.apps.base.db.CalendarManagement) Inject(com.google.inject.Inject) LocalDateTime(java.time.LocalDateTime) Set(java.util.Set) Team(com.axelor.team.db.Team) ICalendarService(com.axelor.apps.base.ical.ICalendarService) ArrayList(java.util.ArrayList) EventRepository(com.axelor.apps.crm.db.repo.EventRepository) List(java.util.List) Lists(com.google.common.collect.Lists) Beans(com.axelor.inject.Beans) ICalendar(com.axelor.apps.base.db.ICalendar) ICalendarRepository(com.axelor.apps.base.db.repo.ICalendarRepository) User(com.axelor.auth.db.User) CalendarManagement(com.axelor.apps.base.db.CalendarManagement) User(com.axelor.auth.db.User) ArrayList(java.util.ArrayList) Team(com.axelor.team.db.Team) ICalendar(com.axelor.apps.base.db.ICalendar)

Aggregations

ICalendar (com.axelor.apps.base.db.ICalendar)11 ICalendarService (com.axelor.apps.base.ical.ICalendarService)5 ICalendarEvent (com.axelor.apps.base.db.ICalendarEvent)3 IOException (java.io.IOException)3 MalformedURLException (java.net.MalformedURLException)3 ParseException (java.text.ParseException)3 ParserException (net.fortuna.ical4j.data.ParserException)3 Calendar (net.fortuna.ical4j.model.Calendar)3 VEvent (net.fortuna.ical4j.model.component.VEvent)3 AxelorException (com.axelor.exception.AxelorException)2 Transactional (com.google.inject.persist.Transactional)2 SocketException (java.net.SocketException)2 URISyntaxException (java.net.URISyntaxException)2 HashMap (java.util.HashMap)2 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)2 FailedOperationException (net.fortuna.ical4j.connector.FailedOperationException)2 ObjectStoreException (net.fortuna.ical4j.connector.ObjectStoreException)2 ConstraintViolationException (net.fortuna.ical4j.model.ConstraintViolationException)2 ValidationException (net.fortuna.ical4j.validate.ValidationException)2 DavException (org.apache.jackrabbit.webdav.DavException)2