File: eaf_n_cst_businessservice.sru
Size: 6597
Date: Tue, 22 Jan 2008 23:40:34 +0100
global type eaf_n_cst_businessservice from n_cst_component
end type
end forward

global type eaf_n_cst_businessservice from n_cst_component
end type
global eaf_n_cst_businessservice eaf_n_cst_businessservice

type variables
n_cst_updatemanager           inv_updatemanager

//Argument Service
n_cst_argumentservice            inv_argument
end variables

forward prototypes
public function long process (ref s_mimerequest astr_mimerequest)
public function long setusername (string as_username)
public function long setlanguageid (long al_languageid)
public function long initializeupdatemanager ()
public function long processmain (long al_processmode)
public function long processprepare (long al_processmode)
public function long processstart (long al_processmode)
public function long processvalidate (long al_processmode)
public function long processend (long al_processmode)
protected function long buildmessagelist ()
end prototypes

public function long process (ref s_mimerequest astr_mimerequest);////////////////////////////////////////////////////////////////
// Description:
//    processing
//    Contains Start and End processing
// Returns: 
//     1 - Success
//     0 - Nothing to process
//    -1 - Failure

constant string METHOD_NAME = "process ( REF s_mimedataset )"

// Declare local variables 
long                             ll_rc
long                             ll_start_rc
long                             ll_end_rc
long                             ll_process_rc
Long                             ll_processmode
string                           ls_errors
string                           ls_str
string                           ls_runtimeerror

   //Initialize the ArgumentService with the XML Arguments
   if inv_argument.initialize( astr_mimerequest.messages ) = -1 then
      inv_log.addError( METHOD_NAME, "Error initializing argument service", inv_messaging )
      return -1
   end if

   //Get process mode argument
   inv_argument.getArgument( "ProcessMode", ls_str )
   if ls_str <> "" and IsNumber(ls_str) then
      ll_processmode = Long(ls_str)
      ll_processmode = 1
   end if
   // Invoke the Start processing method
   ll_start_rc = this.processStart(ll_processmode)
   If ll_start_rc <= 0 Then 
      AddError(METHOD_NAME, "process failed!  process was cancelled by processStart processing." )
      Return -1
   End if
   // Perform the actual process (skipped if ll_start_rc =2)
   If ll_start_rc = 1 Then
      // Invoke the processValidate processing method
      ll_rc = this.processValidate(ll_processmode)
      If ll_rc <= -1 Then 
         AddError(METHOD_NAME, "process Failed.  Failure in validation processing.")
         Return -1
      ElseIf ll_rc = 0 Then
         AddError(METHOD_NAME, "Validation criteria not met.")
         Return -1
      End if
      // Invoke the processPrepare processing method
      ll_rc = this.processPrepare(ll_processmode)
      If ll_rc <= -1 Then 
         AddError(METHOD_NAME, "Failure in process prepare processing.")
         Return -1
      ElseIf ll_rc = 0 Then
         Return -1   
      End if   
      // Invoke the processMain processing method
      ll_process_rc = this.processMain(ll_processmode)
      If isNull(ll_process_rc) Or ll_process_rc = -1 Then
//       AddError(METHOD_NAME, "Process failed in processMain() processing.")
         Return -1
      End If   
   End If   
   // Invoke the End processing method
   ll_end_rc = processEnd(ll_processmode)
   If ll_end_rc < 0 Then
      AddError(METHOD_NAME, "Process was prevented by processEnd processing.")
      Return -1   
   End If
catch ( RuntimeError re )
   ls_runtimeerror = "Runtime Error:" + inv_constants.CRLF + inv_constants.CRLF
   ls_runtimeerror += "Error Code: " + string(re.number) + inv_constants.CRLF
   ls_runtimeerror += "Object: " + re.objectName + inv_constants.CRLF
   ls_runtimeerror += "Class: " + re.class + inv_constants.CRLF
   ls_runtimeerror += "Function/Event: " + re.routineName + inv_constants.CRLF
   ls_runtimeerror += "Line: " + string(re.line) + inv_constants.CRLF
   ls_runtimeerror += "Message: " + re.getMessage() + inv_constants.CRLF
   AddError(METHOD_NAME, "Runtime Error: " + ls_runtimeerror)

   return -1
end try

Return ll_process_rc
end function

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

if IsValid(inv_log) then
end if

return 1
end function

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

if IsValid(inv_objecthelper) then
end if

return 1
end function

public function long initializeupdatemanager ();if not IsValid(inv_updatemanager) then
   inv_updatemanager = create n_cst_updatemanager
   inv_updatemanager.inv_argument.addArgument( inv_constants.EAF_CHARACTER_SET_ARGUMENT_NAME, "ISO-8859-1" )
   inv_updatemanager.inv_argument.addArgument( inv_constants.EAF_INTERFACEMANAGER_COMPONENT_ARGUMENT_NAME, GetComponentName() )
   inv_updatemanager.inv_argument.addArgument( inv_constants.EAF_LANGUAGEID_ARGUMENT_NAME, String(GetLanguageID()) )
   inv_updatemanager.inv_argument.addArgument( inv_constants.EAF_USERID_ARGUMENT_NAME, GetUserName() )
end if

return 1
end function

public function long processmain (long al_processmode);Return 1

end function

public function long processprepare (long al_processmode);return 1
end function

public function long processstart (long al_processmode);return 1
end function

public function long processvalidate (long al_processmode);return 1
end function

public function long processend (long al_processmode);return 1
end function

protected function long buildmessagelist ();if super::buildmessagelist() = -1 then return -1

inv_objecthelper.addMessage("paf_failsvalidation", 1, "Failed validation.  Column  %s  on row  %s.")
inv_objecthelper.addMessage("paf_failsvalidation", 3, "$$HEX5$$938f655184760f684d4f$$ENDHEX$$: %s $$HEX2$$28572c7b$$ENDHEX$$ %s $$HEX9$$4c882a671a90c78f096748652760c0684b6d$$ENDHEX$$.")
inv_objecthelper.addMessage("paf_failsvalidation", 4, "$$HEX5$$388f65518476046b4d4f$$ENDHEX$$: %s $$HEX2$$28572c7b$$ENDHEX$$ %s $$HEX9$$4c882a671a904e90096748652760a26a2c6e$$ENDHEX$$.")

return 1
end function

on eaf_n_cst_businessservice.create
call super::create
end on

on eaf_n_cst_businessservice.destroy
call super::destroy
end on

event constructor;call super::constructor;inv_argument = create n_cst_argumentservice

end event

event destructor;call super::destructor;if IsValid(inv_argument) then
   destroy inv_argument
end if

if IsValid(inv_updatemanager) then
   destroy inv_updatemanager
end if
end event