Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » Problems integrating a workflow in a plugin
Problems integrating a workflow in a plugin [message #650363] Mon, 24 January 2011 16:04 Go to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello,

I decided to open a new thread besides the other "Problems integrating" thread since I have a different problem.

So as an overview: I have a plugin that contributes a command to an Eclipse popup. With this command you can generate code out of a selected UML file.

I already got rid of the error "Missing required plugin 'org.eclipse.uml2.uml.resources' in classpath" described in here and the problem that no logs are sent to the host eclipse if you run the plugin as an eclipse app with this workaround. And now, which isn't surpring to me anymore, I am stuck again Smile

So I managed to let the workflow run in plugin's context and I am seeing its log. This is the workflow:

<?xml version="1.0"?>
<workflow>    
    
    <!-- Set Mappings -->
    <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="Workspace">
    </bean>
    
    <!-- Set Properties -->
    <property name="fileEncoding" value="ISO-8859-1"/>
    
    <!-- Set UML environment -->
    <bean class="org.eclipse.xtend.typesystem.uml2.Setup" standardUML2Setup="true" />
    
    <bean id="UMLMetaModel" 
        class="org.eclipse.xtend.typesystem.uml2.UML2MetaModel">
    </bean>

    <bean id="AnsiCProfile" 
        class="org.eclipse.xtend.typesystem.uml2.profile.ProfileMetaModel">
        <profile value="${ansicextension_uri}"/>
    </bean>
    
    <!-- Read in the model -->
    <component class="org.eclipse.emf.mwe.utils.Reader">
        <modelSlot value="model"/>
        <uri value="${model_uri}"/>
    </component>

    <!-- check model -->
    <component class="org.eclipse.xtend.check.CheckComponent">
        <metaModel idRef="AnsiCProfile"/>              
        <metaModel idRef="UMLMetaModel"/>
        <checkFile value="sc::viper::uml2::codegen::uml22ansic::transformation::generic::UML2ModelCheck" />
        <emfAllChildrenSlot value="model" />
    </component>
    
    <!-- Model-2-Model transformation -->
    <component class="org.eclipse.xtend.XtendComponent">
        <metaModel idRef="AnsiCProfile"/>  
               
        <metaModel idRef="UMLMetaModel"/>
        
        <metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
            <metaModelFile value="${mmANSIC_uri}"/>
        </metaModel>
        
        <globalVarDef name="includesDir" value="'Includes'"/>
        <globalVarDef name="sourcesDir" value="'Sources'"/>
        
        <invoke value="sc::viper::uml2::codegen::uml22ansic::transformation::generic::UMLModel::createModel(model)"/>
        <outputSlot value="model"/>
    </component> 

    <!-- Write the model -->
    <component class="org.eclipse.emf.mwe.utils.Writer">
        <modelSlot value="model"/>
        <uri value="${dump_file_uri}"/>
    </component> 

    <!-- check model -->
    <component class="org.eclipse.xtend.check.CheckComponent">
        <metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
            <metaModelFile value="${mmANSIC_uri}"/>
        </metaModel>
        <checkFile value="sc::viper::uml2::codegen::uml22ansic::generation::generic::AnsiCModelCheck" />
        <emfAllChildrenSlot value="model" />
    </component>
    
    <!-- Generate code -->
    <component id="generator" class="org.eclipse.xpand2.Generator" skipOnErrors="true">
        <metaModel class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
            <metaModelFile value="${mmANSIC_uri}"/>
        </metaModel>
        
        <globalVarDef name="includesDir" value="'Includes'"/>
        <globalVarDef name="sourcesDir" value="'Sources'"/>
        
        <expand value="sc::viper::uml2::codegen::uml22ansic::generation::generic::Model::E FOR model"/>
        <fileEncoding value="ISO-8859-1"/>
        <outlet path="${src_gen_folder}" />
        <resourceManager class ="org.eclipse.xtend.expression.ResourceManagerDefaultImpl">
            <fileEncoding value="ISO-8859-1"/>
        </resourceManager>
        <prSrcPaths value="${src_gen_folder}"/>
        <prDefaultExcludes value="true"/>
        <prExcludes value="*.xml"/>
    </component>
    
</workflow>


Running this workflow through the plugin ends up in this log output:
[INFO] WorkflowRunner - [my log] --------------------------------------------------------------------------------------
[INFO] WorkflowRunner - [my log] EMF Modeling Workflow Engine Development-Snapshot
[INFO] WorkflowRunner - [my log] (c) 2005-2009 openarchitectureware.org and contributors
[INFO] WorkflowRunner - [my log] --------------------------------------------------------------------------------------
[INFO] WorkflowRunner - [my log] running workflow: file:/C:/Programme/Eclipse_Modeling/Workspace/dev.fs.test/workflow/main.mwe
[INFO] WorkflowRunner - [my log] 
[DEBUG] WorkflowRunner - [my log] Params:{...}
[DEBUG] CompositeComponent - [my log] Checking configuration of: Reader: Loading model from platform:/plugin/dev.fs.test/model/fs.uml
[DEBUG] CompositeComponent - [my log] Checking configuration of: CheckComponent: slot model check file(s): sc::viper::uml2::codegen::uml22ansic::transformation::generic::UML2ModelCheck 
[DEBUG] CompositeComponent - [my log] Checking configuration of: XtendComponent: executing 'sc::viper::uml2::codegen::uml22ansic::transformation::generic::UMLModel'
[DEBUG] CompositeComponent - [my log] Checking configuration of: Writer: Writing model to platform:/plugin/dev.fs.test/model/eclipse.ecore
[DEBUG] CompositeComponent - [my log] Checking configuration of: CheckComponent: slot model check file(s): sc::viper::uml2::codegen::uml22ansic::generation::generic::AnsiCModelCheck 
[DEBUG] CompositeComponent - [my log] Checking configuration of: Generator(generator): generating 'sc::viper::uml2::codegen::uml22ansic::generation::generic::Model::E FOR model' => C:/Programme/Eclipse_Modeling/Workspace/test/Sources/
[ERROR] WorkflowRunner - [my log] [ERROR]: Property 'invoke' not specified properly. AbstractExtension file 'sc::viper::uml2::codegen::uml22ansic::transformation::generic::UMLModel' not found.(Element: -UNKNOWN-; Reported by: -UNKNOWN-)
[ERROR] WorkflowRunner - [my log] Workflow interrupted because of configuration errors.

If I run the same workflow in a workspace project everything works and nice code is generated.

If I want to debug a little bit and cut the workflow till the first CheckComponent, then following log output is given:

[INFO] WorkflowRunner - [my log] --------------------------------------------------------------------------------------
[INFO] WorkflowRunner - [my log] EMF Modeling Workflow Engine Development-Snapshot
[INFO] WorkflowRunner - [my log] (c) 2005-2009 openarchitectureware.org and contributors
[INFO] WorkflowRunner - [my log] --------------------------------------------------------------------------------------
[INFO] WorkflowRunner - [my log] running workflow: file:/C:/Programme/Eclipse_Modeling/Workspace/dev.fs.test/workflow/main.mwe
[INFO] WorkflowRunner - [my log] 
[DEBUG] WorkflowRunner - [my log] Params:{...}
[DEBUG] CompositeComponent - [my log] Checking configuration of: Reader: Loading model from platform:/plugin/dev.fs.test/model/fs.uml
[DEBUG] CompositeComponent - [my log] Checking configuration of: CheckComponent: slot model check file(s): sc::viper::uml2::codegen::uml22ansic::transformation::generic::UML2ModelCheck 
[INFO] CompositeComponent - [my log] Reader: Loading model from platform:/plugin/dev.fs.test/model/fs.uml
[INFO] CompositeComponent - [my log] CheckComponent: slot model check file(s): sc::viper::uml2::codegen::uml22ansic::transformation::generic::UML2ModelCheck 
Multiple types (2) with name uml::PrimitiveType found!
Multiple types (2) with name uml::Constraint found!
[ERROR] WorkflowRunner - [my log] Workflow interrupted. Reason: Errors during validation.
[ERROR] WorkflowRunner - [my log] [ERROR]: Could not load Check file 'sc::viper::uml2::codegen::uml22ansic::transformation::generic::UML2ModelCheck'.(Element: -UNKNOWN-; Reported by: -UNKNOWN-)

So if I wouldn't have the problem that sc::viper::uml2::codegen::uml22ansic::transformation::generi c::UMLModel is not found then the workflow would stuck because there are multiple types.

So my questions are:

  • How can I make the workflow find
    sc::viper::uml2::codegen::uml22ansic::transformation::generi c::UMLModel? Obviously sc::viper::uml2::codegen::uml22ansic::transformation::generi c::UML2ModelCheck is found, which is in the same scope. Is it really not found or is there another problem? Unfortunately I don't have other (more detailed) error messages. The plugin is definitely in the classpath.
  • Why there suddenly are multiple types when I execute the workflow in a plugin context run as an eclipse app and how can I avoid them? Reminder: in a workspace project everything works fine.
  • Why it seems to be so hard to deploy a workflow in such a way? Smile

Do you have any idea?

Thanks a lot in advance and best regards
Tom

[Updated on: Mon, 24 January 2011 16:07]

Report message to a moderator

Re: Problems integrating a workflow in a plugin [message #650392 is a reply to message #650363] Mon, 24 January 2011 17:31 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello all,

i quickly made an example workspace where both errors can be reproduced. It can be found here.

The workspace workflow can be executed if you run CMain in dev.test.codegen.invoke. Please be aware of the absolute paths on my filesystem. All files are there but you have to change the locations. The workspace workflow runs on my system.

The UI-plugin project is in dev.test.codegen.ui. Once you run the same as an Eclipse app you'll find "Testbutton" in your ResourceExplorer's popup menu when you do a right-click on an item. Once invoked the log output can be seen in Eclipse's host application in the console.

Maybe it's more understandable in this way. So if someone of you has the time to have a short look into the same, I would be very thankful Smile

By the way - this can be seen as a simple example for a code generation environment, which I havn't found so far on the internet Smile

Thanks in advance and bye
Tom
Re: Problems integrating a workflow in a plugin [message #650393 is a reply to message #650363] Mon, 24 January 2011 17:33 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hello Tom,

maybe there different instances of uml packages registered to your epackage reistry at runtime

here is a action that tests this

package terterter.popup.actions;

import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.mwe.utils.StandaloneSetup;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IActionDelegate;
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.xtend.expression.TypeSystemImpl;
import org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel;
import org.eclipse.xtend.typesystem.uml2.Setup;

public class NewAction implements IObjectActionDelegate {

	private Shell shell;
	
	/**
	 * Constructor for Action1.
	 */
	public NewAction() {
		super();
	}

	/**
	 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
	 */
	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
		shell = targetPart.getSite().getShell();
	}

	/**
	 * @see IActionDelegate#run(IAction)
	 */
	public void run(IAction action) {
		StandaloneSetup ss = new StandaloneSetup();
		Setup s = new Setup();
		s.setStandardUML2Setup(true);
		
		
		EmfRegistryMetaModel mm = new EmfRegistryMetaModel();
		mm.setTypeSystem(new TypeSystemImpl());
		
		
		for (String name : EPackage.Registry.INSTANCE.keySet()) {
			Object o = EPackage.Registry.INSTANCE.get(name);
			if (o instanceof EPackage) {
				if ("uml".equals(((EPackage)o).getNsPrefix())) {
					System.out.println(name + " " + o.hashCode());
				}
			}
		}
	}

	/**
	 * @see IActionDelegate#selectionChanged(IAction, ISelection)
	 */
	public void selectionChanged(IAction action, ISelection selection) {
	}

}



an output like

Quote:

http://www.eclipse.org/uml2/2.0.0/UML 32462141
http://www.eclipse.org/uml2/3.0.0/UML 32462141



is ok since the instance is the same all the time.

Quote:

http://www.eclipse.org/uml2/2.0.0/UML 32462141
http://www.eclipse.org/uml2/3.0.0/UML 32462142



might not be ok since there are different instances bound.

~ Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems integrating a workflow in a plugin [message #650413 is a reply to message #650393] Mon, 24 January 2011 18:26 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi,

Regarding your XtendComponent problem.

do not rely on transitive dependencies.
the workflow is executed in the context of the ui plugin, not the dev.test.codegen plugin. so add the transformation plugin to the ui plugins dependencies.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems integrating a workflow in a plugin [message #650432 is a reply to message #650413] Mon, 24 January 2011 20:27 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi,

so doing following things finally makes your sample runnable with my eclipse

(1) add dev.test.codegen.generation and dev.test.codegen.transformation to deps of dev.test.codegen.ui
(2) let dev.test.codegen.generation export the dev.test.codegen.generation.generic package dev.test.codegen.generation.generic
(3) set the store location for the dump file in CommandHandler to something where eclipse can write to (not a platform:/plugin/...) uri.

~Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems integrating a workflow in a plugin [message #650485 is a reply to message #650432] Tue, 25 January 2011 08:57 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello Christian,

today I made your suggested changes and it works also fine with my real project! Thanks a lot for your spent time!
Somehow I didn't thought of exporting the packages Confused Smile

Do you remember if you still had the following messages?
Multiple types (2) with name uml::PrimitiveType found!
Multiple types (2) with name uml::Constraint found!

I mean, currently the generation is working and I am really happy with this, but as soon as I use uml::PrimitiveType or uml::Constraint in my xTend scripts I run into troubles. Do you know where these warning/error messages come from?

Thank you very much and bye
Tom
Re: Problems integrating a workflow in a plugin [message #650490 is a reply to message #650485] Tue, 25 January 2011 09:20 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi Tom,

see my message with id 650393. there some hints how to analyze this.

~ Christian


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Re: Problems integrating a workflow in a plugin [message #650512 is a reply to message #650490] Tue, 25 January 2011 11:20 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Ah ok, maybe it was to early this morning Smile I've overseen your reply. Maybe I was too curious about whether everything works or not. Sorry for this! I'll check the item accordingly and give a note once I have results.

Thanks and bye
Tom Smile

[Updated on: Tue, 25 January 2011 11:21]

Report message to a moderator

Re: Problems integrating a workflow in a plugin [message #650525 is a reply to message #650512] Tue, 25 January 2011 12:33 Go to previous messageGo to next message
Tom Brandenburg is currently offline Tom BrandenburgFriend
Messages: 58
Registered: October 2010
Location: Abstatt, Germany
Member
Hello,

these metamodels are registered:
http://www.eclipse.org/uml2/3.0.0/UML 18532482
http://www.eclipse.org/uml2/2.0.0/UML 18532482


Not the best news Smile I think since it is a Set the order of UML2/UML3 is not important, right?

Greets,
Tom
Re: Problems integrating a workflow in a plugin [message #650526 is a reply to message #650525] Tue, 25 January 2011 12:37 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14736
Registered: July 2009
Senior Member
Hi,

this seems not be be the problem.
you could try to debug there the duplicate things come from:

org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel.allPac kages()

org.eclipse.xtend.typesystem.emf.EmfRegistryMetaModel.getNam edElementRec(ENamedElement[], String)

~Christian



Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Day Job: https://www.everest-systems.com
Previous Topic:[Xtend] Declaration of a List in List
Next Topic:M2T reverse direction
Goto Forum:
  


Current Time: Tue Dec 10 08:43:35 GMT 2024

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

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

Back to the top