File: eaf_n_cst_retrieveobject.sru
Size: 9689
Date: Tue, 22 Jan 2008 23:40:36 +0100
$PBExportHeader$eaf_n_cst_retrieveobject.sru
forward
global type eaf_n_cst_retrieveobject from n_cst_component
end type
end forward

global type eaf_n_cst_retrieveobject from n_cst_component
end type
global eaf_n_cst_retrieveobject eaf_n_cst_retrieveobject

type variables
n_datastore                   ids_working
n_cst_dataobjectrulesservice  inv_dataobjectrules
string                        is_returnsyntax
end variables

forward prototypes
public function long setusername (string as_username)
public function long setlanguageid (long al_languageid)
public function long applydataobjectrules (string as_datasetid, string as_dataobject, string as_syntaxin, ref string as_syntaxout)
public function long applydataobjectrulesmain ()
public function long applydataobjectrulesafterretrievemain ()
public function long applydataobjectrulesafterretrieve (string as_datasetid, string as_dataobject, string as_syntaxin, string as_datain, boolean ab_retrevedataonly, ref string as_syntaxout, ref string as_dataout, ref string as_returnsyntax)
public subroutine setreturnsyntax (string as_syntax)
end prototypes

public function long setusername (string as_username);super::setusername(as_username)

if IsValid(inv_log) then
   inv_log.SetUserName(as_username)
end if

return 1
end function

public function long setlanguageid (long al_languageid);Super::SetLanguageid(al_languageid)

if IsValid(inv_objecthelper) then
   inv_objecthelper.SetLanguageid(al_languageid)
end if

return 1
end function

public function long applydataobjectrules (string as_datasetid, string as_dataobject, string as_syntaxin, ref string as_syntaxout);////////////////////////////////////////////////////////////////
// Description:
//    Apply DataObject Rules to the passed in Syntax.  
//
//    One can use the n_cst_dataobjectrulesservice to make 
//    the modifications
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_datasetid - DataSet to be worked on
//    as_dataobject - DataWindow DataObject to be used
//    as_syntaxin - Syntax used to create the datawindow (if you don't want to use the supplied datawindow object)
//    as_syntaxout - The output
// Returns: 
//     1 - Success changes were performed to the Syntax
//     0 - No changes were performed to the Syntax
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "applyDataobjectRules "
String ls_error

inv_log.traceLog (METHOD_NAME,  "(as_datasetid, as_dataobject, " + &
      "as_syntaxin, ref as_syntaxout)~r~n"+ &
      "   as_datasetid="+as_datasetid+"~r~n" + &
      "   as_dataobject="+as_dataobject+"~r~n" + &
      "   as_syntaxin="+as_syntaxin+"~r~n" + &
      "   as_syntaxout="+as_syntaxout)

If ids_working.create(as_syntaxin, ls_error) <= 0 Then
   addError (METHOD_NAME,  "Create operation failed, error message: " + ls_error)
   Return -1
End If

if applydataobjectrulesmain() = 0 then
   return 0
else
   as_syntaxout = ids_working.object.datawindow.syntax
   Return 1
end if

end function

public function long applydataobjectrulesmain ();////////////////////////////////////////////////////////////////
// Description:
//    Apply DataObject Rules to the passed in Syntax.  
//
//    One can use the n_cst_dataobjectrulesservice to make 
//    the modifications
// Revisions
//    1.0   - Initial version
// Arguments:  
// Returns: 
//     1 - Success changes were performed to the Syntax
//     0 - No changes were performed to the Syntax
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

//    Example code:

//       inv_dataobjectrules.requestRequiredEmptyIsNull(&
//          {"fname","lname","city","state"})
//       inv_dataobjectrules.requestTextColor("fname", 255)
//       inv_dataobjectrules.requestTextColor("lname", 255)
//       inv_dataobjectrules.requestBackGroundColor("lname", 16776960)
//       inv_dataobjectrules.requestValidation( &
//          "city", "len( gettext()) > 2 ", &
//          "City must be greater than 2 characters")

//       Return 1

constant string METHOD_NAME = "applyDataobjectRulesMain "

inv_log.traceLog (METHOD_NAME,  "")

return 0
end function

