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

Pages: [1] 2
1
Thank you

2
General Board / How to show name as label for class created from image
« on: August 15, 2021, 03:31:56 am »
I am sure there is a simple answer, but I don't see it.

I am working with an Azure diagram. I have imported all the Azure images.
In my diagram, I left-drag one of the Azure images onto the diagram and select "Add as element with image" from the popup menu.
The class is created, with the Azure image.

The problem is that the name I type into the Name field in the Properties does not show up, below the visual element, as a label.
The elements from the sample Azure diagrams do this, so I know it is possible. I don't see a "show label" or similar property that I can select however.

Thanks.




3
I have fixed code and a question about setting the Assigned Columns via the Parameters collection.

Fixed code:  With the suggestions from Geert, I successfully updated my code to create the check constraint.  Feel free to use this in your own script; it works except for issue noted in my question below.

dim newMethod as EA.Method
'This line works to create a new EA.Method object, but that object is useless
'because:
'  - FQStereotype is set to "", it is a read-only property, and that property must be set.
set newMethod = myElement.Methods.AddNew(requiredCheckConstraintName, "")

'This line works, but the resulting EA.Method object is useless because FQStereotype is "".
' ReturnType is also incorrectly set to "EAUML::check"; it needs to be "".
'set newMethod = myElement.Methods.AddNew(constraintName, "EAUML::check")

' For the new EA.Method object, set the various properties.
'ParentID - this is already set to the ElementID value of the parent table, due to the AddNew() function above

newMethod.Code = requiredCheckConstraintExpression
newMethod.Concurrency = "Sequential"
'newMethod.FQStereotype - this will be correctly set to "EAUML::check" when StereotypeEx is set to "check" below.
'newMethod.MethodGUID - this value will be set when the Update() function is executed below
'newMethod.MethodID   - this value will be set when the Update() function is executed below
'newMethod.Name - this is already be set, using value from AddNew() function above
'newMethod.Notes - not needed
'newMethod.ObjectType  - this value is correctly automatically being set 24  'From EAConstants-VBScript:  otMethod = 24
'newMethod.Parameters - PROBLEM: this collection must have an object added, to list the affected table column, but it is documented as read-only
'newMethod.ParentID =  - this value is correctly automatically being set to the table ElementID value
newMethod.Pos = myElement.Methods.Count ' Pos is 0-based.  Use next value.
'newMethod.PostConditions - will be left empty
'newMethod.PreConditions  - will be left empty
newMethod.Stereotype   = "check"
newMethod.StereotypeEx = "check"   ' or maybe newMethod.StereotypeEx = "EAUML::check"
'newMethod.Style and StyleEx - will be left as empty string
'newMethod.TaggedValues - will be left empty
'newMethod.TypeInfoProperties - 9 elements are automatically added to this collection when the Update() function is executed below
newMethod.Visibility = "Public"


dim newParameter as EA.Parameter
' attribute is the database table column object, from the containing "for each attribute in myElement.Attributes" for loop
' this command fails:  newParameter = newMethod.Parameters.AddNew(attribute.Name, attribute.Type)
' this command fails:  newParameter = newMethod.Parameters.AddNew(attribute.Name, "")
' this command fails:  newParameter = newMethod.Parameters.AddNew("", "")


' Save the Method object
newMethod.Update()
myElement.Methods.Refresh()




question about setting the Assigned Columns via the Parameters collection
The above code is sufficient to create a new check constraint. 
Unfortunately I cannot create an element for the Parameters collection in the EA.Method object; this is true both before and after executing Update() and Refresh() on the Methods collection. 
The Parameters collection stores the column that is in the Assigned Columns list in the Involved Columns tab on the Constraints/Indexes page on the Columns and Constraints dialog for the related modelled database table.
The check constraint, without the column in the Parameters collection, will still generate the correct DDL syntax for database generation, so this is not an insurmountable problem.  But I would prefer to have the model include this information.



' An attempt to use GetByName() will fail.
'dim retrievedMethod as EA.Method
'retrievedMethod = myElement.Methods.GetByName(requiredCheckConstraintName)

