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

Pages: [1]
1
General Board / Re: Document Generation Bookmarks in SQL Fragments
« on: November 10, 2023, 01:11:20 am »
You're welcome!
Can you confirm if you can achieve this via sql query - after you tried it? I'm just curious, thanks!

2
General Board / Re: Document Generation Bookmarks in SQL Fragments
« on: November 09, 2023, 01:18:43 am »
Hi,

I managed to create bookmarks with custom script fragments. I share the methodology, maybe this is reproducable in sql fragments as well:
The idea is that if you insert RTF into a custom field, EA will generate that into the output document. So if you insert a small chunk of RTF containing only the bookmark itself, it will work.

The heart is this javascript function:
Code: [Select]
// Returns string with bookmark in EA RTF style
// text: text to be marked with bookmark
// eaguid: the GUID of the element/diagram/package/attribute/operation/... from EA repository in EA style (e.g. {384F9831-D3EF-47d1-A565-DE355E0EFC4C})
// Example output (where <<text>> is the input text parameter):
// {\rtf1\ansi\deff0  {\fonttbl {\f0 Times New Roman;}}{\*\bkmkstart BKM_14F08F8E_31B7_491F_93D7_C6EFA8257B90}<<text>>{\*\bkmkend BKM_14F08F8E_31B7_491F_93D7_C6EFA8257B90}}   
function createRTFBookmark(text, eaguid)
{
const rtfstart = '{\\rtf1\\ansi\\deff0  {\\fonttbl {\\f0 Times New Roman;}}';
const rtfend = '}';
const rtfbkmstart = '{\\*\\bkmkstart ';
const rtfbkmend = '{\\*\\bkmkend ';
let rtfguid = guidToBkmStr(eaguid);
return rtfstart + rtfbkmstart + rtfguid + '}' + text + rtfbkmend + rtfguid + '}' + rtfend;
}

Which calls this other js function in order to convert the guid to bookmark format:
Code: [Select]
// Converts EA GUIDs (e.g. '{384F9831-D3EF-47d1-A565-DE355E0EFC4C}')
// to a bookmark string (e.g. 'BKM_14F08F8E_31B7_491F_93D7_C6EFA8257B901')
function guidToBkmStr(eaguid) {
let rtfguid = eaguid.replace('{', '').replace('}', '').replace(/-/g, '_').toUpperCase();
return 'BKM_' + rtfguid;
}

