Book a Demo

Author Topic: Element.ElementID of interfaceBlock  (Read 4554 times)

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Element.ElementID of interfaceBlock
« on: December 08, 2022, 01:45:24 am »
Hello guys,

do you know if there is a way to distinguish InterfaceBlock from "normal" blocks. If I get element type of something that is an interface block and from block it's both class (interfaceBlock.Type = class also block.Type = class)?

Thanks in advance  :)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Element.ElementID of interfaceBlock
« Reply #1 on: December 08, 2022, 04:51:14 am »
Did you check the stereotype?
If that's the same, check the classifier (using the ClassifierID)

Geert

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #2 on: December 08, 2022, 07:22:12 pm »
Hey Geert,

thank you, Element.Stereotype gives info whether it's block or interface block.

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #3 on: December 16, 2022, 11:02:54 pm »
Hello guys, is there a way to see where is connection from embeddedElement (port) going to, i.e. what is client?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #4 on: December 16, 2022, 11:19:07 pm »
Via its connectors?

q.

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #5 on: December 16, 2022, 11:33:11 pm »
I tried that. I have GUID of an block, .embeddedElements gives me ports in IBD and .connectors gives me all aggregations and generalizations in BDD, but I can't get the other end (ClientID) from connectors, but it shows the port on it's own instance.

This is code I am using:
element = eaRepository.GetElementByGuid(guid) # element in BDD, block
for i in range(element.EmbeddedElements.Count):
    currentEElement = element.EmbeddedElements.GetAt(i)
    print(str(i) + " " + currentEElement.Name)
    for j in range(currentEElement.Connectors.Count):
        currentEConnector = currentEElement.Connectors.GetAt(j)
        print("    " + str(j) + " " + eaRepository.GetElementByID(currentEConnector.ClientID).Name + " " + currentEElement.PropertyTypeName)

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #6 on: December 16, 2022, 11:46:54 pm »
Depends on how you draw the connector. Try using the supplier instead. I for myself have a wrapper for connector yielding "other".

q.

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #7 on: December 17, 2022, 12:38:05 am »
That works  :) Can you please describe this wrapper?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #8 on: December 17, 2022, 01:53:12 am »
Well, I'm coding outside EA in Python. Would work with any other OO-like language, but not with that VB stuff (that's not a language but Babble; hence the B in in VB).

q.

MMiletic

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #9 on: December 17, 2022, 02:26:38 am »
Yeah, after reading your book I've also started working with Python :) So if you can please provide some draft I would be thankful

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Element.ElementID of interfaceBlock
« Reply #10 on: December 17, 2022, 03:06:38 am »
Would be a bit length to post the code. Since it's in some parts written for a customer I can not easily publish it. Maybe I find the time to share common parts on GitHub later. Anyhow, here's my wrapper (you need to create that from within a repository wrapper class whereever you return connectors. It makes use of other wrapper classes in a similar way.

Code: [Select]
class EAConnector(EAComObject):
    """ Wrapper to ease access to "opposite" elements of a connector """

    def __new__(cls, connector):
        if connector == None: return None
        instance = super(EAConnector, cls).__new__(cls)
        instance._comobj = connector
        instance._rep = Repository.Instance()
        instance._taggedValues = None
        return instance

    @property
    def taggedValues(self):
        if self._taggedValues == None:
            self._taggedValues = EATaggedValues(dummy, self._comobj.taggedValues)
        return self._taggedValues

    def other(self, objId):
        if isinstance(objId, EAElement):
            objId = objId.elementID
        elif isinstance(objId, EAPackage):
            objId = objId.element.elementID
        else:
            assert False, "Invalid use of other for %s" %objId
        otherId = self._comobj.supplierId if self._comobj.clientId == objId else self._comobj.clientId
        other = EAElement(self._rep.getElementByID (otherId))
        if other.type == "Package":
            package = self._rep.getPackageByGUID(other.elementGUID)
            return package
        else:
            return other

    def thisEnd(self, objId):
        if isinstance(objId, EAElement):
            objId = objId.elementID
        elif isinstance(objId, EAPackage):
            objId = objId.element.elementID
        else:
            assert False, "Invalid use of thisEnd for %s" %objId
        return  self._comobj.clientEnd if self._comobj.clientId == objId else self._comobj.supplierEnd

    def otherEnd(self, objId):
        if isinstance(objId, EAElement):
            objId = objId.elementID
        elif isinstance(objId, EAPackage):
            objId = objId.element.elementID
        else:
            assert False, "Invalid use of otherEnd for %s" %objId
        return  self._comobj.clientEnd if self._comobj.supplierId == objId else self._comobj.supplierEnd


q.