' Since GetByName() does not work, loop through the methods until the new check constraint is found
'dim method
for each method in myElement.Methods
   if method.FQStereotype = "EAUML::check" and method.Name = requiredCheckConstraintName then
      dim newParameter1 as EA.Parameter
      ' attribute is the database table column object, from the containing "for each attribute in myElement.Attributes" for loop
      ' this command fails:  newParameter1 = method.Parameters.AddNew(attribute.Name, attribute.Type)
      ' this command fails:  newParameter1 = method.Parameters.AddNew(attribute.Name, "")
      ' this command fails:  newParameter1 = method.Parameters.AddNew("", "")

      ' Do not try to set values for newParameter1; the AddNew() command above fails
      if false then
         'dim newParameter as EA.Parameter
         'Alias - ""
         newParameter1.ClassifierID = "0"
         'Default - ""
         'IsConst - False
         newParameter1.Kind = "in"
         'newParameter1.Name - should already be set
         'newParameter1.Notes - not needed
         newParameter1.ObjectType = 25 ' From EAConstants-VBScript:  otParameter                = 25
         newParameter1.OperationID = retrievedMethod.MethodID
         'newParameter1.ParameterGUID - ?
         newParameter1.Position = 0  ' Pos is 0-based
         'newParameter1.Stereotype and StereotypeEx - ""
         'newParameter1.Style and StyleEx - ""
         'newParameter1.TaggedValues - will be left empty
         newParameter1.Type = attribute.Type
         'newParameter1.TypeInfoProperties - might not need to be set; for existing, has 11 elements

         newParameter1.Update()
         'newMethod.Parameters.Refresh()
      end if
      
      exit for
   end if
next


Does anyone have suggestions for how to get EA to allow the creation of a new element for the Parameters collection?

4
General Board / Re: modify sql for view using javascript
« on: March 10, 2021, 10:10:19 am »
Oy veh.  That was it. Thanks

5
General Board / modify sql for view using javascript
« on: March 10, 2021, 08:50:28 am »
I am trying to modify the sql text for a view using javascript. For instance I'd like to change:
SELECT COL1, COL2 FROM [oldSchema].[table1]
to
SELECT COL1, COL2 FROM [newSchema].[table1]

I am able to do this manually using the SQL Object Properties maintenance window in the UI but can't seem to figure where this data lives in the object model.  I've tried modifying the 'viewdef' TaggedValue but without success. This temporarily modifies the text of the Notes, but doesn't change the underlying SQL:
var x = EA.Element
x = Repository.GetContextObject()
var pkg = Repository.GetPackageByID(x.PackageID)
y = x.TaggedValues.GetByName('viewdef')
var re = /oldSchema/ig
var n = y.Notes
y.Notes = n.replace(re, 'newSchema')
x.Update()
pkg.Update()

Any suggestions would be helpful.
Thanks,
Jim

6
Bugs and Issues / Re: Azure Icons print with black background
« on: March 06, 2021, 03:19:41 am »
@Geert:

Did you import all of the icons first using the new model wizard?


Thanks Geert.  After I added the "Microsoft Azure icons and images" model to my project, all works correctly.

7
Thank you Geert.  I'll implement your suggestions and see what happens.

8
@Geert:  Thanks; I'll have a look at your VBScripts repo

@qwerty:  Yeah, I guess the idea of a searchable list of known bugs, with workarounds and fix status sounds good, but quickly becomes a great deal of work.  That kinda sounds like something that a well-managed vendor support team would do.  Some vendors have exactly that on their websites, and Google searches will find current/past tickets related to your query.

9
Bugs and Issues / Re: Azure Icons print with black background
« on: March 05, 2021, 04:12:37 pm »
A)  Cool; I'm glad EA has added icons for Azure
B)  On my screen, none of the icons show up.  I have the boxes, arrows and words.  But when I add the "Azure Example 2" model into my project, none of the icons are displayed.  I had a look at the diagram properties and the properties for one of the icons, but I don't see any obvious issues.  Any suggestions?

10
So I want to have EA automatically add a check constraint, for any column in a modelled database table that uses a particular data type; in my case, the (added) datatype "dbo.adtYesNo".

I made myself a nice script.  I then select all the database tables on the diagram, and run the script.  The script works great for processing all the tables, checking all the columns, and it can alter/update the check constraints that it finds.
The problem is that the script cannot create a new check constraint, if there is currently none.  And that is the biggest part of what I wanted to be automatically handled.  The following is the related code fragment; the comments for "PROBLEM" note the various properties in the EA.Method object that EA does not allow me to set.

dim newMethod as EA.Method
'This line works to create a new EA.Method object, but that object is useless
'because:
'  - FQStereotype is set to "", it is a read-only property, and that property must be set.
set newMethod = myElement.Methods.AddNew(requiredCheckConstraintName, "")