public function long applydataobjectrulesafterretrievemain ();////////////////////////////////////////////////////////////////
// Description:
//    Apply DataObject Rules to the passed in Syntax.  
//
//    One can use the n_cst_dataobjectrulesservice to make 
//    the modifications
// Revisions
//    1.0   - Initial version
// Arguments:  
// Returns: 
//     1 - Success changes were performed to the Syntax
//     0 - No changes were performed to the Syntax
//    -1 - Failure
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

//    Example code:
//       inv_dataobjectrules.requestRequiredEmptyIsNull(&
//          {"fname","lname","city","state"})
//       inv_dataobjectrules.requestTextColor("fname", 255)
//       inv_dataobjectrules.requestTextColor("lname", 255)
//       inv_dataobjectrules.requestBackGroundColor("lname", 16776960)
//       inv_dataobjectrules.requestValidation( &
//          "city", "len( gettext()) > 2 ", &
//          "City must be greater than 2 characters")

//       Return 1

constant string METHOD_NAME = "applyDataobjectRulesAfterRetrieveMain "

inv_log.traceLog (METHOD_NAME,  "")

return 0
end function

public function long applydataobjectrulesafterretrieve (string as_datasetid, string as_dataobject, string as_syntaxin, string as_datain, boolean ab_retrevedataonly, ref string as_syntaxout, ref string as_dataout, ref string as_returnsyntax);////////////////////////////////////////////////////////////////
// Description:
//    Apply DataObject Rules to the passed in Syntax after retrieve.  
//
//    One can use the n_cst_dataobjectrulesservice to make 
//    the modifications
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_datasetid - DataSet to be worked on
//    as_dataobject - DataWindow DataObject to be used
//    as_syntaxin - Syntax used to create the datawindow (if you don't want to use the supplied datawindow object)
//    as_datain   - Data used to import into datawindow
//    as_syntaxout - The output
// R  as_dataout  - The output data
// eturns:  
//     1 - Success changes were performed to the Syntax
//     0 - No changes were performed to the Syntax
//    -1 - Failure
//
////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
//////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "applyDataobjectRules "
String   ls_error
Long     ll_rc, ll_row
string   ls_cname

inv_log.traceLog (METHOD_NAME,  "(as_datasetid, as_dataobject, " + &
      "as_syntaxin, ref as_syntaxout)~r~n"+ &
      "   as_datasetid="+as_datasetid+"~r~n" + &
      "   as_dataobject="+as_dataobject+"~r~n" + &
      "   as_syntaxin="+as_syntaxin+"~r~n" + &
      "   as_syntaxout="+as_syntaxout)
      
If ids_working.create(as_syntaxin, ls_error) <= 0 Then
   addError (METHOD_NAME,  "Create operation failed, error message: " + ls_error)
   Return -1
End If

if IsNull(as_datain) or Trim(as_datain) = "" then
   ids_working.Reset()
else
   if ab_retrevedataonly then
      for ll_row = 1 to Integer(ids_working.Describe("DataWindow.Column.Count"))
          ls_cname = ids_working.Describe("#" + String(ll_row) + ".Name")
          ids_working.SetValidate(ls_cname, "")
      next
   end if
   ll_rc = ids_working.ImportString(as_datain)
   if ll_rc < 0 then
      addError (METHOD_NAME,  "ImportString operation failed, returned rc=" + String(ll_rc))
      Return -1
   end if
   ids_working.ResetUpdate()
end if

if applydataobjectrulesafterretrievemain() = 0 then
   return 0
else
   if not ab_retrevedataonly then
      as_syntaxout = ids_working.object.datawindow.syntax
   end if
   as_dataout      = ids_working.object.datawindow.Data
   as_returnsyntax = is_returnsyntax
   return 1
end if

end function

public subroutine setreturnsyntax (string as_syntax);if is_returnsyntax <> "" then
   is_returnsyntax += "|"
end if

is_returnsyntax += as_syntax

return
end subroutine

on eaf_n_cst_retrieveobject.create
call super::create
end on

on eaf_n_cst_retrieveobject.destroy
call super::destroy
end on

event constructor;call super::constructor;ids_working = create n_datastore
inv_log.propagateSettings( ids_working )

inv_dataobjectrules = create n_cst_dataobjectrulesservice
inv_log.propagateSettings( inv_dataobjectrules )

inv_dataobjectrules.setRequestor(ids_working)

end event

event destructor;call super::destructor;If isValid(ids_working) Then destroy ids_working
If isValid(inv_dataobjectrules) Then destroy inv_dataobjectrules

end event