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()));
}
}
}
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);
}
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);
}
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);
}
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);
}
}
Aggregations