@program FILE(name="Customer.cls", module="AppServer"). @openapi.openedge.export FILE(type="REST", executionMode="singleton", useReturnValue="false", writeDataSetBeforeImage="false"). @progress.service.resource FILE(name="Customer", URI="/Customer", schemaName="dsCustomer", schemaFile="Customer/AppServer/customer.i"). USING Progress.Lang.*. USING OpenEdge.BusinessLogic.BusinessEntity. USING Progress.Json.ObjectModel.*. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Customer INHERITS BusinessEntity: {"customer.i"} . . . @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false"). @progress.service.resourceMapping(type="REST", operation="invoke", URI="/count?filter=~{filter~}", alias="", mediaType="application/json"). METHOD PUBLIC VOID count( INPUT filter AS CHARACTER, OUTPUT numRecs AS INTEGER): DEFINE VARIABLE jsonParser AS ObjectModelParser NO-UNDO. DEFINE VARIABLE jsonObject AS JsonObject NO-UNDO. DEFINE VARIABLE ablFilter AS CHARACTER NO-UNDO. DEFINE VARIABLE cWhere AS CHARACTER NO-UNDO. DEFINE VARIABLE qh AS HANDLE NO-UNDO. IF filter BEGINS "WHERE " THEN cWhere = filter. ELSE IF filter BEGINS "~{" THEN DO: jsonParser = NEW ObjectModelParser(). jsonObject = CAST(jsonParser:Parse(filter), jsonObject). ablFilter = jsonObject:GetCharacter("ablFilter") NO-ERROR. cWhere = "WHERE " + ablFilter. END. ELSE IF filter NE "" THEN DO: /* Use filter as WHERE clause */ cWhere = "WHERE " + filter. END. CREATE QUERY qh. qh:SET-BUFFERS(BUFFER Customer:HANDLE). qh:QUERY-PREPARE("PRESELECT EACH Customer " + cWhere). qh:QUERY-OPEN (). numRecs = qh:NUM-RESULTS. END METHOD. END CLASS. |
@program FILE(name="Customer.cls", module="AppServer"). @openapi.openedge.export FILE(type="REST", executionMode="singleton", useReturnValue="false", writeDataSetBeforeImage="false"). @progress.service.resource FILE(name="Customer", URI="/Customer", schemaName="dsCustomer", schemaFile="Customer/AppServer/customer.i"). USING Progress.Lang.*. USING OpenEdge.BusinessLogic.BusinessEntity. USING Progress.Json.ObjectModel.*. BLOCK-LEVEL ON ERROR UNDO, THROW. CLASS Customer INHERITS BusinessEntity: {"customer.i"} . . . @openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="false"). @progress.service.resourceMapping(type="REST", operation="count", URI="/MyCount?filter=~{filter~}", alias="", mediaType="application/json"). METHOD PUBLIC VOID MyCount( INPUT filter AS CHARACTER, OUTPUT numRecs AS INTEGER): DEFINE VARIABLE jsonParser AS ObjectModelParser NO-UNDO. DEFINE VARIABLE jsonObject AS JsonObject NO-UNDO. DEFINE VARIABLE ablFilter AS CHARACTER NO-UNDO. DEFINE VARIABLE cWhere AS CHARACTER NO-UNDO. DEFINE VARIABLE qh AS HANDLE NO-UNDO. IF filter BEGINS "WHERE " THEN cWhere = filter. ELSE IF filter BEGINS "~{" THEN DO: jsonParser = NEW ObjectModelParser(). jsonObject = CAST(jsonParser:Parse(filter), jsonObject). ablFilter = jsonObject:GetCharacter("ablFilter") NO-ERROR. cWhere = "WHERE " + ablFilter. END. ELSE IF filter NE "" THEN DO: /* Use filter as WHERE clause */ cWhere = "WHERE " + filter. END. CREATE QUERY qh. qh:SET-BUFFERS(BUFFER Customer:HANDLE). qh:QUERY-PREPARE("PRESELECT EACH Customer " + cWhere). qh:QUERY-OPEN (). numRecs = qh:NUM-RESULTS. END METHOD. END CLASS. |