Any server side changes have to be registered with LCDS to get sent out to the clients. So in this case a simple call to DataServiceTransaction.updateItem() is needed, after your database commit is completed on the server.
So as the updateItem() method requires an String of the names of the properties changed for that update, do I need to pass over all changed properties (those changed on the client plus those changed on the server) or it enough to just propagate the one property (version) that has been changed in the persistence layer?
// this is the update Method which is called by the Assembler
// changes is the List of changed properties as provided by the Assembler
public T updateItem(T newVersion, T previousVersion, List<String> changes)
// merge the entity
newVersion = entityManager.merge(newVersion);
// after this merge / flush the version value will be increased and un-synced with the LCDS object state
DataServiceTransaction tx = DataServiceTransaction.getCurrentDataServiceTransaction();
// is this enough? Or do I need to add all properties (including those from the changes List?)
String properties = new String;
properties = "version";
String destination = newVersion.getClass().getSimpleName();
tx.updateItem(destination, newVersion, previousVersion, properties);
You want to send *all* the changed properties: those coming from the client and any additional properties that were changed on the server. Also, send the latest version of the object, as it looks like you have.
This capability propagates all changes to all listening clients, in addition to flagging any potential conflicts on the generating client when the acknowledge message is sent back.
It is described in JavaDoc here:
“Your updateItem method can modify changes sent in from the client and add additional properties. To do this you update properties in the newVersion and add additional property names to the changes property.”