Example usage for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_TIME_ZONE

List of usage examples for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_TIME_ZONE

Introduction

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

Prototype

String COMPANY_DEFAULT_TIME_ZONE

To view the source code for com.liferay.portal.kernel.util PropsKeys COMPANY_DEFAULT_TIME_ZONE.

Click Source Link

Usage

From source file:com.liferay.calendar.hook.upgrade.v1_0_1.UpgradeCalendar.java

License:Open Source License

@Override
protected void doUpgrade() throws Exception {
    Connection con = null;//from  w w w.ja v  a2  s.co  m
    PreparedStatement ps = null;
    ResultSet rs = null;

    try {
        con = DataAccess.getUpgradeOptimizedConnection();

        StringBundler sb = new StringBundler(6);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar ");
        sb.append("inner join CalendarResource on Calendar.");
        sb.append("calendarResourceId = CalendarResource.");
        sb.append("calendarResourceId inner join User_ on ");
        sb.append("CalendarResource.userId = User_.userId");

        ps = con.prepareStatement(sb.toString());

        rs = ps.executeQuery();

        long userClassNameId = PortalUtil.getClassNameId(User.class);

        while (rs.next()) {
            long calendarId = rs.getLong(1);
            long classNameId = rs.getLong(2);

            String timeZoneId = null;

            if (classNameId == userClassNameId) {
                timeZoneId = rs.getString(3);
            } else {
                timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
            }

            updateCalendarTimeZoneId(con, calendarId, timeZoneId);
        }
    } finally {
        DataAccess.cleanUp(con);
    }
}

From source file:com.liferay.calendar.hook.upgrade.v1_0_1.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
            new ServiceContext());

    UpgradeCalendar upgradeCalendar = new UpgradeCalendar();

    upgradeCalendar.doUpgrade();//from w  w  w  . jav a  2s .  com

    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(_group.getGroupId(),
            calendarResource.getCalendarResourceId());

    Calendar calendar = calendars.get(0);

    Assert.assertEquals(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE), calendar.getTimeZoneId());
}

From source file:com.liferay.calendar.internal.upgrade.v1_0_2.UpgradeCalendar.java

License:Open Source License

public void updateCalendarTimeZoneIds() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        StringBundler sb = new StringBundler(5);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar inner ");
        sb.append("join CalendarResource on Calendar.calendarResourceId ");
        sb.append("= CalendarResource.calendarResourceId inner join ");
        sb.append("User_ on CalendarResource.userId = User_.userId");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString());
                ResultSet rs = ps.executeQuery()) {

            long userClassNameId = PortalUtil.getClassNameId(User.class);

            while (rs.next()) {
                long calendarId = rs.getLong(1);
                long classNameId = rs.getLong(2);

                String timeZoneId = null;

                if (classNameId == userClassNameId) {
                    timeZoneId = rs.getString(3);
                } else {
                    timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
                }// www .  j  a  v  a 2 s.c  om

                updateCalendarTimeZoneId(calendarId, timeZoneId);
            }
        }
    }
}

From source file:com.liferay.calendar.upgrade.test.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    CalendarResource calendarResource = CalendarResourceUtil.getGroupCalendarResource(_group.getGroupId(),
            new ServiceContext());

    upgrade();// w w w  .  j a  v a  2s  .c  o  m

    List<Calendar> calendars = CalendarLocalServiceUtil.getCalendarResourceCalendars(_group.getGroupId(),
            calendarResource.getCalendarResourceId());

    Calendar calendar = calendars.get(0);

    Assert.assertEquals(PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE), calendar.getTimeZoneId());
}

From source file:com.liferay.calendar.upgrade.v1_0_2.test.UpgradeCalendarTest.java

License:Open Source License

@Test
public void testUpgradeSetsSiteCalendarTimeZoneId() throws Exception {
    Calendar calendar = CalendarTestUtil.addCalendar(_group);

    _upgradeProcess.upgrade();//  w ww.  j  a  v a2  s .com

    assertCalendarTimeZoneId(calendar, PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE));
}

From source file:com.liferay.calendar.upgrade.v1_0_2.UpgradeCalendar.java

License:Open Source License

protected void updateCalendarTimeZoneIds() throws Exception {
    try (LoggingTimer loggingTimer = new LoggingTimer()) {
        StringBundler sb = new StringBundler(5);

        sb.append("select Calendar.calendarId, CalendarResource.");
        sb.append("classNameId, User_.timeZoneId from Calendar inner ");
        sb.append("join CalendarResource on Calendar.calendarResourceId ");
        sb.append("= CalendarResource.calendarResourceId inner join ");
        sb.append("User_ on CalendarResource.userId = User_.userId");

        try (PreparedStatement ps = connection.prepareStatement(sb.toString());
                ResultSet rs = ps.executeQuery()) {

            long userClassNameId = PortalUtil.getClassNameId(User.class);

            while (rs.next()) {
                long calendarId = rs.getLong(1);
                long classNameId = rs.getLong(2);

                String timeZoneId = null;

                if (classNameId == userClassNameId) {
                    timeZoneId = rs.getString(3);
                } else {
                    timeZoneId = PropsUtil.get(PropsKeys.COMPANY_DEFAULT_TIME_ZONE);
                }//from www.j  ava2 s . com

                updateCalendarTimeZoneId(calendarId, timeZoneId);
            }
        }
    }
}