You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Paul Boldijar <pa...@3sstudio.com> on 2014/10/30 13:34:24 UTC

Problem with Odata

Hello!
I'm using Odata to generate the models for a REST api.
I have an Animal entity.
For it I found 2 collection entities, Animals and AnimalCollection.

When I use container.getAnimals() , I have the .count() method for them.
When I use client.getAnimals() (client is another entity) I get a
AnimalCollection entity that only has .size(), and the problem is if I want
to count the animals, all animals will be loaded, and it will return the
size of the collection...

I need to only get the animals count from the client..
Do you have any ideea what can I do?

I hope you understand what I'm trying to say.

Thanks.

Re: Problem with Odata

Posted by Alex Maiereanu <al...@3sstudio.com>.
I will chip in on this topic since Paul is working on the same team with me.

Paul wants to get all the animals that a client has.

If he uses this code:

AnimalCollection  animals= client.getAnimals(); , he gets an AnimalCollection,
that has no count method or property. There is a size method, but that
method returns all animals, regardless of the client. Is there a way to get
the count or does he need to create a filter like this:
         container.getAnimals().filter("ClientId eq 1 and count eq true")


As a sidenote. The java classes for the client have been generated with the
maven pojo generator




 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Thu, Oct 30, 2014 at 3:47 PM, Paul Boldijar <pa...@3sstudio.com>
wrote:

> Thanks for your reply!
>
> I want to get the number of animals that a client has.
>
> Using
> AnimalCollection  animals= client.getAnimals();
> int count=animals.execute().size();
> This will load all the animals ( everything about them ) and .size will
> give me the count.
> I want to directly get the count of the animals without loading each of
> them....
>
>
> Do you understand now?
>
>
> Thanks!
>
> Paul.
>
> On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com> wrote:
>
>> Paul,
>>
>> Just for some naming semantics, Animal would be a EnityType, Animals and
>> AnimalCollection are EntitySets. You could define as many EnitySets as you
>> want on a given EntityTpe, it really depends on how you defined your
>> metadata.
>>
>> When you are asking "client.getAnimals" you are asking for Animals, that
>> are *associated* with Client vs. when you use container.getAnimals() you
>> are asking for *all* the animals. That is the difference.
>>
>> I am not sure where you are going with count vs size question. Can you
>> clarify?
>>
>> Ramesh..
>>
>> ------------------------------
>>
>> Hello!
>> I'm using Odata to generate the models for a REST api.
>> I have an Animal entity.
>> For it I found 2 collection entities, Animals and AnimalCollection.
>>
>> When I use container.getAnimals() , I have the .count() method for them.
>> When I use client.getAnimals() (client is another entity) I get a
>> AnimalCollection entity that only has .size(), and the problem is if I want
>> to count the animals, all animals will be loaded, and it will return the
>> size of the collection...
>>
>> I need to only get the animals count from the client..
>> Do you have any ideea what can I do?
>>
>> I hope you understand what I'm trying to say.
>>
>> Thanks.
>>
>>
>>
>

Re: Problem with Odata

Posted by "Bolz, Michael" <mi...@sap.com>.
Hi Francesco,

it was not my intention to trouble you in any way with mentioning you on the mailing list.

From my point of view I can fully understand that any support you do is on your private time 
and hence we are really grateful about any support and help from you   ;o)

Wish you a nice weekend,

Kind regards 
Michael

On 31 Oct 2014, at 16:26, Francesco Chicchiriccò <il...@apache.org> wrote:

> Hi all,
> I am subscribed to this mailing list, so there is no point IMHO in pointing directly to my address: if I had time to reply to private questions on Olingo, I also got time to do it here in the public mailing list, which is the appropriate place.
> 
> Unfortunately at the moment I can't find a quick answer to Alex's question, e.g. performing a count() on an entity collection - not an entity set - via proxy *without* fetching the whole collection first.
> 
> I can only suggest to take a look at integration tests:
> 
> https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=fit/src/test/java/org/apache/olingo/fit/proxy/v4
> 
> to see if there something matching your requirements.
> 
> HTH
> Regards.
> 
> On 31/10/2014 15:39, Bolz, Michael wrote:
>> Hi Alex,
>> 
>> nice to here that it worked  ;o)
>> 
>> I think Francesco (ilgrosso@apache.org) is the correct person for the Android Client.
>> And for adding documentation to the Olingo.org homepage it would be Christian (chrisam@apache.org) or me (mibo@apache.org).
>> 
>> And thanks in advance for writing and contribution of documentation  ;o)
>> 
>> Kind regards,
>> Michael
>> 
>> On 31 Oct 2014, at 15:23, Alex Maiereanu <al...@3sstudio.com> wrote:
>> 
>>> Hi Ramesh,
>>> 
>>> Thanks for the input. We just tried out the getRetrieveRequestFactory() way of querying, and it worked :) . Now we would like  to do this with the generated Poco classes for our service. We are using V4.
>>> Can somebody tell us the contact to the guys who have worked on the Android Odata Client ? 
>>> 
>>> Also since, we have played quite a lot with the odata client, maybe we could help you with some documentation. At this point we where thinking of creating a blog post about this topic
> -- 
> Francesco Chicchiriccò
> 
> Tirasa - Open Source Excellence
> http://www.tirasa.net/
> 
> Involved at The Apache Software Foundation:
> member, Syncope PMC chair, Cocoon PMC, Olingo PMC
> http://people.apache.org/~ilgrosso/


