link-move icon indicating copy to clipboard operation
link-move copied to clipboard

feature request: map the value of a target attribute to presence (or absence) of the matching record in the source

Open rzen opened this issue 8 years ago • 5 comments

this would effectively remove the need for a listener-enhanced delete task for a large portion of our use cases where all we want is to set a "delete" flag when source record became unavailable (deleted).

rzen avatar Apr 26 '17 21:04 rzen

Actually this does not remove the need for a listener, because you'd still need to rollback Cayenne changes by hand in order to prevent the deletion of records.

atomashpolskiy avatar Apr 27 '17 09:04 atomashpolskiy

I guess that depends on how this is implemented. I haven't given that much thought yet, but theoretically this can be a special abstraction handled by LM core.

andrus avatar Apr 27 '17 09:04 andrus

To prevent deletions (and it might be useful for creates/updates as well) we could add ~~a new builder method com.nhl.link.move.runtime.task.BaseTaskBuilder.dryRun()~~ LmTask.dryRun(...) (see #125).

To provide custom value suppliers we could add something like this:

interface TargetPropertyWriter<T> {
  T mapFromSource(Map<String,Object> source);
  T onMissingSource();
}

Custom writers then could be registered via a new builder method that would receive two arguments: Cayenne property/literal property name and TargetPropertyWriter instance: <T> ... property(Property<T> p, TargetPropertyWriter<T> w) Object ... property(String p, TargetPropertyWriter<?> w)

atomashpolskiy avatar Apr 27 '17 10:04 atomashpolskiy

I am thinking more in the direction of a new task, like SoftDeleteTask or something.

andrus avatar Apr 27 '17 12:04 andrus

Gentle bump.

rzen avatar Sep 26 '17 12:09 rzen