Search in sources :

Example 1 with LocationHistory

use of org.olat.modules.lecture.model.LocationHistory in project OpenOLAT by OpenOLAT.

the class EditLectureBlockController method updateLocationsPrefs.

private void updateLocationsPrefs(UserRequest ureq) {
    String location = lectureBlock.getLocation();
    if (StringHelper.containsNonWhitespace(location)) {
        List<LocationHistory> newLocations = new ArrayList<>(locations);
        LocationHistory newLocation = new LocationHistory(location, new Date());
        if (locations.contains(newLocation)) {
            int index = locations.indexOf(newLocation);
            locations.get(index).setLastUsed(new Date());
        } else {
            newLocations.add(newLocation);
            Collections.sort(newLocations, new LocationDateComparator());
            if (newLocations.size() > 10) {
                // pack it in a new list for XStream
                newLocations = new ArrayList<>(newLocations.subList(0, 10));
            }
        }
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        if (guiPrefs != null) {
            guiPrefs.putAndSave(LectureBlock.class, getLocationsPrefsId(), newLocations);
        }
    }
}
Also used : LocationHistory(org.olat.modules.lecture.model.LocationHistory) ArrayList(java.util.ArrayList) Preferences(org.olat.core.util.prefs.Preferences) Date(java.util.Date)

Example 2 with LocationHistory

use of org.olat.modules.lecture.model.LocationHistory in project openolat by klemens.

the class EditLectureBlockController method updateLocationsPrefs.

private void updateLocationsPrefs(UserRequest ureq) {
    String location = lectureBlock.getLocation();
    if (StringHelper.containsNonWhitespace(location)) {
        List<LocationHistory> newLocations = new ArrayList<>(locations);
        LocationHistory newLocation = new LocationHistory(location, new Date());
        if (locations.contains(newLocation)) {
            int index = locations.indexOf(newLocation);
            locations.get(index).setLastUsed(new Date());
        } else {
            newLocations.add(newLocation);
            Collections.sort(newLocations, new LocationDateComparator());
            if (newLocations.size() > 10) {
                // pack it in a new list for XStream
                newLocations = new ArrayList<>(newLocations.subList(0, 10));
            }
        }
        Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
        if (guiPrefs != null) {
            guiPrefs.putAndSave(LectureBlock.class, getLocationsPrefsId(), newLocations);
        }
    }
}
Also used : LocationHistory(org.olat.modules.lecture.model.LocationHistory) ArrayList(java.util.ArrayList) Preferences(org.olat.core.util.prefs.Preferences) Date(java.util.Date)

Example 3 with LocationHistory

use of org.olat.modules.lecture.model.LocationHistory in project OpenOLAT by OpenOLAT.

the class EditLectureBlockController method getLocations.

private List<LocationHistory> getLocations(UserRequest ureq) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    List<LocationHistory> showConfig = guiPrefs.getList(LectureBlock.class, getLocationsPrefsId(), LocationHistory.class);
    return showConfig == null ? new ArrayList<>() : showConfig;
}
Also used : LocationHistory(org.olat.modules.lecture.model.LocationHistory) Preferences(org.olat.core.util.prefs.Preferences)

Example 4 with LocationHistory

use of org.olat.modules.lecture.model.LocationHistory in project openolat by klemens.

the class EditLectureBlockController method getLocations.

private List<LocationHistory> getLocations(UserRequest ureq) {
    Preferences guiPrefs = ureq.getUserSession().getGuiPreferences();
    List<LocationHistory> showConfig = guiPrefs.getList(LectureBlock.class, getLocationsPrefsId(), LocationHistory.class);
    return showConfig == null ? new ArrayList<>() : showConfig;
}
Also used : LocationHistory(org.olat.modules.lecture.model.LocationHistory) Preferences(org.olat.core.util.prefs.Preferences)

Aggregations

Preferences (org.olat.core.util.prefs.Preferences)4 LocationHistory (org.olat.modules.lecture.model.LocationHistory)4 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2