Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
richard naoufal
Service builder usage
June 28, 2013 9:32 AM
Answer

richard naoufal

Rank: Junior Member

Posts: 34

Join Date: April 4, 2013

Recent Posts

Hello,

I am thinking about using service builders to handle all the data of a project :

I have several tables that must be put in place (clients, partners, tasks, ... ) and more important i must be able to create links between these elements : my idea was that since i need to have links put in place so why not use services (i can do everything with the data).

I hava a few question :
If i create a service builder for the client data base for example do i need to have it attached to a portlet ? can a service be inependent and be called by serveral portlets ?
What would be the best way to display the client database (asset publisher portlet ? other ? ) if the data is handled by a service builder ?
Is it possible to have a portlet display data coming from different services ? what is the best solution for displaying data coming from one or several tables ?
is it possible to have a service builder dedicated to manage the links between tables rows from different tables each handled by its own service builder ?

Thank you for your point of view/advice

Rregards.
richard naoufal
RE: Service builder usage
June 28, 2013 10:15 AM
Answer

richard naoufal

Rank: Junior Member

Posts: 34

Join Date: April 4, 2013

Recent Posts

i someone thinks that it is impossible or that i got it all rong please speak up.
Wilson Man
RE: Service builder usage
June 28, 2013 10:21 AM
Answer

Wilson Man

LIFERAY STAFF

Rank: Liferay Master

Posts: 580

Join Date: June 21, 2006

Recent Posts

the services built by service builder are indeed independent, meaning each portlet can use several services, and each service can but used by zero or more portlets, not to mention that services can call each other as well.
richard naoufal
RE: Service builder usage
June 28, 2013 10:39 AM
Answer

richard naoufal

Rank: Junior Member

Posts: 34

Join Date: April 4, 2013

Recent Posts

Thank tou verry much for your answer !! emoticon

Is a solution where :


  1. Each table has a service to handle the data and a portlet do display the data.
  2. One service handles the relations between rows of several tables.
  3. Some portlets display altogether data from several tables.


Seems impossible, or too complicated ?
I am trying to find a fast maintenance friendly and evolution friendly solution.
For example for a table (entity) managed by a server builder can i handle the display (display rows of the table) with a asset publisher or other portlet ?
I do not want to re develop everything i just want to have a tight grip on the data !

What would you do ?
Wilson Man
RE: Service builder usage
June 28, 2013 11:31 AM
Answer

Wilson Man

LIFERAY STAFF

Rank: Liferay Master

Posts: 580

Join Date: June 21, 2006

Recent Posts

here's what i tend to do:

1. each service with content/data should be the only service that directly interacts with its table (via its persistence). For example, ClientLocalService should be the only one that directly interacts with ClientPersistence, and the resulting table in the db.
2. If you need a higher level service to manage inserts and updates across several tables, you can always create an additional services in the service.xml that do NOT have <column> elements. Service Builder will generate all the services and their stubs but no persistence for those. You can then use these services to do high level calls to other services. For example, ProcessLocalService will call ClientLocalService and PartnerLocalService to insert the needed data.

Your portlets can call any of these services, which ever one that makes sense for your use cases. Your portlet can call multiple services to get relevant data if that makes sense.

I have not developed with asset publishers so i can't speak to that. I usually just create my own portlets to display the content necessary.

One more thing to call out regarding using SB is that you should try to use singular nouns. For example, do this:

1<entity name="Client" local-service="true" />


and not

1<entity name="Clients" local-service="true" />
David H Nebinger
RE: Service builder usage
June 30, 2013 5:51 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11295

Join Date: September 1, 2006

Recent Posts

richard naoufal:

  1. Each table has a service to handle the data and a portlet do display the data.
  2. One service handles the relations between rows of several tables.
  3. Some portlets display altogether data from several tables.


Too complicated and will consume too many resources...

Create a single service layer to support all tables and data. It can handle the relations, etc., but has all of the knowledge in a single layer.

You can then either add the portlets to this project for the individual table data display or move them to other separate project(s) as you wish.
richard naoufal
RE: Service builder usage
July 3, 2013 6:58 AM
Answer

richard naoufal

Rank: Junior Member

Posts: 34

Join Date: April 4, 2013

Recent Posts

Thank you so much all for your posts,

I thought about using a seperate service for linking rows from different tables because :

1. From one community to another the links cartography might change according to the client needs.
2. I need to extend the content of standard data such as a calendar event, for example :
I want to add custom fields to an event calendar : I would do it by creating a eventExtention service builder and manage the link to the Event with the service that handles links.

Do you think it is a goog solution knowing that a EventExtention can have it's fields change from a community to another ?
richard naoufal
RE: Service builder usage
October 8, 2013 9:49 AM
Answer

richard naoufal

Rank: Junior Member

Posts: 34

Join Date: April 4, 2013

Recent Posts

Hello,

I have been working on this project since the beginning of the post, interesting things have came out, hopefully i would make a presentation one day.

There is a question i need to ask :
If a portlet that has a service.xml is deployed several times in the same page, will the data be store according to which instance of the portlet is being used bu the user ?
Same question with one instance of that portlet per page ?
If that is so who is there a naming convention to make shure that the data of each instance is seperated from the reste ? what is it ? can it be used by an instance to access the tables of a different instance ?

Regards,
David H Nebinger
RE: Service builder usage
October 8, 2013 10:05 AM
Answer

David H Nebinger

Community Moderator

Rank: Liferay Legend

Posts: 11295

Join Date: September 1, 2006

Recent Posts

there is only one portlet deployed, and only one service will be available.

Doesn't matter how many instances of that one portlet you have on a page, there is still only one portlet and one service.