Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » HOW do you Query for multiple values with Texo/JSON REST Web Services(Using Texo JSON/Webservices)
HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1132502] Fri, 11 October 2013 07:30 Go to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Hello,

I'm trying to use the Texo webservice. I have managed to do the basic calls on one object a get all the data on one given object.



But this object has data in a grid which has derived data from other referred-to-entities : proxies. For instance the Fournisseur object.

I am trying to build a grid and I need these other objects.

Can you give me an example off how to query the main object un its proxy objects at the same time ?

Regards

David Namboka
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1132801 is a reply to message #1132502] Fri, 11 October 2013 11:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
See this section, it contains examples on how to get multiple values for an object using queries:
http://wiki.eclipse.org/Texo/JSON_REST_Web_Services#Querying

Should be something like this:
{
"_eclass": "request|QueryType",
"query": "select e, e.author.name from library_Book e where e.title like :title",
"parameters": [{
"name": "title",
"value": "title2%"
}]
}

I have not tested with multiple derived values though, but it should work.

You should also check how your ORM does the joining of these additional values, there is a 'danger' that an inner-join
is being used, which would prevent any records with null values showing up.

gr. Martin

On 10/11/2013 01:04 PM, namboka david wrote:
> Hello,
> I'm trying to use the Texo webservice. I have managed to do the basic calls on one object a get all the data on one
> given object.
>
>
>
> But this object has data in a grid which has derived data from other referred-to-entities : proxies. For instance the
> Fournisseur object.
>
> I am trying to build a grid and I need these other objects.
>
> Can you give me an example off how to query the main object un its proxy objects at the same time ?
>
> Regards
>
> David Namboka


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1132827 is a reply to message #1132801] Fri, 11 October 2013 12:12 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Thank you for this answer Martin.

I have attached the generated JSON I recieve.

I am going to re-check for the joining as you advised.

However I am not sure but when I read this query, isn't it only questionning the library_BOOK table ? I might be clearly confused. :

{
"_eclass": "request|QueryType",
"query": "select e, e.author.name from library_Book e where e.title like :title",
"parameters": [{
"name": "title",
"value": "title2%"
}]
}

Thank you for the link, I've actualy been reading it closely.

For information this is an example json I am dealing with :

I have a first ACHAT object which is returned in the data []. That ACHAT has a joint attribut on FOURNISSEUR object. Therefore my ACHAT.Fourniture attribute has attached FOURNITURE object with an uri that links to the JSON I have to fetch to get the details of my fourniture object.
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1132834 is a reply to message #1132827] Fri, 11 October 2013 12:21 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
I have just gone thrue the ecore in the example shipped in the tutorials. author is a attribut of the BOOK object and is joint with the WRITER object.

I've got the answer to my question.

Thank you and best regards Martin.

I'll keep you posted on how I've dealt with my issue.

David
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1137153 is a reply to message #1132834] Mon, 14 October 2013 09:45 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Hello Martin,

Would it be possible to have a JSON formatted request instead of a query which would fetch all the needed data ? Instead of posting a sql formatted query as you sent in the previous answer ? For instance org.eclipse.emf.texo.web.example/jsonws/BOOK+WRITER ?