Then I return the result of createRTFBookmark() in the custom xml document (documented here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_publishing/example_output_of_an_rtf_templ.html; and here: https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_publishing/example_rtf_template_fragment_.html)
(As per my tests EA doesn't need the formatted="1" attribute for these (RTF) kind of custom fields in the xml.)

My tests shows it is wise to leave the text attribute blank in my function and just use bookmark to point to a position in the document, not to a whole section, because the formating can be ugly.

So, maybe, if you managed to query a custom field containing something like the following RTF (converting ea_guid the correct way), and alias this field in the SQL select to e.g. 'ElementBookmark' and insert the {ElementBookmark} custom field into your fragment, then it can work:
Code: [Select]
{\rtf1\ansi\deff0  {\fonttbl {\f0 Times New Roman;}}{\*\bkmkstart BKM_14F08F8E_31B7_491F_93D7_C6EFA8257B90}{\*\bkmkend BKM_14F08F8E_31B7_491F_93D7_C6EFA8257B90}}
Maybe someone will suggest an easier solution as well.

Farkas

4
Hi Geert,

you're right, I was using the sql scratch pad, and saving the query really did make #DB=<xx># macro work!

It would be nice if the help page about sql queries (https://sparxsystems.com/enterprise_architect_user_guide/16.1/the_application_desktop/creating_filters.html) explicitly mentioned this bit of information.
Though, to be fair, it implies it starting the section that describes the macros with this sentence:
Quote
You can create SQL statements using the SQL Editor through the 'Query Builder' tab.

On the other hand, your tip is the final solution for my original problem (that brought me to the problem of not working macros):
Quote
PS. you can join t_object and t_package on the field ea_guid, which don't require any conversions.
(In a nutshell, I wanted to use a sql query in a document template for excluding packages, like in the manual: https://sparxsystems.com/enterprise_architect_user_guide/16.1/model_publishing/exclude_package_query_and_scri.html. I was hoping for a database-agnostic solution and yours is one, because of not needing conversions.)

Thank you!


5
Hi,

Another way: Start | Appearance | Preferences  -> Object -> untick 'Sort Features by Stereotype' (in the right column)
I hope this will effect javascript iteration as well, not just the appearance on the screen.

Farkas

6
Quote
Which error do you find?
Sorry, this I forgot to add to the original post.
In .qea (SL3) I get this:
Code: [Select]
SQL API Open FAILED with error: near "#DB": syntax errorIn Oracle I get this:
Code: [Select]
SQL API Open FAILED with error: ORA-00911: invalid character(I would share screenshots, just I cannot figure out how  :-\)

If I remove the #DB=<xx># macro part, and only the #Package# remains in the query, there's no error. (Same is true for #WC#, I mentioned in the original post.)

Quote
The manual says to use #DB=ORACLE#, not #DB=Oracle#.
These macro's tend be be case sensitive.
You're quite right, however I tried both ways, and it fails every time.

So, my test query with 'ORACLE' (upper case) is the following:
Code: [Select]
SELECT p1.Package_ID, p1.Parent_ID, o1.Stereotype
FROM T_PACKAGE p1
#DB=SL3# inner join t_object o1 on o1.PDATA1=p1.Package_ID #DB=SL3#
#DB=ORACLE# inner join t_object o1 on o1.PDATA1=TO_CHAR(p1.Package_ID) #DB=ORACLE#
WHERE p1.Package_ID = #Package#

7
Bugs and Issues / #DB=<DBNAME># macro in SQL Search not works in EA 16.1
« on: November 03, 2023, 01:30:57 am »
Hi,

I tried to use the #DB=<DBNAME># type of macro in SQL searches in EA 16.1, but it doesn't seem to work. I got errors for these searches in .qea (SL3 = sqlite) and Oracle db repositories too.
Example query:
Code: [Select]
SELECT p1.Package_ID, p1.Parent_ID, o1.Stereotype
FROM T_PACKAGE p1
#DB=SL3# inner join t_object o1 on o1.PDATA1=p1.Package_ID #DB=SL3#
#DB=Oracle# inner join t_object o1 on o1.PDATA1=TO_CHAR(p1.Package_ID) #DB=Oracle#
WHERE p1.Package_ID = #Package#

However #WC# and #Package# macro works perfectly in all cases.
Examples:
Code: [Select]
SELECT p1.Package_ID, p1.Parent_ID, o1.Stereotype
FROM T_PACKAGE p1
inner join t_object o1 on o1.PDATA1=p1.Package_ID
WHERE p1.Package_ID = #Package#
(like the one above, but only for SL3/.qea)
Code: [Select]
SELECT o1.*
FROM t_object o1
WHERE o1.Name like "Control#WC#"
(this uses #WC# perfectly in .qea and in Oracle too)

Please correct me if I missed something, or please investigate this and fix it!

8
Hi,

maybe I'm just lucky, or maybe this feature of EA improved over time, but for me in EA 16.1 64 bit the following bookmark syntax works:  objectNote.Start and objectNote.End.
(I'm using custom script fragments, not sql fragments, though.)

Best regards,
Farkas

9
Hi,

I think there's no way to set the starting heading level (though this features would be very helpful). You can create your own templates starting with higher heading level, but this method has its own limitations. See my forum post here: https://sparxsystems.com/forums/smf/index.php/topic,48034.0.html

Best regards,
Farkas

Edit: I've just realised that the original post is from 2010. Nonetheless, maybe my answer is helpful to anyone looking for similar questions.

10
Okay, thank you very much for your help, I'll try this out!

11
So, are you suggesting to not include childpackages into the template, and to create a template starting with heading level 3, then use the original (HL2) template to generate the main package and the new (HL3) template to generate the child package?

In a virtual document structure:
<<master document>> My Specification Test
|-- <<model document>> Main package [RTFTemplate = template_starting_with_HL2]
|  |-- Main package [as attribute of model document]
|
|-- <<model document>> Main package [RTFTemplate = template_starting_with_HL3]
   |-- Child package [as attribute of model document]

This can work, but to be honest, this requires a little bit new mindset to generate documentation.

12
Hi everyone,

I recently tried to reproduce my company's quite complex internal specification template in the EA document generation templating feature. We are aiming to use both master documents/model documents and the custom document generation feature.

My main template is the following (comments in the brackets):
Code: [Select]
package >
{Pkg.Name} [as heading level 2]
... some data ...

diagram >
{Diagram.DiagramImg}
{Diagram.Name}
{Diagram.Notes}
< diagram

element >
{Template - mytemplate_for_usecases}
< element

child packages >
< child packages
< package

And the 'mytemplate_for_usecases' is like this:
Code: [Select]
package >
element >
{Element.Name} {Element.Alias} [as heading level 2]
{Element.Notes}
... other data ...
< element
< package

What I've achieved is that I can generate a package with usecases starting from heading level 2. This is needed, because our specifications usually have the following outline:
1. Use Case(s) [fixed text as heading level 1]
1.1. Package containing use cases [generated from EA as heading level 2]
1.1.1. Use Case 1 [as heading level 3]
1.1.1.1. ... some connected/children elements (e.g. boundaries, controls, entities) [as heading level 4 or higher]
1.1.2. Use Case 2 [as heading level 3]
1.1.2.1. ... some connected/children elements (e.g. boundaries, controls, entities) [as heading level 4 or higher]
2. Domain model [fixed text as heading level 1]
2.1. Domain package 1 [generated from EA as heading level 2]
2.1.1. Domain class 1 [as heading level 3]
2.1.2. Domain class 2 [as heading level 3]
2.2. Domain package 2 [generated from EA as heading level 2]
2.2.1. Domain class 3 [as heading level 3]
2.2.2. Domain class 4 [as heading level 3]
...

My problem is that with this template I cannot manage to generate the child packages of the main package in higher heading level (in this example heading level 3).
So with the templates above EA 16.1 generates the following outline:
1.1. Package1 containing use cases [heading level 2]
1.1.1. Use Case 1 [as heading level 3]
1.1.2. Use Case 2 [as heading level 3]
1.2. Subpackage of Package1 [heading level 2]
1.2.1.1. Use Case 3 [interestingly as heading level 4]
1.2.1.2. Use Case 3 [interestingly as heading level 4]

But I would like to have this:
1.1. Package1 containing use cases [heading level 2]
1.1.1. Use Case 1 [as heading level 3]
1.1.2. Use Case 2 [as heading level 3]
1.1.3. Subpackage of Package1 [heading level 3]
1.1.3.1. Use Case 3 [as heading level 4]
1.1.3.2. Use Case 3 [as heading level 4]

However I try, I'm not able to achieve this outline.
Can anyone point me to the right direction what to try, or howto implement this?
(I searched this forum, EA documentation and other sources , but I haven't found solution - this must be something quite obvious or something too hard - I hope for the first one :) )

Thanks in advance,
Farkas

13
General Board / Re: ActiveX vs COMObject and Javascript
« on: September 26, 2023, 01:24:14 am »
Hi!

Maybe everyone found this answer already, maybe not, but now in 2023 the following works with javascript:
Code: [Select]
var xmlDOM = new COMObject("MSXML2.DOMDocument.6.0");
Actually, there's a function in Local Scripts.JavaScript - Model Search (Operations) Example that tries a lot of the possibilities in order to find one working:
Code: [Select]
function CreateXMLObject()
{
var xmlDOM = null;
var ProgId = "";
var attempt = 0;

while (xmlDOM == null)
{
switch (attempt++)
{
case 0: ProgId = "MSXML2.DOMDocument.6.0"; break; //MSXML 6.0
case 1: ProgId = "MSXML2.DOMDocument.3.0"; break; //MSXML 3.0
case 2: ProgId = "MSXML2.DOMDocument"; break; //MSXML 3.0
case 3: ProgId = "MSXML2.DOMDocument.4.0"; break; //MSXML 4.0
default: return;
}
try { xmlDOM = new COMObject( ProgId ); } catch (err) { xmlDOM = null; }
}

if (xmlDOM != null)
{
xmlDOM.validateOnParse = false;
xmlDOM.async = false;
}

return xmlDOM;
}

(I tested this in EA 16.1 and 15.2)

Farkas

14
At the company that I work for, we recently had problems with installed addins not working on some PCs. The error message that was shown in EA's Manage Add-Ins window was: "Error - Missing (0x80040154)".
There's error in the "July 2018 Security and Quality Rollup updates for .NET Framework". I thought this information can be useful for others too:
https://support.microsoft.com/en-us/help/4345913/access-denied-errors-after-installing-july-2018-security-rollup-update

Pages: [1]