Foros de discusión

Adding finder to existing Liferay Service

thumbnail
Alex Wallace, modificado hace 16 años.

Adding finder to existing Liferay Service

Liferay Master Mensajes: 640 Fecha de incorporación: 5/11/07 Mensajes recientes
Hi all!

I want to be able to find a regionId when i have the name... from the Region service...

Is it possible to add a finder to the existing service or should i just write a custom/dynamic query for this?

Thanks!
Alessandro Cosenza, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Junior Member Mensajes: 84 Fecha de incorporación: 19/11/09 Mensajes recientes
Hello Alex, actually I need to do exactly this thing. I need to add a finder method to an already existing service, the TagsAssetService. In the meantime did you resolve that?

Hope you answer me soon.

Thanks in advance,

best regards,
Alessandro
thumbnail
Alex Wallace, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Liferay Master Mensajes: 640 Fecha de incorporación: 5/11/07 Mensajes recientes
I ended up writing dynamic query in one of my own services.

Thanks!
Alessandro Cosenza, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Junior Member Mensajes: 84 Fecha de incorporación: 19/11/09 Mensajes recientes
Thank you! My problem instead is to add a new finder method writing a custom service.xml and referring an existing entity (in my case TagsAsset). But I get several errors because I don't know how to write thatservice.xml. I want to find TagsAssets by classNameId within the whole portal (regardless of communities). If another way to add custom services exists, different from build a custom service.xml, I appreciate if you would give me hints about that. Currently I'm using EXT, you think I could directly extend a class by hand?

Thanks again.
thumbnail
Shagul Khaja, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Liferay Master Mensajes: 758 Fecha de incorporación: 27/09/07 Mensajes recientes
Hi,

Try the following.

1) Add a service.xml in ext-impl and make sure build-services will find this file. You should be able to find wiki pages on this.

2) In this file add an empty entity like shown below.


<entity name="ExtTagsAsset" local-service="true" remote-service="true">
</entity>



3) Build the service.

4) Add ExtTagsAssetFinderImpl in com.....service.persistence package. Take a look at any existing finderImpl.

5) In your ExtTagsLocalServiceImpl call the finder as shown below.

extTagsAssetFinder.getWhateverYouwant(companyId, somemoreparams....);


6) Build you service again to get the updated ExtTagsAssetLocalServiceUtil

7) Call the ExtTagsAssetLocalServiceUtil where ever needed.

You may have to build the services in between some of the steps to make sure the updated API is available in other classes.


Hope this helps.

Best Regards,
Shagul
Alessandro Cosenza, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Junior Member Mensajes: 84 Fecha de incorporación: 19/11/09 Mensajes recientes
Thanks for your answer. But what I want to know is: will my service use the existing TagsAsset entity provided by Liferay? I need to manager that entity.

Thanks again.
thumbnail
Shagul Khaja, modificado hace 14 años.

RE: Adding finder to existing Liferay Service

Liferay Master Mensajes: 758 Fecha de incorporación: 27/09/07 Mensajes recientes
Hi Alessandro,

The steps that I posted is for creating custom finders. In these finders you will be able to execute any custom query to return any Liferay entity.


Take a look at RoleFinderImpl, GroupFinderImpl or any other FinderImpl.

Best Regards,
Shagul
Paolo Pilitti, modificado hace 13 años.

RE: Adding finder to existing Liferay Service

Junior Member Mensajes: 51 Fecha de incorporación: 13/04/11 Mensajes recientes
can you explain point


Add ExtTagsAssetFinderImpl in com.....service.persistence package. Take a look at any existing finderImpl.
Joaquín Fernández, modificado hace 9 años.

RE: Adding finder to existing Liferay Service

Junior Member Mensajes: 93 Fecha de incorporación: 2/01/12 Mensajes recientes
Hi Shagul,

I have a related question,

Is it possible to create a simple finder method for TagsAsset in the entity ExtTagsAsset?
I mean, if a need a simple finder method, is it possible no to use the custom sql with the finderimpl?

For example, i need to find Address with the city and the zip columns. If i create a new table, it would be enough with a finder method in the service.xml, but i don't know how to create this simple finder method for an existing entity.

Thanks!