Release 10.1A: OpenEdge Development:
Java Open Clients

> ## Passing a ProDataGraph as OUTPUT

> To pass a ProDataGraph as output, you create a ProDataGraphHolder instance to contain the ProDataGraph, and pass the holder as the proxy method parameter that maps to the application service DATASET or DATASET-HANDLE OUTPUT parameter. You do not need to create an initial ProDataGraph object to instantiate the ProDataGraphHolder instance. The Java Open Client interface creates the ProDataGraph required to hold the data returned from the corresponding output ProDataSet on the AppServer.

> | To return an output ProDataGraph, get the value of the getProDataGraphValue() method invoked on the output ProDataGraphHolder parameter.

> The actual value and content of the output ProDataGraph can vary depending on how the ProDataSet is defined by the application service. For example, if the OUTPUT ProDataSet is passed as a DATASET-HANDLE (dynamically), this value can be null. A null value indicates that the DATASET-HANDLE parameter was set to the Unknown value (`?`) or undefined (defined with no schema and data) by the application service. A dynamic ProDataSet might also be passed without data-relations created for it, and so on.

> Once you have the output ProDataGraph, you can access its data, depending on whether you already know the schema of the corresponding ProDataSet.

> ##### Accessing a ProDataGraph with a known schema

> If you already know the schema of the ProDataSet, you can use this information to access the data in the ProDataGraph. If you do not know the schema, see the "Accessing the ProDataGraph meta data" section.

> | To access the data in a ProDataGraph:

> 1. Return the ProDataObject list from the ProDataGraph that maps to a specified temp-table using the following ProDataGraph method, where `tableName` is the 4GL name of the temp-table:

> Syntax
>     java.util.List getProDataObjects(String tableName)

> 2. Iterate through the ProDataObject list returned in Step 1 and locate a ProDataObject instance that contains data that you want.

> 3. Use the appropriate ProDataObject property access methods to return the values of specified column properties of the `ProDataObject` found in Step 2, where `propertyIndex` is the index into the `ProDataObject` column property list, and `name` is the 4GL name of the temp-table field that the property maps to.

> Note: For more information on determining the `propertyIndex` of a column property and other information about column properties of a `ProDataObject`, see the "Using Java SDO classes to access Property meta data" section.

> - To return the value of a specified single-valued column property in the form of the Property data type, use one of these ProDataObject methods, where `DataType` is the full Java classname or intrinsic type name of the property data type and `DataTypeName` is a name that closely matches the name of the data type that the method returns:

> Syntax
>     DataType getDataTypeName(int propertyIndex)
>     DataType getDataTypeName(String name)

> To identify the Java intrinsic data type or class of the column property that maps to the 4GL data type of the temp-table field, see Table 5–3. For example, the following two methods return values for an int property (mapped to an `INTEGER` field) and a BigDecimal property (mapped to a `DECIMAL` field):

> Syntax
>     int getInt(String name)
>     java.math.BigDecimal getBigDecimal(String name)

> - To return the value of a specified many-valued property (which maps to a temp-table array field), use one of these ProDataObject methods:

> Syntax
>     java.util.List getList(int propertyIndex)
>     java.util.List getList(String name)

> The objects in the List all have the data type of the column Property.

> Note: You can check that a column Property is many-valued, and therefore returns a List, by testing the value returned by its isMany() method.

> - To return the value of a specified column property in the form of the `java.lang.Object` class, use one of these ProDataObject methods:

> Syntax
>     java.lang.Object get(int propertyIndex)
>     java.lang.Object get(String name)

> The returned Object has the data type of the specified column property, including java.util.List if the property is many-valued.

> 4. If you need to access parent or child relations of the ProDataObject that you access in Step 3, you can use the following methods:

> - To return a list of child rows for the specified `ProDataObject`, use this `ProDataObject` method:

> Syntax
>     java.util.List getChildRows(java.lang.String relationName)

> The method returns a list of child rows (ProDataObject instances) for this parent `ProDataObject` according to the data-relation specified by name (`relationName`). Iterate through the list to locate a `ProDataObject` that you want to access.

> - To return a parent row for the specified `ProDataObject`, use this `ProDataObject` method:

> Syntax
>     ProDataObject getParentRow(java.lang.String relationName)

