Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - m2i7c9k

Pages: [1] 2 3
1
Thank You Sunshine,

I'm going to dive in int.

Mick

2
Automation Interface, Add-Ins and Tools / Virtual document from vbscript?
« on: September 08, 2021, 03:12:57 am »
Hi guys,

please help me! I'm a bit "out of order", because I don't understand how works virtual documents.

Is is possible have 3 element on the diagram and print them by element type?

1 Diagram = 1 UseCase, 1, Class (stereotype="webpage"), 1 Class (stereotype="service")

And I have no idea how create template that read the diagram elements, and use 3 deferent templates
by element type, in one document,  document chapter?

Thanks for advice

Mick


3
Thank you, Geert!

Well, it was horrible code, indeed :)
I rewrite it without SQL.

Your code will help me in other ideas, thank you again.

Mick

Sub main
   
   On Error Resume Next
   Err.Clear
   
   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"
   
   dim msg, appName
   appName = "A&D VBScript"
   
   if Err.Number <> 0 Then
      Session.Output( "NOK" )
      msg=MsgBox( "Unknown Error.", vbOKOnly  + vbExclamation , appName )
      Exit Sub
   else
      dim currentDiagram as EA.Diagram
      set currentDiagram = Repository.GetCurrentDiagram()
      
      'Selected element type=Component check.
      if currentDiagram.SelectedObjects.Count = 0 then
         msg=MsgBox("Select 'Component' element.", vbOKOnly  + vbExclamation , appName)
         Exit Sub
      else
         for each currentDiagram in currentDiagram.SelectedObjects
         
            dim theElement as EA.Element
            set theElement = Repository.GetElementByID(currentDiagram.ElementID)   
            
            if theElement.Stereotype <> "Component" then
               msg=MsgBox("Select 'Component' element.", vbOKOnly  + vbExclamation , appName)
               Exit Sub
            else
               'Check the element has connector.
               dim con as EA.Element
               set con = theElement.Connectors.GetAt(0)
               
               dim client as EA.Element
               set client = Repository.GetElementByID (con.SupplierID )
               
               if client.Name = "" then
                  msg=MsgBox("The connector is missing.", vbOKOnly  + vbExclamation , appName)
                  Exit Sub
               else
                  'Check connector type = Usage.
                  if con.Type <> "Usage" then
                     msg=MsgBox("The connector type must be a 'Usage.'", vbOKOnly  + vbExclamation , appName)
                     Exit Sub
                  else
                     set theElement = Repository.GetElementByID(client.ElementID)
                     
                     dim theComponent as EA.Element
                     set theComponent = Repository.GetElementByID(currentDiagram.ElementID)
                     
                     dim i
                     dim attributes as EA.Collection
                     set attributes = theElement.EmbeddedElements

                     for i = 0 to attributes.Count - 1
                        dim currentAttribute as EA.Element
                        set currentAttribute = attributes.GetAt( i )
                        
                        'pondelok, 09 augusta 2021, 15:19:32
                        'check service name.
                        dim serviceName
                        serviceName = currentAttribute.name
                        if instr(1,serviceName,"(") <> 0 then
                           serviceName = mid(serviceName, 1, instr(1,serviceName,"(") - 1)
                        else
                           serviceName = serviceName
                        end if
                        'Session.Output("serviceName: " & serviceName)
                        'copy webpage interface to the component element
                        Call AddOperation (currentDiagram.ElementID, serviceName, currentAttribute.Notes)
                     next
                  end if
               end if
            end if
         next
      end if
   end if
End Sub

4
Automation Interface, Add-Ins and Tools / Re: interaction points
« on: August 08, 2021, 01:56:29 am »
Hi Guys,

finally, I can't find where is stored info about ProvidedInterface is visible/or not on the diagram?

What is the secret of the Sprax guys?

I tried:
SELECT       
   t_object.Object_ID, t_object.Name,
   t_diagramobjects.ObjectStyle
FROM           
   t_diagramobjects
   INNER JOIN t_object ON t_diagramobjects.Object_ID = t_object.Object_ID
WHERE
   t_object.object_Type = 'ProvidedInterface'

Thanks a lot.

Mick

5
So, I did it. Like this: good enough - for me :)

option explicit

!INC Local Scripts.EAConstants-VBScript
!INC EAScriptLib.VBScript-Logging

