Search in sources :

Example 1 with DefaultNotificationFilterPreference

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

the class WatchedLocationReference method createExclusiveFilterPreference.

@Override
public NotificationFilterPreference createExclusiveFilterPreference() {
    DefaultNotificationFilterPreference preference = createFilterPreference();
    preference.setFilterType(NotificationFilterType.EXCLUSIVE);
    return new ScopeNotificationFilterPreference(preference, entityReference);
}
Also used : DefaultNotificationFilterPreference(org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference) ScopeNotificationFilterPreference(org.xwiki.notifications.filters.internal.scope.ScopeNotificationFilterPreference)

Example 2 with DefaultNotificationFilterPreference

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

the class WatchedLocationReference method createFilterPreference.

private DefaultNotificationFilterPreference createFilterPreference() {
    DefaultNotificationFilterPreference filterPreference = new DefaultNotificationFilterPreference(Long.toString(new Date().getTime()));
    // Fields
    filterPreference.setEnabled(true);
    filterPreference.setFilterType(NotificationFilterType.INCLUSIVE);
    filterPreference.setFilterName(ScopeNotificationFilter.FILTER_NAME);
    filterPreference.setNotificationFormats(ALL_NOTIFICATION_FORMATS);
    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());
    // Scope value
    List<String> value = Collections.singletonList(serializedReference);
    switch(entityReference.getType()) {
        case WIKI:
            preferenceProperties.put(NotificationFilterProperty.WIKI, value);
            break;
        case SPACE:
            preferenceProperties.put(NotificationFilterProperty.SPACE, value);
            break;
        case DOCUMENT:
            preferenceProperties.put(NotificationFilterProperty.PAGE, value);
            break;
        default:
            break;
    }
    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)

Example 3 with DefaultNotificationFilterPreference

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

the class WatchedUserReference method createInclusiveFilterPreference.

@Override
public NotificationFilterPreference createInclusiveFilterPreference() {
    DefaultNotificationFilterPreference filterPreference = new DefaultNotificationFilterPreference(Long.toString(new Date().getTime()));
    filterPreference.setEnabled(true);
    filterPreference.setFilterType(NotificationFilterType.INCLUSIVE);
    filterPreference.setFilterName(EventUserFilter.FILTER_NAME);
    filterPreference.setNotificationFormats(Sets.newHashSet(NotificationFormat.values()));
    filterPreference.setProviderHint(UserProfileNotificationPreferenceProvider.NAME);
    filterPreference.setActive(true);
    // 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)

Example 4 with DefaultNotificationFilterPreference

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

the class WatchlistBridgeProvider method createDefaultNotificationFilterPreference.

private DefaultNotificationFilterPreference createDefaultNotificationFilterPreference(String name) {
    DefaultNotificationFilterPreference pref = new DefaultNotificationFilterPreference(name);
    pref.setEnabled(true);
    pref.setNotificationFormats(Sets.newHashSet(NotificationFormat.values()));
    pref.setProviderHint(PROVIDER_HINT);
    pref.setFilterName(ScopeNotificationFilter.FILTER_NAME);
    pref.setFilterType(NotificationFilterType.INCLUSIVE);
    pref.setPreferenceProperties(new HashMap<>());
    return pref;
}
Also used : DefaultNotificationFilterPreference(org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference)

Example 5 with DefaultNotificationFilterPreference

use of org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference 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)

Aggregations

DefaultNotificationFilterPreference (org.xwiki.notifications.filters.internal.DefaultNotificationFilterPreference)6 HashMap (java.util.HashMap)4 List (java.util.List)4 NotificationFilterProperty (org.xwiki.notifications.filters.NotificationFilterProperty)4 Date (java.util.Date)3 ScopeNotificationFilterPreference (org.xwiki.notifications.filters.internal.scope.ScopeNotificationFilterPreference)1