Re: Problem with Odata

Posted by Alex Maiereanu <al...@3sstudio.com>.
Hey Francesco,

We know that everybody in the olingo team is busy with day to day leaving
and our intention is not to bombard you with mails for every little bit of
problem. Nonetheless, we are actively implementing the framework into an
android app and are finding all sorts of stuff, that may or may not be
bugs. Also, we want to help you guys with the documentation.

We are also using the integration tests for documentation. For the proxy
class we have looked into this collection

https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=fit/src/test/java/org/apache/olingo/fit/proxy/v4;h=88fc3c555577de8ec776dd18981a6e872f389f80;hb=HEAD


 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Fri, Oct 31, 2014 at 5:26 PM, Francesco Chicchiriccò <ilgrosso@apache.org
> wrote:

>  Hi all,
> I am subscribed to this mailing list, so there is no point IMHO in
> pointing directly to my address: if I had time to reply to private
> questions on Olingo, I also got time to do it here in the public mailing
> list, which is the appropriate place.
>
> Unfortunately at the moment I can't find a quick answer to Alex's
> question, e.g. performing a count() on an entity collection - not an entity
> set - via proxy *without* fetching the whole collection first.
>
> I can only suggest to take a look at integration tests:
>
>
> https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=fit/src/test/java/org/apache/olingo/fit/proxy/v4
>
> to see if there something matching your requirements.
>
> HTH
> Regards.
>
> On 31/10/2014 15:39, Bolz, Michael wrote:
>
> Hi Alex,
>
>  nice to here that it worked  ;o)
>
>  I think Francesco (ilgrosso@apache.org) is the correct person for the
> Android Client.
> And for adding documentation to the Olingo.org homepage it would be
> Christian (chrisam@apache.org) or me (mibo@apache.org).
>
>  And thanks in advance for writing and contribution of documentation  ;o)
>
>  Kind regards,
> Michael
>
>  On 31 Oct 2014, at 15:23, Alex Maiereanu <al...@3sstudio.com>
> wrote:
>
>  Hi Ramesh,
>
>  Thanks for the input. We just tried out the getRetrieveRequestFactory()
> way of querying, and it worked :) . Now we would like  to do this with the
> generated Poco classes for our service. We are using V4.
> Can somebody tell us the contact to the guys who have worked on the
> Android Odata Client ?
>
>  Also since, we have played quite a lot with the odata client, maybe we
> could help you with some documentation. At this point we where thinking of
> creating a blog post about this topic
>
>  --
> Francesco Chicchiriccò
>
> Tirasa - Open Source Excellencehttp://www.tirasa.net/
>
> Involved at The Apache Software Foundation:
> member, Syncope PMC chair, Cocoon PMC, Olingo PMChttp://people.apache.org/~ilgrosso/
>
>

Re: Problem with Odata

Posted by Francesco Chicchiriccò <il...@apache.org>.
Hi all,
I am subscribed to this mailing list, so there is no point IMHO in 
pointing directly to my address: if I had time to reply to private 
questions on Olingo, I also got time to do it here in the public mailing 
list, which is the appropriate place.

Unfortunately at the moment I can't find a quick answer to Alex's 
question, e.g. performing a count() on an entity collection - not an 
entity set - via proxy *without* fetching the whole collection first.

I can only suggest to take a look at integration tests:

https://git-wip-us.apache.org/repos/asf?p=olingo-odata4.git;a=tree;f=fit/src/test/java/org/apache/olingo/fit/proxy/v4

to see if there something matching your requirements.

HTH
Regards.

