Author Topic: Use cached diagram images in v13  (Read 433 times)

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7727
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Use cached diagram images in v13
« on: October 18, 2017, 05:11:27 pm »
I just got a change request for one of my add-ins to export a .png of every diagram in scope (selected package tree), along with the xmi export it is already doing.

Now I'm a bit concerned about the performance. I'm afraid export diagram images for each and every diagram is going to be very slow, and if I remember correct EA will also open each and every single diagram before exporting its image to a file.
So that would not be a good user experience.

Now with EA 13 there is an option to cache the diagram images upon saving a diagram.
I was thinking that that might be a much quicker way to get the export I need since the images are already there and I just need to pour them into the right file format.

Has anyone done something similar before?
Where does EA store the cache? (in t_document?)

Any helpful hint is much appreciated.

thanks

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 8952
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Use cached diagram images in v13
« Reply #1 on: October 18, 2017, 06:26:51 pm »
A cache would most probably be implemented in memory, but you never know what they smoked before (designing ?/) implementing. I'll see if there's something in the DB if you tell me where to turn on the cache.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7727
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use cached diagram images in v13
« Reply #2 on: October 18, 2017, 06:51:53 pm »
The cache is indeed stored in t_document. I haven't looked closer into the exact format.
This is used by the cloud server to speed up the diagram image generation (all the images are already stored in the database in the correct format)

You can turn it on by going to Configure | Model | Options | General  and then check the options at the bottom.

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 8952
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Use cached diagram images in v13
« Reply #3 on: October 18, 2017, 08:31:01 pm »
It appears that the format they use is something internal. It's not a BMP, PNG or any other know image format. So no luck here unless you grease some developer's palm.

q.

P.S. This is the hex dump of a cached (very simple) diagram:

3C 95 AD AA E5 F4 1A 93 49 40 13 95 74 2E 6F BE 43 A4 0F 81 F6 AA F1 82 D3 D8 4A 05 FA 21 1B 0D 38 EE 32 9D D2 73 10 1B 13 16 D0 B5 2C 77 04 F1 B0 0C 04 8A FA 8A F1 66 CD 29 41 47 34 88 85 1B 39 F1 08 65 98 55 81 24 D9 4F 95 06 B8 6A 63 D9 98 A6 4E 59 88 B5 8F EE 9C 67 C6 34 02 91 A3 FB 5A A7 73 16 88 F2 C4 B6 B3 EC D8 0D 10 DF 94 17 C3 00 94 5D D6 B2 92 31 0F 20 CB C1 44 FD 14 36 A0 A1 5A 00 0E 6E 4A 91 AF 23 7E 9F B4 42 25 6C F9 0F D3 21 9F 01 5E 25 C7 D3 C6 D8 B7 D2 66 DE CF 99 EB 5F 16 8F DD 2D 7C 38 DC B4 4C 6D 5C 7E F7 B3 8D 27 E3 AF EC 6E 1F EB 11 D5 97 0F 26 38 0E BE 7B 94 BB 89 DC 22 FD F3 BA 02 BB 88 EA 99 46 40 18 4D 82 99 3E 32 95 1D 3E 42 D1 05 43 5C C6 66 0C FF 67 EC 24 28 D0 F0 91 BA 8E A7 B8 3A 9B A6 E0 E1 C7 E1 B0 59 38 A5 FB 0B 76 CC 4B 1E 39 F9 34 E8 DF BA 63 6F EA B7 2F 7A 6A 9C A4 2B 5C B1 61 66 B9 05 F2 CA 13 F7 C8 EC EE 61 D2 EA BF 70 6F 95 9D 2F 96 80 A3 FE 19 28 BA 2B 80 60 D7 F7 85 50 88 58 59 F7 A2 9C 01 71 F5 6E 6C FB BA EC 57 65 58 89 0F E6 CD CD CC 22 5F 02 4A CC 40 F0 77 21 7D E2 EC 06 9B A4 1A 4D FA 30 3C 0E 44 9A 6F BF A3 04 D8 2D 9F 3E 43 11 0C 88 5C 2C 16 92 D9 DB BA E3 46 13 27 1C FD F8 AD 6A 33 02 C6 4D 46 32

There's no magic number in front.

P.P.S. When slightly moving one element, the dump looks completely different.
« Last Edit: October 18, 2017, 08:46:25 pm by qwerty »

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6190
  • Karma: +47/-5
    • View Profile
Re: Use cached diagram images in v13
« Reply #4 on: October 19, 2017, 08:26:14 am »
You'll need to use the API provided to save that image.
Simon

support@sparxsystems.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7727
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use cached diagram images in v13
« Reply #5 on: October 19, 2017, 02:35:26 pm »
You'll need to use the API provided to save that image.

Unless you enlighten us and tell us how to get the image from the cache :D
Please.. pretty please...? :P

