Search in sources :

Example 56 with PortletPreferences

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);
}
Also used : PortletPreferences(javax.portlet.PortletPreferences)

Example 57 with PortletPreferences

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";
}
Also used : PortletPreferences(javax.portlet.PortletPreferences) JsonNode(com.fasterxml.jackson.databind.JsonNode) ResourceMapping(org.springframework.web.portlet.bind.annotation.ResourceMapping)

Example 58 with PortletPreferences

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);
}
Also used : HashMap(java.util.HashMap) ModelAndView(org.springframework.web.servlet.ModelAndView) PortletPreferences(javax.portlet.PortletPreferences) RenderMapping(org.springframework.web.portlet.bind.annotation.RenderMapping)

Example 59 with PortletPreferences

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;
}
Also used : LoginAggregationKey(org.apereo.portal.events.aggr.login.LoginAggregationKey) ConcurrentUserAggregationKey(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKey) ArrayList(java.util.ArrayList) LoginAggregationKeyImpl(org.apereo.portal.events.aggr.login.LoginAggregationKeyImpl) LoginAggregation(org.apereo.portal.events.aggr.login.LoginAggregation) DateTime(org.joda.time.DateTime) ConcurrentUserAggregationKeyImpl(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregationKeyImpl) ConcurrentUserAggregation(org.apereo.portal.events.aggr.concuser.ConcurrentUserAggregation) AggregatedGroupMapping(org.apereo.portal.events.aggr.groups.AggregatedGroupMapping) DateMidnight(org.joda.time.DateMidnight) PortletPreferences(javax.portlet.PortletPreferences) AggregationInterval(org.apereo.portal.events.aggr.AggregationInterval)

Aggregations

PortletPreferences (javax.portlet.PortletPreferences)59 HashMap (java.util.HashMap)12 RenderMapping (org.springframework.web.portlet.bind.annotation.RenderMapping)10 ModelAndView (org.springframework.web.portlet.ModelAndView)9 List (java.util.List)6 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)6 PortletRequest (javax.portlet.PortletRequest)5 HttpServletRequest (javax.servlet.http.HttpServletRequest)5 IPerson (org.apereo.portal.security.IPerson)5 ResourceMapping (org.springframework.web.portlet.bind.annotation.ResourceMapping)5 KBArticle (com.liferay.knowledgebase.model.KBArticle)4 Map (java.util.Map)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 ArrayList (java.util.ArrayList)3 LinkedHashMap (java.util.LinkedHashMap)3 AdminSubscriptionSender (com.liferay.knowledgebase.admin.util.AdminSubscriptionSender)2 KBFolder (com.liferay.knowledgebase.model.KBFolder)2 BaseUpgradePortletPreferences (com.liferay.portal.kernel.upgrade.BaseUpgradePortletPreferences)2 Portlet (com.liferay.portal.model.Portlet)2 ThemeDisplay (com.liferay.portal.theme.ThemeDisplay)2