示例#1
0
  @Test
  @Transactional
  public void testRemoveContactFromEventMultipleGroups() throws Exception {

    groupService.create(group);
    groupService.addAggregation(event, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(event, secondGroup);

    Contact newContact = new Contact();
    newContact.setFirstName("Fresh Contact");
    newContact.setEmail("Fresh email");
    contactService.create(newContact);

    event = eventService.findById(event.getId());
    contactService.attendEvent(newContact, event);

    newContact = contactService.findById(newContact.getId());
    contactService.unattendEvent(newContact, event);

    event = eventService.findById(event.getId());
    assertFalse(event.getAttendees().contains(newContact));

    newContact = contactService.findById(newContact.getId());
    assertFalse(newContact.getAttendedEvents().contains(event));
  }
示例#2
0
  @Test
  @Transactional
  public void testAddContactToMultipleGroupsMultipleConstituents() throws Exception {

    groupService.create(group);
    groupService.addAggregation(committee, group);
    groupService.addAggregation(event, group);

    Group secondGroup = new Group();
    secondGroup.setGroupName("Second Group");
    groupService.create(secondGroup);
    groupService.addAggregation(committee, secondGroup);
    groupService.addAggregation(event, secondGroup);

    Contact contact = new Contact();
    contact.setFirstName("Test Contact");
    contact.setEmail("*****@*****.**");
    contactService.create(contact);

    contactService.addContactToCommittee(contact, committee);
    contactService.attendEvent(contact, event);
    contactService.addToGroup(contact, group);
    contactService.addToGroup(contact, secondGroup);

    contact = contactService.findById(contact.getId());
    group = groupService.findById(group.getId());
    secondGroup = groupService.findById(secondGroup.getId());
    event = eventService.findById(event.getId());
    committee = committeeService.findById(committee.getId());

    assertTrue(contact.getGroups().contains(group));
    assertTrue(contact.getGroups().contains(secondGroup));
    assertTrue(contact.getCommittees().contains(committee));
    assertTrue(contact.getAttendedEvents().contains(event));

    assertTrue(event.getAttendees().contains(contact));
    assertTrue(event.getGroups().contains(group));
    assertTrue(event.getGroups().contains(secondGroup));

    assertTrue(committee.getMembers().contains(contact));
    assertTrue(committee.getGroups().contains(group));
    assertTrue(committee.getGroups().contains(secondGroup));

    assertTrue(group.getTopLevelMembers().contains(contact));
    assertTrue(group.getAggregations().contains(committee));
    assertTrue(group.getAggregations().contains(event));

    assertTrue(secondGroup.getTopLevelMembers().contains(contact));
    assertTrue(secondGroup.getAggregations().contains(committee));
    assertTrue(secondGroup.getAggregations().contains(event));
  }
示例#3
0
 @Override
 protected void addDataRows(Resource resource, long localID, int backrefIdx) {
   Event event = (Event) resource;
   for (Attendee attendee : event.getAttendees())
     pendingOperations.add(
         buildAttendee(
                 newDataInsertBuilder(
                     Attendees.CONTENT_URI, Attendees.EVENT_ID, localID, backrefIdx),
                 attendee)
             .build());
   for (VAlarm alarm : event.getAlarms())
     pendingOperations.add(
         buildReminder(
                 newDataInsertBuilder(
                     Reminders.CONTENT_URI, Reminders.EVENT_ID, localID, backrefIdx),
                 alarm)
             .build());
 }
示例#4
0
  @Override
  protected Builder buildEntry(Builder builder, Resource resource) {
    Event event = (Event) resource;

    builder =
        builder
            .withValue(Events.CALENDAR_ID, id)
            .withValue(entryColumnRemoteName(), event.getName())
            .withValue(entryColumnETag(), event.getETag())
            .withValue(entryColumnUID(), event.getUid())
            .withValue(Events.ALL_DAY, event.isAllDay() ? 1 : 0)
            .withValue(Events.DTSTART, event.getDtStartInMillis())
            .withValue(Events.EVENT_TIMEZONE, event.getDtStartTzID())
            .withValue(Events.HAS_ATTENDEE_DATA, event.getAttendees().isEmpty() ? 0 : 1)
            .withValue(Events.GUESTS_CAN_INVITE_OTHERS, 1)
            .withValue(Events.GUESTS_CAN_MODIFY, 1)
            .withValue(Events.GUESTS_CAN_SEE_GUESTS, 1);

    boolean recurring = false;
    if (event.getRrule() != null) {
      recurring = true;
      builder = builder.withValue(Events.RRULE, event.getRrule().getValue());
    }
    if (event.getRdate() != null) {
      recurring = true;
      builder = builder.withValue(Events.RDATE, event.getRdate().getValue());
    }
    if (event.getExrule() != null)
      builder = builder.withValue(Events.EXRULE, event.getExrule().getValue());
    if (event.getExdate() != null)
      builder = builder.withValue(Events.EXDATE, event.getExdate().getValue());

    // set either DTEND for single-time events or DURATION for recurring events
    // because that's the way Android likes it (see docs)
    if (recurring) {
      // calculate DURATION from start and end date
      Duration duration = new Duration(event.getDtStart().getDate(), event.getDtEnd().getDate());
      builder = builder.withValue(Events.DURATION, duration.getValue());
    } else {
      builder =
          builder
              .withValue(Events.DTEND, event.getDtEndInMillis())
              .withValue(Events.EVENT_END_TIMEZONE, event.getDtEndTzID());
    }

    if (event.getSummary() != null) builder = builder.withValue(Events.TITLE, event.getSummary());
    if (event.getLocation() != null)
      builder = builder.withValue(Events.EVENT_LOCATION, event.getLocation());
    if (event.getDescription() != null)
      builder = builder.withValue(Events.DESCRIPTION, event.getDescription());

    if (event.getOrganizer() != null && event.getOrganizer().getCalAddress() != null) {
      URI organizer = event.getOrganizer().getCalAddress();
      if (organizer.getScheme() != null && organizer.getScheme().equalsIgnoreCase("mailto"))
        builder = builder.withValue(Events.ORGANIZER, organizer.getSchemeSpecificPart());
    }

    Status status = event.getStatus();
    if (status != null) {
      int statusCode = Events.STATUS_TENTATIVE;
      if (status == Status.VEVENT_CONFIRMED) statusCode = Events.STATUS_CONFIRMED;
      else if (status == Status.VEVENT_CANCELLED) statusCode = Events.STATUS_CANCELED;
      builder = builder.withValue(Events.STATUS, statusCode);
    }

    builder =
        builder.withValue(
            Events.AVAILABILITY,
            event.isOpaque() ? Events.AVAILABILITY_BUSY : Events.AVAILABILITY_FREE);

    if (event.getForPublic() != null)
      builder =
          builder.withValue(
              Events.ACCESS_LEVEL,
              event.getForPublic() ? Events.ACCESS_PUBLIC : Events.ACCESS_PRIVATE);

    return builder;
  }