Geert

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6190
  • Karma: +47/-5
    • View Profile
Re: Use cached diagram images in v13
« Reply #6 on: October 19, 2017, 04:29:52 pm »
Is there a reason why you can't or don't want to use the API?
Simon

support@sparxsystems.com

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 7727
  • Karma: +165/-21
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Use cached diagram images in v13
« Reply #7 on: October 19, 2017, 04:44:48 pm »
Is there a reason why you can't or don't want to use the API?

Two reasons actually.
1. IIRC EA opens each and every diagram before saving its image
2. Performance.

Context: One of the add-ins I'm working on exports a part of the model to xmi and uploads that to a web-server to get processed.
I was asked if I could include all the diagram images of the exported part as well.

The thing is that this export/upload/download is an interactive process where the users usually waits for it to finish.
So obviously performance is of the essence here, and opening each and every diagram would simply be pretty darn annoying.

And also, in 99% of the cases, at least 99% of the diagrams haven't changed, so it would make sense to get them from the cache instead of having EA generate the images each time around.

Unless of course you are saying that I can somehow ask the API to get the image from the cache rather then to re-generate it. That would really be the ideal case. :)

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 8952
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Use cached diagram images in v13
« Reply #8 on: October 19, 2017, 06:25:53 pm »
Or ask for a feature to save without opening the diagram first.

q.

OpenIT Solutions

  • EA User
  • **
  • Posts: 456
  • Karma: +4/-0
    • View Profile
Re: Use cached diagram images in v13
« Reply #9 on: October 20, 2017, 02:27:00 am »
Hi,

As you have found its in t_document, it is in png format - however its zipped/compressed - so you need to unzip before you can save as png.

qwerty

  • EA Guru
  • *****
  • Posts: 8952
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Use cached diagram images in v13
« Reply #10 on: October 20, 2017, 07:14:43 am »
That's definitely not png. As said: it has no magic number in front.

q.

Simon M

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 6190
  • Karma: +47/-5
    • View Profile
Re: Use cached diagram images in v13
« Reply #11 on: October 20, 2017, 08:28:57 am »
Unless of course you are saying that I can somehow ask the API to get the image from the cache rather then to re-generate it. That would really be the ideal case. :)
That's exactly what I'm saying. The API to do that was added in the same version that added the capability to save the cache.

Unfortunately, I can now see the problem. It appears that the API functions added for this where misplaced as a result of versioning of the help. I've copied the signatures and descriptions below. I'll see to it that this is included in the help when it's next updated.

GetDiagramImageAndMap(string DiagramGUID, string Directory)Boolean

Notes : Saves the Image and Image-map for the Diagram with the specified GUID in the specified Directory location.
The Image will be saved in PNG format and will have a name same as that of the Diagram GUID.
The Image-map will be saved as a TXT file and
will have a name same as that of the Diagram GUID.
The option Auto Create Diagram Image Map must be enabled in the Model for this function to save the Image and Image-map.

Parameters :
  • Diagram GUID the GUID of the Diagram whose Image and Image-map is to be saved
  • Directory the location where the Image and Image-map is to be saved
GetAllDiagramImageAndMap(string Directory)Boolean

Notes : Saves the Image and Image-map for all the Diagrams in the Model in the specified Directory location.
The Image will be saved in PNG format and will have a name same as that of the Diagram GUID.
The Image-map will be saved as a TXT file and
will have a name same as that of the Diagram GUID.
The option Auto Create Diagram Image Map must be enabled in the Model for this function to save the Image and Image-map.

Parameters :
  • Directory the location where the Image and Image-map is to be saved


Simon

support@sparxsystems.com

qwerty

  • EA Guru
  • *****
  • Posts: 8952
  • Karma: +136/-123
  • I'm no guru at all
    • View Profile
Re: Use cached diagram images in v13
« Reply #12 on: October 20, 2017, 09:49:04 am »
Gosh. That's now at least 10 years ago I asked for a new feature and it was already implemented.

q.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 5874
  • Karma: +71/-77
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Use cached diagram images in v13
« Reply #13 on: October 20, 2017, 10:57:41 am »
Gosh. That's now at least 10 years ago I asked for a new feature and it was already implemented.

q.
Microsoft are quicker!  Only took them 9 years to implement a fix to one of my bugs.

But at least we now have some reference data. It's like when I order from AliExpress or Banggood; I know it's going to take at least a month to get to me with free shipping.

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

Glassboy

  • EA User
  • **
  • Posts: 896
  • Karma: +52/-54
    • View Profile
Re: Use cached diagram images in v13
« Reply #14 on: October 20, 2017, 11:31:08 am »
But at least we now have some reference data. It's like when I order from AliExpress or Banggood; I know it's going to take at least a month to get to me with free shipping.

Now I'm wondering whether banggood is safe to look at from work :-)