Hi Michael,
Thank you for the inputs.
Normally you should define an according Entity (e.g. TaskHeader) which than
> contains the field (projectId, materialNo, version) as key properties. Then
> you can do calls like:
> "…/ReferenceScenario.svc/TaskHeader(projectID=3,materialNo=‘4711’,version=“19’)/“.
>
I will try to do this and revert with the result.
> I tried using the uriInfo.getCustomQueryOptions() and passed the inputs
> as > a query String and is working. Again is this a right approach. Is
> there any > better option? And the example above really is working? Do you
> send the necessary values (projectId, materialNo, version) as URL query?
>
Yeah, this is working for me. Following is the URL. This is a Poc I am
doing for creating Rest Service matching our requirement.
I have created 3 Development Components (library, Web, & Enterprise Application)
http://<hostname>:port/demo.sap.com~rest~web/rest/Employees?recordId=10&department=Dept1
Following is the code:
REmployee employee = null;
String recordID = uriInfo.getCustomQueryOptions().get("recordId");
String department = uriInfo.getCustomQueryOptions().get("department");
try {
InitialContext ic = new InitialContext();
RsEmployeeDaoLocal rsEmpBean = (RsEmployeeDaoLocal) ic
.lookup("demo.sap.com/rest~jpa~app/LOCAL/RsEmployeeDao/com.test.rs.ejb.RsEmployeeDaoLocal");
employee = rsEmpBean.getByIDAndDepartment(Integer.parseInt(recordID),
department);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("RecordId", employee.getRecordID());
data.put("EmpName", employee.getName());
data.put("EmpNo", employee.getEmpNo());
data.put("Department", employee.getDepartment());
return EntityProvider.writeEntry(contentType, entitySet, data,
EntityProviderWriteProperties.serviceRoot(
getContext().getPathInfo().getServiceRoot())
.build());
> We also have some EJB's for execution of Business Rules. A few of these
> rules are to be executed from a UI5 view. And these rules requires a
> minimum of 4 parameters for execution. For passing mutiple inputs, do we
> have any option to pass something like an object containing all parameters?
>
You could define an “FunctionImport” (see:
“http://www.odata.org/documentation/uri-conventions/#AddressingServiceOperations")
which than could be called with the necessary parameters (like:
“/OData.svc/ProductsByColor?color=’red’”)
and internal then call your EJB.
I will try to implement this and revert with the result.
Regards,
Aparnna Prasad
On 23 January 2014 12:11, Aparnna Prasad <[email protected]> wrote:
> Hi Michael,
>
> Following is a sample method signature
>
> public TaskHeaderlDto getByProjectIdMatNoAndVersion(int projectID, String
> materialNo, String version)
>
> All the three input fields are required to find the unique header record.
>
> I tried using the uriInfo.getCustomQueryOptions() and passed the inputs as
> a query String and is working. Again is this a right approach. Is there any
> better option?
>
> We also have some EJB's for execution of Business Rules. A few of these
> rules are to be executed from a UI5 view. And these rules requires a
> minimum of 4 parameters for execution. For passing mutiple inputs, do we
> have any option to pass something like an object containing all parameters?
>
> Regards,
> Aparnna Prasad
>
>
>
> On 22 January 2014 10:18, Aparnna Prasad <[email protected]> wrote:
>
>> Hi
>>
>> I already have some Session beans which has the required methods for Data
>> Read & Manipulation of JPA Entities.
>>
>> I want to reuse these methods without rewriting the same logic. I
>> followed the below approach
>>
>> http://olingo.incubator.apache.org/doc/tutorials/basicread.html
>>
>> Based on this tutorial I implemented the basic Read & in the readEntity
>> method I invoked my ejb method to get the data, and build the response.
>> This is working
>>
>> Is this a right approach?
>>
>> Also I want to invoke some getter methods from EJB, which expects more
>> than 1 parameter as inputs? How can I achieve this?
>>
>> Aparnna
>>
>
>