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 - Ian Mitchell

Pages: [1] 2 3 ... 21
Automation Interface, Add-Ins and Tools / Re: Joining mis-matched columns
« on: February 10, 2020, 11:03:20 pm »
Strange that the act of putting something onto this forum magically helps me find an answer myself.
Seems that coercing strings into numbers isn't allowed ( sensible, I suppose, even though I know it will work in my case, but maybe Access is protecting me from myself..)
..but coercing numbers into strings is allowed.

Key bit of SQL seems to be:
So, I make both sides into strings, and join on them.

So the full SQL to get the Activity-type composite diagrams (see 'Inside EA for more explanation) is:
        s = s & " FROM T_OBJECT, T_DIAGRAM  "
        s = s & " WHERE "
        s = s & " T_OBJECT.NTYPE=8 "  'This is what tells us that PDATA1 is the ID of the Composite diagram
        s = s & " AND "
        s = s & " T_DIAGRAM.PACKAGE_ID in " & instring
        s = s & " AND "
        s = s & " T_OBJECT.PDATA1 = CStr(T_DIAGRAM.DIAGRAM_ID) "

...where instring is a string of numbers of the packages we want to search into.

There's a beer at the next EA User Group for anyone who comes with this. It would be REALLY useful...

Automation Interface, Add-Ins and Tools / Joining mis-matched columns
« on: February 10, 2020, 10:25:37 pm »
I need to do a join on t_object.pdata1 and t_diagram.diagram_ID - as a way to find out which diagrams are Composites (Thanks QUERTY for the hints in 'Inside EA' - how would we manage without this?).
The data types of the columns are different - PDATA1 is a varchar, Diagram_ID is a number.
Stackoverflow etc seem to suggest that it's possible to do a join (in Access - this is an EAPX file at the moment, but will need to work in other DBMSs as well later) where the column data types are different, by 'casting' in the SQL, but I can't seem to get this to work.
Does anyone have experience of doing this kind of cast/join ?

@Geert - you, as always, entirely correct:
From Sparx Support:
The issue has been confirmed and will be investigated further by our development team. The reference number for this issue is 20013927. This will be fixed in a future build.

I agree with the general sentiment about cynicism, and avoiding it where possible. We should remember that, compared to absolutely every software product I have used in the last 40 years, EA is by far the most reliable. Those using other modelling tools are in awe of EA's stability under pressure.

Sadly, the fixing of this particular issue doesn't help me at all, as most users will have EA versions which have the error, so my code still needs to handle the duplicate events. But it's one more improvement in product quality.

OK - I''l try...

You are probably right, but as a minimum, where they randomly move an option from one place to another, it should be possible to find it quickly with 'Find Command...' .
Maybe also explain to us all WHY they moved it - that's just polite.

Oh, and I'm un-installing v15.1.

Just installed V15.1, and about the first thing I did was to set my current diagram as the Model Default.
Or rather, I didn't.

V15 help says (in that the options include 'Set as user Default', and 'Set as Model Default'.

V15.1 help says (in that these options are no longer there. So the code is 100% consistent with the documentation!

Ok, so (1) why are they no longer there? and  (2) where are they now?

Oh, and (3) how many other secret changes to the UI have been made, that I'll only find when I'm in the middle of a customer demo, which will make me look an idiot. Again.
And please can the wonderful person who did a 'DIFF' on the documentation between two previous versions please do it again for v15 to v15.1.

 >:( >:( >:( >:( >:( >:( >:(

...and the point of that would be....

Update to this:
- responding with 'False' to the duplicate event does NOT fix the problem. It appeared to do, but when I click anywhere in the EA UI, Ea falls over. Which is VERY unusual!
- So, I'm left with always responding with 'True' to the duplicate event, and the user sees the strange EA error message.

My addin is looking at elements being added to a diagram, and responding to the broadcast events, but I seem to be getting a duplicate event.

(these test cases were done is a simple 'hello world' addin, with no additional function)

In the simple scenario, all is well:
Drop an element into a diagram, and the events are: (all return 'true' to EA)
  • EA_OnPreNewElement (just provides the type of element being added, and the diagram ID.) The real addin does some checking here, and returns TRUE when it's OK. In this test, always responds TRUE
  • EA_OnPostNewElement - now we have the actual element ID
  • EA_OnPreNewDiagramObject - ElementID and diagram ID provided
  • EA_OnPostNewDiagramObject- Element ID and diagram ID again
Prefect, and exactly as I expected.

Now change the 'pre diagram object' event to reject this element, so it returns 'false', and we get:
  • EA_OnPreNewElement (just provides the type of element being added, and the diagram ID
  • EA_OnPostNewElement - now we have the actual element ID
  • EA_OnPreNewDiagramObject - ElementID and diagram ID provided - Return FALSE to reject the element
But wait - there's more!
I now get ANOTHER 'EA_OnPreNewElement' event, with the same parameters as before: type & stereotype of the element, and the diagramID.

This is (1) unexpected and (2) a problem.
When the extra event is received, the same code runs as on steps(1) above, and it returns TRUE, which causes an EA error:
'Unknown/illegal base type (UseCase)
Command: UML::UseCase'

(UseCase is just the type i'm using to test this)

..and I can't suppress this message.

I've been trying all day to work out (1) why I get a duplicate event and (2) how to detect that I'm getting a duplicate event, and respond with 'false' the second time around.
So far all solutions are horrible, and are not reliable anyway.

Can anyone suggest why I'm getting the second 'On_Pre_Element' event? Is this a bug? Or a feature ?

Declaration of interest - I'm the author of Model Expert.

If you're using mostly a sub-set of Archimate, then an alternative approach is to first create some models that you're happy with, then use Model Expert to reverse-engineer them into a 'Reference (meta) Model', which you can then apply to new bits of model. Meta-model rules are applied real-time, and the Ref Model is saved in EA, so can be updated quickly and changes re-deployed.
There's also an option to generate a simple MDG so that diagrams each have the correct set of items in the toolbox  - either Archimate stuff, UML, or anything else.
Might save you some time, especially of your modelling style is evolving.

I've had some success from using the SQL 'IN' statement for the package IDs.
1. first read the whole package table and
2. create the whole package structure,
3. when you need to get everything under a package, read t_object with 'where package_Id IN (packageid1,packageid2....).
The only difficulty is the length of the list of package IDs, but I test this before submitting the SQL, and split it up into smaller queries if needed (unusual).
This seems to work consistently fast for in most cases, as it needs 2 x SQL queries - mostly.

...but I'm sure Geert's approach is better, if only I understood it...

Thanks Geert/Q - I was just checking I didn't miss something.
I'll pass this along to my customer, and see if they like it. I'm always nervous about solutions like this, where lots of clients are regularly  reading a single part of the model..(I like your 5-minute check - i should reduce the volume a lot)
Thanks guys.

eaDocX has been doing this for years - it finds a URL, and prints a hyperlink in Word.
And you don't need to be a programming genius to use it.
...but I recognize everyone in this thread is already a programming genius...
Just trying to help...

Pages: [1] 2 3 ... 21