Author Topic: Custom Compartments  (Read 1243 times)

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2529
  • Karma: +33/-2
    • View Profile
Custom Compartments
« on: December 23, 2007, 05:15:39 pm »
Hi All,

I've been having a go at creating custom compartments. Here's some code (VB.Net) that seems to work - it creates a deployed artifacts compartment for node elements...
Code: [Select]

Function EA_QueryAvailableCompartments(ByVal Repository As EA.Repository) As Object
   EA_QueryAvailableCompartments = "deployed artifacts"
End Function

Function EA_GetCompartmentData(ByVal Repository As EA.Repository, ByVal sCompartment As String, ByVal sGUID As String, ByVal oType As EA.ObjectType) As Object
   If Repository Is Nothing Then
       EA_GetCompartmentData = ""
       Exit Function
   End If

   Dim el As EA.Element
   el = Repository.GetElementByGuid(sGUID)

   Dim sData As String = ""
   Dim sCompartmentData As String = ""

   If el.Type = "Node" Then
       Dim con As EA.Connector
       For Each con In el.Connectors
           If con.SupplierID = el.ElementID Then
               If (sCompartment = "deployed artifacts" And con.Type = "Deployment") Then
                   Dim art As EA.Element
                   art = Repository.GetElementByID(con.ClientID)
                   If art.Type = "Artifact" Then
                       sData = sData + "Data&_eq_^" + art.Name + "&_sc_^"
                       sData = sData + "GUID&_eq_^" + art.ElementGUID + "&_sc_^,"
                   End If
               End If
           End If
       Next

       If sData <> "" Then
           sCompartmentData = sCompartmentData + "Name=" + sCompartment + ";"
           sCompartmentData = sCompartmentData + "OwnerGUID=" + sGUID + ";"
           sCompartmentData = sCompartmentData + "Options=SkipIfOnDiagram&_eq_^1&_sc_^"
           sCompartmentData = sCompartmentData + "CompartmentData=" + sData + ";"
       End If
   End If
   EA_GetCompartmentData = sCompartmentData    
End Function

Happy holidays,

Neil
The Sparx Team
support@sparxsystems.com

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 6265
  • Karma: +104/-89
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Custom Compartments
« Reply #1 on: December 23, 2007, 08:00:16 pm »
Thanks for that Neil,

Can you post it on the Wiki?

And all the best for the season to you too!

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

neuron

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
Re: Custom Compartments
« Reply #2 on: January 25, 2010, 08:22:52 pm »
Hi,

how can I print compartment value in shapescript ?

neuron