Information

This site will undergo a brief period of maintenance on Thursday, 23 April at 2:30 AM Central/1:00 PM IST. During a 30 minute window, site availability may be intermittent.

Information
This documentation supports the 20.02 version of BMC Helix Platform.To view the documentation for the current version, select 20.08 from the Product version menu.

Creating a DataPageQuery REST interface


DataPageQuery is a standard resource that allows your custom Java classes to return a set of paginated data (syntax supports the notion of page size and start index for returning data in chunks to the client) to a client without defining special parameters for a GET syntax. DataPageQuery class (com.bmc.arsys.rx.services.common.DataPageQuery) represents a generic query that is executed via DataPageResource on @Get call. You can extend this class and overload execute().

DataPageQuery sample code

The following code snippet illustrates sample DataPageQuery code format:

public
abstract class DataPageQuery implements Registerable {

    /** The data page query parameters. */
    private final DataPageQueryParameters dataPageQueryParameters;
    …
   /**
     * Execute the logic of DataPageQuery.
     * @return the data page
     */
    public  abstract
DataPage  execute();

}

Creating DataPageQuery

Let us consider that there is some data source that is not available via the record service (data is not represented by a record definition). You can create a way to perform a query for network information in the form of Node data that looks as follows in JSON:

{
"count": 6,
"ip": "14.233.555.33",
"status": "Loading",
"model": "C-245Z",
"manufacturer": "C-245Z"
}

You can retrieve such data using a REST call. To retrieve data, implement a class that extends the framework class com.bmc.arsys.rx.services.common.DataPageQuery. The framework class implements the execute() method which returns an object called DataPage.

The following code snippet represents a sample DataPageQuery class:

import com.bmc.arsys.rx.services.common.DataPageQuery;
import com.bmc.arsys.rx.services.common.DataPageQueryParameters;
import com.bmc.arsys.rx.services.common.QueryPredicate;

public class NetworkDataPageQuery extends DataPageQuery {

    public class Node {
        // Define the data members to represent a network node
    }

@Override
    public DataPage execute() {

        List<Node> = getNodeData();   // Pseudo-code to represent loading or creation of Node data.

        // Process the pagesize and startindex parameters to isolate the correct
        // chunk of data in a DataPage object.
        int start = getDataPageQueryParameters().getStartIndex();
        if (start >= list.size()) {
            return new DataPage(0, new ArrayList<Node>());
        }
        int end = Math.min(start + getDataPageQueryParameters().getPageSize(), list.size());
        List<Node> page = list.subList(start, end);
        return new DataPage(page.size(), page);
    }
}

The full implementation of this class can be found in the com.example.query package in the sample code. This includes a line of registration code in the MyLibrary bundle class.

public class MyLibrary extends RxBundle {
    protected void register() {

        registerClass(NetworkDataPageQuery.class);
    . . .

You can test the code using an authenticated session in Postman and sending GET operation to the generic resource api/rx/application/datapage.

Related topics

PDFs-videos-and-API-documentation

Creating-a-command-REST-interface

Creating-a-custom-REST-resource

Handling-exceptions

Login-information

Enabling-logging-for-a-Digital-Service-application

Enabling-browser-logging-in-a-Digital-Service-application

 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*

BMC Helix Platform 20.02