cancel
Showing results for 
Search instead for 
Did you mean: 

Access to Entity Service Methods from Application Services

Former Member
0 Kudos

Hi Experts,

I have an Entity called Client with a query method called findById which returns a client. I also have an Application Service called ClientAppService which has a method updateClient which needs to retrieve a certain Client and perform some operations on it. The signature looks as follow:


// Pass Client ID in.
public boolean updateClient(java.lang.String arg0) {
  // Retrieve Client matching the ID
  // Perform operations on the Client
}

I've tried retrieving the Client through the Entity's findById method, but it takes a QueryString as a parameter, not an ID.


getClientService().findById(/* QueryString */);

Is there anyway to retrieve the Client from inside the Application Service by only specifying the Client ID, or do I have to instantiate a QueryString and if so how should I do that?

Thanks,

JP

Accepted Solutions (1)

Accepted Solutions (1)

former_member4529
Active Contributor
0 Kudos

Hi,

You can call the findBy() methods of entity service from an application service method by passing the QueryFilter as input.

For instantiating the QueryFilter and filling the input data write the following line of code:

QueryFilter qfInput = new QueryFilter(clientID, "==");

then :

List result = this.getClientService().findById(qfInput);

Thanks,

Dipankar

Former Member
0 Kudos

Thanks Dipankar,

What should I do with arg0, which contains the client ID to search for?

Also, if I wanted to change the method to return the Clients after modifying them, what should the return type be? I can make it a list, but I would like to bind them to a Context Model Node in the same way I can bind the Entity's getAll method to a Model Node?

Answers (0)