@Override
  protected void doReindex(Calendar calendar) throws Exception {
    Document document = getDocument(calendar);

    SearchEngineUtil.updateDocument(
        getSearchEngineId(), calendar.getCompanyId(), document, isCommitImmediately());
  }
 @Override
 protected void doDelete(Calendar calendar) throws Exception {
   deleteDocument(calendar.getCompanyId(), calendar.getCalendarId());
 }
  @Test
  public void testUpdateExisting() throws Exception {
    long pk = RandomTestUtil.nextLong();

    Calendar newCalendar = _persistence.create(pk);

    newCalendar.setUuid(RandomTestUtil.randomString());

    newCalendar.setGroupId(RandomTestUtil.nextLong());

    newCalendar.setCompanyId(RandomTestUtil.nextLong());

    newCalendar.setUserId(RandomTestUtil.nextLong());

    newCalendar.setUserName(RandomTestUtil.randomString());

    newCalendar.setCreateDate(RandomTestUtil.nextDate());

    newCalendar.setModifiedDate(RandomTestUtil.nextDate());

    newCalendar.setResourceBlockId(RandomTestUtil.nextLong());

    newCalendar.setCalendarResourceId(RandomTestUtil.nextLong());

    newCalendar.setName(RandomTestUtil.randomString());

    newCalendar.setDescription(RandomTestUtil.randomString());

    newCalendar.setTimeZoneId(RandomTestUtil.randomString());

    newCalendar.setColor(RandomTestUtil.nextInt());

    newCalendar.setDefaultCalendar(RandomTestUtil.randomBoolean());

    newCalendar.setEnableComments(RandomTestUtil.randomBoolean());

    newCalendar.setEnableRatings(RandomTestUtil.randomBoolean());

    newCalendar.setLastPublishDate(RandomTestUtil.nextDate());

    _calendars.add(_persistence.update(newCalendar));

    Calendar existingCalendar = _persistence.findByPrimaryKey(newCalendar.getPrimaryKey());

    Assert.assertEquals(existingCalendar.getUuid(), newCalendar.getUuid());
    Assert.assertEquals(existingCalendar.getCalendarId(), newCalendar.getCalendarId());
    Assert.assertEquals(existingCalendar.getGroupId(), newCalendar.getGroupId());
    Assert.assertEquals(existingCalendar.getCompanyId(), newCalendar.getCompanyId());
    Assert.assertEquals(existingCalendar.getUserId(), newCalendar.getUserId());
    Assert.assertEquals(existingCalendar.getUserName(), newCalendar.getUserName());
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getCreateDate()),
        Time.getShortTimestamp(newCalendar.getCreateDate()));
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getModifiedDate()),
        Time.getShortTimestamp(newCalendar.getModifiedDate()));
    Assert.assertEquals(existingCalendar.getResourceBlockId(), newCalendar.getResourceBlockId());
    Assert.assertEquals(
        existingCalendar.getCalendarResourceId(), newCalendar.getCalendarResourceId());
    Assert.assertEquals(existingCalendar.getName(), newCalendar.getName());
    Assert.assertEquals(existingCalendar.getDescription(), newCalendar.getDescription());
    Assert.assertEquals(existingCalendar.getTimeZoneId(), newCalendar.getTimeZoneId());
    Assert.assertEquals(existingCalendar.getColor(), newCalendar.getColor());
    Assert.assertEquals(existingCalendar.getDefaultCalendar(), newCalendar.getDefaultCalendar());
    Assert.assertEquals(existingCalendar.getEnableComments(), newCalendar.getEnableComments());
    Assert.assertEquals(existingCalendar.getEnableRatings(), newCalendar.getEnableRatings());
    Assert.assertEquals(
        Time.getShortTimestamp(existingCalendar.getLastPublishDate()),
        Time.getShortTimestamp(newCalendar.getLastPublishDate()));
  }
  @Override
  protected void doDelete(Object object) throws Exception {
    Calendar calendar = (Calendar) object;

    deleteDocument(calendar.getCompanyId(), calendar.getCalendarId());
  }