Regards
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1137241 is a reply to message #1137153] Mon, 14 October 2013 10:55 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
Afaics the request is a json object with one of the fields being the query. Can you give some more details on what you
think of? (for example I am not sure that BOOK+WRITER will work, I guess maybe BOOK+author, but I can also imagine using
a separate json parameter with additionalProperties: author, author.name etc.

gr. Martin

On 10/14/2013 11:45 AM, namboka david wrote:
> Hello Martin,
> Would it be possible to have a JSON formatted request instead of a query which would fetch all the needed data ? Instead
> of posting a sql formatted query as you sent in the previous answer ? For instance
> org.eclipse.emf.texo.web.example/jsonws/BOOK+WRITER ?
>
> Regards


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1137318 is a reply to message #1137241] Mon, 14 October 2013 12:04 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
I was thinking about the GET request in fact. Yes in fact it would be smarter I assume to do the BOOK request and retrieve the associated data from another table in the additionnal property.

At this point I've managed to query the proxy objects using a recursive jquery $.getJSON() request. It works just fine as I use the uri fetched on the parent object as a parameter to fetch the associated proxy in another function.

Regards
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1196586 is a reply to message #1137241] Tue, 19 November 2013 13:43 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Hello Martin,

I have been using TEXO for the last months. It is really an impressive tool. I have two questions though. I was wondering if TEXO could be used in another JAVA project. For instance an Entreprise Application Project.

Secondly I am facing a dilema. For a project, I need to convert business typed object to MySQL VARCHAR,TINYINT,SMALLINT,MEDIUMINT,INT,BIGINT. Unfortunately, using Texo, all I get in MySQL's Workbench are objects.

Could you indicate where, in TEXO, I can do the mapping of my business object types to Mysql native types ?

Regards
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1196687 is a reply to message #1196586] Tue, 19 November 2013 14:42 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
Afaics you can use Texo in any web project. Texo is based on my experience as software architect at Openbravo (an open
source ERP), and imo Texo can definitely be used in enterprise application projects. See this wiki link for the
dependencies:
http://wiki.eclipse.org/Texo/Download_and_Install#Runtime_usage.2C_web_container

For your mysql question, I don't yet fully understand, Texo uses JPA/ORM to persist in the database, the column types in
the database should be as you want: varchar, tinyint, etc.
Or are you somehow from mysql workbench calling JPA/ORM or the json webservice layer? If so can you give some links to
docs, I am interested to know your use case to also better answer your question.

gr. Martin

On 11/19/2013 02:43 PM, namboka david wrote:
> Hello Martin,
>
> I have been using TEXO for the last months. It is really an impressive tool. I have two questions though. I was
> wondering if TEXO could be used in another JAVA project. For instance an Entreprise Application Project.
> Secondly I am facing a dilema. For a project, I need to convert business typed object to MySQL
> VARCHAR,TINYINT,SMALLINT,MEDIUMINT,INT,BIGINT. Unfortunately, using Texo, all I get in MySQL's Workbench are objects.
> Could you indicate where, in TEXO, I can do the mapping of my business object types to Mysql native types ?
> Regards


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198520 is a reply to message #1196687] Wed, 20 November 2013 11:15 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Thank you for the quick answer Martin. I'm going to come up with a tighter explanation of the issue. Next post should be more precise. In the meantime, I'm glad to learn that you had worked as a software architect on OpenBravo. In fact my functional environment is close to ERP's.

I have a more pattern oriented question I would like to ask concerning your approach on TEXO. As far as my use of the tool is concerned, I understand TEXO generates plain old java objects on which JPA annotations are added. No extra intelligence is added on those objects except assessors for object attributes. Which clearly sounds reasonable.

Now what if one needed to added checking routines on values affected to those attributes.

Two different approaches could be used. Either by enrichening the body of the assessor associated to the attribute. Either by adding another layer above the models and adding the check routines in that layer. I would like to have your opinion on that question, based on your experience. Would you leave the model as POJO objects on which a sort of control layer is added for any extra intelligence injection ? Or would you enrich the body of those POJO assessors ?

Would the DAO object be a good place to add that extra intelligence ?



Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198630 is a reply to message #1198520] Wed, 20 November 2013 12:25 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
Hi David,
It all depends and I know opinions out there differ, but you ask for my opinion :-).

Constraints/validations which can be applied without any contextual knowledge and which are needed for the validity of
persisted data can be done on the data object, for example not-null constraints in the database or only allow positive
integers values in specific member.

But any constraint which needs contextual information (or the value of other attributes) can best be implemented outside
of the data object. There are cases where a data object is being constructed/set and its values are partially set,
validation can not happen when calling a setter then, the whole object needs to be constructed/set before validation can
take place.

I am in favor of light data objects, which serve more as a kind of hashmap/key-value pair and have the main behavior
(incl. validation) implemented in separately pluggable service classes.

So imho I would not do constraint checking in the object itself (except for special cases, there are always special
cases), and do most constraint checking/validation in a separate layer.

Hope this answers your question.

gr. Martin

