OnlineObjectService Class provides methods that perform operations acting on the Kony Fabric endpoint, including basic CRUD. An instance of OnlineObjectService is returned by the getObjectService Method.
The following methods are used by the OnlineObjectService class and its instantiations.
Creates an object in the Kony Fabric endpoint.
create(HashMap<String,String> headers,HashMap<String,String> queryParams,ObjectServiceCallback callback)
None
Input Parameter | Type | Description | Required |
---|---|---|---|
dataObject | DataObject | An instance of the DataObject class that contains details about the object and its data | Yes |
headers | HashMap<String,String> | Key/value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
ObjectService objSvc = konyClient.getObjectService("<objectservicename>"); DataObject dataObject = new DataObject("product"); JSONObject bodyParams = new JSONObject(); bodyParams.put("name", "tv"); dataObject.setRecord(bodyParams); try { objSvc.create(dataObject, new HashMap < String, String > (), new HashMap < String, String > (), new ObjectServiceCallback() { @Override public void onSuccess(JSONObject response) throws KonyException { kony.print("create success : " + response.toString()); } @Override public void onFailure(ObjectServiceException objectServiceException) { kony.print("create failed : " + objectServiceException.getErrorMessage()); } } ); } catch (Exception e) { kony.print("Exception while creating an object : " + e.printStackTrace()); }
Updates an object in the Kony Fabric endpoint.
update(DataObject dataObject,HashMap<String,String> headers,HashMap<String,String> queryParams,ObjectServiceCallback callback)
Input Parameter | Type | Description | Required |
---|---|---|---|
dataObject | DataObject | An instance of the DataObject class that contains details about the object and its data | Yes |
headers | HashMap<String,String> | Key/value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
ObjectService objSvc = konyClient.getObjectService("<objectservicename>"); DataObject dataObject = new DataObject("product"); JSONObject params = new JSONObject(); params.put("name", ”playstation”); dataObject.setRecord(params); try { objSvc.update(dataObject, new HashMap < String, String > (), new HashMap < String, String > (), new ObjectServiceCallback() { @verride public void onSuccess(final JSONObject object) { kony.print("update success : " + response.toString()); } @Override public void onFailure(final ObjectServiceException objectServiceException) { kony.print("update failed : " + objectServiceException.getErrorMessage()); } }); } catch (Exception e) { kony.print("Exception occurred while updating an object : " + e.printStackTrace()); }
Deletes an object in the Kony Fabric endpoint.
delete(DataObject dataObject,HashMap<String,String> headers,HashMap<String,String> queryParams,ObjectServiceCallback callback)
Input Parameter | Type | Description | Required |
---|---|---|---|
dataObject | DataObject | An instance of the DataObject class that contains details about the object and its data | Yes |
headers | HashMap<String,String> | Key/ value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
DataObject dataObject = new DataObject("product"); JSONObject jobject = new JSONObject(); jobject.put("id", 1); dataObject.setRecord(jobject); try { objSvc.delete(dataObject, new HashMap < String, String > (), new HashMap < String, String > (), new ObjectServiceCallback() { @Override public void onSuccess(JSONObject response) throws KonyException { kony.print("delete success : " + response.toString()); } @Override public void onFailure(ObjectServiceException objectServiceException) { kony.print("delete failed" + objectServiceException.getErrorMessage()); } ); }
Fetches an object from the server.
fetch(DataObject dataObject,HashMap<String,String> headers,HashMap<String,String> queryParams,ObjectServiceCallback callback)
Input Parameter | Type | Description | Required |
---|---|---|---|
dataObject | DataObject |
An instance of the DataObject class that contains details about the object and its data |
Yes |
headers | HashMap<String,String> | Key/ value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call. | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
DataObject dataObject = new DataObject("product"); dataObject.setODataUrl("$filter= " + "id" + "eq" + "1"); try { objectService.fetch(dataObject, new HashMap < String, String > (), new HashMap < String, String > (), new ObjectServiceCallback() { @Override public void onSuccess(JSONObject response) throws KonyException { kony.print("fetch success : " + response.toString()); } @Override public void onFailure(ObjectServiceException objectServiceException) { kony.print("fetch failed" + objectServiceException.getErrorMessage()); } }); } catch (Exception e) { kony.print("exception occurred while deleting an object " + e.getMessage()); }
Gets the metadata associated with the objects that are defined in the service from the server.
getMetadataOfAllObjects(boolean getFromServer,String objectName,HashMap<String,String> headers,HashMap<String,String> queryParams,ObjectServiceCallback callback)
Input Parameter | Type | Description | Required |
---|---|---|---|
getFromServer | Boolean |
Flag that retrieves the metadata of the object from the server or local store.
|
Yes |
objectName | String | Name of the object | Yes |
headers | HashMap<String,String> | Key/ value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call. | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
try { objectService.getMetadataOfAllObjects(true, dataObject.getObjectName(), null, null, new ObjectServiceCallback() { @Override public void onSuccess(final JSONObject object) { kony.print("get meta data of all objects success"); } } @Override public void onFailure(final ObjectServiceException objectServiceException) { kony.print("get meta data of all objects failed" + objectServiceException.getErrorMessage()); } } });
Gets the metadata associated with an object that is defined in the service from the server or local store.
getMetadataOfObject(boolean getFromServer,String objectName,HashMap<String,String> headers,HashMap<String,String> queryParams, ObjectServiceCallback callback)
Input Parameter | Type | Description | Required |
---|---|---|---|
getFromServer | Boolean |
Flag that retrieves the metadata of the object from the server or local store.
|
Yes |
objectName | String | Name of the object | Yes |
headers | HashMap<String,String> | Key/ value pairs of httpHeaders that are sent along with the network call. | Optional |
queryParams | HashMap<String,String> | Key/ value pairs of query parameters that are appended to the URL while making a network call. | Optional |
objectServiceCallback | ObjectServiceCallback |
Interface with onSuccess and onFailure methods
|
Yes |
try { objectService.getMetadataOfObject(true, dataObject.getObjectName(), null, null, new ObjectServiceCallback() { @Override public void onSuccess(final JSONObject object) { kony.print("get meta data of object success"); } @Override public void onFailure(final ObjectServiceException objectServiceException) { kony.print("get meta data of object failed" + objectServiceException.getErrorMessage()); } }); } catch (KonyException e) { e.printStackTrace(); }
Copyright © 2020 Kony, Inc. All rights reserved. |