Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » how to access to association end in code
how to access to association end in code [message #988537] Fri, 30 November 2012 11:58 Go to next message
Abbas Mansoori Razi is currently offline Abbas Mansoori RaziFriend
Messages: 7
Registered: August 2012
Junior Member
I use a model with two class diagram.
but I give a error that "not recognized variable referee" for
self.referee->forAll(r| not r.isStudent).

model is attached and a section of my code is:

OCL<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, ?, CallOperationAction, ?, Constraint, EClass, EObject> ocl;
ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);


OCLHelper<EClassifier,?, ?, Constraint> helper = ocl.createOCLHelper();


//start PAPER classfier
// set the OCL context classifier for PAPER--------------------

helper.setContext(PaperresearcherrosemodelPackage.Literals.PAPER);


// create an extent map for 'submission'
Map<EClass, Set<? extends EObject>> extents = new HashMap<EClass, Set<? extends EObject>>();
Set<Paper> submission = new HashSet<Paper>();

extents.put(PaperresearcherrosemodelPackage.Literals.PAPER, submission);

// tell the OCL environment what our classifier extents are
ocl.setExtentMap(extents);

Paper paper = PaperresearcherrosemodelFactory.eINSTANCE.createPaper();


paper.setTitle("uml-ocl verification");
paper.setWordCount(5000);
paper.setStudentPaper(true);
submission.add(paper);



// create an extent map for 'manuscript'

Set<Paper> manuscript = new HashSet<Paper>();

extents.put(PaperresearcherrosemodelPackage.Literals.PAPER, manuscript);

// tell the OCL environment what our classifier extents are
ocl.setExtentMap(extents);


paper.setTitle("uml-ocl verification");
paper.setWordCount(5000);
paper.setStudentPaper(true);
manuscript.add(paper);
//end PAPER classfier **************************************

//start RESEARCHER classfier *********************************************

// create an extent map for 'submission'

Set<Researcher> referee = new HashSet<Researcher>();

extents.put(PaperresearcherrosemodelPackage.Literals.RESEARCHER, referee);

// tell the OCL environment what our classifier extents are
ocl.setExtentMap(extents);

Researcher researcher = aperresearcherrosemodelFactory.eINSTANCE.createResearcher();


researcher.setName("reza");
researcher.setIsStudent(false);
referee.add(researcher);



// create an extent map for 'manuscript'

Set<Researcher> author = new HashSet<Researcher>();

extents.put(PaperresearcherrosemodelPackage.Literals.RESEARCHER,author);

// tell the OCL environment what our classifier extents are
ocl.setExtentMap(extents);

researcher.setName("reza");
researcher.setIsStudent(false);
author.add(researcher);

//end RESEARCHER classfier

//new project is started in date 1391/08/27------------------------------------
helper.setContext(PaperresearcherrosemodelPackage.Literals.PAPER);


