Synchronization is handled by processors which are responsible for creating the messages sent to a destination instance, and processing incoming messages. 

What's a processor

A processor is a groovy based script which can be used to implement filtering, mapping, and transformation. These are essential operations in any synchronization.

Groovy is a dynamic language for the Java platform. Check out the following links to get more details about Groovy and how to develop in this language:

 

Processor types

There are 4 different processor types in the synchronization process. Every processor has its own purpose. 

Data filter

The data filter processor prepares a replica which is sent to the remote instance.

InputissueThe issue you need to synchronize.
OutputreplicaThe replica which will be sent to the remote instance.

 

A simple Data filter example

#
# Send the summary, description, comments and attachments to the remote instance by setting certain fields of the replica object
#
 
replica.summary     = issue.summary
replica.description = issue.description
replica.comments    = issue.comments
replica.attachments = issue.attachments

When the resulting replica is empty, then nothing is synchronized. Check the Unidirectional synchronization for more details.

You can set conditions in Data Filter as below: 

Condition example: Don't send anything when priority is trivial

#
# Send the summary, description, comments and attachments to the remote instance by setting the different fields of the replica object - unless it's a trivial issue.
#
 
if (issue.priority.name = "Trivial") {
	return
}
replica.summary     = issue.summary
replica.description = issue.description 
replica.comments    = issue.comments
replica.attachments = issue.attachments
 


Create processor

The create processor is executed only with the first synchronization request of an issue from the remote instance. Using the create processor, you must define the target project, issuetype, and summary.

Define the fields, you would like to receive from the remote side. You can also set your own values for any local issue field.

InputreplicaThe information sent from the originating instance.
OutputissueAn issue object which will be used to create the local issue.

 

A simple Create processor example

#
#  Set up the issue object so that an appropriate replica can be created
#
 
issue.projectKey = "ACME"
issue.typeName   = "Task"
issue.summary    = replica.summary

If you don't specify the issue reporter in the create processor, the proxy user will be set as default reporter.

You can use script helpers in order to configure advanced conditions for your synchronization.

More advanced example

#
# 	Create a request in the support project, but if it's a critical issue in the customer's WEB project, assign it to Kevin Spacey, as he needs to ensure
#   smooth commmunication.
#
 
 
issue.project = nodeHelper.getProject("ACME")

if (replica.priority.name = "Critical" && replica.project.key = "WEB") {
 	issue.assignee = nodeHelper.getUser("kspacey") // assign to Kevin
	issue.priority = nodeHelper.getPriority("Blocker")
} else {
	issue.priority = nodeHelper.getPriority("Major")
}
 
issue.summary = replica.summary
issue.projectKey = "SUPPORT"
issue.typeName = "Request"

#
#  Set up the issue object such that an appropriate local issue can be created 
#
 
issue.summary = replica.summary
issue.projectKey = "ACME"
issue.typeName = "Task"
 


Change processor

The change processor is executed when an incoming synchronization request is received for an already synced issue.
 

InputreplicaThe current information sent from the originating instance.
 previousThe previous information sent from the originating instance.
OutputissueAn issue object which will be used to update the local node issue.

 

A simple example of the synced issues update

#
# Update the local issue with the data received from the remote side:
# If the remote issue's summary, description, comment or attachment is updated, local issue will be updated as well.
#
 
issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue,replica)
issue.attachments  = commentHelper.mergeAttachments(issue,replica)


The default configuration

By default, Exalate configures some basic scripts in the Sync Rules for your convenience.

Below is the default configuration of the Data Filter, Create Processor and Change Processor. It helps to synchronize an issue fields such as: assignee, reporter, summary, description, comments, resolution, status, attachments and project.

Data filter

Send default data to the remote instance.

Default Data filter scripts

replica.key            = issue.key
replica.assignee       = issue.assignee 
replica.reporter       = issue.reporter
replica.summary        = issue.summary
replica.description    = issue.description
replica.comments       = issue.comments
replica.resolution     = issue.resolution
replica.status         = issue.status
replica.attachments    = issue.attachments
replica.project        = issue.project 


Create processor

When the first synchronization request of an issue from the remote instance is received, create the issue in project TEST, issue type Task. Copy received summary, description, comments, and attachments.

Default Create Processor

issue.projectKey   = "TEST"
issue.typeName     = "Task"
issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue, replica)
issue.attachments  = attachmentHelper.mergeAttachments(issue, replica)

Change processor

Update local issue summary, description, add new comments and attachments and delete removed ones.

Default Change processor

issue.summary      = replica.summary
issue.description  = replica.description
issue.comments     = commentHelper.mergeComments(issue,replica)
issue.attachments  = commentHelper.mergeAttachments(issue,replica)