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 - Pegasus

Pages: [1] 2
1
Hello

Question to use of API for CreateBaseline. API Doc http://www.sparxsystems.com/enterprise_architect_user_guide/13.0/automation/project_2.html describes the requirement to first parameter "PackageGUID: String - the GUID (in XML format) of the Package to Baseline". I found some example for jscript but not for Java API.
I do call
org.sparx.Package packageSel = m_repository.GetTreeSelectedPackage();
...
m_repository.GetProjectInterface().CreateBaseline(packageSel.GetPackageGUID(),startDate, baseLineNoteStr + startDate);

and it runs seemingly well, but I'm not sure if I use the api well.
Can someone confirm or please describe correct use of api.

Thank you  in advance
Pegasus

2
Hello,

I guess I don' see teh forest for the trees...  But I need urgent suggestion

In my HybridScript I added support for baseline nad did static on most "constants" I defined inside my script

org.sparx.Package packageSel = m_repository.GetTreeSelectedPackage();
...
m_repository.GetProjectInterface().CreateBaseline(packageSel.GetPackageGUID(),startDate, baseLineNoteStr + startDate);

 and first time all works right, but suddenly I get following crash message...

java.lang.NoSuchMethodError: Unable to find GetTreeSelectedElements
at org.sparx.Repository.comGetTreeSelectedElements(Native Method)
        at org.sparx.Repository.GetTreeSelectedElements(Repository.java:788)
        at SparxSystems.RepositoryInterface.syncEaWithPtcData(RepositoryInterface.java:1665)
        at SparxSystems.RepositoryInterface.main(RepositoryInterface.java:1768)
[Loaded java.lang.Shutdown from shared objects file]
[Loaded java.lang.Shutdown$Lock from shared objects file]

I deleted the libs eaapi.jar and SSJavaCOM.dll inside my local "lib"-package, but nothing changes.

3
Hallo,
currently I don't know what doing wrong (maybe lack on knowledge of java). I run Update() on a locked element (HybridScript in JAVA) and get an exception

Exception in thread "main" java.lang.Exception: Element locked
at org.sparx.Element.comUpdate(Native Method)
at org.sparx.Element.Update(Element.java:1077)

I surround the elem.SetName and following Update-call with try ... catch (Exception e) and get the message displayed, I put inside catch-block. But nevertheless the script ends with the (stacktrace) messages above. What I expect is, that I can catch the exception and coninue in script sequence. Maybe I catch the wrong Exception-Type. But if so, what will be the right one? I don't know a source describing the JAVA API

Thanks for support

Pegasus

4
If i run script on EA V12.1 calling the connectors graphic representation changed in diagram after script ends. If I call same script in same way in EA V13 I see script runs, but nothing changed in diagram...

5
option explicit

!INC Local Scripts.EAConstants-VBScript

' Script Name: DefaultLineStyles
' Author: Geert Bellekens, Patrick Gottschalk
' Purpose: Allows to change the linestyles to their default
' Date: 27/04/2015; 03.02.2016 (LC->LV für Mode 3 korrigiert), 04.02.2016 trace (UML, Abstraction) -> Mode 3, LV
'
dim lsDirectMode, lsAutoRouteMode, lsCustomMode, lsTreeVerticalTree, lsTreeHorizontalTree, _
lsLateralHorizontalTree, lsLateralVerticalTree, lsOrthogonalSquareTree, lsOrthogonalRoundedTree

lsDirectMode = "1"
lsAutoRouteMode = "2"
lsCustomMode = "3"
lsTreeVerticalTree = "V"
lsTreeHorizontalTree = "H"
lsLateralHorizontalTree = "LH"
lsLateralVerticalTree = "LV"
lsOrthogonalSquareTree = "OS"
lsOrthogonalRoundedTree = "OR"

dim defaultStyle
dim menuDefaultLines


'*********EDIT BETWEEN HERE*************


' set here the default style to be used
defaultStyle = lsOrthogonalSquareTree

' set there the style to be used for each type of connector
function determineStyle(connector)
   dim connectorType
   connectorType = connector.Type
   select case connectorType
      case "StateFlow","ObjectFlow","InformationFlow"
         determineStyle = lsOrthogonalRoundedTree
      case "Generalization", "Realization", "Realisation"
         determineStyle = lsTreeVerticalTree
      case "UseCase","NoteLink"  ' Original:"UseCase", "Dependency","NoteLink"
         determineStyle = lsDirectMode
      case "Dependency"
         determineStyle = lsOrthogonalSquareTree'lsLateralVerticalTree
      case "Abstraction" ' UML trace
         determineStyle = lsTreeHorizontalTree
      case else
         determineStyle = defaultStyle
   end select
