« Back to Scenario Collection

Reacting on adl Export

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Reacting on adl Export
event handler export import adoxx adl setattributevalue startimport
Answer
2/23/16 1:48 PM
Hi,


we are currently developing a new version for our e-GPM modeling implementation for AdoXX.
We have a use-case where we want to react to an export of models (adl).
In our models we are able to assign external graphics to objects via an absolute path.
These graphic are not included when models are exported and that is what we'd like to change.

One solution we could imagine might be to include a base64 encoded image via writing it into a CLOB just before the export and reconstruct it into an internal folder on import (and settting the path again).
To achieve that we would need to be able to react on a StartExport event like it is possible for imports. But there is no such event, or is it?

If the first solution isn’t possible, it might be another solution to store the image into a CLOB whenever the attribute holding the path to the image changes.
This has some drawbacks since the SetAttributeValue event is also invoked on import. Also this is wasting resources.
Does anyone know if it is possible to react to an export event? Or is there a better solution to achieve our goal?
 
A short answer would be nice, even a glimpse of an idea.
 
Thanks.
 
fritz oscar

RE: Reacting on adl Export
Answer
3/3/16 2:26 PM as a reply to Fritz Oscar Berngruber.
Dear Fritz Oscar,

thank you for this interesting question. We are currently preparing a proposal for you to show-case how this potentially could be done. A potential solution would be:

a) Save and store all linked documents in PROGRAMCALL attributes into a base64 encoded STRING attribute during model save
b) Use the default ADL Import/Export functionality
c) Re-construct the files and re-set links during the model-open event.

This approach should make it possible to included images/files and make them portable!
Thanks for your patience!

RE: Reacting on adl Export
Answer
3/9/16 10:24 AM as a reply to Wilfrid Utz.
Dear Wilfrid,


thank you for your response.

Instead of writing the base64 string to a LONGSTRING on a save event we decided to do so on setAttributeValue event.
When exporting on save we had the problem that it was possible to e.g. change a path to an external image, not saving the model and exporting without creating the base64 string.

To make the solution work on setAttributeValue we are setting a “boolean" global variable on StartADLImport to 1 – so that we know we are about to import. And we set it back to 0 on EndADLImport.
Checking that variable on setAttributeValue is giving us the chance to avoid unwanted override actions when an import is running.

But we ran into another problem:
We decided to use CLOBs to save the base64 code of the images. It seems that CLOBs are not supported anymore by the ADO environment:
When we create a CLOB attribute and export and import our library the CLOB attribute is changed to a LONGSTRING attribute...

The problem is that the LONGSTRING attribute does not take enough characters to save an entire base64 encoded image. emoticon
(By the way we took a very small image that was of ~25 KB size not encoded)

We would like to ask you again for your advice – do you have an idea how to solve our problem?
 
Sincerely the e-GPM Team at WPS.

We have found a Solution
Answer
3/14/16 1:39 PM as a reply to Fritz Oscar Berngruber.
Dear Wilfrid,
 
we have come to a complete solution for our import / export problem:
On the setAttributValue event we encode the image as base64, split it into segments and put these segments into a Record.
On the openModel event we check if we can find the original image (as set in the path in our objects)
and if not we recreate the image from the segments of the corresponding record. We then save the recreated image in a specified folder
and reset the path of our object to that folder.
 
Thanks for your help and all the best,
The e-GPM team at WPS
 

Storing files in objects of a model
Answer
10/8/18 12:32 PM as a reply to Fritz Oscar Berngruber.
Hello

Thank you for the idea, I was facing a similar problem: storing file content in the model so it can be exchanged through the import/export functionality. I solved it like you described by storing the file content in a table, split in separate rows. I have also extracted just that functionality and attached it to this post with the necessary AdoScript, a library that shows how it works and a short readme. Note that this solution doesn't allow to directly visualize images stored like this throgh the GraphRep, it only focuses on storing the file content and exchanging it through import/export functionalities.

Best regards,
Patrik
Attachments: StoreFiles.zip (21.1k)