JavaScript Extension Development API for Oracle Visual Builder Cloud Service - Classic Applications

Class: operation/js/api/OperationData

Describes the input data (record or records) and options (filtering, sorting, pagination etc.) which the client selected to perform an Operation instance.

Operation author is expected to process OperationData values and perform corresponding function so that the expected data (filtered, sorted and paginated) are always fetched.

Operation contains all relevant information (e.g. Condition) to allow build up URL correctly or generally process input values any way it need. The OperationData instances are created automatically by Application Builder when Business User is tweaking application UI. For example while Business User is changing "Default Query" in the UI, Application Builder automatically creates different OperationData instance based on the UI selection which is then passed into the Operation.perform(..) method so that the author can take them into account and fetch only corresponding records.

OperationData can be set by one of these options:

  • By Application Builder UI automatically when client is using the Table/List and selects another value in sorting combo-box.
  • By Business User creating and passing its instance directly from the custom code. See Abcs.Operations().read(..) to check how to perform such custom code.

Version:
  • 17.1.1
Source:

Methods

getCondition() → {operation/js/api/Condition}

stable API

Gets the Condition requesting to fetch only records matching the given criteria.

Version:
  • 17.1.1
Source:
See:
Returns:
Type
operation/js/api/Condition
Example

Using an input Condition and processing it with custom ConditionVisitor to get the proper URL.

var findEmployee = function(operationData) {
    var results = [];
    var baseURL = 'http://example.com/employee';
    var condition = operationData.getCondition();

    // The visitor is there to turn Condition abstraction into
    // whatever URL shape data provider expects on it's input
    var resultURL = condition.visit(new MyConditionVisitor(baseURL));

    $.ajax({
        url: resultURL,
        type: 'GET'
    }).done(function(response) {
        // Because the URL was change by the visitor, we should have filtered results here
        fulfil(OperationResult.success(response));
    });
};

getCustomData() → {Object}

stable API

Gets custom data assigned to this OperationData instance.

Custom data Object has no formal structure pre-defined. It's up to the Operation author whether s(he) can handle some custom values as part of the Operation.perform() method implementation. Because of that, the format and contract of the custom data object is completely up to the author. It can be expected as complex Object literal, plain String value or any other valid JS construct.

Version:
  • 17.1.1
Source:
Returns:
Type
Object

getPaginationRequest() → {operation/js/api/PaginationRequest}

stable API

Gets the PaginationRequest value requesting to fetch only certain subset of records.

Version:
  • 17.1.1
Source:
Returns:
Type
operation/js/api/PaginationRequest

getSorting() → {operation/js/api/Sorting}

stable API

Gets the Sorting value requesting to fetch records in certain order.

Version:
  • 17.1.1
Source:
See:
Returns:
Type
operation/js/api/Sorting
Example

Using an input Sorting and processing it to build proper URL.

var findEmployee = function(operationData) {
    var url = 'http://example.com/employee';
    var sorting = operationData.getSorting();
    var criteria = sorting.getSortingCriteria();

    if (criteria && criteria.length > 0) {
        // For simplicity lets assume only one criterion is always available
        var criterion = criteria[0];
        var property = criterion.getProperty();
        var propertyID = property.getId();

        // Assume our server supports URL suffix in form of '?sort=firstname&direction=asc'
        url += '?sort=' + propertyID;
        if (criterion.isAscending()) {
            url += '&direction=asc';
        } else {
            url += '&direction=desc';
        }
    }

    $.ajax({
        url: url,
        type: 'GET'
    }).done(function(response) {
        // Because the URL contain sorting parameter, we should have sorted records here
        fulfil(OperationResult.success(response));
    });
};