Example usage for com.liferay.portal.kernel.util Time HOUR

List of usage examples for com.liferay.portal.kernel.util Time HOUR

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util Time HOUR.

Prototype

long HOUR

To view the source code for com.liferay.portal.kernel.util Time HOUR.

Click Source Link

Usage

From source file:com.liferay.calendar.ratings.test.CalendarBookingRatingsTest.java

License:Open Source License

@Override
protected BaseModel<?> addBaseModel(BaseModel<?> parentBaseModel, ServiceContext serviceContext)
        throws Exception {

    Calendar calendar = (Calendar) parentBaseModel;

    long startTime = System.currentTimeMillis();

    return CalendarBookingLocalServiceUtil.addCalendarBooking(TestPropsValues.getUserId(),
            calendar.getCalendarId(), new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT,
            CalendarBookingConstants.RECURRING_CALENDAR_BOOKING_ID_DEFAULT,
            RandomTestUtil.randomLocaleStringMap(), RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomString(), startTime, startTime + (Time.HOUR * 10), false, null, 0, null, 0,
            null, serviceContext);//from   w w  w .j  a v a2s. com
}

From source file:com.liferay.calendar.search.test.CalendarBookingIndexerTest.java

License:Open Source License

protected void addCalendarBooking(LocalizedValuesMap titleMap) {
    try {//from   w w w  .jav a  2s .  co  m
        ServiceContext serviceContext = new ServiceContext();

        CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
                serviceContext);

        Calendar calendar = CalendarLocalServiceUtil.addCalendar(_user.getUserId(), _group.getGroupId(),
                calendarResource.getCalendarResourceId(), RandomTestUtil.randomLocaleStringMap(),
                RandomTestUtil.randomLocaleStringMap(), StringPool.UTC, RandomTestUtil.randomInt(0, 255), false,
                false, false, serviceContext);

        long startTime = DateUtil.newTime() + RandomTestUtil.randomInt();

        long endTime = startTime + Time.HOUR;

        HashMap<Locale, String> hashMap = new HashMap<>();

        CalendarBookingLocalServiceUtil.addCalendarBooking(_user.getUserId(), calendar.getCalendarId(),
                new long[0], CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, 0,
                titleMap.getValues(), hashMap, null, startTime, endTime, false, null, 0, "email", 0, "email",
                serviceContext);
    } catch (PortalException pe) {
        throw new RuntimeException(pe);
    }
}

From source file:com.liferay.calendar.search.test.CalendarFixture.java

License:Open Source License

public CalendarBooking addCalendarBooking(LocalizedValuesMap titleLocalizedValuesMap, Calendar calendar,
        ServiceContext serviceContext) throws PortalException {

    long startTime = DateUtil.newTime() + RandomTestUtil.randomInt();

    long endTime = startTime + Time.HOUR;

    CalendarBooking calendarBooking = _calendarBookingLocalService.addCalendarBooking(
            serviceContext.getUserId(), calendar.getCalendarId(), new long[0],
            CalendarBookingConstants.PARENT_CALENDAR_BOOKING_ID_DEFAULT, 0, titleLocalizedValuesMap.getValues(),
            Collections.emptyMap(), null, startTime, endTime, false, null, 0, "email", 0, "email",
            serviceContext);// w w w .j ava 2 s.c  o m

    _calendarBookings.add(calendarBooking);

    return calendarBooking;
}

From source file:com.liferay.calendar.service.impl.CalendarImporterLocalServiceImpl.java

License:Open Source License

