|
of_register
|
|
Full name
|
pfc_n_cst_tvsrv_levelsource.of_register
|
Access
|
public
|
Extend of
|
integer
|
Return value
|
integer
|
Prototype
|
public function integer of_register(integer,string,string,string,n_tr,string,string,string,powerobject[],datawindow,datastore,string)
|
Name
|
Datatype
|
lds_test
|
n_ds
|
li_Cnt
|
Integer
|
li_NumDS
|
Integer
|
li_rc
|
Integer
|
ls_columncount
|
String
|
ls_rc
|
String
|
ls_sqlerr
|
String
|
lw_parentwindow
|
window
|
public function integer of_register (integer ai_level, string as_labelcolumn, string as_retrieveargs, string as_dwobjectname, n_tr atr_obj, string as_filtercols, string as_method, string as_sql, powerobject apo_data[], datawindow adw_control, datastore ads_control, string as_importfile);//////////////////////////////////////////////////////////////////////////////
//
// Function: of_register
//
// Access: public
//
// Arguments:
// ai_Level The TreeView level to associate the data source with.
// as_LabelColumn The column in the DataWindow object to display.
// as_RetrieveArgs Retrieval/filter arguments for the level. These should
// be separated by commas in the format:
// :keyword.n.column
// where column is the name of a column in another level's
// data source. If keyword is 'level', n is an absolute level
// number. If keyword is 'parent', n is a number relative to
// the current level (i.e. :parent.2.c1 would be column c1 in
// the DataWindow for the level 2 levels above this one).
// as_DWobjectname The DataWindow object to be used for the data source.
// atr_obj The transaction object for this data source (can be
// different for each level).
// as_FilterCols Columns on the datastore object used for filtering the datastore.
// This type of datasource does a retrieve once and uses the
// retrieval arguments to to filter out those records which do not
// match. The column names should be separated by commas.
// ex: "colname.NA, Col2name.NO, col3name"
// means "Not (Colname=xxx) And Not (col2name=xxx) Or col3name=xxx"
// ex: "colname.A, Col2name"
// means "Colname=xxx And col2name=xxx"
// xxx is the values provided by the retrieval args
// The columns will be the left side of the filter statement and the
// retrieval arguments are the right side (i.e. filtercol='retrieval args')
// as_method The Method we will use to populate the data source
// as_sql The SQL Statement to be used for the data source (if specified).
// apo_data[] The data to be used for the data source (if specified).
// adw_control The datawindow control to be used for the data source (if specified).
// ads_control The datastore control to be used for the data source (if specified).
// as_importfile The import file from which to be used for the data source (if specified).
//
// Returns: integer
// 1 = the data source was added successfully
// -1 = argument validation error
// -3 = a previous level had already been marked as recursive (there can be no more)
// -4 = column label datatype was not in the data source
// -5 = SetTransObject failed for the data source
// -7 = Error from Cache Registration
//
// Description: Register a data source for a level of the TreeView. The data source is a
// DataWindow object that will be linked to the TreeView level and used
// to populate.
//
//////////////////////////////////////////////////////////////////////////////
//
// Revision History
//
// Version
// 6.0 Initial version
//
//////////////////////////////////////////////////////////////////////////////
//
// Copyright © 1996-1997 Sybase, Inc. and its subsidiaries. All rights reserved.
// Any distribution of the PowerBuilder Foundation Classes (PFC)
// source code by other than Sybase, Inc. and its subsidiaries is prohibited.
//
//////////////////////////////////////////////////////////////////////////////
Integer li_NumDS, li_Cnt, li_rc
String ls_rc, ls_columncount, ls_sqlerr
window lw_parentwindow
n_ds lds_test
// Check arguments
if IsNull (ai_level) or ai_level <= 0 or &
Len (as_labelcolumn) = 0 or IsNull (as_labelcolumn) or &
Len (as_DWobjectname) = 0 or IsNull (as_DWobjectname) or &
Len (as_method) = 0 or IsNull (as_method) then
return -1
end if
// Check if recurrsive is being used
li_NumDS = UpperBound(inv_attrib)
If li_NumDS > 0 Then
If inv_attrib[li_NumDS].ib_Recursive Then
// If the last one is recursive, there can be no more
Return -3
End if
End if
// create temporary datastore
lds_test = Create n_ds
If as_method = inv_cache.SQL then
lds_test.Create( as_DWobjectname, ls_sqlerr )
If Len(ls_sqlerr) > 0 Then
Destroy lds_test
Return -1
End If
Else
lds_test.DataObject = as_DWobjectname
End If
// label column must be in the datawindow
If lds_test.Describe(as_LabelColumn + ".Band") = "!" Then
Destroy lds_test
Return -4
End if
// don't need this anymore
Destroy lds_test
// Create a DataStore to use as the data source
// level does not exist and neither does datasource - so create it
If li_NumDS < ai_Level Then
inv_attrib[ai_Level].ids_obj = Create n_ds
If as_method = inv_cache.SQL Then
inv_attrib[ai_Level].ids_obj.Create( as_DWobjectname, ls_sqlerr )
Else
inv_attrib[ai_Level].ids_obj.DataObject = as_DWobjectname
End If
End If
If IsNull(inv_attrib[ai_Level].ids_obj) Or Not IsValid(inv_attrib[ai_Level].ids_obj) Then
// level exists, but no datastore defined for it
inv_attrib[ai_Level].ids_obj = Create n_ds
End if
// create a new dataobject for the level
If as_method = inv_cache.SQL Then
inv_attrib[ai_Level].ids_obj.Create( as_DWobjectname, ls_sqlerr )
Else
inv_attrib[ai_Level].ids_obj.DataObject = as_DWobjectname
End If
// Set values in the structure array
inv_attrib[ai_Level].is_Dataobject = as_DWobjectname
inv_attrib[ai_Level].is_LabelColumn = as_LabelColumn
inv_attrib[ai_Level].is_RetrieveArgs = as_RetrieveArgs
inv_attrib[ai_Level].is_FilterCols = as_filtercols
inv_attrib[ai_Level].itr_obj = atr_obj
inv_attrib[ai_Level].is_Method = as_Method
// Set parameters for the DataStore
inv_attrib[ai_Level].ids_obj.of_SetBase(true)
inv_attrib[ai_Level].ids_obj.of_SetAppend(true)
// datastore needs parent window reference to perform updates
itv_requestor.of_Getparentwindow(lw_parentwindow)
inv_attrib[ai_Level].ids_obj.of_SetParentWindow(lw_parentwindow)
// make sure transaction object is valid
If IsValid(atr_obj) Then
If inv_attrib[ai_Level].ids_obj.of_SetTransObject(atr_obj) <> 1 Then
inv_attrib[ai_Level].is_Dataobject = ""
Destroy inv_attrib[ai_Level].ids_obj
Return -5
End If
End If
// register with cache service
li_rc = of_registerdatasource(ai_level, as_method, as_DWobjectname, atr_obj, &
as_sql, apo_data, adw_control, ads_control, as_importfile)
If li_rc < 1 Then
inv_attrib[ai_Level].is_Dataobject = ""
Destroy inv_attrib[ai_Level].ids_obj
Return -7
End If
Return 1
end function