Hi,
I don't know if this is intended but I am having problems when a mapping that contains a context calls another mapping passing a new context. For example, if a have the classes A, B, M and N:
class A {
List<B> b
}
class B {
String text
}
class M {
String before
String after
List<N> n
}
class N {
String text
}
And the mappings:
A2M.groovy
mappingFor a: A, b: M
b.before = { before }
a.b = b.n
convert to_a: { n -> mapper.map(n, B, new MapContext([anything: "AAA"])) },
to_b: { b -> mapper.map(b, N, new MapContext([anything: "BBB"])) }
b.after = { after }
B2N.groovy
mappingFor a: B, b: N
a.text = { b.text + anything}
the
executes successfully but the line
will throw a NominException telling that the property 'after' isn't defined, because when
mapper.map(b, N, new MapContext([anything: "BBB"]))
is executed, it cleans the context for the A2M.groovy ( the new context is set before calling the B2N mapping, but resets to EmptyContext before returning, through the contextManager.restoreShared() call)
My question is: Is this the intended behavior? Is there a way to restore the previous context after calling the method Nomin::map(source, targetClass, context) inside another mapping?