Events listeners
In this section, we will explain how to work with Projectrak event listeners.
For the moment, these are the events you can listen:
We will provide more event listeners in the future. If you have any suggestions, contact us or let us know in the comments.
How to use Projectrak event listeners
We have built Projectrak event listeners with a similar structure as Jira ones. So, if you are familiar with Jira listeners, you will find Projectrak's listeners really easy to use.
You can extend from 2 different abstract classes to develop your own Projectrak event listeners:
ProjectrakListener
package com.deiser.jira.profields.event.listener; import com.atlassian.crowd.embedded.api.Group; import com.atlassian.event.api.EventPublisher; import com.atlassian.jira.project.Project; import com.atlassian.jira.user.ApplicationUser; import com.deiser.jira.profields.api.event.model.ValueUpdatedEvent; import com.deiser.jira.profields.api.event.model.ProfieldsEvent; import com.deiser.jira.profields.api.event.listener.ProfieldsListener; import com.deiser.jira.profields.api.field.Field; import com.deiser.jira.profields.api.field.item.list.ListItem; import com.deiser.jira.profields.api.field.item.priority.PriorityItem; import com.deiser.jira.profields.api.field.item.status.StatusItem; import org.apache.log4j.Logger; import java.math.BigDecimal; import java.util.Date; import java.util.List; public class DefaultProfieldsListener extends ProfieldsListener { private static final Logger log = Logger.getLogger(DefaultProfieldsListener.class); private EventPublisher eventPublisher; public DefaultProfieldsListener(EventPublisher eventPublisher) { this.eventPublisher = eventPublisher; } @Override public void afterPropertiesSet() throws Exception { eventPublisher.register(this); } @Override public void destroy() throws Exception { eventPublisher.unregister(this); } @Override protected void onProfieldsEvent(ProfieldsEvent profieldsEvent) { log.debug("DefaultProfieldsListener - profieldsEvent"); } @Override protected void onValueUpdated(ApplicationUser user, Project project, Field field, Object oldValue, Object newValue) { log.debug("DefaultProfieldsListener - onValueUpdated"); } }
ProjectrakAutoRegListener
This event listener is registered on the Jira Event Publisher by default.
Remember that you have to init your listener class to be able to be notified by Projectrak events. You can do it by registering your component to the App descriptor or just creating an instance of your class.
package com.deiser.jira.profields.event.listener; import com.atlassian.crowd.embedded.api.Group; import com.atlassian.event.api.EventPublisher; import com.atlassian.jira.project.Project; import com.atlassian.jira.user.ApplicationUser; import com.deiser.jira.profields.api.event.listener.ProfieldsAutoRegListener; import com.deiser.jira.profields.api.event.model.ProfieldsEvent; import com.deiser.jira.profields.api.field.Field; import com.deiser.jira.profields.api.field.item.list.ListItem; import com.deiser.jira.profields.api.field.item.priority.PriorityItem; import com.deiser.jira.profields.api.field.item.status.StatusItem; import org.apache.log4j.Logger; import java.math.BigDecimal; import java.util.Date; import java.util.List; public class DefaultProfieldsAutoRegListener extends ProfieldsAutoRegListener { private static final Logger log = Logger.getLogger(DefaultProfieldsAutoRegListener.class); public DefaultProfieldsAutoRegListener(EventPublisher eventPublisher) { super(eventPublisher); } @Override protected void onProfieldsEvent(ProfieldsEvent profieldsEvent) { log.debug("DefaultProfieldsAutoRegListener - profieldsEvent"); } @Override protected void onValueUpdated(ApplicationUser user, Project project, Field field, Object oldValue, Object newValue) { log.debug("DefaultProfieldsAutoRegListener - onValueUpdated"); } }