I am interested on how import of the RSA-RTE emx models is implemented.
I tried to clone a repository that is specified here: https://wiki.eclipse.org/Papyrus-RT/Developer/Developer_Guide/Git_Repository, but seems like described repository layout does not relate to the real one. I found some classes that I can use at org.eclipse.papyrus-rt\plugins\umlrt\migration\org.eclipse.papyrusrt.umlrt.migration.rsa\src-gen\org\eclipse\papyrusrt\umlrt\tooling\rsa\umlrt but I could not find where these classes are used. After reading README file at the root folder I was thinking "May be I should build the project first and all the source code and dependencies will be downloaded automatically", unfortunately this way also failed due to this error:

FO] Fetching p2.index from http://download.eclipse.org/releases/oxygen/201710111001/
[INFO] Fetching p2.index from http://download.eclipse.org/releases/oxygen/201710111001/
[INFO] Fetching content.xml.xz from http://download.eclipse.org/releases/oxygen/201710111001/ (852,46kB)
[INFO] Fetching content.xml.xz from http://download.eclipse.org/releases/oxygen/201710111001/ (852,46kB)
[ERROR] Failed to resolve target definition C:\GIT\org.eclipse.papyrus-rt\org.eclipse.papyrusrt.targetplatform\papyrusrelease\org.eclipse.papyrusrt.targetplatform.papyrus\org.eclipse.papyrusrt.targetplatform.papyrus.target: Could not find "org.eclipse.equinox.executable.feature.group/3.7.0.v20170531-1133" in the repositories of the current location -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] cwiki.apache.org/confluence/display/MAVEN/MavenExecutionException

Hi. Yes, model migration is handled by the "interoperability" component, more precisely by the "org.eclipse.papyrusrt.umlrt.migration.rsa" plugin. It uses QVTo to perform the transformation and some of the underlying Papyrus interoperability bundles, more precisely "org.eclipse.papyrus.interoperability.rsa".

Unfortunately the build is broken right now due to some plugins that were backported in the Papyrus repo from their master branch to the Oxygen maintenance branch which is used by Papyrus-RT.

We are working trying to fix it, but unfortunately we don't know when it is going to be done. I'll post a message in the forum when the build is fixed.

Can I ask if this is for an academic project or a commercial project (or something else)?

Thanks for your reply. I think this project is kind of both. I am doing my graduational project at the university but for a particular company. So, the assignment was given by this company.

I managed to debug the import, but the problem is that the latest source code is not aligned with the stable Papyrus RT release. How can I get source code for the Papyrus RT that is available for download from the website?

If you are looking for the source of Papyrus itself (rather than Papyrus-RT), clone the repo at http://git.eclipse.org/gitroot/papyrus/org.eclipse.papyrus.git and checkout the streams/3.0-maintenance branch, but unfortunately, I don't know what exactly is the commit that corresponds to the snapshot used when we built the 1.0 release of Papyrus-RT. I think it was commit a344ab568fddf2c2521810d9bba5a1ea87a7c20a, but I'm not 100% certain.

The problem is that, as I mentioned earlier, the Papyrus-RT build is currently broken because of some inconsistencies introduced by Papyrus in their streams/3.0-maintenance branch since the Papyrus-RT release, so you won't be able to build, and unfortunately the fix is not trivial, which means it will take some time.

Sorry I don't have a better answer for you right now. But of course, you can try to get it to compile in your environment if you get the right versions of all the required dependencies, but that is not trivial either.

because uri that is passed to this method is already a platform resourse (the file was already copied to the created project). In my case (I am developing standalone console application) it goes another way:

Papyrus-RT doesn't have it's own way of loading models. It relies on Papyrus for that.

I'm not personally familiar with RSA's .emx format, but if it's EMF based, I don't see why there would be a problem loading with standard EMF resource loading.

It looks to me that the problem is not really loading per se, but the fact that you are developing a standalone application. In a standalone application, calls to methods from Platform will fail because Eclipse is not running, and therefore you will get NPEs.

I think you have two options:

1) make your application a 'headless' Eclipse application, i.e. you run Eclipse, but without a GUI, or

2) a really standalone application, which is what you seem to be doing.

With option 1, if you need to use Papyrus services, you may have to start those services yourself. This option obviously yields a slower program, at least for startup.

For option 2, you may want to look at the org.eclipse.papyrusrt.codegen.standalone plugin, more concretely at the StandaloneUMLRTCodeGenerator class, for an example on how to load models in a standalone application.

For questions about the internals of loading the models, and .emx models in particular, you could ask in the Papyrus forum.

I successfully read the .emx file from the standalone application. Also, I can read elements and get attributes. But for now I faced a new problem - I want nicely get elements from the resource that I just read. For instance, I want to say <packageObject>.getProtocols(). I found an implementation of org.eclipse.papyrusrt.umlrt.uml.UMLRTPackage that provides such a method, but when I am trying to initialize UMLRTPackage object I get null:

Seems like I am missing some configuration. Java doc. for UMLRTFactory.createPackage method says:

