Skip to main content



      Home
Home » Modeling » EMF » [EMF Query 2] Help with writing conditions
[EMF Query 2] Help with writing conditions [message #870660] Wed, 09 May 2012 05:21
Eclipse UserFriend
Hello,

I'm trying to write a query which has a condition composed of two different other conditions, something like:

FROM Book as b
SELECT b.title, b.pages
WHERE b.title = "First book" and b.pages > 20

I need some help cause I have no idea how to convert the finalClause which represents the results of the AND operation applied to this two conditions to a WhereEntry Object in order to be able to pass it to the Where part of the query.

Here is my code:

WhereString whereStringEqualTo = new WhereString("title", Operation.EQUAL, "Second book");
		WhereInt whereIntGreaterThan = new WhereInt("pages", Operation.GREATER, 20);
		
		org.eclipse.emf.query2.WhereEntry whereStringEqualToEntry = new LocalWhereEntry("b", whereStringEqualTo);
		org.eclipse.emf.query2.WhereEntry whereIntGreaterThanEntry = new LocalWhereEntry("b", whereIntGreaterThan);
		ArrayList<WhereClause> clauses = new ArrayList<WhereClause>();
		clauses.add(whereStringEqualTo);
		clauses.add(whereIntGreaterThan);
		
		WhereOr finalClause = new WhereOr(clauses);
		
		org.eclipse.emf.query2.WhereEntry[] whereEntries = new org.eclipse.emf.query2.WhereEntry[] {whereStringEqualToEntry, whereIntGreaterThanEntry};

If I'm running the query now, as it is written I get an AND operator between whereStringEqualToEntry and whereIntGreaterThanEntry but the problem is what if I want to do a OR operations between them?

The second question would be, is it possible to use also OCL Conditions instead these condition classes that are already provided by Query 2? If so, how can I convert from BaseCondition class to a WhatEntry object?

Any answer would be much appreciated.

Best regards,
Radu Comaneci

[Updated on: Wed, 09 May 2012 05:22] by Moderator

Previous Topic:Problem XSD to ECore mapping
Next Topic:Adapt Getters/Setters syntax
Goto Forum:
  


Current Time: Mon Jul 07 22:56:26 EDT 2025

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

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

Back to the top