Developer

Create Operations

Create an ODataEntity using the ScheduleCreateEntity(asynchronous) or executeCreateEntity(synchronous) methods on the OnlineODataStore.

//Create an ODataEntity asynchronously
public ODataRequestExecution scheduleCreateEntity(ODataEntity entity, String collectionPath, ODataRequestListener listener,
		Map<String, String> options) throws ODataContractViolationException


//Create an ODataEntity synchronously
public ODataResponseSingle executeCreateEntity(ODataEntity entity, String collectionPath, Map<String, String> options)
		throws ODataNetworkException, ODataParserException, ODataContractViolationException
scheduleCreateEntity takes an ODataEntity and the collectionPath as the parameter. An ODataEntity is created locally and then passed along as a parameter. The ODataPropMode can be combined using the binary operator.
  1. Create a local ODataEntity and set values for the properties.
  2. Set the PropMode: options are All, Keys, Mandatory, Optional
  3. Call the scheduleCreateEntity method on the SODataStore. Get the response in the proper delegate method.
    ODataEntity entity = new ODataEntityDefaultImpl("Travelagency");
    store.allocateProperties(entity, PropMode.Mandatory);
    ODataRequestListener listener = new ODataRequestListenerImpl();
    Map<String, String> options = null;
    store.scheduleCreateEntity(entity, "TravelAgencies", listener, options);
    
The ODataRequestListenerImpl class must be implemented by the application:
public class ODataRequestListenerImpl implements ODataRequestListener {

@Override
	public void requestStarted(ODataRequestExecution request) {
		// Application logic comes here
	}

	@Override
	public void requestCacheResponse(ODataRequestExecution request) {
		// Application logic comes here
	}

	@Override
	public void requestServerResponse(ODataRequestExecution request) {
		// Application logic comes here
	}

	@Override
	public void requestFailed(ODataRequestExecution request, ODataException exception) {
		// Application logic comes here
	}

	@Override
	public void requestFinished(ODataRequestExecution request) {
		// Application logic comes here
	}
		
}

The synchronous executeCreateEntity method has similar parameters as scheduleCreateEntity. It blocks until the entity is created. When complete, it returns the response (ODataResponseSingle) directly. It does not have a listener parameter.