Implementation
 Dormant

Description

xwiki-activity component

Goals

Short-term: Log events fired by xwiki-observation into a dedicated table in the database, allowing cheap retrieval of activity within various scopes: farm, wiki, space.
Short-term: Use this component as a datasource for the notification module (watchlist).
Long-term: Use this component as a datasource for the statistics module.

Prerequisities

Additions to org.xwiki.observation.event.Event

Event getParent()
Date getDate()
Source getSource()
Data getData()

Creation of:

  • org.xwiki.observation.event.EventCriteria (Used by EventListeners to registers to events)

Addition to AbstractDocumentEvent:
public abstract class AbstractDocumentEvent implements Event, Serializable

Only one notify method:
org.xwiki.observation.internal#DefaultObservationManager#notify(Event event)

DocumentUpdateEventCriteria criteria = new DocumentUpdateEventCriteria();
criteria.setSpaceFilter(new ExactStringFilter("Main"));
criteria.setCreationDateFilter(new DateBeforeFilter("200801010000"));

Architecture proposal

  • xwiki-event/
    • xwiki-event-observation/
      • xwiki-event-observation-local/

      • xwiki-event-observation-remote/
    • xwiki-event-persistence/
      • internal/
        • PersistenceCapableEvent.java (Flattened version of Event)
        • PersistenceEventListener.java (implements org.xwiki.observation.EventListener)
        • DefaultEventPersistenceConfiguration.java (stores all events defined by the configuration)
        • DefaultEventStore.java (short term: implementation in a plugin or xwiki-core, bridge between 1.0 and 2.0 configuration)
      • EventPersistenceConfiguration.java (configure which events the listener must listen to)
      • EventStore.java
        • void addEvent(Event)
        • void removeEvent(Event)
        • List<Event> getEvents(EventCriteria)
/**
 * All Event types must implement this interface.
 */

public interface Event
{    
   Event getParent();
   
   Date getDate();
   
   Object getSource();
   
   Object getData();
   
   String getUser();
   
   String getWiki();
   
   String getSpace();
   
   String getPage();
}

Storage

PersistenceCapableEvent

Notes:

  • EventStore implementation must implement a storage queue and process it with another thread (see statistics implementation).
  • EventStore must rely on xwiki-query to retrieve events from the database (if possible).
String getId()
String getParent()
Date getDate()
String getType() /* Example: org.xwiki.observation.event.DocumentSaveEvent */
String getSource()
String getUser()
String getWiki()
String getSpace()
String getPage()
String getData()

activity.hbm.xml

<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

<hibernate-mapping>
<class name="org.xwiki.activity.internal.DefaultActivityEvent" table="activityevent">
 <id name="id" type="string" unsaved-value="undefined">
   <column name="id" length="255" not-null="true" />
   <generator class="assigned" />
 </id>
 <property name="date" type="timestamp">
   <column name="date" />
 </property>
 <property name="type" type="string">
   <column name="type" length="255" />
 </property>
 <property name="user" type="string">
   <column name="user" length="255" />
 </property>
 <property name="wiki" type="string">
   <column name="wiki" length="255" />
 </property>
 <property name="space" type="string">
   <column name="space" length="255" />
 </property>
 <property name="page" type="string">
   <column name="page" length="255" />
 </property>
 <property name="string1" type="string">
   <column name="string1" length="255" />
 </property>
 <property name="string2" type="string">
   <column name="string2" length="255" />
 </property>
 <property name="string3" type="string">
   <column name="string3" length="255" />
 </property>
  [.. 10 strings]
 <property name="text1" type="string">
   <column name="text1" length="60000" />
 </property>
 <property name="text2" type="string">
   <column name="text2" length="60000" />
 </property>
 <property name="date1" type="timestamp">
   <column name="date1" not-null="true"/>
 </property>
 <property name="date2" type="timestamp">
   <column name="date2" not-null="true"/>
 </property>
 <property name="number1" type="double">
   <column name="number1" />
 </property>
 <property name="number2" type="double">
   <column name="number2" />
 </property>
</class>
</hibernate-mapping>
 

Questions

  • Is it acceptable to lose the activity stream on a XAR export ?
  • Do we delete activity events when a document is deleted ?

 

Tags:
Created by Jean-Vincent Drean on 2013/11/13 15:58
    

Get Connected