Search in sources :

Example 1 with Version

use of teammates.common.util.Version in project teammates by TEAMMATES.

the class AdminActivityLogPageAction method generateStatusMessage.

private void generateStatusMessage(List<String> versionToQuery, AdminActivityLogPageData data, List<ActivityLogEntry> logs, String courseId) {
    StringBuilder status = new StringBuilder(500);
    status.append("Total Logs gone through in last search: " + totalLogsSearched + "<br>Total Relevant Logs found in last search: " + String.format("%s<br>", logs.size()));
    long earliestSearchTime = data.getFromDate();
    ActivityLogEntry earliestLogChecked = null;
    if (!logs.isEmpty()) {
        earliestLogChecked = logs.get(logs.size() - 1);
    }
    // if the search space is limited to a certain log
    if (logs.size() >= RELEVANT_LOGS_PER_PAGE && earliestLogChecked != null) {
        earliestSearchTime = earliestLogChecked.getLogTime();
    }
    ZoneId targetTimeZone = null;
    if (data.isPersonSpecified()) {
        String targetUserGoogleId = data.getPersonSpecified();
        targetTimeZone = getLocalTimeZoneForRequest(targetUserGoogleId, "");
        if (targetTimeZone == null && courseId != null && !courseId.isEmpty()) {
            // if the user is unregistered, try finding the timezone by course id passed from Search page
            targetTimeZone = getLocalTimeZoneForUnregisteredUserRequest(courseId);
        }
    } else {
        targetTimeZone = Const.SystemParams.ADMIN_TIME_ZONE_ID;
    }
    String timeInAdminTimeZone = TimeHelper.formatActivityLogTime(Instant.ofEpochMilli(earliestSearchTime), Const.SystemParams.ADMIN_TIME_ZONE_ID);
    String timeInUserTimeZone = TimeHelper.formatActivityLogTime(Instant.ofEpochMilli(earliestSearchTime), targetTimeZone);
    status.append("The earliest log entry checked on <b>" + timeInAdminTimeZone + "</b> in Admin Time Zone (" + Const.SystemParams.ADMIN_TIME_ZONE_ID.getId() + ") and ");
    if (targetTimeZone == null) {
        status.append(timeInUserTimeZone).append(".<br>");
    } else {
        status.append("on <b>" + timeInUserTimeZone + "</b> in Local Time Zone (" + targetTimeZone + ").<br>");
    }
    status.append("Logs are from following version(s): ");
    for (int i = 0; i < versionToQuery.size(); i++) {
        String version = versionToQuery.get(i).replace('-', '.');
        if (i < versionToQuery.size() - 1) {
            status.append(version).append(", ");
        } else {
            status.append(version).append("<br>");
        }
    }
    status.append("All available version(s): ");
    GaeVersionApi versionApi = new GaeVersionApi();
    List<Version> versionList = versionApi.getAvailableVersions();
    for (int i = 0; i < versionList.size(); i++) {
        String version = versionList.get(i).toString();
        if (i < versionList.size() - 1) {
            status.append(version).append(", ");
        } else {
            status.append(version).append("<br>");
        }
    }
    // the "Search More" button to continue searching from the previous fromDate
    status.append("<button class=\"btn-link\" id=\"button_older\" data-next-end-time-to-search=\"" + nextEndTimeToSearch + "\">Search More</button><input id=\"ifShowAll\" type=\"hidden\" value=\"" + data.getShouldShowAllLogs() + "\"/><input id=\"ifShowTestData\" type=\"hidden\" value=\"" + data.getShouldShowTestData() + "\"/>");
    String statusString = status.toString();
    data.setStatusForAjax(statusString);
    statusToUser.add(new StatusMessage(statusString, StatusMessageColor.INFO));
}
Also used : ActivityLogEntry(teammates.common.util.ActivityLogEntry) ZoneId(java.time.ZoneId) Version(teammates.common.util.Version) GaeVersionApi(teammates.common.util.GaeVersionApi) StatusMessage(teammates.common.util.StatusMessage)

Example 2 with Version

use of teammates.common.util.Version in project teammates by TEAMMATES.

the class VersionTest method testVersionComparison.

@Test
public void testVersionComparison() {
    Version version1 = new Version("15.09");
    Version version2 = new Version("15.09");
    assertEquals(version1.compareTo(version2), 0);
    version1 = new Version("15.09");
    version2 = new Version("1.09");
    assertTrue(version1.compareTo(version2) < 0);
    assertTrue(version2.compareTo(version1) > 0);
    version1 = new Version("15.09");
    version2 = new Version("15.09.01");
    assertTrue(version1.compareTo(version2) > 0);
    ______TS("Test rc versions will come first when the rest are similar");
    version1 = new Version("15.09");
    version2 = new Version("15.09rc");
    // 15.09rc < 15.09
    assertTrue(version2.compareTo(version1) < 0);
}
Also used : Version(teammates.common.util.Version) Test(org.testng.annotations.Test)

Example 3 with Version

use of teammates.common.util.Version in project teammates by TEAMMATES.

the class VersionTest method testVersionConversion.

@Test
// A version with 4 numbers is not an IP address
@SuppressWarnings("PMD.AvoidUsingHardCodedIP")
public void testVersionConversion() {
    ______TS("Test versions with 2 numbers");
    Version version = new Version("15.09");
    assertEquals("15.09", version.toString());
    assertEquals("15-09", version.toStringWithDashes());
    ______TS("Test versions with 3 numbers");
    version = new Version("100-09-01");
    assertEquals("100.09.01", version.toString());
    assertEquals("100-09-01", version.toStringWithDashes());
    ______TS("Test versions with 4 numbers");
    version = new Version("15.09.01.1");
    assertEquals("15.09.01.1", version.toString());
    assertEquals("15-09-01-1", version.toStringWithDashes());
    ______TS("Test versions with rc");
    version = new Version("15.09rc");
    assertEquals("15.09rc", version.toString());
    assertEquals("15-09rc", version.toStringWithDashes());
}
Also used : Version(teammates.common.util.Version) Test(org.testng.annotations.Test)

Aggregations

Version (teammates.common.util.Version)3 Test (org.testng.annotations.Test)2 ZoneId (java.time.ZoneId)1 ActivityLogEntry (teammates.common.util.ActivityLogEntry)1 GaeVersionApi (teammates.common.util.GaeVersionApi)1 StatusMessage (teammates.common.util.StatusMessage)1