Hooks revisited (4) - create an entity to hold seach criteria

Peter Breuer
Peter Breuer
Less Than a Minute Read

Create the CustomAssetEntryQuery entity

We want to extend the AssetEntryQuery by adding the String author to the members. This can be done manually with some coding effort. However the use of Service Builder will offer some additional advantages.

 

<service-builder package-path="...">

...

<entity name="CustomAssetEntryQuery"

local-service="false" remote-service="false"

data-source="no_data_source"

<column name="authorName" type="String" primary="true"

</entity>

</service-builder>

 

The Service Builder creates, among others, the interface CustomAssetEntryQuery, and the class CustomAssetEntryQueryWrapper, with the ubiquitous get and set methods for the authorName. Now we will need to break well-established rules and manually modify the generated class as follows:

 

public class CustomAssetEntryQueryWrapper

extends AssetEntryQuery

implements CustomAssetEntryQuery,

ModelWrapper<CustomAssetEntryQuery> {

public CustomAssetEntryQueryWrapper(

CustomAssetEntryQuery customAssetEntryQuery) {

super((AssetEntryQuery) customAssetEntryQuery);

_customAssetEntryQuery = customAssetEntryQuery;

}

...

}

 

Thus we have a class which implements our new custom model interface and also extends the core class AssetEntryQuery, as required in c). Poking around generated code is not nice, of course. It would be way easier if the meta-data had an extensible model. Anyway, the generated class would be overwritten on the next run, so we need to make a backup for further use. Just one thing we should not play with: never rename the generated classes.

 

In the next segment we will make use of the meta-data extension in a finder. Please read further.

 

Page Comments

The Technicalities of Static Sites

David Oliveira Montenegro
View Blog >

Customization is Dead! Long Live Customization!

David H Nebinger
View Blog >
customization banner image.png

Public Bug Bounty Program

David H Nebinger
View Blog >
bugbounty.png
Showing 1 to 3 of 3 entries.