Is there a method to import transformation scenarios setting the storage option?

Post here questions and problems related to oXygen frameworks/document types.
gerardch
Posts: 11
Joined: Mon Sep 14, 2020 6:43 pm

Is there a method to import transformation scenarios setting the storage option?

Post by gerardch »

Hello,

in Oxygen, there is a menu called " Options > Import Transformation Scenarios... " where you can give a file name with scenarios and then select which ones to import and the storage type " Project Options / Global Options " to use.

I would like to know if there is a way to do this using any API method ?

the objective is to be able to have a way to automatically import a specific file with defined transformation scenarios selecting which storage type to use at runtime based on certain criteria. So sometimes transformations could use storage "Project Options" but some other times it could use "Global Options". Please let me know if this is possible and what alternatives can I try.

Thanks in advance!
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by Radu »

Hi,

Assuming you are working on an Oxygen Java plugin of type Workspace Access:
https://www.oxygenxml.com/doc/versions/ ... lugin.html

there is Java API to import global options from an XML configuration file:
ro.sync.exml.workspace.api.options.GlobalOptionsStorage.importGlobalOptions(File)

https://www.oxygenxml.com/InstData/Edit ... orage.html

You can use the main menu Options->"Export Global Transformation Scenarios" to export transformation scenarios to XML. Also the "Configure Transformation Scenarios" dialog allows you to select scenarios then double click and export them to XML.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gerardch
Posts: 11
Joined: Mon Sep 14, 2020 6:43 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by gerardch »

Hi Radu,

thanks for your reply. Now the only question I have is regarding the importGlobalOptions method.

I have exported some scenarios in order to create my own scenarios file but I do not see any field where I can decide if the trasformation scenario should be Global or Project option.

So I guess this only works for Global Options storage then, correct?
Is there any other method or syntax in order to import it as a Project storage option??

Regards,
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by Radu »

Hi,

I have not tried but the XML scenarios export file looks something like:

Code: Select all

<serialized xml:space="preserve">
	<serializableOrderedMap>
		<entry>
			<String>scenarios</String>
			<scenario-array>
				..........
			</scenario-array>
		</entry>
		<entry>
			<String>scenarios.load.from.project</String>
			<Boolean>false</Boolean>
		</entry>
	</serializableOrderedMap>
</serialized>
so maybe setting that scenarios.load.from.project to true might help.
But this will mean scenarios will be saved directly in the project ".xpr" file.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gerardch
Posts: 11
Joined: Mon Sep 14, 2020 6:43 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by gerardch »

Hi Radu,

I tried what you recommended and I did a test using "scenarios.load.from.project" to "true" but it did not work.
Transformation scenarios kept saving as a Global option.

So just to confirm that there is no way to import scenarios as a Project option. At least not using the API I mean.
It is not a problem, I'll just adjust the logic of my program to use Global option only.

Now I just want to confirm the following behavior using method "importGlobalOptions". When I use this method
to import new transformation scenarios but there are already other existing scenarios then all of these are completely
deleted. Only the ones in the import file are kept.
So everytime I import new global scenarios then I lost any existing ones. Is this valid behavior for this method?
Is there any way to keep existing scenarios when importing new scenarios?

Thanks,
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by Radu »

Hi,

Indeed our preferences key "scenarios" has a list of transformation scenarios associated to it. When you import scenarios for that key, the previous list is overwritten, so the imported scenarios are not merged with the existing scenarios for that key. I'm afraid we do not have an API for merging values for a certain imported key.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gerardch
Posts: 11
Joined: Mon Sep 14, 2020 6:43 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by gerardch »

Hi Radu,

this is only informative. It seems that it is possible indeed to import scenarios and select the storage option with entry key "scenarios.load.from.project".
This does not work for me when I set this in the xml file with all the scenarios to import.
However, it seems it works fine if it's set with method "setGlobalObjectProperty("scenarios.load.from.project", true/false)".
I hope this is okay.

Regards,
Radu
Posts: 8992
Joined: Fri Jul 09, 2004 5:18 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by Radu »

Hi,

This might have to do with the order in which the keys are set, when the XML is imported, keys are set in the order in which they appear in the XML doc. But when you call "setGlobalObjectProperty", you call it after the scenarios were imported.
What you are doing is not something very common among integrators, our users usually define scenarios at framework level or define them in a project and then switch among projects in the Project view.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
gerardch
Posts: 11
Joined: Mon Sep 14, 2020 6:43 pm

Re: Is there a method to import transformation scenarios setting the storage option?

Post by gerardch »

Hi Radu,

this is good to know, it is useful information. Thank you very much.

Regards,
Post Reply