Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Eclipse Generation Factories (EGF) » Programmatically invoking EGF activity and configure the contract
Programmatically invoking EGF activity and configure the contract [message #1404204] Wed, 30 July 2014 12:07 Go to next message
Ke SUN is currently offline Ke SUNFriend
Messages: 11
Registered: July 2009
Junior Member
Hello,

I am studying EGF. I met a problem, that is, how to programmatically invoke EGF activity and configure the contract?

Does anyone know how to programmatically implement this "Run EGF Activity"?

Thanks in advance.
Re: Programmatically invoking EGF activity and configure the contract [message #1404231 is a reply to message #1404204] Wed, 30 July 2014 14:58 Go to previous messageGo to next message
Boubekeur Zendagui is currently offline Boubekeur ZendaguiFriend
Messages: 5
Registered: March 2014
Junior Member
Hello,

you can have a look at the method execute() of the class polarsys.org/c/kitalpha/kitalpha.git/tree/architecture%20description/dsl/plugins/org.polarsys.kitalpha.ad.viewpoint.dsl.generation.helper/src/org/polarsys/kitalpha/ad/viewpoint/dsl/generation/helper/viewpoint/ViewpointGenerationHelper.java

It uses two helpers that allow to :

  1. Set a contract value : polarsys.org/c/kitalpha/kitalpha.git/tree/architecture%20description/dsl/plugins/org.polarsys.kitalpha.ad.viewpoint.dsl.generation.helper/src/org/polarsys/kitalpha/ad/viewpoint/dsl/generation/helper/egf/ContractHelper.java
  2. Run an EGF activity : polarsys.org/c/kitalpha/kitalpha.git/tree/architecture%20description/dsl/plugins/org.polarsys.kitalpha.ad.viewpoint.dsl.generation.helper/src/org/polarsys/kitalpha/ad/viewpoint/dsl/generation/helper/egf/InvokeActivityHelper.java


Best regards,
Boubekeur Zendagui
Re: Programmatically invoking EGF activity and configure the contract [message #1404434 is a reply to message #1404231] Fri, 01 August 2014 11:44 Go to previous messageGo to next message
Ke SUN is currently offline Ke SUNFriend
Messages: 11
Registered: July 2009
Junior Member
Thanks a lot for your reply.

Using the method you provided, I have tried to programmatically invoke EGF activity, which is already defined in a .fcore file. However, this attempt failed since the program cannot read an existing .fcore successfully:

main
{
URI uri = URI.createURI("...");
Activity activity = getActivity(uri); // activity is always null...
...
}

/**
* @param activityURI the URI of an activity
* @return the activity defined by the activityURI parameter
*/
public static Activity getActivity(URI activityURI) {
EditingDomain editingDomain = getEditingDomain();
ResourceSet rs = editingDomain.getResourceSet();
return (Activity) rs.getEObject(activityURI, true);
}

/**
* @return the value of the editingDomain property.
*/
private static EditingDomain getEditingDomain() {
if (editingDomain == null)
return initializeEditingDomain();

return editingDomain;
}

/**
* This initialize the editing domain property
*/
private static EditingDomain initializeEditingDomain() {
final AdapterFactory adapterFactory =
new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
final CommandStack statck = new BasicCommandStack();
final ResourceSet resourceSet = new TargetPlatformResourceSet();
return new AdapterFactoryEditingDomain(adapterFactory, statck, resourceSet);
}

Could you tell me how to read an existing .fcore? Many thanks.

Best regards,
Kirk
Re: Programmatically invoking EGF activity and configure the contract [message #1404461 is a reply to message #1404434] Fri, 01 August 2014 14:04 Go to previous messageGo to next message
Boubekeur Zendagui is currently offline Boubekeur ZendaguiFriend
Messages: 5
Registered: March 2014
Junior Member
Hello Kirk,

Can you tell me what did you put as parameter for the createURI("...") method

Regads,
Boubekeur.
Re: Programmatically invoking EGF activity and configure the contract [message #1404462 is a reply to message #1404461] Fri, 01 August 2014 14:06 Go to previous messageGo to next message
Ke SUN is currently offline Ke SUNFriend
Messages: 11
Registered: July 2009
Junior Member
I send the path of an existing .fcore. For instance,
URI uri = URI.createURI("file:///Users/ksun/Documents/workspaceluna/fr.inria.tea.Sample/egf/Sample.fcore");
Re: Programmatically invoking EGF activity and configure the contract [message #1404468 is a reply to message #1404462] Fri, 01 August 2014 14:27 Go to previous messageGo to next message
Boubekeur Zendagui is currently offline Boubekeur ZendaguiFriend
Messages: 5
Registered: March 2014
Junior Member
You must provide an EMF URI with the activity ID. You can get the activity ID from the Properties View.

Example:
platform:/plugin/fr.inria.tea.Sample/egf/Sample.fcore#ActivityID

Boubekeur.
Re: Programmatically invoking EGF activity and configure the contract [message #1404583 is a reply to message #1404468] Mon, 04 August 2014 09:53 Go to previous messageGo to next message
Ke SUN is currently offline Ke SUNFriend
Messages: 11
Registered: July 2009
Junior Member
Thanks a lot, Boubekeur.

I have tried to add the activity ID, but it still does not work. I found a bug that is located in

public static Activity getActivity(URI activityURI) {
EditingDomain editingDomain = getEditingDomain();
ResourceSet rs = editingDomain.getResourceSet();
System.out.println(rs.getResources().toString());
return (Activity) rs.getResource(activityURI, true);
}

In detail, the returned value of editingDomain.getResourceSet() is always null, thus the existing uri cannot be found.

Could you tell me how to get the resource set, which is located in the Eclipse workspace? Thanks.

Regards,
Kirk
Re: Programmatically invoking EGF activity and configure the contract [message #1404751 is a reply to message #1404583] Tue, 05 August 2014 13:42 Go to previous message
Boubekeur Zendagui is currently offline Boubekeur ZendaguiFriend
Messages: 5
Registered: March 2014
Junior Member
Hello

You can bypass the use of the editing domain and it resource set to get the activity.

To do this, replace the following two lines :
EditingDomain editingDomain = getEditingDomain();
ResourceSet rs = editingDomain.getResourceSet();

by :
ResourceSet rs = new TargetPlatformResourceSet();

regards,
Boubekeur.
Previous Topic:Activity Ant Task
Goto Forum:
  


Current Time: Wed Jan 17 09:30:05 GMT 2018

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

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