end function
'************AND HERE****************


sub main
      dim diagram
      dim diagramLink
      dim connector
      dim dirty
      dirty = false
      set diagram = Repository.GetCurrentDiagram
      'save the diagram first
      Repository.SaveDiagram diagram.DiagramID
      'then loop all diagramLinks
      if not diagram is nothing then
         for each diagramLink in diagram.DiagramLinks
            set connector = Repository.GetConnectorByID(diagramLink.ConnectorID)
            if not connector is nothing then
               'set the connectorstyle
               setConnectorStyle diagramLink, determineStyle(connector)
               'save the diagramlink
               diagramLink.Update
               dirty = true
            end if
         next
         'reload the diagram if we changed something
         if dirty then
            'reload the diagram to show the link style
            Repository.ReloadDiagram diagram.DiagramID
         end if
      end if
end sub

main


'gets the diagram link object
function getdiagramLinkForConnector(connector, diagram)
   dim diagramLink
   set getdiagramLinkForConnector = nothing
   for each diagramLink in diagram.DiagramLinks
      if diagramLink.ConnectorID = connector.ConnectorID then
         set getdiagramLinkForConnector = diagramLink
         exit for
      end if
   next
end function

'actually sets the connector style
function setConnectorStyle(diagramLink, connectorStyle)
   'split the style into its parts
   dim styleparts
   dim styleString
   styleString = diagramLink.Style
   styleparts = Split(styleString,";")
   dim stylePart
   dim mode
   dim modeIndex
   modeIndex = -1
   dim tree
   dim treeIndex
   treeIndex = -1
   mode = ""
   tree = ""
   dim i
   'find if Mode and Tree are already defined
   for i = 0 to Ubound(styleparts) -1
      stylePart = styleparts(i)
      if Instr(stylepart,"Mode=") > 0 then
         modeIndex = i
      elseif Instr(stylepart,"TREE=") > 0 then
         treeIndex = i
      end if
   next
   'these connectorstyles use mode=3 and the tree
   if  connectorStyle = lsTreeVerticalTree or _
      connectorStyle = lsTreeHorizontalTree or _
      connectorStyle = lsLateralHorizontalTree or _
      connectorStyle = lsLateralVerticalTree or _
      connectorStyle = lsOrthogonalSquareTree or _
      connectorStyle = lsOrthogonalRoundedTree then
      mode = "3"
      tree = connectorStyle
   else
      mode = connectorStyle
   end if
   'set the mode value
   if modeIndex >= 0 then
      styleparts(modeIndex) = "Mode=" & mode
      diagramLink.Style = join(styleparts,";")
   else
      diagramLink.Style = "Mode=" & mode& ";"& diagramLink.Style
   end if
   'set the tree value
   if treeIndex >= 0 then
      if len(tree) > 0 then
         styleparts(treeIndex) = "TREE=" & tree
         diagramLink.Style = join(styleparts,";")
      else
         'remove tree part
         diagramLink.Style = replace(diagramLink.Style,styleparts(treeIndex)&";" , "")
      end if
   else
      diagramLink.Style = diagramLink.Style & "TREE=" & tree & ";"
   end if
end function

function getConnectorStyle(diagramLink)
   'split the style
   dim styleparts
   styleparts = Split(diagramLink.Style,";")
   dim stylePart
   dim mode
   dim tree
   mode = ""
   tree = ""
   for each stylepart in styleparts
      if Instr(stylepart,"Mode=") > 0 then
         mode = right(stylepart, 1)
      elseif Instr(stylepart,"TREE=") > 0 then
         tree = replace(stylepart, "TREE=", "")
      end if
   next
   if tree <> "" then
      getConnectorStyle = tree
   else
      getConnectorStyle = mode
   end if
end function

6
Hello,

I just tried to use VB Scripts (diagram goup) changing line style of connectors in a diagramm adapted in EA V12.x inside EA V13 and it seems nothing to be changed. Using same Modell with EA 12.1 it works furthermore fine. Does something changed in API with release EA V13...? 

Thanks
Pegasus

7
General Board / SQL - Macro #Branch#: Result entire model
« on: January 14, 2017, 12:44:21 am »
Hello,

