Labels using if and nvl

Started by nfigay, September 05, 2021, 23:12:22 PM

Previous topic - Next topic

nfigay

Hello,
I'm looking exemples for usage of if and nvl as mentioned for Archi 4.9.
Available somewhere?
BR
Nicolas

Phil Beauvoir

#1
Hi Nicolas,

I updated the wiki with some information on this - https://github.com/archimatetool/archi/wiki/Label-Expressions

This is something that JB very cleverly implemented. A good use case is to display an object's specialization name surrounded by angle brackets if it has one, else display nothing:

${if:${specialization}:<<${specialization}>>}

Regards,

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

nfigay

#2
Thank you very much, Phil.
It is effectively a very useful features, thanks to Jean Sebastien Baptiste for having implemented it :)

rchevallier

#3
Very interesting and useful indeed

However because 4.9 incompatibility with coArchi conflicts (as far I understood), we may have a longer time before adopting 4.9 (waiting then for coArchi v2)
Would it be possible to mark the 4.9 new features in the documentation with a tag or notice (eg: "@since 4.9") ?

Phil Beauvoir

Quote from: rchevallier on September 08, 2021, 13:28:50 PM
Very interesting and useful indeed

However because 4.9 incompatibility with coArchi conflicts (as far I understood), we may have a longer time before adopting 4.9 (waiting then for coArchi v2)
Would it be possible to mark the 4.9 new features in the documentation with a tag or notice (eg: "@since 4.9") ?

Yes, I've added "(Since 4.9)" for the three new label expressions in the wiki.

Archi 4.9 will still work with coArchi, but you won't be able to see the difference when merging if Specializations are used.

(I accidentally edited your message instead of quoting it. I've put it back to how it was  :D)
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

rchevallier

Thanks Phil et again great product !

kimh

Using Archi 4.8.1
I have tried for a while to use there 'if' expression but had no luck. The wiki defines a 'condition' but unsure of its syntax.
I have the following label:

${name}
${property:legacy}
${if: ${property:legacy}: (legacy)}

I want to display '(legacy)' if this property is set to 'true', otherwise it is missing. Or could be set to false.

With the above I get the following displayed:

Parts Service
true
${if: true: (legacy)}

Note the second line is only there to debug the value of the property. What I want is:

Parts Service
  (legacy)

Unclear if the syntax is correct, and then it would be good to test for property:legacy = false.

Thanks
Kim



Phil Beauvoir

#7
Hi Kim,

the "if" expression is implemented in Archi 4.9 which is in beta at the moment.

The wiki does mention "Since 4.9" for this expression.

The condition is not true/false but whether the evaluated expression is an empty string or not.

Regards,

Phil
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Alberto

QuoteThe condition is not true/false but whether the evaluated expression is an empty string or not.

I'm no programmer or philosopher, but wouldn't then "ifEmpty" or "isEmpty" be a more appropriate term for this function? 

At least it would be consistent with other languages that do have different functions for evaluating for empty/undefined/null vs logic. 

Phil Beauvoir

Quote from: Alberto on September 14, 2021, 14:21:20 PM
QuoteThe condition is not true/false but whether the evaluated expression is an empty string or not.

I'm no programmer or philosopher, but wouldn't then "ifEmpty" or "isEmpty" be a more appropriate term for this function? 

At least it would be consistent with other languages that do have different functions for evaluating for empty/undefined/null vs logic.

It would have to be "ifNotEmpty", but that seems rather long-winded.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Jumping in...

Quote from: Phil Beauvoir on September 14, 2021, 14:38:14 PM
It would have to be "ifNotEmpty", but that seems rather long-winded.

Yes, that's the main reason.

Quote from: Phil Beauvoir on September 13, 2021, 22:33:39 PM
The condition is not true/false but whether the evaluated expression is an empty string or not.

It shouldn't be complicated to also make it consider "0" and "false" as false value. BTW, that's how StringTemplate works (primarily based on string being null/empty, but for the same reasons decided to also accept 0/false). In such case a string with only spaces should also be seen as empty.

@Phil: I can submit a patch if you want.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

> @Phil: I can submit a patch if you want.

OK, but I think it would be easy to check for 0 and "false" so I might look at it. But...doesn't this negate the true meaning of "empty value"? Suppose someone sets 0 or false and wants the existing behaviour?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Quote from: Phil Beauvoir on September 14, 2021, 14:56:03 PM
But...doesn't this negate the true meaning of "empty value"? Suppose someone sets 0 or false and wants the existing behaviour?

Well, until we publish Archi 4.9, there's no "existing behavior" :-)

TBH, while first thinking about this "if" expression, I thought it would be useful to also check for 0/false but simply didn't implement it.

I don't see much real life use-cases where someone would have "0" or "false" value somewhere and really want to know if this is empty or not (and "nvl" might still be helpful in this context). But I do see real life use-cases where someone has some "boolean" properties and want to adjust the label based on them.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Phil Beauvoir

Quote from: Jean-Baptiste Sarrodie on September 14, 2021, 16:07:43 PM
But I do see real life use-cases where someone has some "boolean" properties and want to adjust the label based on them.


Then they could leave the property blank?
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

Jean-Baptiste Sarrodie

Hi,

Quote from: Phil Beauvoir on September 14, 2021, 16:12:04 PM
Then they could leave the property blank?

That's not user friendly. For example, if I have a "Is Critical?" property on Application Components, then when publishing my model in HTML so that non architects can have access to it, seing such property name with no value is not an option as people expect to read yes/no or true/false.

Regards,

JB
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.