how to access to association end in code [message #988537] |
Fri, 30 November 2012 06:58  |
Eclipse User |
|
|
|
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 268 times)
|
|
|
Re: how to access to association end in code [message #988680 is a reply to message #988537] |
Sat, 01 December 2012 02:33   |
Eclipse User |
|
|
|
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();
> }
>
|
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03667 seconds