Creating a sample web app using Kendo UI Builder by Progress : Creating and annotating a Business Entity
  

Creating and annotating a Business Entity

We now create a Business Entity in the AppServer layer to access the customer data that we want to make available to our OpenEdge web app.
1. Right-click the OrderEntry project in the Project Explorer and select New > New Business Entity.The Create a Business entity class page of New Business Entity wizard appears.
2. Retain \OrderEntry\AppServer for the Package root field.
3. Enter CustomerBE in the Business Entity name field.
4. Click Next. The Select a schema file page opens
5. Select the CRUD and Submit option button in Operations.
6. Select the Select database table option button. The Connection field displays sports2000.
7. Click the Table drop-down list and select Customer.
8. Click Finish. The CustomerBE.cls file appears under the AppServer folder in the OrderEntry project in Project Explorer.
9. Double-click the CustomerBE.cls file to edit. The class is already annotated as a Data Object Service Interface by the New Business Entity wizard using the annotation:
@progress.service.resource FILE(name="CustomerBE", URI="/CustomerBE", schemaName="dsCustomer", schemaFile="OrderEntry/AppServer/customerbe.i")
10. Scroll down to the ReadCustomerBE method definition. The Read method uses a filter (or a where clause) and returns a dataset of the records matching the filter. We use this method to retrieve the records from the Web UI project.
@openapi.openedge.export(type="REST", useReturnValue="false", writeDataSetBeforeImage="true").
@progress.service.resourceMapping(type="REST", operation="read", URI="?filter=~{filter~}", alias="", mediaType="application/json").
METHOD PUBLIC VOID ReadCustomerBE(
INPUT filter AS CHARACTER,
OUTPUT DATASET dsCustomer):

SUPER:ReadData(filter).

END METHOD.
11. Open the Customerbe.i file under the AppServer folder in the OrderEntry project in Project Explorer. All the columns from the database table sports2000.Customer including the indexes and primary key definitions are displayed as follows:
@openapi.openedge.entity.primarykey (fields="CustNum").

DEFINE TEMP-TABLE ttCustomer BEFORE-TABLE bttCustomer
FIELD CustNum AS INTEGER INITIAL "0" LABEL "Cust Num"
FIELD Country AS CHARACTER INITIAL "USA" LABEL "Country"
FIELD Name AS CHARACTER LABEL "Name"
FIELD Address AS CHARACTER LABEL "Address"
FIELD Address2 AS CHARACTER LABEL "Address2"
FIELD City AS CHARACTER LABEL "City"
FIELD State AS CHARACTER LABEL "State"
FIELD PostalCode AS CHARACTER LABEL "Postal Code"
FIELD Contact AS CHARACTER LABEL "Contact"
FIELD Phone AS CHARACTER LABEL "Phone"
FIELD SalesRep AS CHARACTER LABEL "Sales Rep"
FIELD CreditLimit AS DECIMAL INITIAL "1500" LABEL "Credit Limit"
FIELD Balance AS DECIMAL INITIAL "0" LABEL "Balance"
FIELD Terms AS CHARACTER INITIAL "Net30" LABEL "Terms"
FIELD Discount AS INTEGER INITIAL "0" LABEL "Discount"
FIELD Comments AS CHARACTER LABEL "Comments"
FIELD Fax AS CHARACTER LABEL "Fax"
FIELD EmailAddress AS CHARACTER LABEL "Email"
INDEX Comments Comments ASCENDING
INDEX CountryPost Country ASCENDING PostalCode ASCENDING
INDEX CustNum IS PRIMARY UNIQUE CustNum ASCENDING
INDEX Name Name ASCENDING
INDEX SalesRep SalesRep ASCENDING .


DEFINE DATASET dsCustomer FOR ttCustomer.
12. Right-click anywhere on the editor and select Progress OpenEdge > Define Service Interface. The Define Service Interface page opens.
13. Select all the operations in the ABL routines section and click Next. The Edit Annotation page opens.
14. Click the Field Annotations tab.
15. From the Temp Table drop-down list, select ttCustomer.
16. From the Field drop-down list, select Phone.
17. From the Annotation drop-down list, select Semantic Type.
18. From the Semantic Type drop-down list, select PhoneNumber.
19. Click Apply and then click Finish.
Notice that the Customerbe.i file is annotated.
20. Save and close the CustomerBE.cls and the Customerbe.i files.