Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA2 » Help needed for implementing entity match pattern(Do not know how to express the pattern)
Help needed for implementing entity match pattern [message #1063790] Fri, 14 June 2013 05:14 Go to next message
Alexander Fülleborn is currently offline Alexander Fülleborn
Messages: 74
Registered: April 2013
Member
Hi all,

I am working on implementing a pattern and have trouble in expressing the requirements that this pattern needs to fulfil. In my model that has been imported from .uml files, there is an entity named "PSL problem statement" that is the source of a relation named "uN19363_47" that has the type "appliedStereotype" and the target "PSL problem statement". I need to get a reference to this entity "PSL problem statement". I put these requirements also as comments into the subsequent listing. Any idea/support is highly appreciated.

Thanks in advance and kind regards, Alex

Listing of my transformation:

---
namespace uml.models;
import uml.metamodel.uml;

machine SalaryStatementPCM2PCPTransformation
{
rule main(in Model) =
let DomainSpecificProblemContextModel = undef,
XDomainProblemContextPatternModel = undef in seq{
new (Model(XDomainProblemContextPatternModel) in uml.models);
rename(XDomainProblemContextPatternModel, "Cross-domain Problem Context Pattern Model");
print("'Cross-domain Problem Context Pattern Model' created");
choose DomainSpecificProblemStatement below uml.models with find isProblemStatement(DomainSpecificProblemStatement) do print(name(DomainSpecificProblemStatement));
}
pattern isProblemStatement(DomainSpecificProblemStatement) =
{
// Requirement:
// The entity/model element 'PSL problem statement' needs to be
// found according to the following constraints:
// => 'PSL problem statement is the source element of
// 'DomainSpecificProblemStatement'
// => 'DomainSpecificProblemStatement' is the relation named "uN19363_47"
// of type 'appliedStereotype'
// => with the target "PSL problem statement".
}
}

Re: Help needed for implementing entity match pattern [message #1063802 is a reply to message #1063790] Fri, 14 June 2013 05:58 Go to previous message
Abel Hegedus is currently offline Abel Hegedus
Messages: 88
Registered: July 2009
Member
Hi Alexander,

I will try to walk you through the pattern creation process so you will be able to create other patterns on your own.

Quote:

pattern isProblemStatement(DomainSpecificProblemStatement) =
{
// Requirement:
// The entity/model element 'PSL problem statement' needs to be 
// found according to the following constraints: 
// => 'PSL problem statement is the source element of 
// 'DomainSpecificProblemStatement'
// => 'DomainSpecificProblemStatement' is the relation named "uN19363_47"
//	 of type 'appliedStereotype'
// => with the target "PSL problem statement".	}	
}



If I understand right:
- there is an uml.metamodel.uml.Element typed entity with name "PSL problem statement"
-> Let's call this variable Elem
- there is an uml.metamodel.uml.Stereotype typed entity with name "MyStereoType" (I intentionally changed it to avoid confusion)
-> Let's call this variable StType
- there is a relation with type uml.metamodel.uml.Element.appliedStereotype between Elem and StType
-> Let's call the variable representing the relation AppliedSt

Then, taking advantage of the declarative nature of the pattern language, you just convert each line to a statement, like this:

pattern isProblemStatement(Elem) =
{
  uml.metamodel.uml.Element(Elem);
  uml.metamodel.uml.Stereotype(StType);
  check(name(StType) == "MyStereoType");
  uml.metamodel.uml.Element.appliedStereotype(AppliedST,Elem,StType);
}


The above pattern will match on the entity which has the stereotype with the given name applied on it.

Unfortunately the links on the main site are broken, but the main wiki page has the correct links: http://wiki.eclipse.org/VIATRA2 (under Documentation, the language specfication, though outdated should still help in finding the details that are not covered by the wiki).
Previous Topic:[Import of uml file to model space] Not all Model elements imported
Next Topic:Question concerning my use case for pattern search via EMF-IncQuery
Goto Forum:
  


Current Time: Thu Jul 24 09:20:31 EDT 2014

Powered by FUDForum. Page generated in 0.02216 seconds