Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [henshin-dev] Optional EJavaClass Attribute in HenshinTGG

Hi Marco,

thank you for your example - here is the answer for the HenshinTGG specifics:

A. Your example has some inconsistencies (maybe typos):
a) the first rule uses "DataModel", which is not defined in your ecore - is this a sub class of "DataType"?
b) the second rule has no "++" marker at the second edge. This is not allowed and HenshinTGG automatically adds the marker if you mark an adjacent node.
c) your rules do not have "tr" markers, but you call them FW-rules. I assume that you provided the TGG-triple rules from which you then generate the FT-rules. Please note that the NAC you specified should be specified for the FT-rule only, because the node mapping is not possible in the triple rule. You cannot map from a "++" marked node in the rule to a node in the NAC: The node is created by the rule and thus, it is not in the left hand side of the rule, but only in the right hand side.

B. Your example showed some interesting exception stack traces
a) your case 3 stack trace:
org.eclipse.emf.common.util.WrappedException:
java.lang.ClassNotFoundException: null cannot be found by
org.eclipse.emf.ecore_2.9.1.v20130827-0309
        at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createEJavaClassFromString(Ecor
eFactoryImpl.java:906)
        at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createFromString(EcoreFactoryIm
pl.java:146)
        at
org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3352)
        at
de.tub.tfs.henshin.tggeditor.util.TggHenshinEGraph.henshin2emfGraph(TggHens
hinEGraph.java:107)
[…]
This stack trace can be explained as follows:
the exception occurs during the conversion of a visual graph that is shown in HenshinTGG GUI into an EMF instance. This is performed before the forward translation rules are actually applied. The problem is that EMF cannot create a proper EMF instance from your graph. All String attribute values in the visual graph representation in HenshinGUI are interpreted as Strings. This means that value "null" is a String with 4 letters.
If you want to have a node with attribute value [null], then you just do not specify the attribute value in the visual graph view.

b) The thrown exception in your case 4 is now handled by a bugfix that is committed to the HenshinTGG github repository.
The reason for your problem is the following: if your rule uses a parameter for an attribute value, this parameter can also be matched to the [null] value. If you have put this parameter in a freshly created node in your rule, then this value is copied there.
I assume that you do not want to apply the rule if the attribute value is  [null]. For this purpose, you can create an attribute condition:
"jrt!=null" for the rule (context menu via right click on the rule, editing is performed in the Properties view).


Hope this helps you,

with best regards,

Frank

On 1/10/2014 6:49 PM, Christian Krause wrote:
Hi Marco,

judging from the stacktraces it seems that the problem is in HenshinTGG (if
it is in fact a bug).  What I can say for Henshin (the non-TGG version) is
that matching an unset 0..1 cardinality attribute would be done using
"null" (without quotes).

Cheers,
Christian


2014/1/10 Konersmann, Marco <Marco.Konersmann@xxxxxxxxxxxxxxxxx>

Dear Henshin(TGG) developers,

I have a problem in HenshinTGG with an optional (i.e. a cardinality of
0..1) attribute of the type EJavaClass<T>.

The core question is:
How do I match an empty attribute in HenshinTGG? I.e. the value that is
entered when I use the „Restore Default Value“ button in the properties
view on an attribute in a „Sample Reflective Ecore Editor“.


Please let me explain my situation.

I have a meta model for my source model:
Classes:
DataType,
Operation

References:
ownedOperations: DataType -> Operation,
appReturnType: Operation -> DataType

Attributes:
javaReturnType: Operation

I expect Operations to *either* have an appReturnType, or a
javaReturnType. Having both is semantically forbidden.

So I make 2 Transformations. The first one is FW_Operation2SomethingElse:
from
:DataType ++-ownedOperations-> ++[1]:Operation(attr: javaReturnType=jrt)
to
something else

With a NAC No_AppReturnType:
[1]:Operation -appReturnType-> :DataModel

The second one is FW_Operation2SomethingElse_With_AppReturnType:
from
:DataType ++-ownedOperations-> ++:Operation(attr: *no attributes*)
-appReturnType-> :DataType
to
something else

When I execute the FW-Rules on my model I have the following problem.

javaReturnType may be: correct, incorrect, non-existent
appReturnType may be: set, non-existent


1. If I have an operation with a correct javaReturnType (e.g. „int“) an no
appReturnType it is correctly translated.

2. If I have an operation with a correct javaReturnType and an
appReturnType (which is semantically not correct), it is (syntactically)
correctly translated.

3. If I have an operation with an invalid javaReturnType (e.g. „null“ or
„thisShouldReallyBeEmpty“) (this is also semantically not correct), I get
an exception, because the engine tries to set the value in a EJavaClass
attribtue in the target model and cannot (ecore does not allow to set such
values):

org.eclipse.emf.common.util.WrappedException:
java.lang.ClassNotFoundException: null cannot be found by
org.eclipse.emf.ecore_2.9.1.v20130827-0309
        at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createEJavaClassFromString(Ecor
eFactoryImpl.java:906)
        at
org.eclipse.emf.ecore.impl.EcoreFactoryImpl.createFromString(EcoreFactoryIm
pl.java:146)
        at
org.eclipse.emf.ecore.util.EcoreUtil.createFromString(EcoreUtil.java:3352)
        at
de.tub.tfs.henshin.tggeditor.util.TggHenshinEGraph.henshin2emfGraph(TggHens
hinEGraph.java:107)
[…]


4. If I have an operation with no javaReturnType I get an exception, which
I usually get when a rule checks for an attribute that is not set
(graphNode is null in line 298):
java.lang.NullPointerException
        at
de.tub.tfs.henshin.tggeditor.util.RuleUtil.checkAttributeMarker(RuleUtil.ja
va:298)
        at
de.tub.tfs.henshin.tggeditor.commands.OpRuleAttributeConstraint.check(OpRul
eAttributeConstraint.java:66)
[…]


I just made a table up for these cases as an overview:

javaReturnType  appReturnType   Result
correct         non-existent    correct transformation
correct         set             correct transformation but semantically
forbidden
incorrect       *               incorrect transformation: javaReturnType
is not set on the
other side due to exception
non-existent    *               incorrect transformation: exception due to
non-existent
attribute

All in all I find no possibility to do a correct transformation for the
case that I have an appReturnType in my operation. The problem here is,
that I seem to cannot set any empty javaReturnType.

Thanks for your patience and best regards
Marco




--
Marco Konersmann, né Müller
Research Associate
paluno - The Ruhr Institute for Software Technology
University of Duisburg-Essen * Gerlingstraße 16 * 45127 Essen * Germany
* callto:+49-201-183-4682 * fax:+49-201-183-4698
http://www.paluno.eu * VAT-Nr. DE811272995
PGP/GPG key: http://www.s3.uni-duisburg-essen.de/pub/keys/0x7AE238AC.asc
X.509 cert:
https://pki.pca.dfn.de/uni-duisburg-essen-ca/cgi-bin/pub/pki?cmd=viewCert&k
ey=5639645262406037




_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev



      

_______________________________________________
henshin-dev mailing list
henshin-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/henshin-dev

-- 
________________________________________________________________________

 Dr. Frank Hermann
________________________________________________________________________

 Research Associate at SnT            frank.hermann@xxxxxx
 +352 466644 5864                     www.securityandtrust.lu

 Postal address                       Visiting address
 ---------------------------------    ---------------------------------
 securityandtrust.lu
 University of Luxembourg             D104, Campus Kirchberg
 4, rue Alphonse Weicker              4, rue Alphonse Weicker
 L-2721 Luxembourg                    L-2721 Luxembourg
________________________________________________________________________ 

Back to the top