Sub Main

   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"
   
   dim currentDiagram as EA.Diagram
   set currentDiagram = Repository.GetCurrentDiagram()
   
   for each currentDiagram in currentDiagram.SelectedObjects
      
      dim theElement as EA.Element
      set theElement = Repository.GetElementByID( currentDiagram.ElementID )   
      
      Dim sqlCmd
      Dim queryResult
      
      sqlCmd = "SELECT " &  _
         "   Object_1.Object_ID AS DestID " &  _
         "FROM  " & _
         "   t_object  "  & _
         "   INNER JOIN t_connector INNER JOIN t_object AS Object_1 ON t_connector.End_Object_ID = Object_1.Object_ID "  & _
         "   ON t_object.Object_ID = t_connector.Start_Object_ID "  & _
         "WHERE " &  _
         "    t_object.Object_ID = " & theElement.ElementID
         
      queryResult = Repository.SQLQuery( sqlCmd )
      'Session.Output ( queryResult )
      Session.Output ( getDestObjectID ( queryResult )  )

   next

End Sub

Function getDestObjectID ( queryResult )
'   FUnkcia vráti ID asociované (<<use>>) objektu
      Dim str1,  str2, retVal
      str1 = InStr ( queryResult, "<DestID" )
      str2 = len(queryResult)
      retVal = MID( queryResult, str1, str2 )
      retVal = replace(retVal, "</Row></Data></Dataset_0></EADATA>", "")
      retVal = replace(retVal, "<DestID>", "")
      retVal = replace(retVal, "</DestID>", "")
      'Session.Output ( retVal )
      getDestObjectID = retVal
End Function

Main

6
Hi Guy,

pleas HELP :) I'd like to retrieve from SQLQuery only ONE value <DestID>.

Sub Main

   Repository.EnsureOutputVisible "Script"
   Repository.ClearOutput "Script"
   
   dim currentDiagram as EA.Diagram
   set currentDiagram = Repository.GetCurrentDiagram()
   
   for each currentDiagram in currentDiagram.SelectedObjects
      
      dim theElement as EA.Element
      set theElement = Repository.GetElementByID( currentDiagram.ElementID )   
      
      Dim sqlCmd
      sqlCmd = "SELECT " &  _
         "   Object_1.Object_ID AS DestID " &  _
         "FROM  " & _
         "   t_object  "  & _
         "   INNER JOIN t_connector INNER JOIN t_object AS Object_1 ON
t_connector.End_Object_ID = Object_1.Object_ID "  & _
         "   ON t_object.Object_ID = t_connector.Start_Object_ID "  & _
         "WHERE " &  _
         "    t_object.Object_ID = " & theElement.ElementID
      
      Dim queryResult
      queryResult = Repository.SQLQuery(sqlCmd)
      'LOGInfo (queryResult)
      
      getDiagramOccurences  (queryResult)

                The result id:
                2021-8-7 14:27:24 [INFO]: <?xml version="1.0"?>
               <EADATA version="1.0" exporter="Enterprise Architect">
          <Dataset_0><Data><Row><DestID>2</DestID></Row></Data></Dataset_0></EADATA>
                   
                But I want to <DestID> value
End Sub

Thanx a lot

Mick

7
Automation Interface, Add-Ins and Tools / Re: interaction points
« on: August 04, 2021, 11:24:13 pm »
Oh, Yes, it is... thank you, I was blind like dark night :)

8
Automation Interface, Add-Ins and Tools / interaction points
« on: August 04, 2021, 10:28:26 pm »
Hi Guys,

I'd like to know where is stored relation between the element and its interaction points?

Situation:
I have a diagram with class element and ProvidetInterface, but I can't find their relationship in the BD (MS SQL)?

img:https://ibb.co/02GpcjF
https://ibb.co/02GpcjF

My Goal:
I want to create VBScript that copy ProvidetInterface data and add them (insert) into t_attributes.

What am I missing?
Thanx.

Mick

9
OK I got it :)

option explicit

!INC Local Scripts.EAConstants-VBScript