try {

query= helper.createQuery("self.referee->forAll(r| not r.isStudent)");

} catch (ParserException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
  • Attachment: model.JPG
    (Size: 16.75KB, Downloaded 227 times)
Re: how to access to association end in code [message #988680 is a reply to message #988537] Sat, 01 December 2012 07:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you understand you're problem well enough to present only a part of
it, you are surely able to solve the problem yourself.

I see no question in your report and no error message either, so it is
far from clear to me what you want to know.

I can only guess that you have neglected to realize that EMF reifies
model properties with getters and setters, so getXXXX.

If you want help ZIP up a simple project that demonstrates your best
endeavours at solving a clearly expressed problem.

Regards

Ed Willink

On 30/11/2012 13:35, Abbas Mansoori Razi wrote:
> I use a model with two class diagram.
> but I give a error that "not recognized variable referee" for
> self.referee->forAll(r| not r.isStudent).
>
> model is attached and a section of my code is:
>
> OCL<?, EClassifier, EOperation, EStructuralFeature, EEnumLiteral, EParameter, ?, CallOperationAction, ?, Constraint, EClass, EObject> ocl;
> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
>
>
> OCLHelper<EClassifier,?, ?, Constraint> helper = ocl.createOCLHelper();
>
>
> //start PAPER classfier
> // set the OCL context classifier for PAPER--------------------
>
> helper.setContext(PaperresearcherrosemodelPackage.Literals.PAPER);
>
>
> // create an extent map for 'submission'
> Map<EClass, Set<? extends EObject>> extents = new HashMap<EClass, Set<? extends EObject>>();
> Set<Paper> submission = new HashSet<Paper>();
>
> extents.put(PaperresearcherrosemodelPackage.Literals.PAPER, submission);
>
> // tell the OCL environment what our classifier extents are
> ocl.setExtentMap(extents);
>
> Paper paper = PaperresearcherrosemodelFactory.eINSTANCE.createPaper();
>
>
> paper.setTitle("uml-ocl verification");
> paper.setWordCount(5000);
> paper.setStudentPaper(true);
> submission.add(paper);
>
>
>
> // create an extent map for 'manuscript'
>
> Set<Paper> manuscript = new HashSet<Paper>();
>
> extents.put(PaperresearcherrosemodelPackage.Literals.PAPER, manuscript);
>
> // tell the OCL environment what our classifier extents are
> ocl.setExtentMap(extents);
>
>
> paper.setTitle("uml-ocl verification");
> paper.setWordCount(5000);
> paper.setStudentPaper(true);
> manuscript.add(paper);
> //end PAPER classfier **************************************
>
> //start RESEARCHER classfier *********************************************
>
> // create an extent map for 'submission'
>
> Set<Researcher> referee = new HashSet<Researcher>();
>
> extents.put(PaperresearcherrosemodelPackage.Literals.RESEARCHER, referee);
>
> // tell the OCL environment what our classifier extents are
> ocl.setExtentMap(extents);
>
> Researcher researcher = aperresearcherrosemodelFactory.eINSTANCE.createResearcher();
>
>
> researcher.setName("reza");
> researcher.setIsStudent(false);
> referee.add(researcher);
>
>
>
> // create an extent map for 'manuscript'
>
> Set<Researcher> author = new HashSet<Researcher>();
>
> extents.put(PaperresearcherrosemodelPackage.Literals.RESEARCHER,author);
>
> // tell the OCL environment what our classifier extents are
> ocl.setExtentMap(extents);
>
> researcher.setName("reza");
> researcher.setIsStudent(false);
> author.add(researcher);
>
> //end RESEARCHER classfier
>
> //new project is started in date 1391/08/27------------------------------------
> helper.setContext(PaperresearcherrosemodelPackage.Literals.PAPER);
>
>
> try {
>
> query= helper.createQuery("self.referee->forAll(r| not r.isStudent)");
>
> } catch (ParserException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
Re: how to access to association end in code [message #988708 is a reply to message #988680] Sat, 01 December 2012 18:50 Go to previous messageGo to next message
Abbas Mansoori Razi is currently offline Abbas Mansoori RaziFriend
Messages: 7
Registered: August 2012
Junior Member
thanks for fast your respond.
my project is attached.my first model was "paper-researcher-rose model.mdl"(rational rose model) that convert to .ecore and .genmodel model with eclipse and then
I build automatically code from .genmodel model but this code doesn't include association end's from uml model(.mdl).
how to built code from .genmodel model with association end's as attribute of classes.


error is:

org.eclipse.ocl.SemanticException: Unrecognized variable: (referee)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:358)
...
Re: how to access to association end in code [message #988738 is a reply to message #988708] Sun, 02 December 2012 10:22 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The most obvious problem is that your genmodel uses

xmlns:genmodel="http://www.eclipse.org/emf/2002/GenModel

rather than

xmlns:genmodel="http://www.eclipse.org/uml2/2.2.0/GenModel"

so you have excluded UML support.

When I try to create a GenModel from your paper-researcher-rose
model.mdl file, I get three errors: an unresolved type name and two
unresolved stereotypes, so it looks as if your *.mdl file is not
compatible with the *.mdl load. If the first step fails, it's not
surprising that subsequent steps also fail.

I don't have any *.mdl tooling but it looks to me as if you are using a
Framework and have not yet filled in all the blanks.

e.g.

object Class "<Process Name>"

defines a class name with angle brackets in; surely a bad idea.

You need to finish/stub out your design and pay attention to diagnostics.

Regards

Ed Willink



On 01/12/2012 18:50, Abbas Mansoori Razi wrote:
> thanks for fast your respond.
> my project is attached.my first model was "paper-researcher-rose model.mdl"(rational rose model) that convert to .ecore and .genmodel model with eclipse and then
> I build automatically code from .genmodel model but this code doesn't include association end's from uml model(.mdl).
> how to built code from .genmodel model with association end's as attribute of classes.
>
>
> error is:
>
> org.eclipse.ocl.SemanticException: Unrecognized variable: (referee)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:358)
> ...
Re: how to access to association end in code [message #989120 is a reply to message #988738] Tue, 04 December 2012 17:08 Go to previous messageGo to next message
Abbas Mansoori Razi is currently offline Abbas Mansoori RaziFriend
Messages: 7
Registered: August 2012
Junior Member
Hi Ed
I found a solution for own problem.the first converted new "paper-researcher-rose model.mdl" to .ecore
but still don't add association ends to clesses in .ecore model.
I manually edited .ecore model and added association ends attribute to classes and then create .genmodel.
in finally my project works without any error.
please more explain about "defines a class name with angle brackets in; surely a bad idea."

Best regards
Re: how to access to association end in code [message #989122 is a reply to message #989120] Tue, 04 December 2012 17:24 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You MDL file has lines such as

object Class "<Process Name>"

which suggests to me that you have defined a class named "<Process
Name>" ; i.e with angle brackets in.

It seems like you think you have solved your problems. It seems to me
that you have hidden them and are now waiting for them to reappear in
some new annoying way.

Regards

Ed Willink


On 04/12/2012 17:08, Abbas Mansoori Razi wrote:
> Hi Ed
> I found a solution for own problem.the first converted new "paper-researcher-rose model.mdl" to .ecore
> but still don't add association ends to clesses in .ecore model.
> I manually edited .ecore model and added association ends attribute to classes and then create .genmodel.
> in finally my project works without any error.
> please more explain about "defines a class name with angle brackets in; surely a bad idea."
>
> Best regards
>
Re: how to access to association end in code [message #989126 is a reply to message #989122] Tue, 04 December 2012 17:47 Go to previous message
Abbas Mansoori Razi is currently offline Abbas Mansoori RaziFriend
Messages: 7
Registered: August 2012
Junior Member
Thank's a lot.

Best regards
Previous Topic:Using OCL MDT sources from git
Next Topic:OCLinEcore : PermGen space error
Goto Forum:
  


Current Time: Fri Apr 19 13:02:21 GMT 2024

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

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

Back to the top