Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML Report error when there are Properties #981

Open
Phillipus opened this issue Oct 18, 2023 · 2 comments
Open

HTML Report error when there are Properties #981

Phillipus opened this issue Oct 18, 2023 · 2 comments
Assignees

Comments

@Phillipus
Copy link
Member

Phillipus commented Oct 18, 2023

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:

classesFromProperties(object) ::= <<
^object.Properties:{p | ^(["IGNORE_ERROR_", p.Key])(p.Value)^ }^
>>
IGNORE_ERROR__hide_from_export_(value) ::= <<
hide-^value;format="lower"^
>>

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

@jbsarrodie
Copy link
Member

jbsarrodie commented Oct 18, 2023

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 Phillipus changed the title HTML Report error if Property value is empty HTML Report error when there are Properties Oct 18, 2023
@Phillipus
Copy link
Member Author

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.

@jbsarrodie jbsarrodie self-assigned this Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants