RavenDb: OnBeforeStore / OnAfterSaveChanges not firing when perfoming Patch or Add Attachment - ravendb

I want to make sure that every time I make a change to a document, a certain action is performed. For this I wanted to use OnBeforeStore or OnAfterSaveChanges.
Unfortunately, these two events are not triggered when I save a change via patch or add/delete an attachment.
We use the CQRS pattern and have several commands making changes to entities / collections. I need a central place to execute every change to a particular collection, no matter which command is used.
Is there such a thing in RavenDB?

There is no "central place" that track every change to collection.
About the OnAfterSaveChanges event, it should fire on those actions too.
https://issues.hibernatingrhinos.com/issue/RavenDB-13906

Related

Listing current Ignite jobs and cancelling them

I got a partial answer here but not exactly what I wanted.
The link describes how to get a list of task futures but what I'd really like to be able to do is list out and cancel individual jobs (that might be hung, long running etc etc). I've seen another post implying that this is not possible but I'd like to confirm (see second link)
Thanks
http://apache-ignite-users.70518.x6.nabble.com/How-can-I-obtain-a-list-of-executing-jobs-on-an-ignite-node-td8841.html
http://apache-ignite-users.70518.x6.nabble.com/Cancel-tasks-on-Ignite-compute-grid-worker-nodes-td5027.html
Yes, this is not possible and actually I'm not sure how this can be done in general case. Imagine there are 5 jobs running and you want to cancel one of them. How are you going to identify it? It seems to be very use case specific to me.
However, you can always implement your own mechanism to do this. One of the possible ways is to use ComputeTaskSession API and task attributes. E.g., set a special attribute that will act as signal for job cancellation and create attribute listener that will stop job execution accordingly.

Scintilla 'Before change' notification

I need to do certain processing when a Scintilla editor first becomes 'dirty' before the document actually changes.
The SCN_SAVEPOINTLEFT notification seems like the obvious candidate, but unfortunately this is fired after the change that made the document dirty has occurred.
Looking through the other available notifications, SCN_MODIFIED also is fired after the change has happened (and the same is true of SCEN_CHANGE of course).
The best I can think of is to start macro recording in response to SCN_SAVEPOINTREACHED (i.e. when the document is saved or all changes are undone). Then when I detect the first change with SCN_MODIFIED, I stop recording, undo all changes until I get back to the save point, perform my custom processing (which happens to be modifying a date field in the document), then replay the recorded macros to restore the undone changes.
This seems horribly convoluted. Is there an easier way? (Maybe it would be simpler to create my own custom version of Scintilla with a SCN_BEFORECHANGE notification, but I'd prefer to avoid creating a fork. And a cursory glance through the source suggests that there are a great many points from where this notification would have to be sent, making it easy to miss some.)
Update: The real requirement was that when the user executes 'Undo' after first modifying the document, the 'automatic' edit and the user's first edit are not in the wrong order in the undo buffer. The simplest solution turned out to be, not to force the automatic update to be first, but to coalesce these two actions into a single undo action using SCI_BEGINUNDOACTION/SCI_ENDUNDOACTION. See my comment below on how I did this.
The SCN_MODIFIED notification does seem to fit your spec. The modificationType field provides information about what has been done, including:
SC_MOD_BEFOREINSERT 0x400 Text is about to be inserted into the document.
SC_MOD_BEFOREDELETE 0x800 Text is about to be deleted from the document.

Can I associate a change set with a work item after it has been delivered?

If I deliver a change set to a stream and not associate it with a work item can the change set be associated with a work item after it has been delivered ?
Yes.
The changeset itself is closed upon delivery to the stream.
But its associated work-item(s) is not: you can add or remove one or several work-items in association with the delivered changeset.
That being said, I have a special hook which makes that association mandatory on deliver: ie, you cannot deliver without having first associated your change set first to a Work Item.
I am not sure if that hook is a custom one for my organization, but here is where you can check if it is there:
It is in the Project Area administration, under
Team Configuration /
Operation Behavior /
Source Control /
Deliver (client) /
Preconditions and follow-up actions are configured for this operation /
Require Work Items and comments

Track changes in a Java source

I want to track changes in a java source file in my eclipse plugin to update some references I keep of methods/variables/types if they are renamed.
I am interested in the IJavaElement before it was changed and how it is after the change.
I found
JavaCore.addElementChangedListener(/**/, ElementChangedEvent.POST_RECONCILE);
to obtain notifications of changes. The JavaElementDelta that the listener-event provide enables me to get the IJavaElement. Unfortunately, the notifications are difficult to handle.
For instance, if the user renames a method and pauses for a fraction of a second an event is fired and once the user finish typing the new name a further event is fired. That makes it necessary to track all those (incomplete) changes. That is cumbersome.
Is there a better way to obtain the before-after name an IJavaElement in a source file?

What Rest API definition to use when moving items between collections

I am building a REST/JSON based service which has in it's API a couple of collections that contain items. All these items are of the same type.
As an example: The service much resembles a TODO list with collections for items that still need to be done, are in the progress of being completed and are finished.
The API would be something like
/todo/new
/todo/inprogress
/todo/finished
So how would one define an instruction to move an item from the /todo/new to the /todo/inprogress ?
Basically both collections are as much responsible to perform the move. Should one of them be responsible? or should I make another API called /todo/item which will receive the move instruction?
Ideally you would use the PATCH method to modify a single item.
PATCH /todos/:id?status=finished
However PATCH is infrequently used and server/client support isn't always present. You may wish to use PUT instead.