Search in sources :

Example 6 with NotificationFilterProperty

use of org.xwiki.notifications.filters.NotificationFilterProperty in project xwiki-platform by xwiki.

the class WatchlistBridgeProvider method getValues.

private void getValues(BaseObject obj, String fieldName, NotificationFilterProperty property, Set<NotificationFilterPreference> results) {
    List<String> values = obj.getListValue(fieldName);
    if (values != null && !values.isEmpty()) {
        for (String value : values) {
            DefaultNotificationFilterPreference pref = createDefaultNotificationFilterPreference(String.format(WATCHLIST_FILTER_PREFERENCES_NAME, property.name(), sha256Hex(value)));
            Map<NotificationFilterProperty, List<String>> preferenceProperties = new HashMap<>();
            preferenceProperties.put(property, Collections.singletonList(value));
            pref.setPreferenceProperties(preferenceProperties);
            results.add(pref);
        }
    }
}
Also used : DefaultNotificationFilterPreference(org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference) NotificationFilterProperty(org.xwiki.notifications.filters.NotificationFilterProperty) HashMap(java.util.HashMap) List(java.util.List)

Example 7 with NotificationFilterProperty

use of org.xwiki.notifications.filters.NotificationFilterProperty in project xwiki-platform by xwiki.

the class WatchedUserReference method createExclusiveFilterPreference.

@Override
public NotificationFilterPreference createExclusiveFilterPreference() {
    DefaultNotificationFilterPreference filterPreference = new DefaultNotificationFilterPreference(Long.toString(new Date().getTime()));
    filterPreference.setEnabled(true);
    filterPreference.setFilterType(NotificationFilterType.EXCLUSIVE);
    filterPreference.setFilterName(EventUserFilter.FILTER_NAME);
    filterPreference.setNotificationFormats(Sets.newHashSet(NotificationFormat.values()));
    filterPreference.setProviderHint(UserProfileNotificationPreferenceProvider.NAME);
    filterPreference.setActive(false);
    // Properties
    Map<NotificationFilterProperty, List<String>> preferenceProperties = new HashMap<>();
    filterPreference.setPreferenceProperties(preferenceProperties);
    preferenceProperties.put(NotificationFilterProperty.EVENT_TYPE, Collections.emptyList());
    preferenceProperties.put(NotificationFilterProperty.USER, Collections.singletonList(userId));
    return filterPreference;
}
Also used : DefaultNotificationFilterPreference(org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference) NotificationFilterProperty(org.xwiki.notifications.filters.NotificationFilterProperty) HashMap(java.util.HashMap) List(java.util.List) Date(java.util.Date)

Aggregations

NotificationFilterProperty (org.xwiki.notifications.filters.NotificationFilterProperty)7 List (java.util.List)6 HashMap (java.util.HashMap)5 DefaultNotificationFilterPreference (org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference)4 Date (java.util.Date)3 NotificationFormat (org.xwiki.notifications.NotificationFormat)2 NotificationFilterPreference (org.xwiki.notifications.filters.NotificationFilterPreference)2 NotificationFilterType (org.xwiki.notifications.filters.NotificationFilterType)2 XWiki (com.xpn.xwiki.XWiki)1 XWikiContext (com.xpn.xwiki.XWikiContext)1 XWikiException (com.xpn.xwiki.XWikiException)1 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 BaseObject (com.xpn.xwiki.objects.BaseObject)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 NotificationException (org.xwiki.notifications.NotificationException)1