Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » Syntax for use of ecore types within HUTN(HUTN syntax)
Syntax for use of ecore types within HUTN [message #878747] Tue, 29 May 2012 21:21 Go to next message
Chris Holmes is currently offline Chris HolmesFriend
Messages: 2
Registered: May 2012
Junior Member
I have a minimal model expressed in EMF:
package ThingWrappers;

class ThingWrapper {
attr String name = "";
val ecore.EClassifier thing;
}

I define the attribute 'thing' on class ThingWrapper to be of type ecore.EClassifier such that it may accommodate actual things of any type within the EClassifier hierarchy. I would like to create a test model using HUTN to instantiate the model:

@Spec {
metamodel "ThingWrappers" {
nsUri: "ThingWrappers"
}
metamodel "ecore" {
nsUri: "<link to ecore metamodel>"
}
}

ThingWrappers {
ThingWrapper "TW1" {
name: "My Thing Wrapper"
thing: EBoolean#true
}
}

What's the correct syntax for assigning the Boolean value 'true' to 'thing'?

Thanks in advance ...
Re: Syntax for use of ecore types within HUTN [message #879135 is a reply to message #878747] Wed, 30 May 2012 15:27 Go to previous messageGo to next message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Chris,

I'm not quite clear on what you'd like to achieve, because EBoolean#true isn't an instance of EClassifier. (In fact, I'm pretty sure EBoolean#true isn't an instance of anything in Ecore: "true" is just a string that EcoreFactory recognises and uses to create a copy of java.lang.Boolean.TRUE).

Do you want to be able to reference an EClassifier (i.e. any instance of EClass or EDataType) from ThingWrapper? If so, then the following should do the trick:

@Spec {
	metamodel "ThingWrappers" {
		nsUri: "ThingWrappers"
	}
	metamodel "Ecore" {
		nsUri: "http://www.eclipse.org/emf/2002/Ecore"
	}
}

ThingWrappers {
	ThingWrapper {
		thing: EClass "Foo" {}
	}
}



If you'd like to be able to wrap any model element, then you'd need to set the type of the thing reference to be EObject. If you'd like to be able to wrap any primitive, than we may need to do some further investigation, as I'm pretty sure Ecore doesn't support this natively.

Hope this helps,
Louis.
Re: Syntax for use of ecore types within HUTN [message #879264 is a reply to message #878747] Wed, 30 May 2012 21:50 Go to previous messageGo to next message
Chris Holmes is currently offline Chris HolmesFriend
Messages: 2
Registered: May 2012
Junior Member
Hi Louis,
I'd like to be able to wrap instances of classes defined in my metamodel that are not necesarily related by class hierachy, and also instances of primitives such as the Boolean values, Integer values, etc. In XMF I would have set the attribute 'thing' to be of type XCore:Element.

I'd expected to be able to write something like:
@Spec {
<blah>
}

ThingWrappers {
ThingWrapper "TW1" {
name: "My Thing Wrapper"
thing: true
}
ThingWrapper "TW2" {
name: "Box Wrapper"
thing:
BoxOfChocolates "Chocs" {
name: "Milk Chocolates"
}
}
}

Best Wishes
Chris
Re: Syntax for use of ecore types within HUTN [message #880964 is a reply to message #879264] Sun, 03 June 2012 14:03 Go to previous message
Louis Rose is currently offline Louis RoseFriend
Messages: 440
Registered: July 2009
Location: York, United Kingdom
Senior Member
Hi Chris,

Thanks a lot for the clarification; I think that I understand now.

Unfortunately, I'm almost certain that EMF doesn't have an equivalent of the "thing" type. In fact, I think that primitive and model element types are disjoint in Ecore. One possible way to approach this would be to have a slightly less elegant metamodel, that provides separate wrappers for the primitives and for model elements:

class BooleanWrapper {
  attr Boolean[1] value;
}

class IntegerWrapper {
  attr Integer[1] value;
}

// etc, for other primitive values

class ThingWrapper {
  val EObject[1] thing;
}


With this metamodel, the HUTN would be as follows:

@Spec {
  <blah>
}

ThingWrappers {
  ThingWrapper "TW1" {
    thing: BooleanWrapper { value: true }
}
  ThingWrapper "TW2" {
    thing:  BoxOfChocolates "Chocs" {
      name: "Milk Chocolates"
   }
  }
}


I hope this (slightly clunky) solution will work for you. If not, then we should perhaps ask for some help on the EMF forum.

Cheers,
Louis.
Previous Topic:[ETL] 'group' keyword
Next Topic:"Special" usecase, reuse same element in different diagrams
Goto Forum:
  


Current Time: Thu Apr 25 20:25:26 GMT 2024

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

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

Back to the top