Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MDT (Model Development Tools) » [BPMN2] extending attribute of Process node
[BPMN2] extending attribute of Process node [message #653921] Fri, 11 February 2011 20:57 Go to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
I was wondering how to add custom attributes do node types. For my app I need to have for example:

<bpmn2:process id="_zoxqUDVBEeCqf5cJFwvEIg" name="myProcess" packageName="myPackage">

the packageName attribute is specific for my use only, however I am struggling to find out how to achieve this without going all the way back to the bpmn.ecore and adding a new property etc...and also cannot find any examples on maybe creating an extension only for the Process node. Is this possible?

Thanks in advance for any input!

[Updated on: Fri, 11 February 2011 20:58]

Report message to a moderator

Re: [BPMN2] extending attribute of Process node [message #654223 is a reply to message #653921] Mon, 14 February 2011 16:22 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
BPMN 2.0 does not allow you to use extension attibutes in the BPMN XML namespace. However it allows to do so in your own namespace, and MDT-BPMN2 supports this approach, e.g.
<bpmn2:process id="_zoxqUDVBEeCqf5cJFwvEIg" name="myProcess" ext:packageName="myPackage" xmlns:ext="http://www.,mycomapany.com/myExtensions">

If you load such a file, you will find your attributes in the "getAnyAttribute()" feature map.

BPMN2 also supports more sphisticated ways of extensibility. E.g. you can create a so-called extension XML schema. In this schema you create sub-classes of the standard BPN classes. E.g. you could defined a complex type "MyProcess" extending BPMN:Process. In this extension class you can declare your mandatory extension attributes.

You find examples of the cool extensibility features in Bugzilla https://bugs.eclipse.org/bugs/show_bug.cgi?id=323170

Reiner.
Re: [BPMN2] extending attribute of Process node [message #654303 is a reply to message #654223] Tue, 15 February 2011 01:15 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Hi Reiner, thank you for the info!

Regarding your first approach - I am creating the bpmn2 structure programatically and wanted to ask you how I could add this attribute through the API?

For example I have:
Process p = Bpmn2Factory.eINSTANCE.createProcess();
p.setProcessType(....);
p.process.setIsExecutable(...);
...
p.getAnyAttribute().add(what_goes_here??)

if you could show me an example on how to create and use an Entry here, or do I have to create a structural feature and add it, I am just not sure.

Regarding your second approach, that's really cool, do you happen to have example on how to apply the extension schema in the API?

Thanks for any input.

[Updated on: Tue, 15 February 2011 01:16]

Report message to a moderator

Re: [BPMN2] extending attribute of Process node [message #654375 is a reply to message #654303] Tue, 15 February 2011 13:52 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,
here is an example for 1. For 2 I should spend some time to write an article.


Process p = Bpmn2Factory.eINSTANCE.createProcess();
p.setProcessType(ProcessType.NONE);
p.setIsExecutable(false);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
"http://example.org", "packageName", false, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute,
"myPackage");
p.getAnyAttribute().add(extensionEntry);

Reiner.
Re: [BPMN2] extending attribute of Process node [message #654419 is a reply to message #654375] Tue, 15 February 2011 17:00 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Thanks again!
The first approach worked out great, just in case anyone else is reading this, to get the extended parameter back out you can do:

Iterator<FeatureMap.Entry> iter = ((Process) rootElement).getAnyAttribute().iterator();
while(iter.hasNext()) {
FeatureMap.Entry entry = iter.next();
if(entry.getEStructuralFeature().getName().equals("packageName ")) {
Object val = entry.getValue();
....
}
}

Looking forward on a blog on the second approach.
Re: [BPMN2] extending attribute of Process node [message #665770 is a reply to message #654375] Fri, 15 April 2011 19:51 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
HI Reiner, have you had the chance to write up an article on extension elements in eclipse bpmn2? If so please link. Thanks!
Re: [BPMN2] extending attribute of Process node [message #693042 is a reply to message #654375] Tue, 05 July 2011 16:52 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Hi Reiner, was wondering if you had a chance yet to write something up for extension element example. Please let me know.

Thanks!
Re: [BPMN2] extending attribute of Process node [message #696579 is a reply to message #693042] Thu, 14 July 2011 10:32 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
I'm starting to write a article. Here is the first chapter - far away from being complete.
Re: [BPMN2] extending attribute of Process node [message #696665 is a reply to message #696579] Thu, 14 July 2011 14:15 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Thanks Reiner! Looking forward to the rest Smile
Re: [BPMN2] extending attribute of Process node [message #696704 is a reply to message #696665] Thu, 14 July 2011 16:24 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Next iteration, now already with a simple extension schema.
Re: [BPMN2] extending attribute of Process node [message #696747 is a reply to message #696704] Thu, 14 July 2011 18:45 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Have a question about your second version - in the example where you are programatically creating extension element:

<extensionElements>
<myns:process_authors>
<myns:author name="rhille" date="20110508"/>
</myns:process_authors>
</extensionElements>

What if you had:
<extensionElements>
<myns:process_authors>
<myns:author>rhille</myns:author>
</myns:process_authors>
</extensionElements>

For the AnyType author in your example code would "rhille" be a defaultValue structuralFeature? Could you please show me how that would look like?

Thanks.
Re: [BPMN2] extending attribute of Process node [message #696784 is a reply to message #696704] Thu, 14 July 2011 20:15 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Also, followed your example on generating programatically and what gets printed out for me is like:


<bpmn2:extensionElements>
<myns:onEntry-script>

org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@31237c2a (mixed: [myns:script=org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@10acc29a (mixed: null, anyAttribute: [myns:type=, myns:value=12345])], anyAttribute: null)

</myns:onEntry-script>
</bpmn2:extensionElements>

I'll check what could be going on.

Thanks.
Re: [BPMN2] extending attribute of Process node [message #696963 is a reply to message #696784] Fri, 15 July 2011 08:18 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Hi,
your second point: (
<myns:onEntry-script>
org.eclipse.emf.ecore.xml.type.impl.AnyTypeImpl@31237c2a ...)
:
I have seen this as well, that's why I have a "TBD" there. I need some time to debug - I expect only a litte error there.

Your first point (simple content in extension element):
Here is a simpler example: You see that you can put the simple content directly into the feature map without using a AnyType in the middle:

Process p = Bpmn2Factory.eINSTANCE.createProcess();
p.setProcessType(ProcessType.NONE);
p.setIsExecutable(false);
ExtendedMetaData metadata = ExtendedMetaData.INSTANCE;
EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
"http://example.org", "foo", true, false);
SimpleFeatureMapEntry extensionEntry = new SimpleFeatureMapEntry(extensionAttribute, "bar");
ExtensionAttributeValue extension = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
extension.getValue().add(extensionEntry);

p.getExtensionValues().add(extension);
// It looks odd that you need to add an extensionAttributeValue that contains a list of
// extension to a list here.
// However, the XSD allows only 0..1 element here, while CMOF allows multiple.

model.getRootElements().add(p);
Re: [BPMN2] extending attribute of Process node [message #697139 is a reply to message #696963] Fri, 15 July 2011 16:15 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Thanks for this info Reiner. Your latest example works great.
For the example in your doc, would you be willing to use a structure like this for example:


<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL"
xmlns:myns="http://www.mycompany.com/myns" targetNamespace="http://www.mycompany.com/mytarget">
<process id="p1" isClosed="false" isExecutable="false" processType="None">
<extensionElements>
<myns:process_authors includeemail="false">
<myns:author date="20110508">rhille</myns:author>
</myns:process_authors>
</extensionElements>
</process>
</definitions>


Thanks.
Re: [BPMN2] extending attribute of Process node [message #697145 is a reply to message #697139] Fri, 15 July 2011 16:25 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
You mean to include attributes on multiple levels (includeemail="false") and also simple content (<myns:author date="20110508">rhille</myns:author>)? Sure, I can do this.
Unfortunately I can't promise you a final release date for the document, as I'm working full time on a different project. But I'll try to write enough to unblock you. So please guide me which areas are most important for you.
Re: [BPMN2] extending attribute of Process node [message #697149 is a reply to message #697145] Fri, 15 July 2011 16:31 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
I am looking now only at the programatic creation (you can leave the extensions with xsd schema chapters for whenever you have time for it).
Being able to create an example like:

<extensionElements>
<myns:process_authors includeemail="false">
<myns:author date="20110508">rhille</myns:author>
</myns:process_authors>
</extensionElements>

would unblock me and I'll stop bugging you about this Smile

And thank you very much for doing all this. Know you are busy.

Re: [BPMN2] extending attribute of Process node [message #697152 is a reply to message #697139] Fri, 15 July 2011 16:41 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Why don't you want to use an extension schema for programatic extension creation? I know that this is also missing yet, but making this work is much simpler than the generic way.
You you ship the ECore model generated from the extension schema together with your application. I think this is quite handy.
The generic approach is only really needed, if your extension itself is very generic. Or if you need to understand generic extensions from outer sources. E.g. if you like to create a generic property sheet that is able to understand all kind of extensions. But this would be anyway extremely complicated.
Maybe you could give me some background. You are working for the Graphity-based BPMN-modeler, right?
Re: [BPMN2] extending attribute of Process node [message #697154 is a reply to message #697152] Fri, 15 July 2011 16:57 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
It's not that I would not use an extension schema, just given your time constraints and what is in your document so far, I thought it would be easier and take less time to get the existing example modified a little and get it working...that's all.

The BPMN2 modeller I am working on exposes the process info as JSON and I use eclipse.bpmn2 for marshalling/unmarshalling. The BPMN2 processes should be fully executable in jBPM5 and jBPM5 uses extension elements for on-entry and on-exit actions of task nodes and also has a good number of extension attributes.

You are right, the best scenario for me would be to be able just to have a jBPM5 extension schema to BPMN2 that everyone could use, but just getting the extension elements working in any way would be a great deal for me right now Smile

[Updated on: Fri, 15 July 2011 17:05]

Report message to a moderator

Re: [BPMN2] extending attribute of Process node [message #697993 is a reply to message #697154] Mon, 18 July 2011 15:11 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Next iteration: I have modified the extension schema to the way how you proposed (simple content with attribute). Based on it, I added an example how to create the extension attribute and the extension element from the XSD-generated code.
Re: [BPMN2] extending attribute of Process node [message #702714 is a reply to message #697993] Tue, 26 July 2011 18:00 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Thanks! Sorry was gone for a week (bet you didn't mind Smile ), will try your updates asap and report findings.
Re: [BPMN2] extending attribute of Process node [message #707641 is a reply to message #697993] Mon, 01 August 2011 22:24 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Hi Reiner, first of all thank you - this got me started in the right direction Smile
I had a question:

With my xsd I am generating following extension element to the bpmn2 task types:

<bpmn2:extensionElements>
<emfextmodel:onEntry-script scriptFormat="java">
<emfextmodel:script>System.out.println(&quot;hello&quot;);</emfextmodel:script>
</emfextmodel:onEntry-script>
</bpmn2:extensionElements>

-- is it possible to surpress the namespace of the inner elements? so for example be able to just have <script> instead of <emfextmodel:script> ... </> ?

Thanks.

[Updated on: Tue, 02 August 2011 05:41]

Report message to a moderator

Re: [BPMN2] extending attribute of Process node [message #714705 is a reply to message #707641] Thu, 11 August 2011 10:19 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
You could try to use elementFormDefault=unqualified in your extension schema. This could do it, but I'm not sure if it has negative effects.
Re: [BPMN2] extending attribute of Process node [message #714800 is a reply to message #714705] Thu, 11 August 2011 14:20 Go to previous messageGo to next message
karthick9686@gmail.com Missing nameFriend
Messages: 41
Registered: July 2011
Member
i am trying to develop the bpmn2 modeler using GEF alone . I have the emf bpmn2 model in place and really confused of how to use the model and create an fully functional Bpmn2 editor using Gef alone.

i have gone through various tutorials in internet of how to build the graphical editor from emf model, but the emf bpmn2 metamodel is complex and i am stuck in the middle and i face issues when setting the bounds for each shape (setBounds and getBounds) and it goes on.

The bpmn modeler being developed at the following location (www.eclipse.org/modeling/mdt/?project=bpmn2) is using graphiti. the bpmn2 modeler i propose is done enteirly in Gef (graphical editing framework).

if anyone of u are working towards the same effort or if u know anyone creating bpmn2 modeler entirely in Gef please let me know so that we can put our efforts to accomplish the goal.

you are welcome to share your views and any resource related to this effort . Thanks IN Advance
Re: [BPMN2] extending attribute of Process node [message #715430 is a reply to message #714705] Sun, 14 August 2011 01:08 Go to previous messageGo to next message
tsurdilo  is currently offline tsurdilo Friend
Messages: 41
Registered: February 2011
Member
Tried it and yes as you mentioned it causes issues when reading in the xml:

Feature 'script' not found. (inputStream://dummyUriWithValidSuffix.xml, 10, 19)
2011-08-13 20:59:47,074 ERROR [STDERR] (http-localhost%2F127.0.0.1-8080-5) at org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl.handleErrors(XMLLoadImpl.java:83)
.....

Seems its not possible, but that's fine.
Thanks.
Re: [BPMN2] extending attribute of Process node [message #757029 is a reply to message #715430] Wed, 16 November 2011 07:28 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi Reiner,
I am creating BPMN 2 editor. I have given option for Changing color of individual shape in the editor. But I do not know how to save the color of individual shape in the xml in GEF Editor, so that i could be available while reopening the editor. In GMF there is option of GMF notation to achieve this concept. But I do not know how it can be done in GEF editor. Kindly reply me if you got any suggestions.

Thanks & Regards,
Karthikeyan
Re: [BPMN2] extending attribute of Process node [message #758192 is a reply to message #757029] Tue, 22 November 2011 09:53 Go to previous messageGo to next message
Reiner Hille is currently offline Reiner HilleFriend
Messages: 18
Registered: July 2009
Junior Member
Hi Karrthikeyan,
could you please explain how your question is related to the topic of this thread?
Do you want to put the colour information as an extension into the BPMN2 model? If yes, you can follow the suggestions here in the thread and in the attached Word document.

Reiner.
Re: [BPMN2] extending attribute of Process node [message #758391 is a reply to message #758192] Wed, 23 November 2011 04:28 Go to previous messageGo to next message
Karthikeyan Missing name is currently offline Karthikeyan Missing nameFriend
Messages: 47
Registered: July 2011
Member
Hi,

Thank you for your reply. I have checked with extension its working fine, but my doubt is, whether is there any optional way of using EObject Annotation for saving the attribute values using its key and value. Because if we use extension then, the colored elements in our file does not apply while opening in other editor, but if we use annotation I can be achieved.

Thanks & Regards,
Karthikeyan

[Updated on: Wed, 23 November 2011 04:29]

Report message to a moderator

Re: [BPMN2] extending attribute of Process node [message #1005114 is a reply to message #697152] Thu, 24 January 2013 13:53 Go to previous message
Marcel Michel is currently offline Marcel MichelFriend
Messages: 10
Registered: January 2011
Junior Member
Sorry for reviving this old thread.

But I still get trouble with the XML namespace prefix.

With the code:

EAttributeImpl extensionAttribute = (EAttributeImpl) metadata.demandFeature(
		"www.mycompany.com/myns", "style", true, false);


I got the following XML File:

<definitions [...] xmlns:myns="www.mycompany.com/myns"  [...]>
[...]
<myns:extensionElement>
[...]
</myns:extensionElement>
[...]


But I need the following output:

<definitions [...] xmlns:myns="www.mycompany.com"  [...]>
[...]
<myns:extensionElement>
[...]
</myns:extensionElement>
[...]


Is there an easy way to archive this?

I tried to create and register a separated ecore file with my desired ns prefix and ns uri. Seems to have no effect at all...

The ecore registration code:
Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl());

ResourceSet rs = new ResourceSetImpl();

final ExtendedMetaData extendedMetaData = new BasicExtendedMetaData(rs.getPackageRegistry());
rs.getLoadOptions().put(XMLResource.OPTION_EXTENDED_META_DATA, extendedMetaData);

URI test = URI.createFileURI(new File("file.ecore").getAbsolutePath());
Resource r = rs.getResource(test, true);
EObject eObject = r.getContents().get(0);
if (eObject instanceof EPackage) {
    EPackage p = (EPackage)eObject;
    rs.getPackageRegistry().put(p.getNsURI(), p);
}


The ecore file:
<?xml version="1.0" encoding="UTF-8"?>
<ecore:EPackage xmi:version="2.0"
    xmlns:xmi="www.omg.org/XMI" xmlns:ecore="www.eclipse.org/emf/2002/Ecore" name="www.mycompany.com"
    nsURI="www.mycompany.com" nsPrefix="myns"/>



Thanks for any advise...

P.S.: Sorry, for the missing https of the namespaces. Workaround for the eclipse spam protection -.-

[Updated on: Thu, 24 January 2013 13:56]

Report message to a moderator

Previous Topic:[MDT-OclInEcore] Code executed for dynamic instances but not for generated editor
Next Topic:Extending BPMN2 Metamodel
Goto Forum:
  


Current Time: Fri Feb 07 02:54:27 GMT 2025

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

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

Back to the top