On 11/20/2013 12:15 PM, namboka david wrote:
> Thank you for the quick answer Martin. I'm going to come up with a tighter explanation of the issue. Next post should be
> more precise. In the meantime, I'm glad to learn that you had worked as a software architect on OpenBravo. In fact my
> functional environment is close to ERP's.
> I have a more pattern oriented question I would like to ask concerning your approach on TEXO. As far as my use of the
> tool is concerned, I understand TEXO generates plain old java objects on which JPA annotations are added. No extra
> intelligence is added on those objects except assessors for object attributes. Which clearly sounds reasonable.
>
> Now what if one needed to added checking routines on values affected to those attributes.
> Two different approaches could be used. Either by enrichening the body of the assessor associated to the attribute.
> Either by adding another layer above the models and adding the check routines in that layer. I would like to have your
> opinion on that question, based on your experience. Would you leave the model as POJO objects on which a sort of control
> layer is added for any extra intelligence injection ? Or would you enrich the body of those POJO assessors ?
> Would the DAO object be a good place to add that extra intelligence ?
>
>
>
>


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198739 is a reply to message #1198630] Wed, 20 November 2013 13:36 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
To be honest I'm glad to read this answer. I have the same convictions. Although I had not picked up the eventuality that some checks may need to be done on the objects. (A negative INT typed cost attribute on a Sales object for instance).

I'm studying the DAO pattern in detail wondering if constraints and validation could inserted on the DAO layer. As you said it may be actually smarter to handle this in a layer that has nothing to do with data access.

DAO's are the link between pojo's and the persistant layer after all. Which already quite a huge task. I can not help thinking that the checking should be done before accessing the model.

David
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198741 is a reply to message #1198739] Wed, 20 November 2013 13:38 Go to previous messageGo to next message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Oh, by the way just for record what do you mean by separately pluggable service classes ?
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198757 is a reply to message #1198741] Wed, 20 November 2013 13:46 Go to previous messageGo to next message
Martin Taal is currently offline Martin TaalFriend
Messages: 5468
Registered: July 2009
Senior Member
A dao could be seen as a service, so a daofactory can be used to make it configurable what Dao implementation is being
used.

The same for validation, you can create separate validators for each eclass (the approach followed by EMF standard also).

So in my view an application is a set of service classes which are instantiated on the fly and pluggable (i.e. can be
replaced by other implementations), the data traveling through these service classes are simple pojos.

The service classes should implement an api defined by an abstract class (I don't particurarly like interfaces as they
make result in binary incompatibility when extending the api, it is better (all imho) to use abstract classes with
default implementations of the api where it makes sense).

gr. Martin


On 11/20/2013 02:38 PM, namboka david wrote:
> Oh, by the way just for record what do you mean by separately pluggable service classes ?


--

With Regards, Martin Taal

Springsite/Elver.org
Office: Hardwareweg 4, 3821 BV Amersfoort
Postal: Nassaulaan 7, 3941 EC Doorn
The Netherlands
Cell: +31 (0)6 288 48 943
Tel: +31 (0)84 420 2397
Fax: +31 (0)84 225 9307
Mail: mtaal@xxxxxxxx - mtaal@xxxxxxxx
Web: www.springsite.com - www.elver.org
Re: HOW do you Query for multiple values with Texo/JSON REST Web Services [message #1198780 is a reply to message #1198757] Wed, 20 November 2013 14:02 Go to previous message
namboka david is currently offline namboka davidFriend
Messages: 13
Registered: September 2013
Junior Member
Very interesting. It is a real pleasure. I agree at all levels. I'm in the process of auditing tools to help a client take the MDD curve. My opinion is that TEXO covers a lot
of what is needed. After this exchange I'm going read about the pluggable services and see they can be integrated to interact smartely with TEXO. I will surely keep you posted on the project and on the issue I have spoke about ealier. Thanks for the exchange.

With Regards,

David Namboka.


Previous Topic:[Texo] Save proxy
Next Topic:Ecore Tools - Graphical editor extension
Goto Forum:
  


Current Time: Fri Mar 29 12:29:33 GMT 2024

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

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

Back to the top