@Override @Transactional public MSEvent convertEventToMSEvent(UserDataRequest udr, Event event) throws DaoException, ConversionException { MSEventUid msEventUid = getMSEventUidFor(event.getExtId(), udr.getDevice()); MSEvent msEvent = eventConverter.convert(event, msEventUid, udr.getCredentials().getUser()); return msEvent; }
private EventPrivacy privacy(Event oldEvent, CalendarSensitivity sensitivity) { if (sensitivity == null) { return oldEvent != null ? oldEvent.getPrivacy() : EventPrivacy.PUBLIC; } switch (sensitivity) { case CONFIDENTIAL: case PERSONAL: case PRIVATE: return EventPrivacy.PRIVATE; case NORMAL: default: return EventPrivacy.PUBLIC; } }
private Attendee convertAttendee(UserDataRequest udr, Event oldEvent) { ParticipationState oldState = ParticipationState.NEEDSACTION; if (oldEvent != null) { for (Attendee oldAtt : oldEvent.getAttendees()) { if (oldAtt.getEmail().equals(udr.getCredentials().getUser().getEmail())) { oldState = oldAtt.getState(); break; } } } Attendee ret = new Attendee(); ret.setEmail(udr.getCredentials().getUser().getEmail()); ret.setParticipationRole(ParticipationRole.REQ); ret.setState(status(oldState, AttendeeStatus.ACCEPT)); return ret; }
public IApplicationData convert(Event e) { MSTask mse = new MSTask(); mse.setSubject(e.getTitle()); mse.setDescription(e.getDescription()); if (e.getPriority() <= 1) { mse.setImportance(0); } else if (e.getPriority() > 1 && e.getPriority() <= 3) { mse.setImportance(1); } else { mse.setImportance(2); } mse.setSensitivity( e.getPrivacy() == EventPrivacy.PUBLIC ? CalendarSensitivity.NORMAL : CalendarSensitivity.PRIVATE); Date dateTimeEnd = new Date(e.getStartDate().getTime() + e.getDuration() * 1000); mse.setUtcDueDate(dateTimeEnd); mse.setDueDate(getDateInTimeZone(dateTimeEnd, e.getTimezoneName())); // if (e.getAlert() != null && e.getAlert() != 0) { // mse.setReminderSet(true); // Calendar cal = Calendar.getInstance(); // cal.setTime(e.getDate()); // cal.add(Calendar.SECOND, e.getAlert()); // mse.setReminderTime(cal.getTime()); // } mse.setStartDate(getDateInTimeZone(e.getStartDate(), e.getTimezoneName())); mse.setUtcStartDate(e.getStartDate()); mse.setRecurrence(getRecurrence(e.getRecurrence())); return mse; }
public Event convert( UserDataRequest udr, Event oldEvent, MSTask task, Boolean isObmInternalEvent) { Event e = new Event(); e.setInternalEvent(isObmInternalEvent); if (oldEvent != null) { e.setExtId(oldEvent.getExtId()); for (Attendee att : oldEvent.getAttendees()) { if (task.getComplete()) { att.setPercent(100); } else if (att.getPercent() >= 100) { att.setPercent(0); } e.addAttendee(att); } } else { Attendee att = convertAttendee(udr, null); if (task.getComplete()) { att.setPercent(100); } e.addAttendee(att); } e.setType(EventType.VTODO); e.setTitle(task.getSubject()); e.setDescription(task.getDescription()); if (task.getUtcStartDate() != null) { e.setStartDate(task.getUtcStartDate()); e.setTimezoneName("GMT"); } else { Calendar cal = Calendar.getInstance(); cal.set(Calendar.MILLISECOND, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.HOUR, 0); e.setStartDate(cal.getTime()); } int importance = Objects.firstNonNull(task.getImportance(), TASK_IMPORTANCE_NORMAL); switch (importance) { case 0: e.setPriority(1); break; case 2: e.setPriority(5); break; default: case 1: e.setPriority(3); break; } if (task.getReminderSet()) { long alert = Math.abs(task.getUtcStartDate().getTime() - task.getReminderTime().getTime()); e.setAlert((int) alert); } e.setPrivacy(privacy(oldEvent, task.getSensitivity())); if (task.getUtcDueDate() != null) { long durmili = Math.abs(task.getUtcStartDate().getTime() - task.getUtcDueDate().getTime()); e.setDuration((int) durmili / 1000); } e.setRecurrence(getRecurrence(task)); return e; }
public void createOrUpdate(Event ev) { logger.info("[event " + ev.getObmId() + "] scheduled for solr indexing"); EventIndexer ci = eventIndexerFactory.createIndexer(sEvent, domain, ev); executor.execute(ci); }
public void delete(Event e) { logger.info("[event " + e.getObmId() + "] scheduled for solr removal"); Remover rm = new Remover(sEvent, Integer.toString(e.getObmId().getObmId())); executor.execute(rm); }
private Map.Entry<EventObmId, Event> newEntryWithId(int id) { Event event = new Event(); EventObmId eventId = new EventObmId(id); event.setUid(eventId); return Maps.immutableEntry(eventId, event); }