> The method returns a parent ProDataObject for this child `ProDataObject` according to the data-relation specified by name (`relationName`).

> Note: For a `ProDataGraph`, the `relationName` identifies a `DATA-RELATION` defined in the corresponding ProDataSet parameter of the application service, and this name is identical to the 4GL name of the specified `DATA-RELATION`.

> Once you have a child or parent `ProDataObject`, you can continue with Step 3 to access its data.

> For more information on `ProDataObject` methods, see the "ProDataObject class" section.

> ##### Accessing the ProDataGraph meta data

> You might not know any or all of the schema for an output `ProDataGraph`. In this case, you can introspect the `ProDataGraph` to identify all of its meta data, including the names and locations of all `ProDataGraph` components that map to the corresponding ProDataSet `OUTPUT` parameter. These components can include only the functional Java components of the `ProDataGraph` or they can also include the names, locations, and data types of the ProDataSet, its temp-tables, fields, and data-relations, as you might require.

> You can get meta data for an unknown `ProDataGraph` in different ways. The following procedure shows one approach for accessing `ProDataGraph`, primarily by identifying and using component names. You can also identify component locations and use indexes (rather than names) to more directly and efficiently access components.

> | To access the meta data of a ProDataGraph:

> 1. If you need the 4GL name of the ProDataSet that the `ProDataGraph` maps to, use this `ProDataGraph` method:

> Syntax
>     java.lang.String getProDataGraphName()

> 2. To get 4GL schema information for temp-tables or get information on data-relations that have been passed in the ProDataGraph, get its associated ProDataGraphMetaData object using this ProDataGraph method:

> Syntax
>     ProDataGraphMetaData getMetaData()

> 3. To get 4GL schema information for each temp-table passed in the ProDataGraph:

> 1. Get the 4GL names for all ProDataSet temp-tables (`ProDataObject` collections) in the `ProDataGraph` using this `ProDataGraphMetaData` method:

> Syntax
>     java.lang.String[] getTableNames()

> 2. Get the ProDataObjectMetaData for a temp-table using this ProDataGraphMetaData method, where the `idx` value corresponds to the index into the list of table names that refers to the name of the given temp-table:

> Syntax
>     ProDataObjectMetaData getTableMetaData(int idx)

> 3. Some useful schema information you can get from this meta data for an output temp-table is the field name, the Progress 4GL data type, any extent (for an array), and the specified user order of each temp-table field using these ProDataObjectMetaData methods:

> Syntax
>     int getFieldName(int propertyIndex)
>     int getProType(int propertyIndex)
>     int getExtent(int propertyIndex)
>     int getUserOrder(int propertyIndex)

> The `propertyIndex` is a 0-based value that you can obtain by looping through the number of temp-table fields returned by this `ProDataObjectMetaData` method:

> Syntax
>     int getFieldCount()

> This value is also identical to the index into the corresponding ProDataObject property list that references the corresponding column property (see "Using Java SDO classes to access Property meta data" section).

> For more information on ProDataObjectMetaData methods, see the "ProDataObjectMetaData class" section.

> 4. To get the meta data for data-relations passed in the ProDataGraph:

> 1. Get the number of `ProDataRelationMetaData` objects in the `ProDataGraph` using this `ProDataGraphMetaData` method:

> Syntax
>     int getNumRelations()

> 2. Get each ProDataRelationMetaData object associated with the ProDataGraph using this ProDataGraphMetaData method, where `idx` starts at 0 for the number of data-relations in the ProDataGraph:

> Syntax
>     ProDataRelationMetaData getRelationMetaData(int idx)

> 3. Some useful data-relation information you can get from each ProDataRelationMetaData object for an output ProDataGraph is the specified data-relation name, parent table name, parent table index columns, child table name, and child table index columns, all specified according to a corresponding ProDataSet data-relation and accessible using these ProDataRelationMetaData methods:

> Syntax
>     String getRelationName()
>     String getParentTable()
>     int[] getParentColumns()
>     String getChildTable()
>     int[] getChildColumns()

> For more information on ProDataRelationMetaData methods, see the "ProDataRelationMetaData class" section.

> For more information on ProDataGraphMetaData methods, see the "ProDataGraphMetaData class" section.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095