Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Papyrus for Real Time » Import RSA-RTE
Import RSA-RTE [message #1781427] Wed, 07 February 2018 09:23 Go to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hello,

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


After that, I tried to follow https://wiki.eclipse.org/Papyrus-RT/Developer/Developer_Guide/DevEnv tutorial with a hope that I will be able to find all sources of the RSA-RTE model import, but again I got stuck because of the problem that described here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=526168.

Is this https://git.eclipse.org/r/papyrus-rt/org.eclipse.papyrus-rt repository correct? Does it contain all the source code of PapyrusRT? May be somebody can give me a direction where is the entry point of the RSA model import?
Re: Import RSA-RTE [message #1781532 is a reply to message #1781427] Thu, 08 February 2018 08:57 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Basically, what I want is read .emx model file and then work with the read data.
Re: Import RSA-RTE [message #1781560 is a reply to message #1781532] Thu, 08 February 2018 15:16 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Found where to start:
<extension
point="org.eclipse.ui.commands">
<command
defaultHandler="org.eclipse.papyrus.interoperability.rsa.handler.ImportHandler"
id="org.eclipse.papyrus.interoperability.rsa.import"
name="Import RSA Model/Profile">
</command>
</extension>

Everything that I need is in interoperability module.
Re: Import RSA-RTE [message #1781730 is a reply to message #1781560] Mon, 12 February 2018 16:10 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
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)?

[Updated on: Mon, 12 February 2018 16:15]

Report message to a moderator

Re: Import RSA-RTE [message #1781879 is a reply to message #1781730] Wed, 14 February 2018 08:55 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Ernesto,

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?
Re: Import RSA-RTE [message #1781917 is a reply to message #1781879] Wed, 14 February 2018 15:49 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Another question - does the import take into account RSA-RTE model dependencies that are specified in transformation configuration file in RSA-RTE, dependencies of the dependencies and so on?

[Updated on: Wed, 14 February 2018 15:59]

Report message to a moderator

Re: Import RSA-RTE [message #1781922 is a reply to message #1781879] Wed, 14 February 2018 16:13 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
You can get the source by cloning the git repo: http://git.eclipse.org/gitroot/papyrus-rt/org.eclipse.papyrus-rt.git. The releases/1.0.0 tag points to the commit that matches the code of the official 1.0 release, and the HEAD and master branch are currently pointing at that.

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.



Re: Import RSA-RTE [message #1781923 is a reply to message #1781917] Wed, 14 February 2018 16:28 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
No, Papyrus-RT does not yet implement transformation configurations (although it's in the roadmap) so all the information there would be lost on import.
Re: Import RSA-RTE [message #1782049 is a reply to message #1781923] Fri, 16 February 2018 13:28 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
My plan right now is to try to reproduce .emx model file reading in order to have java object with the file content. For now I am trying to do:
ContentHandler.Registry.INSTANCE.put(2000,new PlatformContentHandlerImpl());
        List<ContentHandler> contentHandlerList = ContentHandler.Registry.INSTANCE.contentHandlers();
        MigrationResourceSet resourceSet = new MigrationResourceSetImpl(null);
        synchronized (UMLUtil.class) {
            UMLUtil.init(resourceSet);
        }
        resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_ATTACHMENT, true);
        resourceSet.getLoadOptions().put(XMLResource.OPTION_DEFER_IDREF_RESOLUTION, true);
        resourceSet.getLoadOptions().put(XMLResource.OPTION_RECORD_UNKNOWN_FEATURE, Boolean.TRUE);
        resourceSet.getLoadOptions().put(XMLResource.OPTION_USE_PACKAGE_NS_URI_AS_LOCATION, Boolean.FALSE);
        try {
            resourceSet.getResource(modelFileURI, true);
        } catch (Exception ex) {
            ex.printStackTrace(System.out);
        }


But the problem is that even file reading is so dependent on Eclipse platform. As far as I understand, Papyrus-RT takes the input file, creates a new project and puts the file into the project: https://i.imgur.com/VKLUr4K.png

So, I found the place org.eclipse.emf.ecore.resource.impl.PlatformContentHandlerImpl:
  */
  @Override
  public Map<String, Object> contentDescription(URI uri, InputStream inputStream, Map<?, ?> options, Map<Object, Object> context) throws IOException
  {
    IContentDescription contentDescription;
    try
    {
      if (uri.isPlatformResource() && PlatformResourceURIHandlerImpl.workspaceRoot != null)
      {
        contentDescription = PlatformResourceURIHandlerImpl.WorkbenchHelper.getContentDescription(uri.toPlatformString(true), options);
      }
      else
      {
        contentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, uri.lastSegment(), IContentDescription.ALL);
      }
    }
    catch (Throwable exception)
    {
      return super.contentDescription(uri, inputStream, options, context);
    }


Papyrus-RT goes to this way:
contentDescription = PlatformResourceURIHandlerImpl.WorkbenchHelper.getContentDescription(uri.toPlatformString(true), options);

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:
contentDescription = Platform.getContentTypeManager().getDescriptionFor(inputStream, uri.lastSegment(), IContentDescription.ALL);
And here I get NPE during Platform.getContentTypeManager() call. I assume it happens because I execute this method not in the Eclipse platform context. In the org.eclipse.core.runtime.Platform.class:
public static IContentTypeManager getContentTypeManager() {
        return InternalPlatform.getDefault().getContentTypeManager(); // here I get null from InternalPlatform.getDefault()
    }

Is there a workaround? Or may be I am doing something wrong. What I want is just to have some ResourceSet or whatever so I can access any element from the file.

[Updated on: Tue, 20 February 2018 09:06]

Report message to a moderator

Re: Import RSA-RTE [message #1782060 is a reply to message #1782049] Fri, 16 February 2018 16:15 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Is the code you are quoting from Papyrus-RT or from Papyrus?

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.

[Updated on: Fri, 16 February 2018 16:23]

Report message to a moderator

Re: Import RSA-RTE [message #1782347 is a reply to message #1782060] Thu, 22 February 2018 09:32 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Ernesto,

I added package and class names to the previous post. Following your advice I asked for help in the Papyrus forum
Re: Import RSA-RTE [message #1784217 is a reply to message #1782347] Fri, 23 March 2018 15:59 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
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:
UMLRTPackage umlrtPackage = UMLRTFactory.createPackage((Package) resource.getContents().get(0));


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:
static final FacadeType<Package, EObject, UMLRTPackageImpl> TYPE = new FacadeType<>(
			UMLRTPackageImpl.class,
			UMLPackage.Literals.PACKAGE,
			NO_STEREOTYPE,
			UMLRTPackageImpl::getInstance,
			null,
			UMLRTPackageImpl::maybeCreate);

public static UMLRTPackageImpl getInstance(Package package_) {
		return getFacade(package_, TYPE);
	}

org.eclipse.papyrusrt.umlrt.uml.internal.facade.impl.FacadeObjectImpl
static <T extends Element, U extends EObject, F extends FacadeObjectImpl> //
	F getFacade(T element, FacadeType<T, U, F> type) {
		BasicFacadeAdapter<? extends FacadeObjectImpl> adapter = null;

		if (element != null) {
			adapter = type.getAdapter(element);
			if (adapter == null) {
				adapter = type.createAdapter(element);
			}
		}

		return (adapter == null) ? null : type.getFacade(adapter);
	}

In both cases adapter = type.getAdapter(element); and adapter = type.createAdapter(element) adapter is null.
What am I missing?

The package that I am sending as a parameter looks like this:
https://i.imgur.com/37R5DJn.png


In addition, just in case I call the following util methods before getting resource:
org.eclipse.papyrusrt.umlrt.uml.util
UMLRTResourcesUtil.init(resourceSet);
        UMLRTResourcesUtil.initLocalRegistries(resourceSet);



Re: Import RSA-RTE [message #1784218 is a reply to message #1784217] Fri, 23 March 2018 16:16 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
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?


Re: Import RSA-RTE [message #1784279 is a reply to message #1784218] Mon, 26 March 2018 08:18 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
Hi Ernesto,

Thank you for your reply.

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:
https://i.imgur.com/wAHjhol.png

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:
https://i.imgur.com/bt59O9W.png

Regards,
Dmitrii
  • Attachment: PingPong.emx
    (Size: 59.64KB, Downloaded 167 times)

[Updated on: Mon, 26 March 2018 08:21]

Report message to a moderator

Re: Import RSA-RTE [message #1784314 is a reply to message #1784279] Mon, 26 March 2018 16:04 Go to previous messageGo to next message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
Ok, from your screenshot (looks like IntelliJ IDEA?) it seems that UMLRT is in the package registry, which is that you get by initializing your resource set with

UMLRTResourcesUtil.init(resourceSet); UMLRTResourcesUtil.initLocalRegistries(resourceSet);


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.

[Updated on: Mon, 26 March 2018 16:05]

Report message to a moderator

Re: Import RSA-RTE [message #1784348 is a reply to message #1784314] Tue, 27 March 2018 07:27 Go to previous messageGo to next message
Dmitrii Nikeshkin is currently offline Dmitrii NikeshkinFriend
Messages: 28
Registered: February 2018
Junior Member
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?
  • Attachment: PingPong.uml
    (Size: 17.66KB, Downloaded 231 times)
Re: Import RSA-RTE [message #1784399 is a reply to message #1784348] Tue, 27 March 2018 15:44 Go to previous message
Ernesto Posse is currently offline Ernesto PosseFriend
Messages: 438
Registered: March 2011
Senior Member
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).

I hope this helps.
Previous Topic:Layout issue
Next Topic:Synchronous send() in UML-RT/Papyrus-RT
Goto Forum:
  


Current Time: Thu Mar 28 14:21:04 GMT 2024

Powered by FUDForum. Page generated in 0.08265 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top