Found the kind of an objet.

Started by TNT44, April 30, 2023, 15:40:32 PM

Previous topic - Next topic

TNT44

Hi,

I wish found the kind of an object ..

For example, know if it's a [Visual Object / Visual Connections] or an [elements / relationships / folder]

Know if it's a "relationhip" , an "element", a "folder" or anything else.

When I m looking for the type of an objet
It's the same in View[Visual Object / Visual Connections]  and Elements/Relationships .

Thanks.



Phil Beauvoir

#1
Hi,

you can determine the type from object.type and, if it's a concept, determine if the object is part of a view (diagram).

For example:

function getType(object) {
    // If the object has an ArchiMate concept and is in a View then it's a visual object/connection
    if(object.concept && object.view) {
        return object.concept.type.includes("relationship") ? "view-connection" : "view-object";
    }

    // Else return the concept type if it is has a concept, or the object type
    return object.concept ? object.concept.type : object.type;
}
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.

TNT44

Thank for the script ..

One more question every object contains a "concept" ?

my example,

id =id-173630a418fa4192a111dd3ece1a1de4 nom =AA type =application-component gettype =view-object
 concept --> id =id-c2886f837bab4250b9b1b4e1a44b87e0 nom =AA type =application-component gettype =application-component
sub concept id =id-c2886f837bab4250b9b1b4e1a44b87e0 nom =AA type =application-component gettype =application-component

id =id-e552ce5694b343eab378c9cda87e8d65 nom =R1 type =flow-relationship gettype =view-connection
 concept --> id =id-32795bf1f0c840bf81f9eb485af4e299 nom =R1 type =flow-relationship gettype =flow-relationship
sub concept id =id-32795bf1f0c840bf81f9eb485af4e299 nom =R1 type =flow-relationship gettype =flow-relationship

As you can see "concept" equals "sub concept".

Phil Beauvoir

#3
> One more question every object contains a "concept" ?

Only ArchiMate elements and relationships, in the Models Tree and as objects/connections in a View.

The "concept" returned from "object.concept" is the element or relationship. Once you have that you can get its name, type, properties, etc.

The concept's concept is itself. So you could do "object.concept.concept" and it would be the same concept.
If you value and use Archi, please consider making a donation!
Ask your ArchiMate related questions to the ArchiMate Community's Discussion Board.