Search in sources :

Example 1 with Event

use of com.axelor.apps.crm.db.Event in project axelor-open-suite by axelor.

the class EventController method computeFromEndDateTime.

public void computeFromEndDateTime(ActionRequest request, ActionResponse response) {
    Event event = request.getContext().asType(Event.class);
    LOG.debug("event : {}", event);
    if (event.getEndDateTime() != null) {
        if (event.getStartDateTime() != null && event.getStartDateTime().isBefore(event.getEndDateTime())) {
            Duration duration = DurationTool.computeDuration(event.getStartDateTime(), event.getEndDateTime());
            response.setValue("duration", DurationTool.getSecondsDuration(duration));
        } else if (event.getDuration() != null) {
            response.setValue("startDateTime", DateTool.minusSeconds(event.getEndDateTime(), event.getDuration()));
        }
    }
}
Also used : Event(com.axelor.apps.crm.db.Event) Duration(java.time.Duration)

Example 2 with Event

use of com.axelor.apps.crm.db.Event in project axelor-open-suite by axelor.

the class EventController method applyChangesToAll.

public void applyChangesToAll(ActionRequest request, ActionResponse response) {
    EventRepository eventRepository = Beans.get(EventRepository.class);
    Event thisEvent = eventRepository.find(new Long(request.getContext().get("_idEvent").toString()));
    Event event = eventRepository.find(thisEvent.getId());
    Beans.get(EventService.class).applyChangesToAll(event);
    response.setCanClose(true);
    response.setReload(true);
}
Also used : Event(com.axelor.apps.crm.db.Event) EventRepository(com.axelor.apps.crm.db.repo.EventRepository) EventService(com.axelor.apps.crm.service.EventService) ICalendarEventService(com.axelor.base.service.ical.ICalendarEventService)

Example 3 with Event

use of com.axelor.apps.crm.db.Event in project axelor-open-suite by axelor.

the class EventController method deleteNext.

@Transactional
public void deleteNext(ActionRequest request, ActionResponse response) {
    Long eventId = new Long(request.getContext().getParent().get("id").toString());
    EventRepository eventRepository = Beans.get(EventRepository.class);
    Event event = eventRepository.find(eventId);
    Event child = eventRepository.all().filter("self.parentEvent.id = ?1", event.getId()).fetchOne();
    while (child != null) {
        child.setParentEvent(null);
        eventRepository.remove(event);
        event = child;
        child = eventRepository.all().filter("self.parentEvent.id = ?1", event.getId()).fetchOne();
    }
    response.setCanClose(true);
    response.setReload(true);
}
Also used : Event(com.axelor.apps.crm.db.Event) EventRepository(com.axelor.apps.crm.db.repo.EventRepository) Transactional(com.google.inject.persist.Transactional)

Example 4 with Event

use of com.axelor.apps.crm.db.Event in project axelor-open-suite by axelor.

the class EventController method deleteAll.

@Transactional
public void deleteAll(ActionRequest request, ActionResponse response) {
    Long eventId = new Long(request.getContext().getParent().get("id").toString());
    EventRepository eventRepository = Beans.get(EventRepository.class);
    Event event = eventRepository.find(eventId);
    Event child = eventRepository.all().filter("self.parentEvent.id = ?1", event.getId()).fetchOne();
    Event parent = event.getParentEvent();
    while (child != null) {
        child.setParentEvent(null);
        eventRepository.remove(event);
        event = child;
        child = eventRepository.all().filter("self.parentEvent.id = ?1", event.getId()).fetchOne();
    }
    while (parent != null) {
        Event nextParent = parent.getParentEvent();
        eventRepository.remove(parent);
        parent = nextParent;
    }
    response.setCanClose(true);
    response.setReload(true);
}
Also used : Event(com.axelor.apps.crm.db.Event) EventRepository(com.axelor.apps.crm.db.repo.EventRepository) Transactional(com.google.inject.persist.Transactional)

Example 5 with Event

use of com.axelor.apps.crm.db.Event in project axelor-open-suite by axelor.

the class EventController method viewMap.

public void viewMap(ActionRequest request, ActionResponse response) {
    try {
        Event event = request.getContext().asType(Event.class);
        if (event.getLocation() != null) {
            Map<String, Object> result = Beans.get(MapService.class).getMap(event.getLocation());
            if (result != null) {
                Map<String, Object> mapView = new HashMap<>();
                mapView.put("title", "Map");
                mapView.put("resource", result.get("url"));
                mapView.put("viewType", "html");
                response.setView(mapView);
            } else
                response.setFlash(String.format(I18n.get(com.axelor.apps.base.exceptions.IExceptionMessage.ADDRESS_5), event.getLocation()));
        } else
            response.setFlash(I18n.get(IExceptionMessage.EVENT_1));
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : HashMap(java.util.HashMap) Event(com.axelor.apps.crm.db.Event) MapService(com.axelor.apps.base.service.MapService) AxelorException(com.axelor.exception.AxelorException)

Aggregations

Event (com.axelor.apps.crm.db.Event)36 Transactional (com.google.inject.persist.Transactional)21 EventRepository (com.axelor.apps.crm.db.repo.EventRepository)11 EventService (com.axelor.apps.crm.service.EventService)7 ICalendarEventService (com.axelor.base.service.ical.ICalendarEventService)7 TrainingRegister (com.axelor.apps.talent.db.TrainingRegister)6 Duration (java.time.Duration)6 AxelorException (com.axelor.exception.AxelorException)5 LocalDateTime (java.time.LocalDateTime)4 RecurrenceConfiguration (com.axelor.apps.crm.db.RecurrenceConfiguration)3 RecurrenceConfigurationRepository (com.axelor.apps.crm.db.repo.RecurrenceConfigurationRepository)3 HashMap (java.util.HashMap)3 TooManyIterationsException (org.apache.commons.math3.exception.TooManyIterationsException)3 Partner (com.axelor.apps.base.db.Partner)2 Lead (com.axelor.apps.crm.db.Lead)2 Training (com.axelor.apps.talent.db.Training)2 TrainingSession (com.axelor.apps.talent.db.TrainingSession)2 TrainingSessionRepository (com.axelor.apps.talent.db.repo.TrainingSessionRepository)2 User (com.axelor.auth.db.User)2 DayOfWeek (java.time.DayOfWeek)2