'This line works, but the resulting EA.Method object is useless because FQStereotype is "".
' ReturnType is also incorrectly set to "EAUML::check"; it needs to be "".
'set newMethod = myElement.Methods.AddNew(constraintName, "EAUML::check")

' For the new EA.Method object, set the various properties.
newMethod.Code = requiredCheckConstraintExpression
newMethod.Concurrency = "Sequential"
'newMethod.FQStereotype = "EAUML::check" - PROBLEM: this property must be set, but it is read-only
'newMethod.MethodGUID - need to set?
'newMethod.MethodID   - need to set?  - PROBLEM: this property likely needs be set, as the value is currently 0, but it is read-only
'newMethod.Name - this is already set; good
'newMethod.Notes - not needed
'newMethod.ObjectType = 24  'From EAConstants-VBScript:  otMethod = 24   - PROBLEM: this property must be set, but it is read-only
'newMethod.Parameters - - PROBLEM: this collection must have an object added, to list the affected table column, but it is documented as read-only in https://www.sparxsystems.com/enterprise_architect_user_guide/15.2/automation/method.html
'newMethod.ParentID = myElement.ElementID ' - PROBLEM: need to set the table ElementID into newMethod.ParentID, but it is read-only
newMethod.Pos = myElement.Methods.Count ' Pos is 0-based.  Use next value.
'newMethod.PostConditions - will be left empty
'newMethod.PreConditions  - will be left empty
newMethod.Stereotype   = "check"
newMethod.StereotypeEx = "check"
'newMethod.Style and StyleEx - will be left as empty string
'newMethod.TaggedValues - will be left empty
'newMethod.TypeInfoProperties - might not need to be set
newMethod.Visibility = "Public"

' Save the Method object
newMethod.Update()
myElement.Methods.Refresh()


dim retrievedMethod as EA.Method
retrievedMethod = myElement.Methods.GetByName(requiredCheckConstraintName)

dim newParameter as EA.Parameter
newParameter = retrievedMethod.Parameters.AddNew(attribute.Name, attribute.Type)

newParameter.ClassifierID = "0"
newParameter.Kind = "in"
'newParameter.Name - should already be set
'newParameter.Notes - not needed
newParameter.ObjectType = 25 ' From EAConstants-VBScript:  otParameter                = 25
newParameter.OperationID = retrievedMethod.MethodID
'newParameter.ParameterGUID - ?
newParameter.Position = 0  ' Pos is 0-based
'newParameter.Stereotype and Stereotype - ""
'newParameter.Style and StyleEx - ""
'newParameter.TaggedValues - will be left empty
newParameter.Type = attribute.Type
'newParameter.TypeInfoProperties - might not need to be set

newParameter.Update()
retrievedMethod.Parameters.Refresh()



Any ideas?
I had a look at Geert's framework for add-ons.  Geert has code there for check constraints; I don't know if his framework is only capable of reading existing check constraints, of if it can successfully create new ones also.

Thanks.

11
I have a document that I have been maintaining, with known bugs and workarounds for EA.
I also have made dozens of fixes to the Transform Templates, a few fixes to the DDL Templates, and I have some Scripts I wrote to automate working around other bugs or limitations in EA.

Where is a good place to post the above, for the community?  I looked at the https://community.sparxsystems.com/ website, but don't see a "freebie code" section.