'
' Script Name: createAnalyticalService Diagram
' Author: Milan Hudec
' Purpose: N/A
' Date: streda, 17 marca 2021, 15:46:45
'
sub main

   dim i

   dim msg
   dim iBox
   dim appName
   appName = "Package"
   
   dim thePackage as EA.Package
   set thePackage = Repository.GetTreeSelectedPackage()

   dim theElement as EA.Element
   set theElement = Repository.GetTreeSelectedObject()

   dim packages as EA.Collection
   set packages = thePackage.Packages
   
   dim elements as EA.Collection
   set elements = thePackage.Elements

   dim subPackage as EA.Package
   set subPackage = packages.AddNew("[data - t]", "Class")
   subPackage.Update()
   
   dim theNewPackage as EA.Element
   set theNewPackage = Repository.GetTreeSelectedObject()
   theNewPackage.update()
   Session.Output  ( theNewPackage.PackageID & " - " & theNewPackage.name )
   
   dim updatequery
   updatequery = "UPDATE t_package SET PackageFlags = 'RTF=F;' WHERE t_package.Package_ID = " & subPackage.PackageID
   Repository.Execute updatequery

   Repository.Models.Refresh()
end sub

main

10
Hi Guys,

is it possible to create the package by VBScript with "Exclude from Generated Report"?

sub main

   dim i

   dim msg
   dim iBox
   dim appName
   appName = "Package"
   
   dim thePackage as EA.Package
   set thePackage = Repository.GetTreeSelectedPackage()

   dim theElement as EA.Element
   set theElement = Repository.GetTreeSelectedObject()

   dim packages as EA.Collection
   set packages = thePackage.Packages
   
   dim elements as EA.Collection
   set elements = thePackage.Elements

   dim subPackage as EA.Package
   set subPackage = packages.AddNew("[data]", "Class")
        subPackage.what?
   subPackage.Update()
         
         
   Repository.Models.Refresh()
end sub

Thanks for HELP :)

Mick

11
General Board / Re: Enum Class as Table Column?
« on: April 22, 2021, 09:53:00 pm »
Well, here is the way :)

1.
In Transformation Table
%if classStereotype=="enumeration"%
%endTemplate%

Table
{
   %TRANSFORM_REFERENCE("Table")%
   %TRANSFORM_CURRENT("language", "stereotype")%
 
   name=%qt%%CONVERT_NAME(className, "Camel Case", "ab(_)ab")%%qt%
   language=%qt%%genOptDefaultDatabase%%qt%
   
   %list="Attribute" @separator="\n" @indent="  "%
   
   $COMMENT="Enum class ako attribút v Tabuľke."
   %list="Connector__Enum" @separator="\n" @indent="  "%
...

2 adding a new Connector__Enum Template
%if connectorType == "Association" or connectorType=="Aggregation"%

   %if connectorSourceElemStereotype == "enumeration" %
      Column
      {
         %if connectorSourceRole != ""%
            name=%qt%%CONVERT_NAME(connectorSourceRole, "cascal Case", "ab(_)ab")%%qt%
         %else%
            name=%qt%%CONVERT_NAME(connectorSourceElemName, "cascal Case", "ab(_)ab")%%qt%
         %endIf%
         
         type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,"varchar(10)")%%qt%
         
         %if connectorNotes != ""%
            notes=%qt%%connectorNotes% %connectorSourceElemNotes%%qt%
         %else%
            notes=%qt%%connectorSourceElemNotes%%qt%
         %endIf%
          
         Tag
         {
            name="LengthType"
            value="CHAR"
         }
      }
   %endIf%
%endIf%

.... in the end, it worked :)






12
General Board / Re: Enum Class as Table Column?
« on: April 22, 2021, 09:12:11 pm »
Hi Geert,

well, you're right :) So here are more details.
1. I have a PIM model that has enum associated to the class as (composite)
2. when I run transformation PIM to Table for MS SQL DB, the code does noting with enum?

so I thought that I can somehow add the enum class name as a Table column?


13
General Board / Enum Class as Table Column?
« on: April 22, 2021, 08:26:14 pm »
Hi guys,

I can't figure out how can I add ENUM class associated (aggregation) to another Class?
I'd like to add the ENUM class name as Tabel Columnt name?

Thanks

MIck

14
I've figured out it:

   
   %if attType=="String" and attTag:"mytag" != ""%
      type=%qt%%attTag:"mytag"%%qt%
   %endIf%

15
Hi Gus,

Please help me: In my model, I have a class that has an attribute with a tagged value that
I want to use as destination DB Table.attribute.type.

Example:
Class(Person).Attribute(firstName).Type(string) ----> DB.Table(Person).Attribute(fistrName).Type(Varchar(250)

How can I achieve that?

Thanks for the advice.

Mick

Pages: [1] 2 3