Try OpenEdge Now
skip to main content
Java Open Clients
Accessing ABL ProDataSets : Preparing and passing ProDataSets as ProDataGraph parameters : Passing a ProDataGraph as INPUT or INPUT-OUTPUT : Creating and initializing a ProDataGraph object with meta data
 
Creating and initializing a ProDataGraph object with meta data
You can use a number of approaches for creating and initializing a ProDataGraph with meta data.
These approaches include two main variations:
1. Start by creating the meta data and use it to create the ProDataGraph using the appropriate constructor.
2. Start by creating a Java SDO DataGraph that conforms to the OpenEdge ProDataGraph object model, and create the ProDataGraph from this using the appropriate constructor.
The following procedure suggests one such approach starting with the meta data. For information on creating an OpenEdge ProDataGraph from a Java SDO DataGraph, see the appropriate ProDataGraph constructor in ProDataGraphclass.
To create and initialize a ProDataGraph with meta data:
1. Create a ProDataGraphMetaData object using the following constructor:
Syntax
ProDataGraphMetaData(String dataSetName)
Where dataSetName is the ABL name of the ProDataSet in the application service.
2. Create a ProDataObjectMetaData object for each temp-table defined in the corresponding application service ProDataSet using the following constructor:
Syntax
ProDataObjectMetaData(String tableName, int numFields,
                      boolean bimageFlag,
                      int numIndexes, String multiIxCols,
                      String XMLNamespace, String XMLPrefix)
The parameters specify, respectively:
*The ABL name of the temp-table
*The number of temp-table fields
*An indication if there is a BEFORE-TABLE defined for the temp-table (required in order to update the temp-table)
*The number of indexes on the temp-table
*A formatted string that specifies all the index information for this temp-table
*Any XML namespace (or null)
*Any XML prefix (or null)
For more information, see ProDataObjectMetaData class.
3. For each ProDataObjectMetaData object created in Step 2, add the column meta data to match the schema of a corresponding temp-table field. So, for each field in the temp-table, invoke the following ProDataObjectMetaData method:
Syntax
void setFieldMetaData(int fieldNumber, String fieldName, int extent,
                      int proType, int userOrder, int xmlMapping)
The parameters specify, respectively:
*The 1-based number of the temp-table field.
*The ABL field name.
*If an array field, a value greater than 1 indicating the extent.
*A value specified by a class constant defined in com.progress.open4gl.Parameter that indicates the ABL data type of the field. For more information, see the information on specifying data type meta data for temp-tables in Passing Parameters
*A 0-based user position order for the field.
*An XML serialization value for later use, currently set to 0.
For more information on creating table meta data, see ProDataObjectMetaData class.
4. Add each ProDataObjectMetaData object completed in Step 3 to the ProDataGraphMetaData object created in Step 1 using the following ProDataGraphMetaData method:
Syntax
void addTable(ProDataObjectMetaData tablemd)
5. For each DATA-RELATION object defined for the ProDataSet in the application service, create a corresponding ProDataRelationMetaData object using the following constructor:
Syntax
ProDataRelationMetaData(String name, ProDataObjectMetaData parent,
                        ProDataObjectMetaData child)
ProDataRelationMetaData(String name, int parentIdx, int childIdx,
                        int numPairs, String pairsList, )
The second constructor allows you to set foreign-primary key relationships for one or more columns between parent and child tables explicitly. The parentIdx and childIdx correspond to indexes into the list of table names returned by the ProDataGraphMetaData method, getTableNames(). You can also set these relationships in the instantiated ProDataRelationMetaData object using the overloaded setColumns() methods.
For more information on creating data-relations, see ProDataRelationMetaData class.
6. Add each ProDataRelationMetaData object completed in Step 5 to the ProDataGraphMetaData object created in Step 1 using the following ProDataGraphMetaData method:
Syntax
void addDataRelation(ProDataRelationMetaData drmd)
7. Create the ProDataGraph from the ProDataGraphMetaData object completed in Step 4 and Step 6 using the following constructor:
Syntax
ProDataGraph(ProDataGraphMetaData dgmd)
For more information on creating meta data for a ProDataGraph, see ProDataGraphMetaDataclass.