Kbase P114707: How to pass a ProDataSet from Java Open Client to the AppServer in 10.1A
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  08/05/2006 |
|
Status: Verified
GOAL:
How to pass a ProDataSet from Java Open Client to the AppServer in 10.1A
FACT(s) (Environment):
OpenEdge 10.1A
FIX:
The following Java code shows the steps needed to define a ProDataset, define Temp-Table and add them to the ProDataSet, add records to the Temp-Table then pass the ProDataSet to the AppServer:
import com.progress.open4gl.*;
import com.somecompany.SomeProxy;
public class SampleInputOutputDataSet
{
public static void main(String[] args) throws Exception, ProDataException
{
// STEP 1:
// A) Instantiate a new ProDataSet schema object (ProDataGraphMetaData)
// B) Pass a string as a parameter to the constructor. The string should
// be the name of the ProDataSet as defined in your 4GL program
ProDataGraphMetaData myDataSetSchema = new ProDataGraphMetaData("dsHello");
// STEP 2:
// A) Instantiate a new Temp-Table schema object (ProDataObjectMetaData)
// B) Pass the following as the parameter list to the constructor:
// 1) String - Name of Temp-Table as defined in your 4GL program
// 2) Integer - Number of fields that this Temp-Table has (one-based)
// 3) Boolean - Does Temp-Table have a before-image table defined?
// 4) Integer - Unknown Parameter, pass a zero
// 5) String - Unknown Parameter, pass an empty string
// 6) String - Unknown Parameter, pass an empty string
// 7) String - Unknown Parameter, pass an empty string
ProDataObjectMetaData myHelloTableSchema = new ProDataObjectMetaData("ttHello", 3, false, 0, "", "", "");
// STEP 3:
// A) Call the setFieldDataData method of the Temp-Table schema object
// created in step 2 once for each field defined in the Temp-Table
// as defined in your 4GL program
// B) Pass the following as the parameter list to the method:
// 1) Integer - Position of the field in the Temp-Table
// 2) String - Name of the field in the Temp-Table
// 3) Integer - Number of extents (if field is an array field), zero if normal field
&nbs.p; // 4) Integer - Data type of the field (take from com.progress.open4gl.Parameter.PRO_* constant value list)
// 5) Integer - User based position of field (zero based, should use "first parameter minus one"
// 6) Integer - Unknown Parameter, pass a zero for now
myHelloTableSchema.setFieldMetaData(1, "Hello", 0, Parameter.PRO_CHARACTER, 0, 0);
myHelloTableSchema.setFieldMetaData(2, "There", 0, Parameter.PRO_CHARACTER, 1, 0);
myHelloTableSchema.setFieldMetaData(3, "YearsOld", 0, Parameter.PRO_INTEGER, 2, 0);
// STEP 4:
// A) Add meta schema for Temp-Table to the ProDataSet meta schema
myDataSetSchema.addTable(myHelloTableSchema);
// STEP 5:
// A) Repeat steps 2 through 5 for each ProDataSet Temp-Table defined in your 4GL program
// STEP 6:
// A) Instantiate a new ProDataSet object (ProDataGraph)
// B) Pass the ProDataSet schema object created in step 1 to the constructor.
ProDataGraph myDataSet = new ProDataGraph(myDataSetSchema);
// STEP 7:
// A) Call the createProDataObject method of your ProDataGraph object
// to create a new record
// B) Pass the following as the parameter list to the method:
// 1) String - Name of the Temp-Table that this record will be added to
ProDataObject myRecord = myDataSet.createProDataObject("ttHello");
// STEP 8:
// A) Call the set* methods of the ProDataObject to add the data to the
// newly created record. One call should be made for each field that
// you want to assign data to
myRecord.setString("Hello", "Hello People");
myRecord.setString("There", "You Have Quite A World");
myRecord.setInt("YearsOld", 375);
// STEP 9:
// A) Call the addProDataObject met.hod of your ProDataSet (ProDataGraph) object
// to add the record into the Temp-Table
// B) Pass the following as the parameter list to the method:
// 1) ProDataObject - The record object that you created in step 7
myDataSet.addProDataObject(myRecord);
// The building of the ProDataSet is now complete and data has been added
// to it so lets go ahead and pass the ProDataSet to the AppServer as an INPUT
// parameter
ProDataGraphHolder myDataSetHolder = new ProDataGraphHolder(myDataSet);
SomeProxy appServer = new SomeProxy("AppServer://localhost:5162/asbroker1", "", "", "");
appServer.someInputOutputDataSet(myDataSetHolder);
appServer._release();
}
}.