• Post Reply Bookmark Topic Watch Topic
  • New Topic

Please HELP - I cant understand this concept

 
Lmn Opq
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There is this thing which I really can't understand about REST's concept.
Suppose I have a resource called Company which has the following attributes : name, address, etc... and another resource called employee with the attributes : name, companyName, etc..

The employeeResource class will implement a method to GET the company name (having the ID identified in the URI) plus the other information ( adrress ... etc )

The employeesResource class will implement a method to GET all the companies names and relevant information

same thing for the employee and employees resource class.

Suppose the client wants to get the name of all employees and the name of the company they work at and its address. so WHERE should the function that performs this query be placed ? and what should be the URI in this case ? here in this case we are not accessing only one resource, but two at the same time as I can understand.

PLEASE can any one help me understand this ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Whats wrong with considering that as a new kind of resource that combines information from both Company and Employee using a new class?

Bill
 
Lmn Opq
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I thought of this, but didn't know if this would violate REST's concept which states that every resource should have one resource class.
And one more thing, if for this get request I need to specify some filtering for the search criteria, ex : not just get the names of all the employees and their company name and address, I should get the employees that are
- older than 40 years,
- lives in city X
- works in company Y

I don't wont these three data to be included in the URI, for example, I don't want it to be like this : http://www.example.com/employee?age=over40&lives?X&.... etc
I need to send these data in an xml file in the http get request, how could this be possible ?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!