ObeoNetwork / M2Doc

The M2Doc technology enables the generation of Office Open XML documents from models.
http://obeonetwork.github.io/M2Doc/
Eclipse Public License 2.0
38 stars 22 forks source link

Cant pass Void or similar as variable to M2DocUtils.generate #475

Open jmauersberger opened 1 year ago

jmauersberger commented 1 year ago

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report  
[x] Feature request
[ ] Documentation issue or request
[x] Support request => Please have a look to the support pages of our website : http://m2doc.org/support/

Current behavior

I can pass a map of variable -> value to the generate method, all works nice, I can pass single EMF objects, plain text and EMF collections. However, I can't pass null to express "Void" or "unset" (see also See also https://forum.mbse-capella.org/t/m2doc-how-to-use-optional-template-variables/4555/6)

Expected behavior

I would like to pass OclVoid or Null or any other value so that any AQL expression is not broken but evaluates to nothing.

Minimal reproduction of the problem with instructions

What is the motivation / use case for changing the behavior?

We use the m2doc API programatically, so variable definition and value assignment is on our end. We cant distinguish between "not set" and "empty" at the moment.

Environment


M2Doc version: 3.2.0
Eclipse version: 4.X
Platform version:  Windows  X.Y.Z

Others:

ylussaud commented 12 months ago

Did you try org.eclipse.acceleo.query.runtime.impl.Nothing:

variables.put("myVariable", new Nothing("..."))
jmauersberger commented 11 months ago

Let me try ...

jmauersberger commented 11 months ago

@ylussaud if I do that it improves a bit, anyway, I still get warnings that there is actually no service on that Object type available, so it does not work as in OCL where I can just execute any Collection operation also on OclVoid, right?

ylussaud commented 2 weeks ago

I think this issue might be fixed with AQL 8.x by doing something like:

variables.put("myVariable", new NullValue(types))

Where types is a Set of IType. This allows AQL to keep track of types for null values and prevent service lookup failures.

There is an experimental build of M2Doc with AQL 8.x, the update site is here. Note that this update site should be used for testing only.

Let me know if this helps with your issue.