/**
* Creates a package façade.
*
* @param package_
* a package
* @return its façade, or {@code null} if the {@code package_} is not a valid package,
* for example if it is a protocol container or does not have or inherit an application
* of the UML-RT profile
*/

If I follow the chain of calls in debugger it tries to get some adapter for the package that I am sending as a parameter
org.eclipse.papyrusrt.umlrt.uml.internal.facade.impl.UMLRTPackageImpl:

It looks like you've found the right API for accessing UML-RT model elements. This is the so-called UML-RT "façade", which provides a UML-RT interface to UML model elements. It is in the org.eclipse.papyrusrt.umlrt.uml plugin, as you've found out. However, for the façade to work, the UML-RT profile must be loaded and registered, and the profile is applied to the model being examined.

So you are doing this in a stand-alone application, rather than within a running Papyrus environment. Is that right?

Are you sure the UML-RT profile is applied to the model that you are trying to examine?

Also, just to confirm, the original model is an RSA-RTE model, not just a plain RSA model? And to import it, are you using the Papyrus importer, or the Papyrus-RT importer?

Yes, I'm developing stand-alone application.
"Are you sure the UML-RT profile is applied to the model that you are trying to examine?" - First of all, I tried to import the model to Papyrus-RT and it worked, on the following screenshot you can see what import I use and what result I get in a model explorer:

Yes, it is RSA-RTE model, build by myself in RSA-RTE, I followed the PingPong tutorial just and for test sake I took this model.

"the UML-RT profile must be loaded and registered, and the profile is applied to the model being examined" - I use UMLRTResourcesUtil.init(resourceSet); UMLRTResourcesUtil.initLocalRegistries(resourceSet); and I assume that profile is loaded correctly. Where can I check it? May be in some registry?

Just in case in the attachment you can find the model that I am using.

This is how PackageRegistries look like in my resourceSet after initialization:

So that part seems OK. But this doesn't tell me whether the model itself has the profile applied. If the model doesn't have the profile applies, the the façade methods will not provide the expected behaviour.

Also, it's not clear to me whether you are doing the import from an RSA-RTE model to a Papyrus-RT model in your standalone application, or you imported it manually in Papyrus-RT and then your stand-alone application loads the transformed model.

I developing stand-alone application that reads RSA-RTE models and does some actions with it. In order to do so, I am trying to reuse Papyrus-RT way of importing but in stand-alone application. I use Papyrus-RT as something to compare with.

It seems that UMLRT profile is not applied to the model. Perhaps, I need to do some transformations before using the façade methods or I can implement them by myself or something similar to them.

After importing my model to Papyrus-RT I get the .uml file which has UMRT profile applied (see attachment). So, in order to apply this profile in stand-alone application what do I need to do?

I'm still unclear about one thing: when you say you import from RSA-RTE to Papyrus-RT, are you doing this manually, running Papyrus-RT, or are you doing this programmatically in your stand-alone application, using the org.eclipse.papyrusrt.umlrt.migration.rsa plugin? That plugin ensures that the UML-RT profile is applied to the resulting model. However, I do not know if it works on stand-alone, or how to invoke it from stand-alone. It uses the Papyrus infrastructure for importing, and I don't know if that could be invoked in stand-alone.

Nevertheless, assuming that somehow you managed to execute the import in your stand-alone application, or that the input to your stand-alone application is a .uml file with the UML-RT profile applied, then something that might help is to use the ExternalPackageManager from the org.eclipse.papyrusrt.xtumlrt.external plugin. This is specially useful in stand-alone. For an example on how to use it, take a look at org.eclipse.papyrusrt.codegen.cpp.AbstractUMLRT2CppCodeGenerator.setupExternalPackageManagement(ResourceSet). The ExternalPackageManager automatically finds and registers the UML-RT profiles and RTS library.

After you have executed the setup method of the ExternalPackageManager, you can load the model, and if this has the profile applications, the loaded model will have the profile and stereotype applications as well, and you'll be able to use the façade methods. See org.eclipse.papyrusrt.codegen.standalone.StandaloneUMLRTCodeGenerator.

Note that the ExternalPackageManager has a flag that tells it whether you are using in stand-alone mode or not, and a corresponding setter: setStandalone(boolean standalone).

This ExternalPackageManager has a list of required packages (no need to explicitly add the UML-RT profiles and the RTS library because they are included by default). It tries to resolve the required packages in the current resource set, and if it cannot find them there, it uses an instance of the PluginFinder class (which you can find in the same plugin) to locate them. This PluginFinder scans several "root" search paths for the packages. The "root" search paths are the paths in the Java class path, as well as any paths registered with org.eclipse.papyrusrt.xtumlrt.external.PluginFinder.addSearchPaths(String). It will search them in those paths up-tp a folder depth of 2, I think, and the package can be in a jar file or a normal folder. So normally you would add the path to the 'plugins' folder of your Papyrus-RT installation to this list of search paths, so it will find the profiles and library.

If you are doing the import programatically, then you should execute the import after the profile registration (with the ExternalPackageManager), because the import also assumes that the UML-RT profile is registered. Otherwise the import won't work. I'm not sure what the exact effect would be, but it would result in a model without the profile (if it succeeds at all).