On 31/10/2014 15:39, Bolz, Michael wrote:
> Hi Alex,
>
> nice to here that it worked  ;o)
>
> I think Francesco (ilgrosso@apache.org <ma...@apache.org>) 
> is the correct person for the Android Client.
> And for adding documentation to the Olingo.org <http://Olingo.org> 
> homepage it would be Christian (chrisam@apache.org 
> <ma...@apache.org>) or me (mibo@apache.org 
> <ma...@apache.org>).
>
> And thanks in advance for writing and contribution of documentation  ;o)
>
> Kind regards,
> Michael
>
> On 31 Oct 2014, at 15:23, Alex Maiereanu <alex.maiereanu@3sstudio.com 
> <ma...@3sstudio.com>> wrote:
>
>> Hi Ramesh,
>>
>> Thanks for the input. We just tried out the 
>> getRetrieveRequestFactory() way of querying, and it worked :) . Now 
>> we would like  to do this with the generated Poco classes for our 
>> service. We are using V4.
>> Can somebody tell us the contact to the guys who have worked on the 
>> Android Odata Client ?
>>
>> Also since, we have played quite a lot with the odata client, maybe 
>> we could help you with some documentation. At this point we where 
>> thinking of creating a blog post about this topic

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: Problem with Odata

Posted by "Bolz, Michael" <mi...@sap.com>.
Hi Alex,

nice to here that it worked  ;o)

I think Francesco (ilgrosso@apache.org) is the correct person for the Android Client.
And for adding documentation to the Olingo.org homepage it would be Christian (chrisam@apache.org) or me (mibo@apache.org).

And thanks in advance for writing and contribution of documentation  ;o)

Kind regards,
Michael

On 31 Oct 2014, at 15:23, Alex Maiereanu <al...@3sstudio.com> wrote:

> Hi Ramesh,
> 
> Thanks for the input. We just tried out the getRetrieveRequestFactory() way of querying, and it worked :) . Now we would like  to do this with the generated Poco classes for our service. We are using V4.
> Can somebody tell us the contact to the guys who have worked on the Android Odata Client ? 
> 
> Also since, we have played quite a lot with the odata client, maybe we could help you with some documentation. At this point we where thinking of creating a blog post about this topic
> 
>  Salutari din Brasov /  Greetings from Brasov
> 
> Alex-Paul Maiereanu
> 
> +40 761 684 212
> www.3sstudio.com
> 
> Facebook Twitter Google+
> 


Re: Problem with Odata

Posted by Alex Maiereanu <al...@3sstudio.com>.
Hi Ramesh,

Thanks for the input. We just tried out the getRetrieveRequestFactory() way
of querying, and it worked :) . Now we would like  to do this with the
generated Poco classes for our service. We are using V4.
Can somebody tell us the contact to the guys who have worked on the Android
Odata Client ?

Also since, we have played quite a lot with the odata client, maybe we
could help you with some documentation. At this point we where thinking of
creating a blog post about this topic

 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Fri, Oct 31, 2014 at 3:28 PM, Ramesh Reddy <ra...@redhat.com> wrote:

> Alex,
>
> Is this using V4 or V2?
>
> I do not remember V2 of the Odata spec has support for $count on
> associated entities. V4 most definitely supports it. The client request for
> V4 needs to be something like
>
> final ODataValueRequest request = getClient().getRetrieveRequestFactory()
>   .appendEntitySetSegment("client")
>   .appendKeySegment("client-id")
>   .appendNavigationSegment("Animals")
>   .count()
>   .build());
>
> Ramesh..
>
> ------------------------------
>
> Hey Michael,
>
> We already know how the $count works. We also know how to request the
> $filter based inline count so that we get the count of the filtered
> entities.
>
> The client code/classes have been generated using this plugin:
>
> http://mvnrepository.com/artifact/org.apache.olingo/pojogen-maven-plugin
>
> Paul will mail the exact code later in the afternoon.
>
> To get back on track, the problem is, when we want to get the count of a
> related entities.
>
> In our EDM, we have a Client Entity and an Animal Entity. There is a one
> to many relationship between Client 1 - n Animals. The generated code
> provides a method to getAnimals for a Client.
>
> client.getAnimals()
>
> This returns an AnimalCollection that has no count method, only size. If
> we run the size methods, the client api fetches all animals and tells us
> how many animals are on the server, for all clients
>
>
>
>
>
>
>
>  Salutari din Brasov /  Greetings from Brasov
>
> Alex-Paul Maiereanu
>
> +40 761 684 212
>
> www.3sstudio.com
>
> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
> <https://twitter.com/SmartSocialSoft> Google+
> <https://plus.google.com/101299629750815349588/posts>
>
> On Fri, Oct 31, 2014 at 10:09 AM, Bolz, Michael <mi...@sap.com>
> wrote:
>
>>  Hi Alex,
>>
>>  As Ramesh already mentioned with the “$count” System Query Option (see:
>> http://www.odata.org/getting-started/basic-tutorial#count)
>> it is possible to only request the count for an resource.
>>
>>  For better understanding, how do you created/implemented the “Animal”
>> and “AnimalCollection”?
>>
>>  Kind regards,
>> Michael
>>
>>   From: Alex Maiereanu <al...@3sstudio.com>
>> Reply-To: "user@olingo.apache.org" <us...@olingo.apache.org>
>> Date: Thursday 30 October 2014 15:22
>> To: "user@olingo.apache.org" <us...@olingo.apache.org>
>> Subject: Re: Problem with Odata
>>
>>   Hi Ramesh,
>>
>>  With that query, we would get all the animals that are in the database.
>> In the case with the filter, we can find out how many animals a client has
>>
>>   Salutari din Brasov /  Greetings from Brasov
>>
>> Alex-Paul Maiereanu
>>
>> +40 761 684 212
>>
>> www.3sstudio.com
>>
>> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
>> <https://twitter.com/SmartSocialSoft> Google+
>> <https://plus.google.com/101299629750815349588/posts>
>>
>> On Thu, Oct 30, 2014 at 3:56 PM, Ramesh Reddy <ra...@redhat.com> wrote:
>>
>>>  You can do count query like
>>>
>>>  http://service/client(id)/Animlas/$count
>>>
>>>  But I am not sure how one can do that with Olingo client API.
>>>
>>>  Ramesh..
>>>
>>>  ------------------------------
>>>
>>> Thanks for your reply!
>>>
>>>  I want to get the number of animals that a client has.
>>>
>>>  Using
>>> AnimalCollection  animals= client.getAnimals();
>>> int count=animals.execute().size();
>>> This will load all the animals ( everything about them ) and .size will
>>> give me the count.
>>> I want to directly get the count of the animals without loading each of
>>> them....
>>>
>>>
>>>  Do you understand now?
>>>
>>>
>>>  Thanks!
>>>
>>>  Paul.
>>>
>>> On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com>
>>> wrote:
>>>
>>>>  Paul,
>>>>
>>>>  Just for some naming semantics, Animal would be a EnityType, Animals
>>>> and AnimalCollection are EntitySets. You could define as many EnitySets as
>>>> you want on a given EntityTpe, it really depends on how you defined your
>>>> metadata.
>>>>
>>>>  When you are asking "client.getAnimals" you are asking for Animals,
>>>> that are *associated* with Client vs. when you use container.getAnimals()
>>>> you are asking for *all* the animals. That is the difference.
>>>>
>>>>  I am not sure where you are going with count vs size question. Can
>>>> you clarify?
>>>>
>>>>  Ramesh..
>>>>
>>>>  ------------------------------
>>>>
>>>> Hello!
>>>> I'm using Odata to generate the models for a REST api.
>>>> I have an Animal entity.
>>>> For it I found 2 collection entities, Animals and AnimalCollection.
>>>>
>>>>  When I use container.getAnimals() , I have the .count() method for
>>>> them.
>>>> When I use client.getAnimals() (client is another entity) I get a
>>>> AnimalCollection entity that only has .size(), and the problem is if I want
>>>> to count the animals, all animals will be loaded, and it will return the
>>>> size of the collection...
>>>>
>>>>  I need to only get the animals count from the client..
>>>> Do you have any ideea what can I do?
>>>>
>>>>  I hope you understand what I'm trying to say.
>>>>
>>>>  Thanks.
>>>>
>>>>
>>>>
>>>
>>>
>>
>
>

Re: Problem with Odata

Posted by Ramesh Reddy <ra...@redhat.com>.
Alex, 

Is this using V4 or V2? 

I do not remember V2 of the Odata spec has support for $count on associated entities. V4 most definitely supports it. The client request for V4 needs to be something like 

final ODataValueRequest request = getClient().getRetrieveRequestFactory() 
.appendEntitySetSegment("client") 
.appendKeySegment("client-id") 
.appendNavigationSegment("Animals") 
.count() 
.build()); 
Ramesh.. 

----- Original Message -----

> Hey Michael,

> We already know how the $count works. We also know how to request the $filter
> based inline count so that we get the count of the filtered entities.

> The client code/classes have been generated using this plugin:

> http://mvnrepository.com/artifact/org.apache.olingo/pojogen-maven-plugin

> Paul will mail the exact code later in the afternoon.

> To get back on track, the problem is, when we want to get the count of a
> related entities.

> In our EDM, we have a Client Entity and an Animal Entity. There is a one to
> many relationship between Client 1 - n Animals. The generated code provides
> a method to getAnimals for a Client.

> client.getAnimals()

> This returns an AnimalCollection that has no count method, only size. If we
> run the size methods, the client api fetches all animals and tells us how
> many animals are on the server, for all clients

> Salutari din Brasov / Greetings from Brasov

> Alex-Paul Maiereanu

> +40 761 684 212

> www.3sstudio.com

> Facebook Twitter Google+

> On Fri, Oct 31, 2014 at 10:09 AM, Bolz, Michael < michael.bolz@sap.com >
> wrote:

> > Hi Alex,
> 

> > As Ramesh already mentioned with the “$count” System Query Option (see:
> > http://www.odata.org/getting-started/basic-tutorial#count )
> 
> > it is possible to only request the count for an resource.
> 

> > For better understanding, how do you created/implemented the “Animal” and
> > “AnimalCollection”?
> 

> > Kind regards,
> 
> > Michael
> 

> > From: Alex Maiereanu < alex.maiereanu@3sstudio.com >
> 
> > Reply-To: " user@olingo.apache.org " < user@olingo.apache.org >
> 
> > Date: Thursday 30 October 2014 15:22
> 
> > To: " user@olingo.apache.org " < user@olingo.apache.org >
> 
> > Subject: Re: Problem with Odata
> 

> > Hi Ramesh,
> 

> > With that query, we would get all the animals that are in the database. In
> > the case with the filter, we can find out how many animals a client has
> 

> > Salutari din Brasov / Greetings from Brasov
> 

> > Alex-Paul Maiereanu
> 

> > +40 761 684 212
> 

> > www.3sstudio.com
> 

> > Facebook Twitter Google+
> 

> > On Thu, Oct 30, 2014 at 3:56 PM, Ramesh Reddy < rareddy@redhat.com > wrote:
> 

> > > You can do count query like
> > 
> 

> > > http://service/client(id)/Animlas/$count
> > 
> 

> > > But I am not sure how one can do that with Olingo client API.
> > 
> 

> > > Ramesh..
> > 
> 

> > > > Thanks for your reply!
> > > 
> > 
> 

> > > > I want to get the number of animals that a client has.
> > > 
> > 
> 

> > > > Using
> > > 
> > 
> 
> > > > AnimalCollection animals= client.getAnimals();
> > > 
> > 
> 
> > > > int count=animals.execute().size();
> > > 
> > 
> 
> > > > This will load all the animals ( everything about them ) and .size will
> > > > give
> > > > me the count.
> > > 
> > 
> 
> > > > I want to directly get the count of the animals without loading each of
> > > > them....
> > > 
> > 
> 

> > > > Do you understand now?
> > > 
> > 
> 

> > > > Thanks!
> > > 
> > 
> 

> > > > Paul.
> > > 
> > 
> 

> > > > On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy < rareddy@redhat.com >
> > > > wrote:
> > > 
> > 
> 

> > > > > Paul,
> > > > 
> > > 
> > 
> 

> > > > > Just for some naming semantics, Animal would be a EnityType, Animals
> > > > > and
> > > > > AnimalCollection are EntitySets. You could define as many EnitySets
> > > > > as
> > > > > you
> > > > > want on a given EntityTpe, it really depends on how you defined your
> > > > > metadata.
> > > > 
> > > 
> > 
> 

> > > > > When you are asking "client.getAnimals" you are asking for Animals,
> > > > > that
> > > > > are
> > > > > *associated* with Client vs. when you use container.getAnimals() you
> > > > > are
> > > > > asking for *all* the animals. That is the difference.
> > > > 
> > > 
> > 
> 

> > > > > I am not sure where you are going with count vs size question. Can
> > > > > you
> > > > > clarify?
> > > > 
> > > 
> > 
> 

> > > > > Ramesh..
> > > > 
> > > 
> > 
> 

> > > > > > Hello!
> > > > > 
> > > > 
> > > 
> > 
> 
> > > > > > I'm using Odata to generate the models for a REST api.
> > > > > 
> > > > 
> > > 
> > 
> 
> > > > > > I have an Animal entity.
> > > > > 
> > > > 
> > > 
> > 
> 
> > > > > > For it I found 2 collection entities, Animals and AnimalCollection.
> > > > > 
> > > > 
> > > 
> > 
> 

> > > > > > When I use container.getAnimals() , I have the .count() method for
> > > > > > them.
> > > > > 
> > > > 
> > > 
> > 
> 
> > > > > > When I use client.getAnimals() (client is another entity) I get a
> > > > > > AnimalCollection entity that only has .size(), and the problem is
> > > > > > if
> > > > > > I
> > > > > > want
> > > > > > to count the animals, all animals will be loaded, and it will
> > > > > > return
> > > > > > the
> > > > > > size of the collection...
> > > > > 
> > > > 
> > > 
> > 
> 

> > > > > > I need to only get the animals count from the client..
> > > > > 
> > > > 
> > > 
> > 
> 
> > > > > > Do you have any ideea what can I do?
> > > > > 
> > > > 
> > > 
> > 
> 

> > > > > > I hope you understand what I'm trying to say.
> > > > > 
> > > > 
> > > 
> > 
> 

> > > > > > Thanks.
> > > > > 
> > > > 
> > > 
> > 
> 

Re: Problem with Odata

Posted by Alex Maiereanu <al...@3sstudio.com>.
Hey Michael,

We already know how the $count works. We also know how to request the
$filter based inline count so that we get the count of the filtered
entities.

The client code/classes have been generated using this plugin:

http://mvnrepository.com/artifact/org.apache.olingo/pojogen-maven-plugin

Paul will mail the exact code later in the afternoon.

To get back on track, the problem is, when we want to get the count of a
related entities.

In our EDM, we have a Client Entity and an Animal Entity. There is a one to
many relationship between Client 1 - n Animals. The generated code provides
a method to getAnimals for a Client.

client.getAnimals()

This returns an AnimalCollection that has no count method, only size. If we
run the size methods, the client api fetches all animals and tells us how
many animals are on the server, for all clients







 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Fri, Oct 31, 2014 at 10:09 AM, Bolz, Michael <mi...@sap.com>
wrote:

>  Hi Alex,
>
>  As Ramesh already mentioned with the “$count” System Query Option (see:
> http://www.odata.org/getting-started/basic-tutorial#count)
> it is possible to only request the count for an resource.
>
>  For better understanding, how do you created/implemented the “Animal”
> and “AnimalCollection”?
>
>  Kind regards,
> Michael
>
>   From: Alex Maiereanu <al...@3sstudio.com>
> Reply-To: "user@olingo.apache.org" <us...@olingo.apache.org>
> Date: Thursday 30 October 2014 15:22
> To: "user@olingo.apache.org" <us...@olingo.apache.org>
> Subject: Re: Problem with Odata
>
>   Hi Ramesh,
>
>  With that query, we would get all the animals that are in the database.
> In the case with the filter, we can find out how many animals a client has
>
>   Salutari din Brasov /  Greetings from Brasov
>
> Alex-Paul Maiereanu
>
> +40 761 684 212
>
> www.3sstudio.com
>
> Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
> <https://twitter.com/SmartSocialSoft> Google+
> <https://plus.google.com/101299629750815349588/posts>
>
> On Thu, Oct 30, 2014 at 3:56 PM, Ramesh Reddy <ra...@redhat.com> wrote:
>
>>  You can do count query like
>>
>>  http://service/client(id)/Animlas/$count
>>
>>  But I am not sure how one can do that with Olingo client API.
>>
>>  Ramesh..
>>
>>  ------------------------------
>>
>> Thanks for your reply!
>>
>>  I want to get the number of animals that a client has.
>>
>>  Using
>> AnimalCollection  animals= client.getAnimals();
>> int count=animals.execute().size();
>> This will load all the animals ( everything about them ) and .size will
>> give me the count.
>> I want to directly get the count of the animals without loading each of
>> them....
>>
>>
>>  Do you understand now?
>>
>>
>>  Thanks!
>>
>>  Paul.
>>
>> On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com> wrote:
>>
>>>  Paul,
>>>
>>>  Just for some naming semantics, Animal would be a EnityType, Animals
>>> and AnimalCollection are EntitySets. You could define as many EnitySets as
>>> you want on a given EntityTpe, it really depends on how you defined your
>>> metadata.
>>>
>>>  When you are asking "client.getAnimals" you are asking for Animals,
>>> that are *associated* with Client vs. when you use container.getAnimals()
>>> you are asking for *all* the animals. That is the difference.
>>>
>>>  I am not sure where you are going with count vs size question. Can you
>>> clarify?
>>>
>>>  Ramesh..
>>>
>>>  ------------------------------
>>>
>>> Hello!
>>> I'm using Odata to generate the models for a REST api.
>>> I have an Animal entity.
>>> For it I found 2 collection entities, Animals and AnimalCollection.
>>>
>>>  When I use container.getAnimals() , I have the .count() method for
>>> them.
>>> When I use client.getAnimals() (client is another entity) I get a
>>> AnimalCollection entity that only has .size(), and the problem is if I want
>>> to count the animals, all animals will be loaded, and it will return the
>>> size of the collection...
>>>
>>>  I need to only get the animals count from the client..
>>> Do you have any ideea what can I do?
>>>
>>>  I hope you understand what I'm trying to say.
>>>
>>>  Thanks.
>>>
>>>
>>>
>>
>>
>

Re: Problem with Odata

Posted by "Bolz, Michael" <mi...@sap.com>.
Hi Alex,

As Ramesh already mentioned with the “$count” System Query Option (see: http://www.odata.org/getting-started/basic-tutorial#count)
it is possible to only request the count for an resource.

For better understanding, how do you created/implemented the “Animal” and “AnimalCollection”?

Kind regards,
Michael

From: Alex Maiereanu <al...@3sstudio.com>>
Reply-To: "user@olingo.apache.org<ma...@olingo.apache.org>" <us...@olingo.apache.org>>
Date: Thursday 30 October 2014 15:22
To: "user@olingo.apache.org<ma...@olingo.apache.org>" <us...@olingo.apache.org>>
Subject: Re: Problem with Odata

Hi Ramesh,

With that query, we would get all the animals that are in the database. In the case with the filter, we can find out how many animals a client has

 Salutari din Brasov /  Greetings from Brasov
[http://www.3sstudio.com/email-signatures/email-signature-icon.png]

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com<http://www.3sstudio.com/>

[http://www.3sstudio.com/email-signatures/email-signature-facebook.png]Facebook<https://www.facebook.com/smartsocialsoftware> [http://www.3sstudio.com/email-signatures/email-signature-twitter.png] Twitter<https://twitter.com/SmartSocialSoft> [http://www.3sstudio.com/email-signatures/email-signature-google.png] Google+<https://plus.google.com/101299629750815349588/posts>

On Thu, Oct 30, 2014 at 3:56 PM, Ramesh Reddy <ra...@redhat.com>> wrote:
You can do count query like

http://service/client(id)/Animlas/$count

But I am not sure how one can do that with Olingo client API.

Ramesh..

________________________________
Thanks for your reply!

I want to get the number of animals that a client has.

Using
AnimalCollection  animals= client.getAnimals();
int count=animals.execute().size();
This will load all the animals ( everything about them ) and .size will give me the count.
I want to directly get the count of the animals without loading each of them....


Do you understand now?


Thanks!

Paul.

On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com>> wrote:
Paul,

Just for some naming semantics, Animal would be a EnityType, Animals and AnimalCollection are EntitySets. You could define as many EnitySets as you want on a given EntityTpe, it really depends on how you defined your metadata.

When you are asking "client.getAnimals" you are asking for Animals, that are *associated* with Client vs. when you use container.getAnimals() you are asking for *all* the animals. That is the difference.

I am not sure where you are going with count vs size question. Can you clarify?

Ramesh..

________________________________
Hello!
I'm using Odata to generate the models for a REST api.
I have an Animal entity.
For it I found 2 collection entities, Animals and AnimalCollection.

When I use container.getAnimals() , I have the .count() method for them.
When I use client.getAnimals() (client is another entity) I get a AnimalCollection entity that only has .size(), and the problem is if I want to count the animals, all animals will be loaded, and it will return the size of the collection...

I need to only get the animals count from the client..
Do you have any ideea what can I do?

I hope you understand what I'm trying to say.

Thanks.





Re: Problem with Odata

Posted by Alex Maiereanu <al...@3sstudio.com>.
Hi Ramesh,

With that query, we would get all the animals that are in the database. In
the case with the filter, we can find out how many animals a client has

 Salutari din Brasov /  Greetings from Brasov

Alex-Paul Maiereanu

+40 761 684 212

www.3sstudio.com

Facebook <https://www.facebook.com/smartsocialsoftware> Twitter
<https://twitter.com/SmartSocialSoft> Google+
<https://plus.google.com/101299629750815349588/posts>

On Thu, Oct 30, 2014 at 3:56 PM, Ramesh Reddy <ra...@redhat.com> wrote:

> You can do count query like
>
> http://service/client(id)/Animlas/$count
>
> But I am not sure how one can do that with Olingo client API.
>
> Ramesh..
>
> ------------------------------
>
> Thanks for your reply!
>
> I want to get the number of animals that a client has.
>
> Using
> AnimalCollection  animals= client.getAnimals();
> int count=animals.execute().size();
> This will load all the animals ( everything about them ) and .size will
> give me the count.
> I want to directly get the count of the animals without loading each of
> them....
>
>
> Do you understand now?
>
>
> Thanks!
>
> Paul.
>
> On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com> wrote:
>
>> Paul,
>>
>> Just for some naming semantics, Animal would be a EnityType, Animals and
>> AnimalCollection are EntitySets. You could define as many EnitySets as you
>> want on a given EntityTpe, it really depends on how you defined your
>> metadata.
>>
>> When you are asking "client.getAnimals" you are asking for Animals, that
>> are *associated* with Client vs. when you use container.getAnimals() you
>> are asking for *all* the animals. That is the difference.
>>
>> I am not sure where you are going with count vs size question. Can you
>> clarify?
>>
>> Ramesh..
>>
>> ------------------------------
>>
>> Hello!
>> I'm using Odata to generate the models for a REST api.
>> I have an Animal entity.
>> For it I found 2 collection entities, Animals and AnimalCollection.
>>
>> When I use container.getAnimals() , I have the .count() method for them.
>> When I use client.getAnimals() (client is another entity) I get a
>> AnimalCollection entity that only has .size(), and the problem is if I want
>> to count the animals, all animals will be loaded, and it will return the
>> size of the collection...
>>
>> I need to only get the animals count from the client..
>> Do you have any ideea what can I do?
>>
>> I hope you understand what I'm trying to say.
>>
>> Thanks.
>>
>>
>>
>
>

Re: Problem with Odata

Posted by Ramesh Reddy <ra...@redhat.com>.
You can do count query like 

http://service/client(id)/Animlas/$count 

But I am not sure how one can do that with Olingo client API. 

Ramesh.. 

----- Original Message -----

> Thanks for your reply!

> I want to get the number of animals that a client has.

> Using
> AnimalCollection animals= client.getAnimals();
> int count=animals.execute().size();
> This will load all the animals ( everything about them ) and .size will give
> me the count.
> I want to directly get the count of the animals without loading each of
> them....

> Do you understand now?

> Thanks!

> Paul.

> On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy < rareddy@redhat.com > wrote:

> > Paul,
> 

> > Just for some naming semantics, Animal would be a EnityType, Animals and
> > AnimalCollection are EntitySets. You could define as many EnitySets as you
> > want on a given EntityTpe, it really depends on how you defined your
> > metadata.
> 

> > When you are asking "client.getAnimals" you are asking for Animals, that
> > are
> > *associated* with Client vs. when you use container.getAnimals() you are
> > asking for *all* the animals. That is the difference.
> 

> > I am not sure where you are going with count vs size question. Can you
> > clarify?
> 

> > Ramesh..
> 

> > > Hello!
> > 
> 
> > > I'm using Odata to generate the models for a REST api.
> > 
> 
> > > I have an Animal entity.
> > 
> 
> > > For it I found 2 collection entities, Animals and AnimalCollection.
> > 
> 

> > > When I use container.getAnimals() , I have the .count() method for them.
> > 
> 
> > > When I use client.getAnimals() (client is another entity) I get a
> > > AnimalCollection entity that only has .size(), and the problem is if I
> > > want
> > > to count the animals, all animals will be loaded, and it will return the
> > > size of the collection...
> > 
> 

> > > I need to only get the animals count from the client..
> > 
> 
> > > Do you have any ideea what can I do?
> > 
> 

> > > I hope you understand what I'm trying to say.
> > 
> 

> > > Thanks.
> > 
> 

Re: Problem with Odata

Posted by Paul Boldijar <pa...@3sstudio.com>.
Thanks for your reply!

I want to get the number of animals that a client has.

Using
AnimalCollection  animals= client.getAnimals();
int count=animals.execute().size();
This will load all the animals ( everything about them ) and .size will
give me the count.
I want to directly get the count of the animals without loading each of
them....


Do you understand now?


Thanks!

Paul.

On Thu, Oct 30, 2014 at 3:33 PM, Ramesh Reddy <ra...@redhat.com> wrote:

> Paul,
>
> Just for some naming semantics, Animal would be a EnityType, Animals and
> AnimalCollection are EntitySets. You could define as many EnitySets as you
> want on a given EntityTpe, it really depends on how you defined your
> metadata.
>
> When you are asking "client.getAnimals" you are asking for Animals, that
> are *associated* with Client vs. when you use container.getAnimals() you
> are asking for *all* the animals. That is the difference.
>
> I am not sure where you are going with count vs size question. Can you
> clarify?
>
> Ramesh..
>
> ------------------------------
>
> Hello!
> I'm using Odata to generate the models for a REST api.
> I have an Animal entity.
> For it I found 2 collection entities, Animals and AnimalCollection.
>
> When I use container.getAnimals() , I have the .count() method for them.
> When I use client.getAnimals() (client is another entity) I get a
> AnimalCollection entity that only has .size(), and the problem is if I want
> to count the animals, all animals will be loaded, and it will return the
> size of the collection...
>
> I need to only get the animals count from the client..
> Do you have any ideea what can I do?
>
> I hope you understand what I'm trying to say.
>
> Thanks.
>
>
>

Re: Problem with Odata

Posted by Ramesh Reddy <ra...@redhat.com>.
Paul, 

Just for some naming semantics, Animal would be a EnityType, Animals and AnimalCollection are EntitySets. You could define as many EnitySets as you want on a given EntityTpe, it really depends on how you defined your metadata. 

When you are asking "client.getAnimals" you are asking for Animals, that are *associated* with Client vs. when you use container.getAnimals() you are asking for *all* the animals. That is the difference. 

I am not sure where you are going with count vs size question. Can you clarify? 

Ramesh.. 

----- Original Message -----

> Hello!
> I'm using Odata to generate the models for a REST api.
> I have an Animal entity.
> For it I found 2 collection entities, Animals and AnimalCollection.

> When I use container.getAnimals() , I have the .count() method for them.
> When I use client.getAnimals() (client is another entity) I get a
> AnimalCollection entity that only has .size(), and the problem is if I want
> to count the animals, all animals will be loaded, and it will return the
> size of the collection...

> I need to only get the animals count from the client..
> Do you have any ideea what can I do?

> I hope you understand what I'm trying to say.

> Thanks.