How to config custom relationship on Automatic Event Attachment
Bretto opened this issue · 5 comments
I have
com.graphaware.module.TT.event=hasLabel("Item")
associated with
com.graphaware.module.TT.relationship=Created
is there a way to associate
com.graphaware.module.TT.event=hasLabel("Item") && hasProperty('Modified')
with
com.graphaware.module.TT.relationship=Modified
or something equivalent, I would like to keep track of the creation and modification of my items via the timetree.
Hi,
You can create two module definitions with two different logics, for e.g. in your use case :
com.graphaware.runtime.enabled=true
# Module TTCREATED for creation logic
com.graphaware.module.TTCREATED.1=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTCREATED.event=hasLabel('Feedback') && !hasProperty('Modified')
com.graphaware.module.TTCREATED.relationship=CREATED
com.graphaware.module.TTCREATED.autoAttach=true
# Module TTMODIFIED for modification logic
com.graphaware.module.TTMODIFIED.2=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTMODIFIED.event=hasLabel('Feedback') && hasProperty('Modified')
com.graphaware.module.TTMODIFIED.relationship=MODIFIED
com.graphaware.module.TTMODIFIED.autoAttach=true
Thanks for the feedback,
However,it seems that the Automatic Event Attachment pattern is only recognise on node creation.
Is there a way to get the trigger to execute for an update
ie:
match (item:Item {uid:'9d64eb20-1799-11e5-892b-58b035739566'})
set item.modified_v=1 return item
and subsequently when the 'modified_v' prop changes...
If Automatic Event Attachment is not the right tool for this job, I will just use the rest api to do the modified updates.
UPDATE
After re-reading your MATCH statement, yes indeed this will not work. Simply because the relationship already exist between the event and the instant node. You would better create a modified property holding the timestamp of the modification, then a new relationship will be created representing the modification time only if the modified timestamp does not represent the same time instant (which can occur depending of your resolution settings)
There is a look for changes during the beforeCommit
hook here : https://github.com/graphaware/neo4j-timetree/blob/master/src/main/java/com/graphaware/module/timetree/module/TimeTreeModule.java#L76
So the changes are handled, however I think I forgot to mention for your use case to use two different timestamp properties :
com.graphaware.runtime.enabled=true
# Module TTCREATED for creation logic
com.graphaware.module.TTCREATED.1=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTCREATED.event=hasLabel('Feedback') && !hasProperty('Modified')
com.graphaware.module.TTCREATED.relationship=CREATED
com.graphaware.module.TTCREATED.timestamp=created
com.graphaware.module.TTCREATED.autoAttach=true
# Module TTMODIFIED for modification logic
com.graphaware.module.TTMODIFIED.2=com.graphaware.module.timetree.module.TimeTreeModuleBootstrapper
com.graphaware.module.TTMODIFIED.event=hasLabel('Feedback') && hasProperty('Modified')
com.graphaware.module.TTMODIFIED.relationship=MODIFIED
com.graphaware.module.TTMODIFIED.timestamp=modified
com.graphaware.module.TTMODIFIED.autoAttach=true
Wow this is great, thank you for your support !
You're welcome. If it resolve your issue, please close it when confirmed. Thanks ;-)