Thursday, December 5, 2013

RIDC: GET_DATARESULTSET Service to get the list of docTypes

To achieve the above requirement we would need to use GET_DATARESULTSET service which by definition executes a Select query against the database.

Required parameter for this service is "dataSource" which is a preset query present in std_resources.htm (location : <mw_home>/Oracle_ECM1/ucm/idc/resources/core/tables) under <@table DataSources@>.



package client;

import oracle.stellent.ridc.IdcClient;
import oracle.stellent.ridc.IdcClientException;
import oracle.stellent.ridc.IdcClientManager;
import oracle.stellent.ridc.IdcContext;
import oracle.stellent.ridc.model.DataBinder;
import oracle.stellent.ridc.model.DataObject;
import oracle.stellent.ridc.model.DataResultSet;
import oracle.stellent.ridc.protocol.ServiceResponse;


public class RIDCDocTypes {
    
    private static final String WHERE_CLAUSE = null;
    private static final String ORDER_CLAUSE = " order by DocTypes.dDocType desc";

    public static void main(String[] args) {
        IdcClientManager manager = new IdcClientManager();
        try {
            IdcClient idcClient = manager.createClient("idc://127.0.0.1:4444");
            IdcContext userContext = new IdcContext("sysadmin");

            //HdaBinderSerializer serializer = new HdaBinderSerializer("UTF-8", idcClient.getDataFactory());

            DataBinder serviceBinder = idcClient.createBinder();
            serviceBinder.putLocal("IdcService", "GET_DATARESULTSET");
            serviceBinder.putLocal("dataSource", "DocTypes");
            serviceBinder.putLocal("resultName", "DocTypesList");
            
            if (WHERE_CLAUSE != null) {
                    serviceBinder.putLocal("whereClause", WHERE_CLAUSE);
            }

            if (ORDER_CLAUSE != null) {
                    serviceBinder.putLocal("orderClause", ORDER_CLAUSE);
            }

            //serializer.serializeBinder(System.out, dataBinder);
            ServiceResponse response = idcClient.sendRequest(userContext, serviceBinder);
            DataBinder responseData = response.getResponseAsBinder();
            //serializer.serializeBinder(System.out, responseData);

            DataResultSet resultSet = responseData.getResultSet("DocTypesList");

            for (DataObject dataObject : resultSet.getRows()) {
                System.out.println(dataObject.get("dDocType"));
            }

        } catch (IdcClientException ice) {
            ice.printStackTrace();
        } /*catch (IOException ioe) {
            ioe.printStackTrace();
        }*/
    }
}

Similarly, we can get the list of all documents, users, workflows, revisions, etc. This service can be used from browser as well in the following manner : 

http://hostname:port/cs/idcplg?IdcService=GET_DATARESULTSET&dataSource=DocTypes&resultName=DocTypesList&IsJava=1

No comments:

Post a Comment