Template returns "invalid" after switching from "Acceleo Plug-in Application" to [message #1782558] |
Mon, 26 February 2018 13:16 |
Frank Poppen Messages: 21 Registered: February 2018 |
Junior Member |
|
|
What I want to do:
===================
I'm working with a SysML Model. I want to find all "Requirements" that are part of my "SysML" model and check what "Block" should fulfill the requirement. The following Acceleo template code does mainly do what I need (as a test case):
[for (aRequirement : Requirement | collectionOfAllRequirements())]
aRequirement: [aRequirement/]
aRequirement.satisfiedBy: [aRequirement.satisfiedBy/]
[for (satisfyingBlock : NamedElement | aRequirement.satisfiedBy)]
satisfyingBlock.name: [satisfyingBlock.name/]
[/for]
[/for]
The resulting output is is:
aRequirement: org.eclipse.papyrus.sysml14.requirements.RequirementCustomImpl@1f65433a (id: CONTRACT_System, text:
A: Input occurs every 33ms with jitter 5ms.
G: Reaction(Input,Output) within [0,33]ms.)
aRequirement.satisfiedBy: org.eclipse.uml2.uml.internal.impl.ClassImpl@4f33c0de (name: BLOCK_System, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
satisfyingBlock.name: BLOCK_System
Which is correct: I have a requirement named "CONTRACT_System" which is to be fulfilled by the block "BLOCK_System"
PROBLEM:
=========
Due to the issue https://www.eclipse.org/forums/index.php/t/1091816/ I learned that I should no longer use the "Acceleo Plug-in Application" and I switched to "Java Application". With this the same code now generates an invalid return:
aRequirement: org.eclipse.papyrus.sysml14.requirements.internal.impl.RequirementImpl@2f9a01c1 (id: CONTRACT_System, text:
A: Input occurs every 33ms with jitter 5ms.
G: Reaction(Input,Output) within [0,33]ms.)
aRequirement.satisfiedBy: invalid
With the "invalid" of course I get messages like: "Invalid loop iteration at line 41 in Module moduleBlock for block for (aRequirement.satisfiedBy)"
QUESTION:
==========
How come that "[aRequirement.satisfiedBy/]" suddenly becomes invalid when I change the runtime environment? Something else that needs to be done when switching from "Acceleo Plug-in Application" to "Java Application"? What are the difference between the two?
|
|
|
|
Re: Template returns "invalid" after switching from "Acceleo Plug-in Application& [message #1782571 is a reply to message #1782559] |
Mon, 26 February 2018 15:06 |
Frank Poppen Messages: 21 Registered: February 2018 |
Junior Member |
|
|
I'm not sure, if the last answer involved all of the situation I described above. But I'm also very new to all of this. So let me rephrase.
The template works with "Acceleo Plug-in Application"
The template does NOT work with "Java Application"
I created another test as follows:
[aRequirement.base_Class.name/].derived : [aRequirement.derived/]
[aRequirement.base_Class.name/].derivedFrom : [aRequirement.derivedFrom/]
[aRequirement.base_Class.name/].id : [aRequirement.id/]
[aRequirement.base_Class.name/].master : [aRequirement.master/]
[aRequirement.base_Class.name/].refinedBy : [aRequirement.refinedBy/]
[aRequirement.base_Class.name/].satisfiedBy : [aRequirement.satisfiedBy/]
[aRequirement.base_Class.name/].text : [aRequirement.text/]
[aRequirement.base_Class.name/].tracedTo : [aRequirement.tracedTo/]
[aRequirement.base_Class.name/].verifiedBy : [aRequirement.verifiedBy/]
The result that returns with "Acceleo Plug-in Application" is:
CONTRACT_System.derived :
CONTRACT_System.derivedFrom :
CONTRACT_System.id : CONTRACT_System
CONTRACT_System.master :
CONTRACT_System.refinedBy :
CONTRACT_System.satisfiedBy : org.eclipse.uml2.uml.internal.impl.ClassImpl@36f40ddf (name: BLOCK_System, visibility: <unset>) (isLeaf: false, isAbstract: false, isFinalSpecialization: false) (isActive: false)
CONTRACT_System.text :
A: Input occurs every 33ms with jitter 5ms.
G: Reaction(Input,Output) within [0,33]ms.
CONTRACT_System.tracedTo :
CONTRACT_System.verifiedBy :
If I change the configuration to "Java Application" (and change nothing else) I get:
CONTRACT_System.derived : invalid
CONTRACT_System.derivedFrom : invalid
CONTRACT_System.id : CONTRACT_System
CONTRACT_System.master : invalid
CONTRACT_System.refinedBy : invalid
CONTRACT_System.satisfiedBy : invalid
CONTRACT_System.text :
A: Input occurs every 33ms with jitter 5ms.
G: Reaction(Input,Output) within [0,33]ms.
CONTRACT_System.tracedTo : invalid
CONTRACT_System.verifiedBy : invalid
What else besides switching the configuration to "Java Application" has to be configured to make this work (again)?
Especially: "CONTRACT_System.id" and "CONTRACT_System.text " are working for both cases. So after change, the template is not broken completely. What is the difference between the call to ".id" and ".satisfiedBy"? (The first working, the second not working.)
[Updated on: Mon, 26 February 2018 15:09] Report message to a moderator
|
|
|
|
Re: Template returns "invalid" after switching from "Acceleo Plug-in Application& [message #1782635 is a reply to message #1782572] |
Tue, 27 February 2018 10:00 |
|
Hello Frank,
"Acceleo plug-in application" was trying to run your generator in the context of your current eclipse.
"Acceleo Java application" is running your generator in standalone.
What this means is that for the second, you have to be careful to properly register all required packages and profiles. In your case, I'll wager you're missing the registration for SysML.
Please check that the "registerResourceFactories" method in your generated launcher has the line "UMLResourcesUtil.init(resourceSet)" so that everything from the UML side is properly registered.
As for SysML, there is no "all-in-one" utility method to properly set it up as far as I recall. You should raise a bug against Papyrus so that they provide a "SysMLResourcesUtil.init(...)" that will take care of registrations as the UMLResourcesUtil does for UML.
At the very least, you will need the following, hopefully I'm not forgetting too many:
resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
uriMap.put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
uriMap.put(URI.createURI(SysmlResource.PROFILES_PATHMAP), uri.appendSegment("model").appendSegment(""));
Laurent Goubet
Obeo
|
|
|
|
|
Re: Template returns "invalid" after switching from "Acceleo Plug-in Application& [message #1782709 is a reply to message #1782638] |
Wed, 28 February 2018 08:16 |
Frank Poppen Messages: 21 Registered: February 2018 |
Junior Member |
|
|
Update:
=================
We were working on this quite some time yesterday, but did not find the solution yet. Today I will (have to) with a debugger step through the working runtime and in parallel through the not working runtime, to figure out what the difference is. Hope I find something.
What I understand:
===================
In the meantime I got it, that we are not only talking about compiling/linking but also the execution where things have to be registered in a factory. Laurent Goubet answer gave me a good inside into this, but the Acceleo generated code already seems to contain all of this:
public void registerPackages(ResourceSet resourceSet) {
super.registerPackages(resourceSet);
if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.sysmlPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.sysmlPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.sysmlPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.activities.ActivitiesPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.activities.ActivitiesPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.activities.ActivitiesPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.allocations.AllocationsPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.allocations.AllocationsPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.allocations.AllocationsPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.blocks.BlocksPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.blocks.BlocksPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.blocks.BlocksPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.constraintblocks.ConstraintblocksPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.constraintblocks.ConstraintblocksPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.constraintblocks.ConstraintblocksPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.deprecatedelements.DeprecatedelementsPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.deprecatedelements.DeprecatedelementsPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.deprecatedelements.DeprecatedelementsPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.portsandflows.PortsandflowsPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.portsandflows.PortsandflowsPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.portsandflows.PortsandflowsPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.modelelements.ModelelementsPackage.eINSTANCE);
}
if (!isInWorkspace(org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.class)) {
resourceSet.getPackageRegistry().put(org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.eINSTANCE.getNsURI(), org.eclipse.papyrus.sysml14.requirements.RequirementsPackage.eINSTANCE);
}
Never the less I added also to "registerResourceFactories" the following (which, too, did not do the trick):
resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(sysmlPackage.eNS_URI, sysmlPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(ActivitiesPackage.eNS_URI, ActivitiesPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(AllocationsPackage.eNS_URI, AllocationsPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(ConstraintblocksPackage.eNS_URI, ConstraintblocksPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(DeprecatedelementsPackage.eNS_URI, DeprecatedelementsPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(PortsandflowsPackage.eNS_URI, PortsandflowsPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(ModelelementsPackage.eNS_URI, ModelelementsPackage.eINSTANCE );
resourceSet.getPackageRegistry().put(RequirementsPackage.eNS_URI, RequirementsPackage.eINSTANCE );
Unless I don't receive further ideas, like I wrote, I will have to step through the code to figure this out.
=====================================================================================
IMPORTANT QUESTION: Is Accello mature enough to be used in a productive environment?
=====================================================================================
(Created a new Issue on this: https://www.eclipse.org/forums/index.php/m/1782710/#msg_1782710)
[Updated on: Wed, 28 February 2018 08:22] Report message to a moderator
|
|
|
|
Re: Template returns "invalid" after switching from "Acceleo Plug-in Application& [message #1782771 is a reply to message #1782711] |
Thu, 01 March 2018 08:58 |
|
Frank,
You shouldn't be doing any registration for UML. As I mentionned above, everything from UML will be (and should be) handled through UMLResourcesUtil.init(resourceSet). You do not want to do anything else than that.
The problem is papyrus and what should be registered to use its metamodels and profiles in standalone. You are not registering any of its profiles, so that will be something that cannot work on your generation. See my previous message for the minimum you need, knowing that there might be a few things missing from this that you should ask to the papyrus team either through their forum or the bugzilla:
resourceSet.getPackageRegistry().put(SysmlPackage.eNS_URI, SysmlPackage.eINSTANCE);
resourceSet.getPackageRegistry().put(BlocksPackage.eNS_URI, BlocksPackage.eINSTANCE);
uri = URI.createURI("platform:/plugin/org.eclipse.papyrus.sysml14");
resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysMLResource.LIBRARIES_PATHMAP), uri.appendSegment("libraries").appendSegment(""));
resourceSet.getURIConverter().getURIMap().put(URI.createURI(SysmlResource.PROFILES_PATHMAP), uri.appendSegment("model").appendSegment(""));
Laurent Goubet
Obeo
|
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04987 seconds