Page 1 of 1

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

Posted: Wed Jun 09, 2021 8:39 pm
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!

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

Posted: Thu Jun 10, 2021 7:42 am
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

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

Posted: Thu Jun 10, 2021 8:22 pm
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,

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

Posted: Mon Jun 14, 2021 2:19 pm
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

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

Posted: Fri Jun 25, 2021 1:55 am
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,

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

Posted: Mon Jun 28, 2021 11:17 am
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

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

Posted: Thu Jul 01, 2021 7:50 pm
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,

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

Posted: Fri Jul 02, 2021 6:48 am
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

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

Posted: Fri Jul 09, 2021 5:52 am
by gerardch
Hi Radu,

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

Regards,