I am just testing #Branch# Macro with some case
and is see that result seems to be entire modell wheater if selected package contains further packages  or not? I expecte #Branch contains
Query:
select o.ea_guid AS CLASSGUID, o.Object_Type AS CLASSTYPE, o.name, o.ea_guid, o.Object_type AS Type, o.Stereotype, o.Author, o.modifiedDate AS Modified, o.note AS [Notes] FROM t_object o, t_package pkg WHERE pkg.Package_ID IN (#Branch#)

from user guide
http://sparxsystems.com/enterprise_architect_user_guide/13.0/model_navigation/creating_filters.html
Gets the IDs of the child Packages of the currently-selected Package, working recursively down to the lowest level of sub-Package. For example:
t_object.Package_ID IN (#Branch#)

Thanks
Pegasus

8
Hello
I found "problem". It was part of setValue-parameter. In real code "new Date" ist result of an other api call  (Java API of PTCIntegrity) and this seems not to be well done by me. If I assing result to String variable first and call SetValute (strVal) afterwards, all is fine.

9
Hello,

I don't understand API for modifiy (update) tagged values.  (EA 13)
What I want is to update existiing Tagged Values if content changed  see part of my code (part of function call)...

Collection<org.sparx.TaggedValue> elemTaVs = eaElem.GetTaggedValues();  // what means read only`?
...
tv_ptcModifDate = elemTaVs.GetByName( eaPtcFNameModifDate ); // returns null if not found
tv_ptcModifDate.SetValue( "new Date" );
if (tv_ptcModifDate.Update()) {
  updateCount++;
}

but new value isn't set in Modell (seen by Wizard in Model)

Thanks for support
Pegasus

10
Hello,

there are some contratictory topics to question how to get in projectbrowser selected Obejcts (e.g. packages, requirements/elements); e.g. http://sparxsystems.com/forums/smf/index.php/topic,30519.msg222208.html#msg222208 [Geerd] and http://sparxsystems.com/forums/smf/index.php/topic,5050.msg123251.html#msg123251 [Aaron]. I do have same problem. In EA 13 using Java API GetTreeSelectedElements returns collection with e.g requirements only not also selected packages, so I assume there isn't an interface returning collection of selected "objects" [in project-browser]. But how is it possible to recognise multiple selections of "objects" e.g. packages and elements at once

Thanks for support and elucidation
Pegasus

11
First, Thanks for hint to specials of root.
Exception bases on an writeto script output and I didn' investigate.

I'm now able to access TV (displayed as Tags Tab), but I don't understand how to access on TV defined in an MDG e.g. SysML1.4 and I don't understand FQName in TV class (filled if e.g. SysML1.4 ?)
What I'm always confused is where to find definiton of e.g GetName() to access Name of e.g. Element, not write Element.Name ...?

I hope for further hints to lift the fog in my thougths

12
Hello,

Preferences: I'm not realy familar with java, but need to use it to access via an API to an external applikation (PTCIntegrity)

I try to run from easy to more complex example (based on hyperscript example from Sparx using java)
I try to run first on packages and read TV (if exist) but I get Exception if I try to print of name of Element (package) of a root (Model) package....   I am not sure if I understand API at all.,
Where come e.g. GetPackages() from and how do I get access on e.g. isModel. I don't see this methods in online help (automation interface/Package package, ..)
If I understand right, I do have first getPackages(collection) than iterate with GetAt(idx) collection and call pgk.GetElement() to get access to e.g. TV. To get the TV for one element I do need a new collection TaggedValue filled by element.GetTaggedValues() ?

Where do I went wrong.
Sorry,  if my description isn't well english and confuse, but it reflects my current problem in understandig API
Tanks in advance for support and hints



13
Bugs and Issues / Create diagram with use alias
« on: November 24, 2016, 11:54:15 pm »
Hello,
I trie to find the place(dialog) in EA V13.0.1305 where to configure that when creating new diagramm (browser/"add diagram") checkbox Properties/Diagram: "Use Alais if Available" and "Show Diagram Details" are selected (preset). Currently I do have to change manually for each diagram.
Thanks for support in advance

Pegaus

14
Bugs and Issues / CSV-Import: DAO.Fields [3265]
« on: November 24, 2016, 07:54:32 pm »
Hello,

I do import (EA 13.0.1305) from excel/csv-file with hierarchical informations (CSV_KEY/CSV_PARENT_KEY) and get following message DAO.Fields [3265] Element in dieser Auflistung nicht gefunden. If export results (including GUI-ID) from EA into csv-file and compare this file wiht the i did the import with, I don't see differences. But what cause this messages. I fear inconsistency in data?

Thanks for feedback in advance
Pegasus

15
Bugs and Issues / Re: CSV import with preserve hierarchy
« on: November 08, 2016, 08:32:25 pm »
Hello Uffe, thanks for reply. Maybe I expressed misunderstanding. I need to use the CSV_(PARENT_)KEY columns to build the hierarchy in EA like the other tool respectively excel export. If CSV_(PARENT_)Key are emtpy all elements (Packages, Requirements, ..) will generate plane. thats not what I need.  The IDs itself I import into Tagged values as you describe

Pages: [1] 2