I know Geert has generously created a Git site for his Add-ons.  That (currently) only has add-on code however, not templates and scripts.  (Given the grief I had editing the templates, I suspect Geert's method of using Add-ons is smarter than what I did.)

12
I had a similar question for support a few weeks ago.  If you right-click on the Attribute in the class diagram, select Properties, then you will see a property/attribute called IsID under the Advanced header.  So I thought that the transform process should use that, instead of creating a standard <ClassName>ID column for the Primary key.  EA support people disagreed, and thought it was fine for EA to ignore IsID.  I'm not sure what the point is of having the IsID property/attribute....


So you will need to alter the Transform Templates yourself, for the DDL language.  You will need to alter:
- Attribute: add code to suppress creating the column in this template, if the attribute is to be used as the PK
- Class:  add code to skip the standard Transform Template code to create the standard PK column (<ClassName>ID) and to instead create a PK based on your requirements
- Connection:  If the PK column has changed, you also need to alter all the Transform Template code in this template that creates a column for the FK column in a table that refers to the table for which you altered the PK column, plus alter the creation of the FK constraint.

I did the above, but I only altered Connection as far as was necessary for my case.  For example, I only wanted to alter the PK for tables that would be used as lookup/reference/type tables; e.g. a Status table, and then other tables would have a "StatusCode" column and an FK to Status.StatusCode.
Relationships such as many-to-many, or inherited classes (Generalization) are not yet handled.

I wrote the Transform Template alterations so that you must add up to two Tagged Values on the class:
  • one to specify the column to be used as the PK
  • one to specify the data type for the column to be used as the PK (Yes it would have been smarter to somehow find the required Attribute and read the datatype value, but I did not quickly see a way to do this in the documentation that EA provides.  If you find a better way, please let me know.

Will the above be sufficient for you?  I can paste in the code if it is.  I will ask in another post where this type of code should be posted, to help the community.

Dale Fox

13
In my class diagram, I have some documentation that applies to many classes.  I put the document link on the diagram, but I would also like to have a connector from the documentation artifact to the various classes that are affected by it.
All connector types, such as trace, information flow, and association try to create a connection with a role, such as "0..1 to 0..*", and when I transform this class model, EA tries to treat the document as if it is a class.
I just want a link to show, to prompt the reader to be aware that this class is affected by the documentation.  How do I do this, without the Transformation process trying to create Foreign Key relationships in the generated DDL model?

14
Thank you for the sample code

15
In case anyone else has the same need to alter mappings for data types from the source class model to a destination model, such as DDL, here is a method that works.  There should be a better method, but I did not find it.


**********************************************************************
First, ensure the destination model in EA already has all appropriate data types defined. 
**********************************************************************
If your destination is a database and you want to use User Defined Data Types (UDDT) / Alias Data Types (ADT), create those in the model.

Configure \ Reference Data \ Settings \ Database Datatypes…

When you define the adt in EA in the Database Datatypes dialog:
    • select the None radio button in the Size group; not doing this will  result in EA creating DDL scripts for database generation with invalid syntax
        ◦ do not include a length for ADTs based on a type such as char or varchar;.
        ◦ do not include the precision and scale for ADTs based on a type such as decimal
    • Maybe include the schema name with the name of the ADT in the Datatype field, such as "dbo.adtYesNo" instead of "adtYesNo"


You will need to create the ADT in the target database, before executing DDL scripts generated by EA that use the ADT.  Sample script: 
create type dbo.adtTaxRate
    from decimal(9,8) not null;
create type dbo.adtYesNo
    from char(1) not null;
--drop type dbo.adtTaxRate;
--drop type dbo.adtYesNo;



**********************************************************************
Second, consider creating Type elements, for reuse and ease
**********************************************************************
I do not know if this is the best or proper method to create reusable data types, but it works.
    1. Create Types for use in the source Domain Model
    • In the Project Browser, create a "Types" package to hold the new types to be created
    • Right-click the "Types" package, choose "Add Element..."
    • In the New Element dialog:
        ◦ Enter a name for the type or alias data type (ADT)
        ◦ Set Type to "Type"
    2. In the classes in the Domain Model, set types for the various attributes as needed.
    • Select a class in the Domain Model
    • Open Features pane.  If necessary, move the selector to Attributes at the top, to show Attributes.
    • Use dropdown list for Type.  If the type you want is not already available; select "Select Type..."; browse to the package that holds your Types; select the appropriate type.


**********************************************************************
Third, correct the mapping
**********************************************************************
Open the Transformation Editor; see the “Opening the Transformation Editor” section.

Select the “DDL” language (this assumes destination model is DDL).
Select the Attribute template.
Modify the code starting about line 6, as shown below.  It will be necessary to make this correction in every EA project file.
Column
{
  %TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile", "derived")%
  name=%qt%%CONVERT_NAME(attName, "Spaced", "Pascal Case")%%qt%
 
  %if attType == "adtTaxRate"%
   type=%qt%adtTaxRate%qt%
  %elseIf attType == "adtYesNo"%
    type=%qt%adtYesNo%qt%
  %elseIf attType == "money"%
    type=%qt%money%qt%
  %else%
   type=%qt%%CONVERT_DB_TYPE(genOptDefaultDatabase, attType)%%qt%
  %endIf%
}

This code might work to set a char(3) or varchar(11) data type:
        type = %qt%varchar%qt%
        length = %255%qt%



Pages: [1] 2