archimatetool / archi

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

Label ${properties:separator:key} in ${if:condition:display_value1:display_value2} shows unexpected results #805

Open sawanar opened 2 years ago

sawanar commented 2 years ago

Version of Archi

4.9.2

Archi Plug-ins

none

Operating System

Win 10

Expected Behaviour

In the below explanation I would expect with the not connected Note in row 4 the same result as in row 3. Or did I misunderstood something?

Actual Behaviour

In a Note Label this is entered:

  1. "$connection:target{property:REMARK}"
  2. "$connection:target{properties: --- :REMARK}"
  3. "${if:$connection:target{property:REMARK}:('REMARK' properties found):(no 'REMARK' properties found)}"
  4. "${if:$connection:target{property:REMARK}:$connection:target{properties: --- :REMARK}:(no 'REMARK' properties found)}"

The Note is not connected and shows following result, here row 4 is strange for me:

  1. ""
  2. "$connection:target{properties: --- :REMARK}"
  3. "(no 'REMARK' properties found)"
  4. "${if::$connection:target{properties: --- :REMARK}:(no 'REMARK' properties found)}"

When I connect this Note to an object with two 'REMARK' properties following is shown and what I expected:

  1. "1. value of 'REMARK' property."
  2. "1. value of 'REMARK' property. --- 2. value of 'REMARK' property."
  3. "('REMARK' properties found)"
  4. "1. value of 'REMARK' property. --- 2. value of 'REMARK' property."

Thanks and kind regards.

Phillipus commented 2 years ago

Can you please attach a simple model that demonstrates this problem with simple instructions on what to expect. I'm having difficulty understanding your problem. Maybe if you reduced it to a simple case it would help.

sawanar commented 2 years ago

Good morning, please find attached a model with just this issue. Also a screenshot as it looks on my screen. Thanks for your help.

Issue 805 Example Screenshot

Issue 805 Example.archimate.zip

Phillipus commented 2 years ago

Seems to be do with the : character and escaping them.

@jbsarrodie Can you see the problem here?

jbsarrodie commented 2 years ago

Hi,

This is due to some discrepencies in the way ${property} and ${properties} work. In the first case, it renders to an empty string if there's no connection, in the second one, it doesn't render at all (and left you with the label expression unchanged).

I'm investigating to find the root cause of this...

jbsarrodie commented 2 years ago

I'm investigating to find the root cause of this...

Done ;-)

In PropertiesRenderer.java, text.replace is called outside of the refObject instanceof IProperties check for property, but inside for properties.

@Phillipus for the sake of consistency, I'd suggest to alway have text.replace inside, this would make it clear that the expression has not been evaluated because the prefix was invalid. If you're ok I can commit a (really small) patch.

jbsarrodie commented 2 years ago

Seems to be do with the : character and escaping them.

That's what I first though, but no :-)

jbsarrodie commented 2 years ago

Seems to be do with the : character and escaping them.

That's what I first though, but no :-)

But, if I submit a patch, I can also use this opportunity to refactor a bit the regexp for $prefix{properties:separator:propname} so that colon can be escaped and used as part of the separator.

Phillipus commented 2 years ago

OK for a patch, thanks for looking at this.

olwol commented 2 years ago

Hi, will it fix the following as well?

Label expression is recursive to some extent

I can share a model to show it. If you want me to do this, please tell me, how I can upload the model file.