Search in sources :

Example 31 with Event

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

the class EventController method computeFromDuration.

public void computeFromDuration(ActionRequest request, ActionResponse response) {
    Event event = request.getContext().asType(Event.class);
    LOG.debug("event : {}", event);
    if (event.getDuration() != null) {
        if (event.getStartDateTime() != null) {
            response.setValue("endDateTime", DateTool.plusSeconds(event.getStartDateTime(), event.getDuration()));
        } else if (event.getEndDateTime() != null) {
            response.setValue("startDateTime", DateTool.minusSeconds(event.getEndDateTime(), event.getDuration()));
        }
    }
}
Also used : Event(com.axelor.apps.crm.db.Event)

Example 32 with Event

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

the class EventController method saveEventTaskStatusSelect.

public void saveEventTaskStatusSelect(ActionRequest request, ActionResponse response) throws AxelorException {
    Event event = request.getContext().asType(Event.class);
    Event persistEvent = Beans.get(EventRepository.class).find(event.getId());
    persistEvent.setStatusSelect(event.getStatusSelect());
    Beans.get(EventService.class).saveEvent(persistEvent);
}
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 33 with Event

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

the class EventController method generateRecurrentEvents.

@Transactional(rollbackOn = { Exception.class })
public void generateRecurrentEvents(ActionRequest request, ActionResponse response) throws AxelorException {
    try {
        Long eventId = (Long) request.getContext().get("id");
        if (eventId == null)
            throw new AxelorException(Event.class, TraceBackRepository.CATEGORY_INCONSISTENCY, I18n.get(IExceptionMessage.EVENT_SAVED));
        Event event = Beans.get(EventRepository.class).find(eventId);
        RecurrenceConfigurationRepository confRepo = Beans.get(RecurrenceConfigurationRepository.class);
        RecurrenceConfiguration conf = event.getRecurrenceConfiguration();
        if (conf != null) {
            conf = confRepo.save(conf);
            Beans.get(EventService.class).generateRecurrentEvents(event, conf);
        }
    } catch (Exception e) {
        TraceBackService.trace(response, e);
    }
}
Also used : RecurrenceConfigurationRepository(com.axelor.apps.crm.db.repo.RecurrenceConfigurationRepository) AxelorException(com.axelor.exception.AxelorException) 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) AxelorException(com.axelor.exception.AxelorException) RecurrenceConfiguration(com.axelor.apps.crm.db.RecurrenceConfiguration) Transactional(com.google.inject.persist.Transactional)

Example 34 with Event

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

the class TrainingRegisterController method EventFromDateUpdate.

@Transactional
public void EventFromDateUpdate(ActionRequest request, ActionResponse response) {
    TrainingRegister trainingRegister = request.getContext().asType(TrainingRegister.class);
    if (trainingRegister.getEventList() != null) {
        for (Event event : trainingRegister.getEventList()) {
            event.setStartDateTime(trainingRegister.getFromDate());
            eventRepository.save(event);
        }
    }
}
Also used : TrainingRegister(com.axelor.apps.talent.db.TrainingRegister) Event(com.axelor.apps.crm.db.Event) Transactional(com.google.inject.persist.Transactional)

Example 35 with Event

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

the class TrainingRegisterController method massTrainingRegisterCreation.

@SuppressWarnings("unchecked")
public void massTrainingRegisterCreation(ActionRequest request, ActionResponse response) {
    Context context = request.getContext();
    ArrayList<LinkedHashMap<String, Object>> employeeList = (ArrayList<LinkedHashMap<String, Object>>) context.get("employeeList");
    TrainingSession trainingSession = Beans.get(TrainingSessionRepository.class).find(Long.parseLong(context.get("_trainingSessionId").toString()));
    String eventList = Beans.get(TrainingRegisterService.class).massTrainingRegisterCreation(employeeList, trainingSession);
    response.setCanClose(true);
    if (!eventList.equals("()")) {
        response.setView(ActionView.define("Meeting").model(Event.class.getCanonicalName()).add("grid", "event-grid").add("form", "event-form").param("search-filters", "event-filters").domain("self.id in " + eventList).map());
    } else {
        response.setAlert(IExceptionMessage.NO_EVENT_GENERATED);
    }
}
Also used : Context(com.axelor.rpc.Context) TrainingSessionRepository(com.axelor.apps.talent.db.repo.TrainingSessionRepository) ArrayList(java.util.ArrayList) Event(com.axelor.apps.crm.db.Event) TrainingRegisterService(com.axelor.apps.talent.service.TrainingRegisterService) LinkedHashMap(java.util.LinkedHashMap) TrainingSession(com.axelor.apps.talent.db.TrainingSession)

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