@Override
public void importCalEvent(CalEvent calEvent) throws PortalException {

    // Calendar event

    CalendarBooking calendarBooking = fetchCalendarBooking(calEvent);

    if (calendarBooking != null) {
        verifyCalendarBooking(calendarBooking, calEvent);

        return;// ww  w  .  j a  v a2s .  c  o m
    }

    long calendarBookingId = counterLocalService.increment();

    CalendarResource calendarResource = getCalendarResource(calEvent.getCompanyId(), calEvent.getGroupId());

    Date startDate = calEvent.getStartDate();

    long startTime = startDate.getTime();

    long endTime = startTime + calEvent.getDurationHour() * Time.HOUR
            + calEvent.getDurationMinute() * Time.MINUTE;

    if (calEvent.isAllDay()) {
        endTime = endTime - 1;
    }

    String recurrence = getRecurrence(calEvent.getRecurrenceObj());

    addCalendarBooking(calEvent.getUuid(), calendarBookingId, calEvent.getCompanyId(),
            calendarResource.getGroupId(), calEvent.getUserId(), calEvent.getUserName(),
            calEvent.getCreateDate(), calEvent.getModifiedDate(), calendarResource.getDefaultCalendarId(),
            calendarResource.getCalendarResourceId(), calEvent.getTitle(), calEvent.getDescription(),
            calEvent.getLocation(), startTime, endTime, calEvent.getAllDay(), recurrence,
            calEvent.getFirstReminder(), NotificationType.EMAIL, calEvent.getSecondReminder(),
            NotificationType.EMAIL);

    // Resources

    importCalendarBookingResourcePermissions(calEvent, calendarBookingId);

    // Subscriptions

    importSubscriptions(calEvent, calendarBookingId);

    // Asset

    importAssets(calEvent, calendarBookingId);

    // Message boards

    importMBDiscussion(calEvent, calendarBookingId);

    // Social

    importSocialActivities(calEvent, calendarBookingId);

    // Ratings

    importRatings(classNameLocalService.getClassNameId(CalEvent.class.getName()), calEvent.getEventId(),
            classNameLocalService.getClassNameId(CalendarBooking.class.getName()), calendarBookingId);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testAddCalendarBooking() throws Exception {
    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    serviceContext.setLanguageId("fr_FR");

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRegularCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), serviceContext);

    Assert.assertEquals("fr_FR", LocalizationUtil.getDefaultLanguageId(calendarBooking.getTitle()));
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testAddCalendarBookingDoesNotNotifyCreatorTwice() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    _invitingUser = UserTestUtil.addUser();

    Calendar calendar = CalendarTestUtil.addCalendar(_invitingUser, serviceContext);

    Calendar invitedCalendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis() + Time.MINUTE;

    long endTime = startTime + Time.HOUR;

    long firstReminder = Time.MINUTE;

    serviceContext.setWorkflowAction(WorkflowConstants.ACTION_PUBLISH);

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addCalendarBooking(_invitingUser, calendar,
            new long[] { invitedCalendar.getCalendarId() }, RandomTestUtil.randomLocaleStringMap(),
            RandomTestUtil.randomLocaleStringMap(), startTime, endTime, null, (int) firstReminder,
            NotificationType.EMAIL, 0, NotificationType.EMAIL, serviceContext);

    CalendarBooking childCalendarBooking = getChildCalendarBooking(calendarBooking);

    CalendarBookingLocalServiceUtil.updateStatus(_user.getUserId(), childCalendarBooking,
            CalendarBookingWorkflowConstants.STATUS_APPROVED, serviceContext);

    CalendarBookingLocalServiceUtil.checkCalendarBookings();

    String mailMessageSubject = "Calendar: Event Reminder for " + StringPool.QUOTE
            + calendarBooking.getTitle(LocaleUtil.getDefault()) + StringPool.QUOTE;

    List<com.dumbster.smtp.MailMessage> mailMessages = MailServiceTestUtil.getMailMessages("Subject",
            mailMessageSubject);/*  ww w.j  av  a  2 s  .  c om*/

    Assert.assertEquals(mailMessages.toString(), 2, mailMessages.size());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testAddRecurringCalendarBookingUntilStartTime() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, _losAngelesTimeZone, serviceContext);

    java.util.Calendar startTimeJCalendar = CalendarFactoryUtil.getCalendar(2017, java.util.Calendar.JANUARY, 1,
            20, 0, 0, 0, _losAngelesTimeZone);

    java.util.Calendar untilJCalendar = (java.util.Calendar) startTimeJCalendar.clone();

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence(_losAngelesTimeZone, untilJCalendar);

    long startTime = startTimeJCalendar.getTimeInMillis();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext);

    long calendarBookingId = calendarBooking.getCalendarBookingId();

    assertCalendarBookingInstancesCount(calendarBookingId, 1);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testDeleteCalendarBooking() throws Exception {
    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext);

    long instanceStartTime = startTime + Time.DAY * 2;

    Map<Locale, String> titleMap = RandomTestUtil.randomLocaleStringMap();

    CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(
            _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), titleMap,
            calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime,
            instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext);

    CalendarBookingLocalServiceUtil.deleteCalendarBooking(calendarBooking);

    calendarBookingInstance = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId());

    Assert.assertEquals(titleMap, calendarBookingInstance.getTitleMap());
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testDeleteCalendarBookingWithAllFollowingInstances() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext);

    long instanceStartTime = startTime + Time.DAY * 2;

    Map<Locale, String> titleMap = RandomTestUtil.randomLocaleStringMap();

    CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(
            _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(), titleMap,
            calendarBooking.getDescriptionMap(), calendarBooking.getLocation(), instanceStartTime,
            instanceStartTime + (Time.HOUR * 10), false, null, false, 0, null, 0, null, serviceContext);

    CalendarBookingLocalServiceUtil.deleteCalendarBookingInstance(calendarBooking, 1, true, true);

    calendarBookingInstance = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId());

    Assert.assertNull(calendarBookingInstance);

    assertCalendarBookingInstancesCount(calendarBooking.getCalendarBookingId(), 1);
}

From source file:com.liferay.calendar.service.test.CalendarBookingLocalServiceTest.java

License:Open Source License

@Test
public void testDeleteCalendarBookingWithAllRecurringInstances() throws Exception {

    ServiceContext serviceContext = createServiceContext();

    Calendar calendar = CalendarTestUtil.addCalendar(_user, serviceContext);

    long startTime = System.currentTimeMillis();

    Recurrence recurrence = RecurrenceTestUtil.getDailyRecurrence();

    CalendarBooking calendarBooking = CalendarBookingTestUtil.addRecurringCalendarBooking(_user, calendar,
            startTime, startTime + (Time.HOUR * 10), recurrence, serviceContext);

    long instanceStartTime = startTime + Time.DAY * 2;

    CalendarBooking calendarBookingInstance = CalendarBookingLocalServiceUtil.updateCalendarBookingInstance(
            _user.getUserId(), calendarBooking.getCalendarBookingId(), 2, calendar.getCalendarId(),
            RandomTestUtil.randomLocaleStringMap(), calendarBooking.getDescriptionMap(),
            calendarBooking.getLocation(), instanceStartTime, instanceStartTime + (Time.HOUR * 10), false, null,
            false, 0, null, 0, null, serviceContext);

    CalendarBookingLocalServiceUtil.deleteCalendarBooking(calendarBooking, true);

    calendarBookingInstance = CalendarBookingLocalServiceUtil
            .fetchCalendarBooking(calendarBookingInstance.getCalendarBookingId());

    Assert.assertNull(calendarBookingInstance);
}