use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class RoleBasedBackgroundSetSelectionStrategy method getBackgroundContainerSelector.
@Override
public String getBackgroundContainerSelector(PortletRequest req) {
PreferenceNames names = PreferenceNames.getInstance(req);
PortletPreferences prefs = req.getPreferences();
return prefs.getValue(names.getBackgroundContainerSelectorPreferenceName(), null);
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class GoogleAnalyticsConfigController method getData.
@ResourceMapping("getData")
public String getData(PortletRequest portletRequest, ModelMap model) throws IOException {
final PortletPreferences preferences = portletRequest.getPreferences();
final JsonNode config = this.portletPreferencesJsonDao.getJsonNode(preferences, CONFIG_PREF_NAME);
model.put("data", config);
return "jsonView";
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class ActivityController method summary.
@RenderMapping
public ModelAndView summary(PortletRequest request) throws TypeMismatchException {
final Map<String, Object> model = new HashMap<String, Object>();
final PortalActivity now = buildPortalActivity(request, NOW);
final PortalActivity today = buildPortalActivity(request, TODAY);
final PortalActivity yesterday = buildPortalActivity(request, YESTERDAY);
model.put("usageNow", now);
model.put("usageToday", today);
model.put("usageYesterday", yesterday);
// Searches
// default
List<SearchInfo> popularSearchTerms = Collections.emptyList();
final PortletPreferences prefs = request.getPreferences();
final Boolean showSearches = Boolean.valueOf(prefs.getValue(PREFERENCE_SHOW_SEACHES, DEFAULT_PREFERENCE_SHOW_SEARCHES));
if (showSearches) {
popularSearchTerms = getPopularSearchTerms();
}
model.put("showSearches", showSearches);
model.put("popularSearchTerms", popularSearchTerms);
return new ModelAndView("jsp/Activity/activity", model);
}
use of javax.portlet.PortletPreferences in project uPortal by Jasig.
the class ActivityController method buildPortalActivity.
private PortalActivity buildPortalActivity(PortletRequest request, int timeframe) {
PortletPreferences prefs = request.getPreferences();
DateTime begin, end;
final AggregationInterval interval;
final List<PortalGroupActivity> groupActivities = new ArrayList<PortalGroupActivity>();
switch(timeframe) {
case NOW:
{
end = new DateTime();
begin = end.minusHours(1);
interval = AggregationInterval.FIVE_MINUTE;
break;
}
case TODAY:
{
begin = new DateMidnight().toDateTime();
end = begin.plusDays(1);
interval = AggregationInterval.DAY;
break;
}
case YESTERDAY:
{
end = new DateMidnight().toDateTime().minusSeconds(1);
begin = end.minusDays(1);
interval = AggregationInterval.DAY;
break;
}
default:
{
end = new DateTime();
begin = end.minusHours(1);
interval = AggregationInterval.HOUR;
break;
}
}
String masterGroup = prefs.getValue(PREFERENCE_MASTER_GROUP, DEFAULT_PREFERENCE_MASTER_GROUP);
List<String> displayGroups = Arrays.asList(prefs.getValues(PREFERENCE_DISPLAY_GROUPS, DEFAULT_PREFERENCE_DISPLAY_GROUPS));
boolean displayOther = Boolean.valueOf(prefs.getValue(PREFERENCE_DISPLAY_OTHER, DEFAULT_PREFERENCE_DISPLAY_OTHER));
int masterTotal = 0;
int absTotal = 0;
int subTotal = 0;
switch(timeframe) {
case NOW:
for (AggregatedGroupMapping group : concurrentUserAggregationDao.getAggregatedGroupMappings()) {
ConcurrentUserAggregationKey key = new ConcurrentUserAggregationKeyImpl(interval, group);
final List<ConcurrentUserAggregation> aggregations = concurrentUserAggregationDao.getAggregations(begin, end, key);
// NB: We only care about the most recent entry (??)
if (aggregations.size() != 0) {
final ConcurrentUserAggregation aggregation = aggregations.get(0);
int groupTotal = aggregation.getConcurrentUsers();
absTotal += aggregation.getConcurrentUsers();
if (group.getGroupName().equalsIgnoreCase(masterGroup)) {
masterTotal = groupTotal;
} else {
subTotal += groupTotal;
}
if (!group.getGroupName().equals(masterGroup)) {
if (displayGroups.isEmpty() || displayGroups.contains(group.getGroupName())) {
final PortalGroupActivity groupActivity = new PortalGroupActivity(group.getGroupName(), groupTotal);
groupActivities.add(groupActivity);
}
}
}
}
break;
default:
String uniqueLoginsPref = prefs.getValue(PREFERENCE_UNIQUE_LOGINS, DEFAULT_PREFERENCE_UNIQUE_LOGINS);
Boolean uniqueLogins = Boolean.valueOf(uniqueLoginsPref);
for (AggregatedGroupMapping group : loginAggregationDao.getAggregatedGroupMappings()) {
final LoginAggregationKey key = new LoginAggregationKeyImpl(interval, group);
final List<LoginAggregation> aggregations = loginAggregationDao.getAggregations(begin, end, key);
// NB: We only care about the most recent entry (??)
if (aggregations.size() != 0) {
final LoginAggregation aggregation = aggregations.get(0);
int groupTotal = getAggregationLoginCount(aggregation, uniqueLogins);
absTotal += groupTotal;
if (group.getGroupName().equalsIgnoreCase(masterGroup)) {
masterTotal = groupTotal;
} else {
subTotal += groupTotal;
}
if (!group.getGroupName().equals(masterGroup)) {
if (displayGroups.isEmpty() || displayGroups.contains(group.getGroupName())) {
PortalGroupActivity groupActivity = new PortalGroupActivity(group.getGroupName(), groupTotal);
groupActivities.add(groupActivity);
}
}
}
}
break;
}
if (displayOther) {
int otherTotal = masterTotal - subTotal;
if (otherTotal > 0) {
PortalGroupActivity otherGroup = new PortalGroupActivity("Other", otherTotal);
groupActivities.add(otherGroup);
}
}
Collections.sort(groupActivities);
Collections.reverse(groupActivities);
int total = masterTotal > 0 ? masterTotal : absTotal;
final PortalActivity activity = new PortalActivity(total, groupActivities);
return activity;
}
Aggregations