ContextMapper / context-mapper-examples

ContextMapper DSL: Examples
https://contextmapper.org/
Apache License 2.0
204 stars 78 forks source link

Example for Resource Operation delegate #21

Closed sunilk-m closed 3 years ago

sunilk-m commented 3 years ago

It would be good to have an example of resource operation delegate to the service operation. I have defined a service and a resource and I am able to inject the service into the resource. I am not able to provide a delegation to the service operation from resource operation. My understanding is following should work but I am getting syntax error. String createEmployee(@EmployeeDto emp) POST path="/employee" DELEGATE @EmployeeService.addEmployee; When I use ctrl spacebar I don't get Delegate in the proposal.

stefan-ka commented 3 years ago

Hi @sunilk-m

Sorry for the late response! (I'm quite busy right now)

Actually DELEGATE is not a keyword, but the following terminal rule:

terminal DELEGATE :
  ('=>'|('delegates to'));

For some reason delegates to does not work (don't understand why right now), but you can use the following syntax:

String createEmployee(@EmployeeDto emp) POST path="/employee" => @EmployeeService.addEmployee ;

Let me know if this solves your issue and whether we can close this one.

Best regards, Stefan

sunilk-m commented 3 years ago

Hi Stefan => worked. You can close the issue.

Regards Sunil