Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

"AND" logic for expressions #355

Closed
ghost opened this issue Oct 19, 2023 · 3 comments
Closed

"AND" logic for expressions #355

ghost opened this issue Oct 19, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@ghost
Copy link

ghost commented Oct 19, 2023

Description

This follows on from #348, I believe the feature I'm requesting will solve their problem as well as mine. In my case I have a container representing a DB with components representing tables, and in a separate container there are several different components that interact with particular tables. I wish there was a simple way to express "include all components with direct relationships to the components within this container".

My use case is that I'm trying to model some legacy software that is really poorly organised so we can assess and plan our upgrades. The example in the cookbook that was mentioned in #348 as a solution has two major drawbacks for me:

  1. I can use include element.parent==Container2 but then I have many additional components included that do not interact with this particular DB (like I said, it's legacy software), too many to manually list and exclude.
  2. I can use include component1 component2 component3 ... but this requires me to keep careful track of exactly which components are interacting with the DB and list them manually, which is not very convenient but the better of the two approaches.
  3. There is also potentially a third way of doing it by tagging the specific components that interact with the DB, but this is not really any better than option 2 above so I haven't even tried it.

Being able to use an "AND" statement between "include" expressions would be very powerful and solve this problem with a straightforward expression like the following:

views {
    component DBcontainer {
        include ->(element.parent==DBcontainer)-> AND element.type==Component
    }
}

Such that only elements that satisfy both expressions are included. The way it currently works (where you just leave a space between each expression) is effectively like having "OR" between each expression.

Priority

Low

Resolution

I have no budget and there's no rush, please add this feature for free

More information

No response

@ghost ghost added the enhancement New feature or request label Oct 19, 2023
@ghost
Copy link
Author

ghost commented Oct 19, 2023

Funny how I spent half an hour writing this, but it only took 10 minutes of going over the source code to realise this feature already exists, it just has to be in quote marks and use && instead of AND:

views {
    component DBcontainer {
        include "->element.parent==DBcontainer-> && element.type==Component"
    }
}

This feature should definitely be explained more clearly in the language reference, the cookbook, and elsewhere in the documentation

@ghost ghost closed this as completed Oct 19, 2023
@shahabganji
Copy link

For Containers, it works if:

container CONTAINER_NAME "DIAGRAM_KEY" "DIAGRAM_DESCRIPTION" {
    include "->element.parent==CONTAINER_NAME-> && element.type==container"
}

@ghost
Copy link
Author

ghost commented Oct 19, 2023

Good spot @shahabganji! Just a typo on my part, the parentheses don't work and shouldn't have been there, I've edited my comment to avoid confusion.

This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant