What is the unique ID (identifier) for a Google GData ContactEntry object? - gdata-api

Is there a unique identifier for the Google GData ContactEntry object? Basically, if there are two entries with names "Andy Lim" for example, we need to distinguish the entries and what is the identifier that can be used. Also, if we copy the contactentry to contacts folder in another google account, will the identifier stays the same, or will it change?
Regards,
Dicky

According to ContactEntry API documentation, the ContactEntry class extends google.gdata.atom.Entry, where it inherits a getId() method.

Related

Laravel Eloquent choosing which model to find

I have a Player model that has homeAddress which has homeAddressPhoto, linked by foreign key.
I could get the list of home address photos by calling this:
Player::find($player_id)->homeAddress->homeAddressPhoto;
Now I want to find the photos by homeAddressPhoto id, but the code below finds the photo by homeAddress id.
Player::find($player_id)->homeAddress->homeAddressPhoto()->where('id',$photo_id)->first();
How should I write the where part to get the id from homeAddressPhoto instead of homeAddress?
try this:
Player::find($player_id)->homeAddress->homeAddressPhoto->where('id',$photo_id)->first();

Method: people.get() does not return names

I have a question regarding API:
GET https://people.googleapis.com/v1/{resourceName=people/*}
When the resourceName = people/account_id and the personFields is 'names' the API returns names only when the account_id has a Google+ account associated with it. For the account_id without associate Google+ account, no names are returned.
My application scopes are:
https://www.googleapis.com/auth/userinfo.email
https://www.googleapis.com/auth/contacts
https://www.googleapis.com/auth/plus.login
Is this expected behaviour? Is it possible to get account name by account_id without Google+ account?
Thank you in advance.
This is expected behavior. In general when getting data on other users, you only get their public data. Non G+ users don't have a public profile and so their name is not public unless they have explicitly set their name to be public.
See https://developers.google.com/people/#a_merged_view_of_people_information for more details on what data you should get.

How to resolve a relationship to get a hold of the reference being pointed to?

I have been creating a model where one of my assets have a reference to a specific participant.
When I retrieve my asset using the composer-client API I would like to retrieve the details of the participant being referenced.
In the CTO language document I saw this sentence:
"Relationships must be resolved to retrieve an instance of the object being referenced. The act of resolution may result in null, if the object no longer exists or the information in the relationship is invalid." but it does not describe how to do it.
Can someone please let me know what is the best way to resolve a relationship so that I can retrieve the instance of the object (in this case a participant) that I am pointing to?
You can resolve relationships a couple of ways
Lets say we have an asset Widget that is defined as:
namespace SO
participant Person identified by email {
o String email
}
asset Widget identified by assetId {
o String email
--> Person owner
}
Once you have a Widget asset, you can call Widget.owner.getFullyQualifiedType() which returns the name of the participant registry the owner is in. Then call Widget.owner.getIdentifier() to get the id of the owner in the PersonRegistry, then call PersonRegistry.get(identifier) to get the owner participant
When getting the Widget from the WidgetRegistry, you can call WidgetRegistry.resolve(identifier) to resolve all relationships

Hibernate: Child table having two different ManyToOne relationships

In the Spring/Hibernate/Java/Tomcat app I'm writing I have a OneToMany relationship between an Organization and its Contacts.
Organization 1:M Contact (has foreign key org_id)
In Organization I have this field:
#OneToMany(mappedBy="organization")
private List<Contact> contacts;
In Contact I have this field:
#ManyToOne
#JoinColumn(name="org_id")
private Organization organization;
All is working OK so far. Now I'm adding the concept of an Offer. The Offer can be made by an Organization, and you speak with the designated Contact for that particular Offer.
Offer has foreign keys for its organization (org_id) and designated contact (contact_id).
So far, the Offer would look like:
#OneToOne
#JoinColumn(...)
private Organization offering_org;
#OneToOne
#JoinColumn(...)
private Contact offering_contact;
Here comes the point of my question. I've already annotated the Contact class for use with Organization. If I try to persist the Offer object in the usual Hibernate way, I'll need to store copies of an Organization object and a Contact object into the Offer object. This seems to conflict with my existing Organization : Contact use of the two Java classes. For example, if I've a 1:1 with Offer, if I put this into the Contact class do I get an optional use of either or a mandatory simultaneous use of both?
Since the Offer is yet another relationship, do I need to write a data transfer object version of Contact for use in the Offer relationship?
Thanks,
Jerome.
Perhaps I do not fully understand the problem but I'd just do something like this:
// contact & organization being already persisted entity objects
Offer offer = new Offer();
offer.setOffering_org(organization);
offer.setOffering_contact(contact);
// Persisting the new Offer object to the database,
// implicitly making the relations.
service.saveObject(offer);
I see no reason to create copy(s) of the organization object?
It just happens to be that the collection of "contacts" in the Organization object can also be a Contact within one or more Offer objects.
I'm thinking that my original question is kind of stupid. What I did try is to put this in Offer.java:
#Column(name="org_id")
private Long orgId = null;
#Column(name="contact_id")
private Long contactId = null;
I fill orgId manually because an offer is always tied to the user's Organization. It is a hidden field in the web page.
I put a SELECT filled with appropriate Contact objects (contact.id, contact.name) in the web page.
When the web page is submitted the Offer's orgId and contactId fields are filled in the #ModelAttribute parameter. This takes me where I want to go.
To address the comments of Mr. mspringer, your example could work (you illustrated a "create new" situation) if I were willing to use an Organization or Contact list in my Offer object. It is also somewhat the topic of my original question. But since I see that I don't really want to play with the expanded objects within Offer, nor do I wish to, I can avoid the topic of my original question.
Thanks to all who looked at my exercise in confusion.

Google Contacts API not returning contacts with a directory profile

I am trying to search through "my contacts" on my google account. The account belongs to a Google for Business domain. I have already managed to retrieve all contacts which works by querying to the following url:
https://www.google.com/m8/feeds/contacts/{userEmail}/full
or
https://www.google.com/m8/feeds/contacts/default/full
Now, when I search using the q=searchString or myQuery.setFullTextQuery(searchString); (in Java). I only get some of the results. In particular contacts that I have created and do not belong to the same domain as me.
I assume that this has to do with the fact that google has not stored a name entry for contacts tha have a directory profile. Thus it will only search within their email address (and if I'm lucky and the email address contains the name only then it will find it).
As a workaround I also get all the profiles (which does not seem to work with a full text search string) from the domain and then merge/parse them in order to get the results I need.
My question now is, is there a single call in order to retrieve ALL contacts (from my contacts) that contain a specific search string in either the NAME (first and last), EMAIL and perhaps field labels?
I do not see a point of using a full text search string when the contact entries that have a directory profile do not contain any name... (it is stored in the profile).
Many thanks in advance!
You should fill all fields manually(only primary email and photo shared between directory profile and your contact) in contact entry. So you can't find in one request all that you need

Resources