2017-05-18 15:15 GMT+02:00 Vincent Massol <[email protected]>:

> Hi,
>
> > On 17 May 2017, at 23:29, Clément Aubin <[email protected]> wrote:
> >
> > Hi everyone,
> >
> > I’m currently working on a feature that should allow users to define
> > custom notification types in XWiki only through the definition of an
> > XObject (link to the issue : https://jira.xwiki.org/browse/XWIKI-14119).
> >
> > In this context, I wanted to know your thoughts about what properties
> > should be proposed by this XObject.
> >
> > Currently, here is my proposition :
> >
> > - The application name (applicationName) : the event application name
> >
> > - A unique ID for the event (eventId)
> >
> > - An event «pretty» name / description (eventPrettyName)
> >
> > - An event icon, mainly displayed in the user notification preferences
> > pane (eventIcon)
> >
> > - An event type (eventType) : the name of the event that should trigger
> > the notification (such as org.xwiki.bridge.event.DocumentUpdatedEvent)
>
> So this means that the application would still need to have some java to
> generate the custom event?
>

No. Clement is making a generic listener. When the listener receive an
event of the type defined by a descriptor, it will perform some actions
(ie: sending a more specific event that will be stored in the event stream).

All the application have to do is to specify with event to listen, what is
the specific event to send (which is a generic
ParametrizableRecordableEvent with a "type" parameter), and what XObject to
look at in order to send or not the specific event.


>
> Of course it’s possible to define a wiki component that implements
> EventListener but this requires PR.
>
> There are 2 ways I can think of:
>
> 1) We could offer a specific XClass that would be a specific wrapper
> around Wiki Components for EventListener and that wouldn’t require PR. It
> could require Admin permissions if we want to err on the safe side. A
> typical use case is the ability to register an EventListener when an
> xobject of a given type is modified and allow executing some script.
>
> 2) Have something specific to notifications for some specific use cases.
> For example we could have 3 xproperties:
> - an xproperty to specify its name (eg “BlogPostPublished”)
> - a “strategy” xproperty with one option being to “send on save”.
> - a “object” xproperty representing the xobject type to listen to (e.g.
> Blog.BlogPostClass). Note: this xproperty depends on the “strategy” one.
>
> With these 3 pieces of info you can write a generic (but specific to this
> use case) listener that would listen on
>

That is the idea. Clément and I did not think about this "strategy"
property but it's a good idea.


>
> 2) is nice but only solves specific use cases but it could be extended
> with a “custom” strategy.
>
> > - An object type (objectType) : an XObject that _has_ to be associated
> > with the document triggering the event in order to trigger the custom
> > notification
>
> I don’t understand what this is.
>

It's what you call the "object” xproperty (representing the xobject type to
listen to (e.g. Blog.BlogPostClass)).

>
> What would be nice would be to take the example of the Blog application
> and show us how you’d use your xobject to represent the notification for it.
>
> Thanks!
> -Vincent
>
> > - A validation expression (validationExpression) : a script that will be
> > parsed in the event context in order to filter certain event kinds.
> >
> > - A notification template (notificationTemplate) : the template that
> > should be used for rendering the notification in the notification center
> >
> > To summarize, a custom notification is triggered if the following
> > expression is fully satisfied :
> > «The (eventType) has been triggered on a document having (objectType) in
> > his XObjects and the (validationExpression) is true in the current
> context».
> >
> > What do you think ?
> >
> > Thanks,
> >
> > -- Clément Aubin Web Developer Intern @XWiki SAS [email protected]
> > More about us at http://www.xwiki.com
> >
>
>


-- 
Guillaume Delhumeau ([email protected])
Research & Development Engineer at XWiki SAS
Committer on the XWiki.org project

Reply via email to