Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Dynamic UML
Dynamic UML [message #547720] Mon, 19 July 2010 13:11 Go to next message
Eclipse UserFriend
Originally posted by: ML1984.gmx.de

Hi there,

is there something like 'Dynamic UML' (similar to Dynamic EMF)? The
following tutorial gives a brief overview of the features of Dynamic EMF.

http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/

My precise question is, whether it is possible to create an dynamic
instance of a UML class? I tried to rewrite the code of the above
example using the UML API, but stucked at Listing 4: getEFactoryInstance().

There is no such method in class org.eclipse.uml2.uml.Package. Is there
another way of doing this?

Cheers,
Mark
Re: Dynamic UML [message #547789 is a reply to message #547720] Mon, 19 July 2010 15:32 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Mark,

As far as I know, nothing at Eclipse provides such a thing, i.e., direct
instantiation of UML2 models. You could map UML2 to Ecore and then use
dynamic EMF...


Mark L. wrote:
> Hi there,
>
> is there something like 'Dynamic UML' (similar to Dynamic EMF)? The
> following tutorial gives a brief overview of the features of Dynamic EMF.
>
> http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/
>
> My precise question is, whether it is possible to create an dynamic
> instance of a UML class? I tried to rewrite the code of the above
> example using the UML API, but stucked at Listing 4:
> getEFactoryInstance().
>
> There is no such method in class org.eclipse.uml2.uml.Package. Is
> there another way of doing this?
>
> Cheers,
> Mark


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Dynamic UML [message #547794 is a reply to message #547789] Mon, 19 July 2010 15:51 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Mark

The generalisation of OCL support to treat Ecore and UML uniformly may
in due course provide this, but certainly not soon.

Regards

Ed Willink

On 19/07/2010 16:32, Ed Merks wrote:
> Mark,
>
> As far as I know, nothing at Eclipse provides such a thing, i.e., direct
> instantiation of UML2 models. You could map UML2 to Ecore and then use
> dynamic EMF...
>
>
> Mark L. wrote:
>> Hi there,
>>
>> is there something like 'Dynamic UML' (similar to Dynamic EMF)? The
>> following tutorial gives a brief overview of the features of Dynamic EMF.
>>
>> http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/
>>
>> My precise question is, whether it is possible to create an dynamic
>> instance of a UML class? I tried to rewrite the code of the above
>> example using the UML API, but stucked at Listing 4:
>> getEFactoryInstance().
>>
>> There is no such method in class org.eclipse.uml2.uml.Package. Is
>> there another way of doing this?
>>
>> Cheers,
>> Mark
Re: Dynamic UML [message #547882 is a reply to message #547720] Tue, 20 July 2010 05:06 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Mark, is this what you are looking for?

package foo.tests;

import junit.framework.TestCase;

import org.eclipse.emf.common.util.*;
import org.eclipse.emf.ecore.*;
import org.eclipse.uml2.uml.NamedElement;

public class ReflectiveUMLTest extends TestCase{
  public void testFoo() {
    String umlNamespaceURI = "http://www.eclipse.org/uml2/3.0.0/UML";
    EPackage umlPackage = EPackage.Registry.INSTANCE.getEPackage(umlNamespaceURI);
    EFactory umlFactory = EPackage.Registry.INSTANCE.getEFactory(umlNamespaceURI);
    
    EClass namedElementMetaClass = (EClass) umlPackage.getEClassifier("NamedElement");
    EStructuralFeature namedElementName = namedElementMetaClass.getEStructuralFeature("name");
    
    EClass packageMetaClass = (EClass) umlPackage.getEClassifier("Package");
    EClass classMetaClass = (EClass) umlPackage.getEClassifier("Class");
    EObject bookstorePackage = umlFactory.create(packageMetaClass);
    bookstorePackage.eSet(namedElementName, "BookstorePackage");
    EObject bookClass = umlFactory.create(classMetaClass);
    bookClass.eSet(namedElementName, "Book");
    EReference packagedElement = (EReference) packageMetaClass.getEStructuralFeature("packagedElement");
    ((EList<EObject>) bookstorePackage.eGet(packagedElement)).add(bookClass);
    
    EObject subPackage = umlFactory.create(packageMetaClass);
    subPackage.eSet(namedElementName, "SubPackage");
    
    ((EList) bookstorePackage.eGet(packagedElement)).add(subPackage);
    
    EReference namespace = (EReference) namedElementMetaClass.getEStructuralFeature("namespace");
    assertSame(bookstorePackage, bookClass.eGet(namespace));

    // use the static API to show it worked        
    assertEquals("BookstorePackage::Book", ((NamedElement)bookClass).getQualifiedName());
    assertEquals("BookstorePackage::SubPackage", ((NamedElement)subPackage).getQualifiedName());
    
    // derived/subset collections work normally
    EReference packageOwnedTypes = (EReference) packageMetaClass.getEStructuralFeature("ownedType");
    assertTrue(((EList) bookstorePackage.eGet(packageOwnedTypes)).contains(bookClass));
    assertFalse(((EList) bookstorePackage.eGet(packageOwnedTypes)).contains(subPackage));
    
    EReference packageNestedPackages = (EReference) packageMetaClass.getEStructuralFeature("nestedPackage");
    assertFalse(((EList) bookstorePackage.eGet(packageNestedPackages)).contains(bookClass));
    assertTrue(((EList) bookstorePackage.eGet(packageNestedPackages)).contains(subPackage));
  }
}



You still get EMF's management of relationships, and type-safe collections. But this is a really painful way to go about doing things. Not to mention you lose access to the behavioral aspects of the UML metamodel implementation, such as implementation of OCL queries.

Rafael Chaves
http://abstratt.com/blog
Re: Dynamic UML [message #547993 is a reply to message #547882] Tue, 20 July 2010 10:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: ML1984.gmx.de

Thanks for the quick replies!

> Mark, is this what you are looking for?

No, it is not. The most important thing is missing: creating dynamic
objects, but Ed Merks already gave a statement about this. I think the
situation is clear.

Cheers,
Mark
Re: Dynamic UML [message #548095 is a reply to message #547993] Tue, 20 July 2010 16:01 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Mark,

Do you mind clarifying what was that you needed then?

With at least two metalevels involved, the words 'class' and 'instance'/'object' in this forum need to be better qualified or else they are too ambiguous to be meaningful.

Cheers,

Rafael
Re: Dynamic UML [message #548140 is a reply to message #548095] Tue, 20 July 2010 18:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Rafael

The Dynamic UML functionality that I consider missing and want to see
working for OCL is:

In a context that supports selection of a UML class (e.g. the UML model
editor) invoke Create Dynamic Instance.

A UML2Ecore meta-model conversion occurs automatically and the
corresponding dynamic instance of the Ecore Class is created and opened
in the Sample Reflective Ecore Editor.

The OCL console then supports OCL evaluation on that model with the OCL
embedded in the UML model, possibly augmented by a Complete OCL document.

More challenging is to have this to continue to work transparently after
the UML meta-model is edited to debug an OCL constraint.

Regards

Ed Willink




On 20/07/2010 17:01, Rafael Chaves wrote:
> Mark,
>
> Do you mind clarifying what was that you needed then?
>
> With at least two metalevels involved, the words 'class' and
> 'instance'/'object' in this forum need to be better qualified or else
> they are too ambiguous to be meaningful.
>
> Cheers,
>
> Rafael
Re: Dynamic UML [message #628545 is a reply to message #547720] Mon, 19 July 2010 15:32 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Mark,

As far as I know, nothing at Eclipse provides such a thing, i.e., direct
instantiation of UML2 models. You could map UML2 to Ecore and then use
dynamic EMF...


Mark L. wrote:
> Hi there,
>
> is there something like 'Dynamic UML' (similar to Dynamic EMF)? The
> following tutorial gives a brief overview of the features of Dynamic EMF.
>
> http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/
>
> My precise question is, whether it is possible to create an dynamic
> instance of a UML class? I tried to rewrite the code of the above
> example using the UML API, but stucked at Listing 4:
> getEFactoryInstance().
>
> There is no such method in class org.eclipse.uml2.uml.Package. Is
> there another way of doing this?
>
> Cheers,
> Mark


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Dynamic UML [message #628546 is a reply to message #547789] Mon, 19 July 2010 15:51 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Mark

The generalisation of OCL support to treat Ecore and UML uniformly may
in due course provide this, but certainly not soon.

Regards

Ed Willink

On 19/07/2010 16:32, Ed Merks wrote:
> Mark,
>
> As far as I know, nothing at Eclipse provides such a thing, i.e., direct
> instantiation of UML2 models. You could map UML2 to Ecore and then use
> dynamic EMF...
>
>
> Mark L. wrote:
>> Hi there,
>>
>> is there something like 'Dynamic UML' (similar to Dynamic EMF)? The
>> following tutorial gives a brief overview of the features of Dynamic EMF.
>>
>> http://www.ibm.com/developerworks/library/os-eclipse-dynamic emf/
>>
>> My precise question is, whether it is possible to create an dynamic
>> instance of a UML class? I tried to rewrite the code of the above
>> example using the UML API, but stucked at Listing 4:
>> getEFactoryInstance().
>>
>> There is no such method in class org.eclipse.uml2.uml.Package. Is
>> there another way of doing this?
>>
>> Cheers,
>> Mark
Re: Dynamic UML [message #628548 is a reply to message #547720] Tue, 20 July 2010 05:07 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Mark, is this what you are looking for?

package foo.tests;

import junit.framework.TestCase;

import org.eclipse.emf.common.util.*;
import org.eclipse.emf.ecore.*;
import org.eclipse.uml2.uml.NamedElement;

public class ReflectiveUMLTest extends TestCase{
public void testFoo() {
String umlNamespaceURI = "http://www.eclipse.org/uml2/3.0.0/UML";
EPackage umlPackage = EPackage.Registry.INSTANCE.getEPackage(umlNamespaceURI);
EFactory umlFactory = EPackage.Registry.INSTANCE.getEFactory(umlNamespaceURI);

EClass namedElementMetaClass = (EClass) umlPackage.getEClassifier("NamedElement");
EStructuralFeature namedElementName = namedElementMetaClass.getEStructuralFeature("name");

EClass packageMetaClass = (EClass) umlPackage.getEClassifier("Package");
EClass classMetaClass = (EClass) umlPackage.getEClassifier("Class");
EObject bookstorePackage = umlFactory.create(packageMetaClass);
bookstorePackage.eSet(namedElementName, "BookstorePackage");
EObject bookClass = umlFactory.create(classMetaClass);
bookClass.eSet(namedElementName, "Book");
EReference packagedElement = (EReference) packageMetaClass.getEStructuralFeature("packagedElement");
((EList<EObject>) bookstorePackage.eGet(packagedElement)).add(bookClass);

EObject subPackage = umlFactory.create(packageMetaClass);
subPackage.eSet(namedElementName, "SubPackage");

((EList) bookstorePackage.eGet(packagedElement)).add(subPackage);

EReference namespace = (EReference) namedElementMetaClass.getEStructuralFeature("namespace");
assertSame(bookstorePackage, bookClass.eGet(namespace));

// use the static API to show it worked
assertEquals("BookstorePackage::Book", ((NamedElement)bookClass).getQualifiedName());
assertEquals("BookstorePackage::SubPackage", ((NamedElement)subPackage).getQualifiedName());

// derived/subset collections work normally
EReference packageOwnedTypes = (EReference) packageMetaClass.getEStructuralFeature("ownedType");
assertTrue(((EList) bookstorePackage.eGet(packageOwnedTypes)).contains(bookClass ));
assertFalse(((EList) bookstorePackage.eGet(packageOwnedTypes)).contains(subPackag e));

EReference packageNestedPackages = (EReference) packageMetaClass.getEStructuralFeature("nestedPackage");
assertFalse(((EList) bookstorePackage.eGet(packageNestedPackages)).contains(bookC lass));
assertTrue(((EList) bookstorePackage.eGet(packageNestedPackages)).contains(subPa ckage));
}
}



You still get EMF's management of relationships, and type-safe collections. But this is a really painful way to go about doing things. Not to mention you lose access to the behavioral aspects of the UML metamodel implementation, such as implementation of OCL queries.

Rafael Chaves
http://abstratt.com/blog
Re: Dynamic UML [message #628549 is a reply to message #628548] Tue, 20 July 2010 10:56 Go to previous message
Eclipse UserFriend
Originally posted by: ML1984.gmx.de

Thanks for the quick replies!

> Mark, is this what you are looking for?

No, it is not. The most important thing is missing: creating dynamic
objects, but Ed Merks already gave a statement about this. I think the
situation is clear.

Cheers,
Mark
Re: Dynamic UML [message #628550 is a reply to message #547993] Tue, 20 July 2010 16:01 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 161
Registered: July 2009
Senior Member
Mark,

Do you mind clarifying what was that you needed then?

With at least two metalevels involved, the words 'class' and 'instance'/'object' in this forum need to be better qualified or else they are too ambiguous to be meaningful.

Cheers,

Rafael
Re: Dynamic UML [message #628552 is a reply to message #628550] Tue, 20 July 2010 18:43 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Rafael

The Dynamic UML functionality that I consider missing and want to see
working for OCL is:

In a context that supports selection of a UML class (e.g. the UML model
editor) invoke Create Dynamic Instance.

A UML2Ecore meta-model conversion occurs automatically and the
corresponding dynamic instance of the Ecore Class is created and opened
in the Sample Reflective Ecore Editor.

The OCL console then supports OCL evaluation on that model with the OCL
embedded in the UML model, possibly augmented by a Complete OCL document.

More challenging is to have this to continue to work transparently after
the UML meta-model is edited to debug an OCL constraint.

Regards

Ed Willink




On 20/07/2010 17:01, Rafael Chaves wrote:
> Mark,
>
> Do you mind clarifying what was that you needed then?
>
> With at least two metalevels involved, the words 'class' and
> 'instance'/'object' in this forum need to be better qualified or else
> they are too ambiguous to be meaningful.
>
> Cheers,
>
> Rafael
Previous Topic:Dynamic UML
Next Topic:EMF bidirectional validation failing
Goto Forum:
  


Current Time: Thu Mar 28 15:03:05 GMT 2024

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

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

Back to the top