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 4
16
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

17
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

18
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 :)

19
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

20
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

21
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

22
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 :)






23
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?


24
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

25
I've figured out it:

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

26
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

27
As always, thank you, Geert; it works perfectly.

28
Suggestions and Requests / VBScript: Select element in the browser tree
« on: January 21, 2021, 08:54:42 pm »
Hi Guys,

I can't figure out how c I select the element in the browser tree after adding new attributes to the element?
My code will select the newly added attribute in the Class, and I'd like to select the parent Class where I startred from.
Thanks for the advice.

sub main
   
   Repository.ClearOutput "Script"
   Repository.EnsureOutputVisible "Script"
   
   dim theElement as EA.Element
   set theElement = Repository.GetTreeSelectedObject()
   
   if not theElement is nothing and theElement.ObjectType = otElement then
      
      dim i, addedAttributeID
      
      Session.Output( "Working on element '" & theElement.Name & "' (Type=" & theElement.Type & _
         ", ID=" & theElement.ElementID & ")" )
      
      ' Create an attribute to work on
      dim attributes as EA.Collection
      set attributes = theElement.Attributes
      
      dim attName, attType, attScope
      dim newAtt, splitAtt
      
      dim iBox
      iBox=InputBox("Enter attribute", "Class Attribute", "attribute_name, string(150), public")
      
      if IsEmpty(iBox) Then
         exit sub
      else
         newAtt = iBox '"fullname, string(150), public"
         splitAtt = Array(Split(newAtt, ","))
         for each i in splitAtt
            attName = trim(i(0))
            Session.Output  attName
            attType = trim(i(1))
            Session.Output  attType
            attScope = trim(i(2))
            Session.Output  attScope
         next
         
         
         dim newAttribute as EA.Attribute
         set newAttribute = attributes.AddNew( attName, attType )
         newAttribute.Visibility(attScope)
         newAttribute.Update()
         attributes.Refresh()
         
         addedAttributeID = newAttribute.AttributeID
         
         Session.Output( "Added attribute: " & newAttribute.Name & _
            "(Type=" & newAttribute.Type & _
            ", ID=" & addedAttributeID & ")" )
      end if
   end if
   -->> SELECT the ELEMENT?
main

29
General Board / Re: Tagged Value Window in EA 15.1.1526
« on: February 26, 2020, 05:41:20 am »
Hi Roy,

Thank you :) You helped me a lot :) After importing my profile, I saw my tagged values.

Milan

30
General Board / Tagged Value Window in EA 15.1.1526
« on: February 25, 2020, 08:22:25 am »
Hi Guys!

What is to happen when I click on the Editor's icon (Element group) and then click on the Tagged values? Because I do not see tagged value window :(
What I missed?

Thanks

Milan

Pages: 1 [2] 3 4