archimatetool / archi

Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
MIT License
952 stars 268 forks source link

HTML Report error when there are Properties #981

Open Phillipus opened 11 months ago

Phillipus commented 11 months ago

If an element has a Property with key "abc" ~but no value~ the following is written to the console:

context [/modelreport /expandFolder /_sub1 /expandFolder /_sub2 /classesFromProperties /_sub3] 1:25 no such template: /IGNORE_ERROR_abc

AFAICS it's related to these lines:

https://github.com/archimatetool/archi/blob/ee3e1fe4d4c706c4be98fb999308b467cec08836/com.archimatetool.reports/templates/st/modelreport.stg#L23-L30

I'm not sure what's going on there. @jbsarrodie Is this something you can help with?

jbsarrodie commented 11 months ago

If an element has a Property with key "abc" but no value the following is written to the console:

In fact it does show the message even if the property has a value.

The reason is that, in order to hide some elements or folders, I have to check if a known property (_hide_from_export_) has a known value (yes in this case). By design, StringTemplate does not allow such tests, so I had to find a workaround. This workaround is to call a template function (i.e. a subtemplate) whose name is based on the property's name.

Of course, the drawback is that we'll call these "dynamic" functions for each properties, and for 99% of them there is no function defined, and this raises the error message.

The first option I see to solve this would be to implement a custom error listener for run-time errors, and to filter these messages based on the IGNORE_ERRORtext.

Another potential way to solve this (but that's a hack), would be to define a custom renderer for com.archimatetool.model.Property class that would accept a format that would encode property's key & value, and would return a non empty string only if the property matches the criterias. We could then use StringTemplate conditional expression such as:

classesFromProperties(object) ::= << 
 ^object.Properties:{p | ^if(p;format="_hide_from_export_::true")^
      hide-true
   ^endif^
}^
 >> 

This needs some investigations...

Phillipus commented 11 months ago

In fact it does show the message even if the property has a value.

Yes, my bad.

This needs some investigations...

As long as the report renders OK, should not be a hurry.