Search in sources :

Example 1 with EventRepository

use of com.axelor.apps.crm.db.repo.EventRepository 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 2 with EventRepository

use of com.axelor.apps.crm.db.repo.EventRepository 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 3 with EventRepository

use of com.axelor.apps.crm.db.repo.EventRepository 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 4 with EventRepository

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

the class EventController method assignToMeEvent.

@SuppressWarnings("rawtypes")
public void assignToMeEvent(ActionRequest request, ActionResponse response) {
    EventRepository eventRepository = Beans.get(EventRepository.class);
    if (request.getContext().get("id") != null) {
        Event event = eventRepository.find((Long) request.getContext().get("id"));
        event.setUser(AuthUtils.getUser());
        Beans.get(EventService.class).saveEvent(event);
    } else if (!((List) request.getContext().get("_ids")).isEmpty()) {
        for (Event event : eventRepository.all().filter("id in ?1", request.getContext().get("_ids")).fetch()) {
            event.setUser(AuthUtils.getUser());
            Beans.get(EventService.class).saveEvent(event);
        }
    }
    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) List(java.util.List)

Example 5 with EventRepository

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

the class EventController method deleteThis.

@Transactional
public void deleteThis(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();
    if (child != null) {
        child.setParentEvent(event.getParentEvent());
    }
    eventRepository.remove(event);
    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)

Aggregations

Event (com.axelor.apps.crm.db.Event)6 EventRepository (com.axelor.apps.crm.db.repo.EventRepository)6 Transactional (com.google.inject.persist.Transactional)4 EventService (com.axelor.apps.crm.service.EventService)3 ICalendarEventService (com.axelor.base.service.ical.ICalendarEventService)3 AppBaseService (com.axelor.apps.base.service.app.AppBaseService)1 RecurrenceConfiguration (com.axelor.apps.crm.db.RecurrenceConfiguration)1 RecurrenceConfigurationRepository (com.axelor.apps.crm.db.repo.RecurrenceConfigurationRepository)1 AxelorException (com.axelor.exception.AxelorException)1 LocalDate (java.time.LocalDate)1 HashMap (java.util.HashMap)1 List (java.util.List)1