archi icon indicating copy to clipboard operation
archi copied to clipboard

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

Open sawanar opened this issue 3 years ago • 9 comments

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.

sawanar avatar Jan 25 '22 22:01 sawanar

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.

Phillipus avatar Jan 25 '22 22:01 Phillipus

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

sawanar avatar Jan 26 '22 07:01 sawanar

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

@jbsarrodie Can you see the problem here?

Phillipus avatar Jan 26 '22 10:01 Phillipus

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 avatar Jan 26 '22 10:01 jbsarrodie

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 avatar Jan 26 '22 10:01 jbsarrodie

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

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

jbsarrodie avatar Jan 26 '22 10:01 jbsarrodie

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.

jbsarrodie avatar Jan 26 '22 10:01 jbsarrodie

OK for a patch, thanks for looking at this.

Phillipus avatar Jan 26 '22 10:01 Phillipus

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.

olwol avatar Jan 26 '22 13:01 olwol