Odata Olingo lib JAVA

Hi,
I am trying to use Apache Olingo library(java based) for consuming the DSS REST API. I am not able to find any examples or documentation to do that. Wanted to check if someone has used this before.
Code Sample:
Just doing a POC to write an equivalent code using Apache Olingo for the below DSS2Java Example
/**
* This is a composite On Demand Extraction Request
*
* Here is the reference doc for the Async mechanism:
* https://hosted.datascopeapi.reuters.com/RestApi.Help/Home/KeyMechanisms#sectionAsync
*
*/
public void compositeRequest() {
try {
HttpPost httppost = new HttpPost(urlHost + "/Extractions/ExtractWithNotes");
httppost.addHeader("content-type", "application/json;odata.metadata=minimal");
httppost.addHeader("Authorization", "Token " + sessionToken);
// Use the 1st line for your program, the 2nd line to test a timeout (HTTP status 202):
httppost.addHeader("Prefer", "respond-async");
//httppost.addHeader("Prefer", "respond-async, wait=5");
JSONOrderedObject compositeExtractJSONObject = new JSONOrderedObject()
.put("ExtractionRequest", new JSONOrderedObject()
.put("@odata.type", "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.CompositeExtractionRequest")
.put("ContentFieldNames", new JSONArray()
.put("RIC")
.put("CUSIP")
.put("ISIN")
.put("SEDOL")
.put("Issuer OrgID")
.put("Currency Code")
.put("Annualized Dividend Period Start Date")
.put("Annualized Dividend Adjusted Gross Amount")
.put("Balance Sheet - Enterprise Value")
.put("Balance Sheet - Market Value"))
.put("IdentifierList", new JSONOrderedObject()
.put("@odata.type", "#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList")
.put("InstrumentIdentifiers", new JSONArray()
.put(new JSONObject()
.put("Identifier", "00209tab1")
.put("IdentifierType", "Cusip"))
.put(new JSONObject()
.put("Identifier", "IBM.N")
.put("IdentifierType", "Ric"))
.put(new JSONObject()
.put("Identifier", "US4592001014")
.put("IdentifierType", "Isin"))
.put(new JSONObject()
.put("Identifier", "B1YW440")
.put("IdentifierType", "Sedol")))));
System.out.println("Composite extraction JSON request content:\n"+ compositeExtractJSONObject.toString() +"\n");
StringEntity requestBody = new StringEntity(compositeExtractJSONObject.toString());
httppost.setEntity(requestBody);
// NOTE: If the extraction request takes more than 30 seconds the async mechanism will be used.
System.out.println("We submit the request, a response should arrive in approximately 30 seconds ...\n");
HttpResponse response = httpclient.execute(httppost);
StringBuffer result = new StringBuffer();
// Get the response status code
int respStatusCode = response.getStatusLine().getStatusCode();
Sample Code using Olingo: (Snapshot)
ODataClient client = ODataClientFactory.getClient();
client.getConfiguration()
.setHttpClientFactory(new BasicAuthHttpClientFactory("<username>", "<password>"));
ODataRetrieveRequest<ClientEntitySet> request = client.getRetrieveRequestFactory()
.getEntitySetRequest(client.newURIBuilder(urlHost)
.appendActionCallSegment("Extractions/CompositeExtractionRequest")
.build());
/request.addCustomHeader("Authorization", "Token <token>");
final ODataRetrieveResponse<ClientEntitySet> response = request.execute();
final ClientEntitySet entitySet = response.getBody();
System.out.println(entitySet);
Best Answer
-
I am also new to Apache Olingo. After trying to use it for a while, the code could be like this:
public void CompositeExtractionRequest() {
ClientEntity newEntity = client.getObjectFactory().newEntity(new FullQualifiedName("ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.CompositeExtractionRequest"));
newEntity.getProperties()
.add(client.getObjectFactory().newComplexProperty("ExtractionRequest",
client.getObjectFactory().newComplexValue("ExtractionRequest")
.add(client.getObjectFactory().newPrimitiveProperty("@odata.type", client.getObjectFactory().newPrimitiveValueBuilder().buildString("#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.CompositeExtractionRequest")))
.add(client.getObjectFactory().newCollectionProperty("ContentFieldNames", client.getObjectFactory().newCollectionValue("ContentFieldNames")
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("RIC"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("CUSIP"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("ISIN"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("SEDOL"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Issuer OrgID"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Currency Code"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Annualized Dividend Period Start Date"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Annualized Dividend Adjusted Gross Amount"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Balance Sheet - Enterprise Value"))
.add(client.getObjectFactory().newPrimitiveValueBuilder().buildString("Balance Sheet - Market Value"))
))
.add(client.getObjectFactory().newComplexProperty("IdentifierList", client.getObjectFactory().newComplexValue("IdentifierList")
.add(client.getObjectFactory().newPrimitiveProperty("@odata.type", client.getObjectFactory().newPrimitiveValueBuilder().buildString("#ThomsonReuters.Dss.Api.Extractions.ExtractionRequests.InstrumentIdentifierList")))
.add(client.getObjectFactory().newCollectionProperty("InstrumentIdentifiers", client.getObjectFactory().newCollectionValue("InstrumentIdentifiers")
.add(client.getObjectFactory().newComplexValue("Ident1")
.add(client.getObjectFactory().newPrimitiveProperty("Identifier", client.getObjectFactory().newPrimitiveValueBuilder().buildString("00209tab1")))
.add(client.getObjectFactory().newPrimitiveProperty("IdentifierType", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Cusip")))
)
.add(client.getObjectFactory().newComplexValue("Ident2")
.add(client.getObjectFactory().newPrimitiveProperty("Identifier", client.getObjectFactory().newPrimitiveValueBuilder().buildString("IBM.N")))
.add(client.getObjectFactory().newPrimitiveProperty("IdentifierType", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Ric")))
)
.add(client.getObjectFactory().newComplexValue("Ident3")
.add(client.getObjectFactory().newPrimitiveProperty("Identifier", client.getObjectFactory().newPrimitiveValueBuilder().buildString("US4592001014")))
.add(client.getObjectFactory().newPrimitiveProperty("IdentifierType", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Isin")))
)
.add(client.getObjectFactory().newComplexValue("Ident4")
.add(client.getObjectFactory().newPrimitiveProperty("Identifier", client.getObjectFactory().newPrimitiveValueBuilder().buildString("B1YW440")))
.add(client.getObjectFactory().newPrimitiveProperty("IdentifierType", client.getObjectFactory().newPrimitiveValueBuilder().buildString("Sedol")))
)
)
)
)
)
));
ODataEntityCreateRequest<ClientEntity> createRequest = client.getCUDRequestFactory().getEntityCreateRequest(
client.newURIBuilder(serviceUrl).appendEntitySetSegment("Extractions/ExtractWithNotes").build(),
newEntity);
createRequest.addCustomHeader("Authorization", "Token "+token);
ODataEntityCreateResponse<ClientEntity> createResponse = createRequest.execute();
ClientEntity createdEntity = createResponse.getBody();
System.out.println(createdEntity.toString());
}The full example is olingoexamplejava.txt
0
Categories
- All Categories
- 6 AHS
- 36 Alpha
- 166 App Studio
- 6 Block Chain
- 4 Bot Platform
- 18 Connected Risk APIs
- 47 Data Fusion
- 33 Data Model Discovery
- 682 Datastream
- 1.4K DSS
- 613 Eikon COM
- 5.2K Eikon Data APIs
- 10 Electronic Trading
- Generic FIX
- 7 Local Bank Node API
- 3 Trading API
- 2.9K Elektron
- 1.4K EMA
- 248 ETA
- 552 WebSocket API
- 37 FX Venues
- 14 FX Market Data
- 1 FX Post Trade
- 1 FX Trading - Matching
- 12 FX Trading – RFQ Maker
- 5 Intelligent Tagging
- 2 Legal One
- 23 Messenger Bot
- 3 Messenger Side by Side
- 9 ONESOURCE
- 7 Indirect Tax
- 60 Open Calais
- 275 Open PermID
- 44 Entity Search
- 2 Org ID
- 1 PAM
- PAM - Logging
- 6 Product Insight
- Project Tracking
- ProView
- ProView Internal
- 22 RDMS
- 1.8K Refinitiv Data Platform
- 625 Refinitiv Data Platform Libraries
- 5 LSEG Due Diligence
- 1 LSEG Due Diligence Portal API
- 4 Refinitiv Due Dilligence Centre
- Rose's Space
- 1.2K Screening
- 18 Qual-ID API
- 13 Screening Deployed
- 23 Screening Online
- 12 World-Check Customer Risk Screener
- 1K World-Check One
- 46 World-Check One Zero Footprint
- 45 Side by Side Integration API
- 2 Test Space
- 3 Thomson One Smart
- 10 TR Knowledge Graph
- 151 Transactions
- 143 REDI API
- 1.8K TREP APIs
- 4 CAT
- 26 DACS Station
- 121 Open DACS
- 1.1K RFA
- 104 UPA
- 191 TREP Infrastructure
- 228 TRKD
- 915 TRTH
- 5 Velocity Analytics
- 9 Wealth Management Web Services
- 83 Workspace SDK
- 11 Element Framework
- 5 Grid
- 18 World-Check Data File
- 1 Yield Book Analytics
- 46 中文论坛