$PBExportHeader$eaf_n_cst_businessobject.sru forward global type eaf_n_cst_businessobject from n_cst_component end type end forward global type eaf_n_cst_businessobject from n_cst_component end type global eaf_n_cst_businessobject eaf_n_cst_businessobject type variables Protected: constant string DATAACCESS_BASE = "n_cst_dataaccessservice" constant string DATASTORE_BASE = "n_datastore" string is_dataobject= "" string is_dataobjectrequiredfields[] string is_dataaccessservice = "n_cst_dataaccessservice" string is_datastore = "n_datastore" string is_dataset boolean ib_checkrequiredupdateonly = true n_cst_dataaccessservice inv_dataaccess string is_sessionid end variables forward prototypes protected function long setdataobjectrequiredfields (string as_requiredfields[]) protected function long setdataobject (string as_dataobject) protected function long checkrequiredfields (ref n_datastore ads_working, ref string as_missingentrymessage) protected function long setdataaccess (string as_dataaccess) protected function long setdatastore (string as_datastore) protected function long setdataaccess (ref n_cst_dataaccessservice anv_dataaccess) protected function string getdataset () public function long update (ref s_mimedataset astr_mimedataset) protected function long updateend (ref n_cst_businessobjectattrib anv_boattrib) protected function long updatestart (ref n_cst_businessobjectattrib anv_boattrib) protected function long updateprepare (ref n_cst_businessobjectattrib anv_boattrib) protected function long updatemain (ref n_cst_businessobjectattrib anv_boattrib) protected function long updatevalidate (ref n_cst_businessobjectattrib anv_boattrib) public function long setusername (string as_username) public function long setlanguageid (long al_languageid) protected function long assignrequiredfields (ref n_datastore ads_working) end prototypes protected function long setdataobjectrequiredfields (string as_requiredfields[]);//////////////////////////////////////////////////////////////// // Description: // Sets the DataWindow Dataobject Required Fields. // // Call can only be made after a dataobject has been assigned // Revisions // 1.0 - Initial version // Arguments: // as_requiredfields[] - The name the required fields // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "setDataobjectRequiredFields " inv_log.traceLog (METHOD_NAME, "(as_requiredfieds[]) ") // Declare local variables string ls_column string ls_type n_datastore lds_working long ll_upper long ll_idx // Validate arguments If isNull(as_requiredfields) Then addError(METHOD_NAME, "Invalid as_requiredfields argument.") Return -1 End If // Enforce that value can only after the dataobject has been assigned If isNull(is_dataobject) Or Len(is_dataobject) = 0 Then addError(METHOD_NAME, "Value can only be set after a dataobject assignment. ") Return -1 End If // Create the working datastore If isNull(is_datastore) Or len(trim(is_datastore)) = 0 Then addError(METHOD_NAME, "Error on is_datastore value") Return -1 End If lds_working = create using is_datastore inv_log.propagateSettings( lds_working ) // Assign the dataobject If lds_working.setDataobject(is_dataobject) <= 0 Then addError(METHOD_NAME, "Failed setDataobject(" + is_dataobject + ") operation") destroy lds_working Return -1 End If // Validate all passed in columns ll_upper = upperBound(as_requiredfields) For ll_idx = 1 to ll_upper ls_column = as_requiredfields[ll_idx] ls_type = lower(lds_working.Describe (ls_column+'.Type')) If ls_type <> 'column' Then If isNull(ls_column) Then ls_column = "null" addError(METHOD_NAME, "Passed in RequiredField is not a column " + & "(" + ls_column + ") index ="+string(ll_idx) + " " + & "dataobject = " +is_dataobject) destroy lds_working Return -1 End If Next // Store the required fields is_dataobjectrequiredfields = as_requiredfields // Perform cleanup destroy lds_working Return 1 end function protected function long setdataobject (string as_dataobject);//////////////////////////////////////////////////////////////// // Description: // Sets the DataWindow Dataobject to be used by this object. // The dataobject should contain no GUI/DropDowns/Masking/etc info. // // Call to set value can only be made once. // Revisions // 1.0 - Initial version // Arguments: // as_dataobject - The name of the dataobject to be assigned // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "setDataobject " inv_log.traceLog (METHOD_NAME, "(as_dataobject) as_dataobject='"+as_dataobject+"'") // Declare local variables long ll_upper long ll_idx long ll_rc long ll_method_rc = 1 string ls_columns[] n_datastore lds_working // Perform cleanup as_dataobject = Trim(as_dataobject) // Validate arguments If isNull(as_dataobject) Or len(as_dataobject) = 0 Then addError(METHOD_NAME, "Invalid as_dataobject argument") Return -1 End If // Enforce that value can only set once If Len(is_dataobject) > 0 Then addError(METHOD_NAME, "Value can only be set once. " + & "Current value ("+is_dataobject+")") Return -1 End If // Create the working datastore If isNull(is_datastore) Or len(trim(is_datastore)) = 0 Then addError(METHOD_NAME, "Error on is_datastore value") Return -1 End If lds_working = create using is_datastore inv_log.propagateSettings( lds_working ) // Assign the dataobject If lds_working.setDataobject(as_dataobject) <= 0 Then addError(METHOD_NAME, "Failed setDataobject(" + as_dataobject + ") operation") destroy lds_working Return -1 End If // Set the attribute is_dataobject = as_dataobject destroy lds_working Return ll_method_rc end function protected function long checkrequiredfields (ref n_datastore ads_working, ref string as_missingentrymessage);//////////////////////////////////////////////////////////////// // Description: // Determines if any required column contains a NULL value. // Invoked by the Framework from the update(). // Revisions // 1.0 - Initial version // Arguments: // ads_working - The information to update // as_missingentrymessage - A place holder for a Missing Value Message // Returns: // 1 - Success - No required columns were found to have a NULL value // 0 - Success - Yes a required column was found to have a NULL value // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "checkRequiredFields " inv_log.traceLog (METHOD_NAME, "(ref ads_working, ref as_missingentrymessage)") // Declare local variables long ll_rc long ll_method_rc = 1 long ll_row integer li_column string ls_column string ls_parms[] n_cst_datastoreservice lnv_dssrv // Perform cleanup as_missingentrymessage = "" // Validate arguments If isNull(ads_working) Or Not isValid(ads_working) Then addError (METHOD_NAME, "Invalid ads_working argument") Return -1 End If // First deal with the Primary Buffer ll_row = 1 li_column = 1 ls_column = "" ll_rc = ads_working.findRequired (Primary!, ll_row, li_column, ls_column, ib_checkrequiredupdateonly) if isNull(ll_rc) or ll_rc <= 0 Then addError (METHOD_NAME, "Failed findRequired on Primary buffer operation") Return -1 end If try lnv_dssrv = create n_cst_datastoreservice inv_log.propagateSettings( lnv_dssrv ) If ll_row > 0 Then // A required field that has not been entered has been encountered lnv_dssrv.setRequestor(ads_working) ls_parms[1] = lnv_dssrv.getColumnHeaderName(ls_column, "") inv_objecthelper.messagePrepare("eaf_primary_missing_value", as_missingentrymessage, ls_parms) // Return Success - Yes a required column was found to have a NULL value ll_method_rc = 0 else // Next deal with a possible Filter Buffer If ads_working.filteredCount() > 0 Then ll_row = 1 li_column = 1 ls_column = "" ll_rc = ads_working.findRequired (Filter!, ll_row, li_column, ls_column, ib_checkrequiredupdateonly) If isNull(ll_rc) or ll_rc <= 0 Then addError (METHOD_NAME, "Failed findRequired on Filter buffer operation") ll_method_rc = -1 else If ll_row > 0 Then lnv_dssrv.setRequestor(ads_working) ls_parms[1] = lnv_dssrv.getColumnHeaderName(ls_column, "") inv_objecthelper.messagePrepare("eaf_filter_missing_value", as_missingentrymessage, ls_parms) // Return Success - Yes a required column was found to have a NULL value ll_method_rc = 0 end If end if end If end if finally if isValid( lnv_dssrv ) then destroy lnv_dssrv end if end try // Return even better Success - No required columns were found to have a NULL value Return ll_method_rc end function protected function long setdataaccess (string as_dataaccess);//////////////////////////////////////////////////////////////// // Description: // Set a DataAccess service for the object to use // // Can only be set once // Revisions // 1.0 - Initial version // Arguments: // as_dataaccess - The dataaccess object to be created // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "setDataAccess " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_dataaccess) as_dataaccess="+as_dataaccess) End If // Declare local variables long ll_method_rc = 1 n_cst_dataaccessservice lnv_dataaccess n_cst_classdefinitionservice lnv_classdefinition // Perform clenaup as_dataaccess = trim(lower(as_dataaccess)) // Validate arguments If IsNull(as_dataaccess) Or len(as_dataaccess) = 0 Then addError(METHOD_NAME, "Invalid as_dataaccess argument") Return -1 End If try //create class definition service lnv_classdefinition = create n_cst_classdefinitionservice inv_log.propagateSettings( lnv_classdefinition ) // If not the base dataaccess object, confirm the object is class is // valid prior to creating it If as_dataaccess <> DATAACCESS_BASE Then // Confirm the object is a descendant of the DataAccess Service If Not lnv_classdefinition.isDescendant & (as_dataaccess, DATAACCESS_BASE) Then addError(METHOD_NAME, "DataAccess object " + & "("+as_dataaccess+") is Not a descendant of " + DATAACCESS_BASE) ll_method_rc = -1 End If End If if ( ll_method_rc = 1 ) then // Create the service lnv_dataaccess = Create Using as_dataaccess inv_log.propagateSettings( lnv_dataaccess ) // Assign the service object ll_method_rc = setDataaccess (lnv_dataaccess) If ll_method_rc <= 0 Then If isValid(lnv_dataaccess) Then destroy lnv_dataaccess end if End If end if finally destroy lnv_classdefinition end try Return ll_method_rc end function protected function long setdatastore (string as_datastore);//////////////////////////////////////////////////////////////// // Description: // Set a Datastore object for the object to use // Revisions // 1.0 - Initial version // Arguments: // as_datastore - The datastore to be used // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "setDatastore " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(as_datastore) as_datastore="+as_datastore) End If // Declare local variables n_cst_classdefinitionservice lnv_classdefinition // Perform clenaup as_datastore = trim(lower(as_datastore)) // Validate arguments If IsNull(as_datastore) Or len(as_datastore) = 0 Then addError(METHOD_NAME, "Invalid as_datastore argument") Return -1 End If try lnv_classdefinition = create n_cst_classdefinitionservice inv_log.propagateSettings( lnv_classdefinition ) // If not the base datastore object, confirm the object class is // valid prior to creating it If as_datastore <> DATASTORE_BASE Then // Confirm the object is a descendant of the base datastore If Not lnv_classdefinition.isDescendant (as_datastore, DATASTORE_BASE) Then addError(METHOD_NAME, "Datastore object " + & "("+as_datastore+") is Not a descendant of " + DATASTORE_BASE) Return -1 End If End If finally destroy lnv_classdefinition end try // Store the new Datastore object is_datastore = as_datastore Return 1 end function protected function long setdataaccess (ref n_cst_dataaccessservice anv_dataaccess);//////////////////////////////////////////////////////////////// // Description: // Set a DataAccess service for the object to use // // Can only be set once // Revisions // 1.0 - Initial version // Arguments: // anv_dataaccess - The created dataaccess object // Returns: // 1 - Success // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "setDataAccess " If ib_trace Then inv_log.traceLog (METHOD_NAME, "(anv_dataaccess) anv_dataaccess="+anv_dataaccess.className()) End If // Validate arguments If IsNull(anv_dataaccess) Or Not isValid(anv_dataaccess) Then addError(METHOD_NAME, "Invalid anv_dataaccess argument") Return -1 End If // Value can only be set once If IsValid(inv_dataaccess) Then addError(METHOD_NAME, "DataAccess can only be set once") Return -1 End If // Assign the object to the instance variable inv_dataaccess = anv_dataaccess is_dataaccessservice = anv_dataaccess.className() inv_log.propagateSettings(inv_dataaccess) Return 1 end function protected function string getdataset ();//////////////////////////////////////////////////////////////// // Description: // Get the name of the dataset being updated // Revisions // 2.0 - Initial version // Arguments: // None // Returns: // String : name of the dataset being updated //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "getDataSet " If ib_trace Then inv_log.traceLog (METHOD_NAME, "() = "+is_dataset) End If return is_dataset end function public function long update (ref s_mimedataset astr_mimedataset);//////////////////////////////////////////////////////////////// // Description: // Update processing // // Contains Start and End processing // Revisions // 3.0 - Initial version // Arguments: // astr_mimedataset : holds the information that is to be updated // Returns: // 1 - Success // 0 - Nothing to update // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "update ( REF s_mimedataset )" inv_log.traceLog (METHOD_NAME, "") // Declare local variables long ll_rc long ll_start_rc long ll_end_rc long ll_update_rc string ls_updateinformation string ls_describeresult string ls_updateaction string ls_characterset string ls_runtimeerror string ls_action n_cst_businessobjectattrib lnv_boattrib try //Add messages to the instance message service inv_messaging.parse( astr_mimedataset.messages ) // Validate arguments If isNull(astr_mimedataset) Or Not isValid(astr_mimedataset) Then addError(METHOD_NAME, "Invalid astr_mimedataset argument") Return -1 End If // Validate required values // If isNull(is_dataobject) Or Len(Trim(is_dataobject)) = 0 Then // addError(METHOD_NAME, "Object is lacking a dataobject") // Return -1 // End If //create the attribute object lnv_boattrib = create n_cst_businessobjectattrib //Create the ArgumentService lnv_boattrib.inv_argumentservice = create n_cst_argumentservice inv_log.propagateSettings( lnv_boattrib.inv_argumentservice ) //Parse arguments if lnv_boattrib.inv_argumentservice.initialize( astr_mimedataset.arguments ) = -1 then inv_messaging.append( lnv_boattrib.inv_argumentservice.inv_messaging ) return -1 end if //Get the Character Set lnv_boattrib.inv_argumentservice.getArgument( inv_constants.EAF_CHARACTER_SET_ARGUMENT_NAME, ls_characterset ) //See if session id exists lnv_boattrib.inv_argumentservice.getArgument( inv_constants.EAF_SESSION_ID_ARGUMENT_NAME, is_sessionid ) //Assign dataset name lnv_boattrib.is_name = astr_mimedataset.name //Assign update action type lnv_boattrib.inv_argumentservice.getArgument( inv_constants.EAF_UPDATE_ACTION_TYPE_ARGUMENT_NAME, ls_action ) lnv_boattrib.is_action = ls_action // Create the working datastore If isNull(is_datastore) Or len(trim(is_datastore)) = 0 Then addError(METHOD_NAME, "Error on is_datastore value") Return -1 End If lnv_boattrib.ids_working = create using is_datastore inv_log.propagateSettings( lnv_boattrib.ids_working ) // Assign the dataobject if is_dataobject <> "" then If lnv_boattrib.ids_working.setDataobject(is_dataobject) <= 0 Then inv_messaging.append( lnv_boattrib.ids_working.inv_messaging ) addError(METHOD_NAME, "Failed setDataobject(" + is_dataobject + ") operation") Return -1 End If end if is_dataset = astr_mimedataset.name inv_log.traceLog (METHOD_NAME, "(astr_mimedataset.name = "+astr_mimedataset.name+")") // Apply the passed in changes to the working datastore If lnv_boattrib.ids_working.SetFullState (astr_mimedataset.data.state) < 0 Then addError(METHOD_NAME, "Invalid setfullstate operation") Return -1 End If // Apply the transaction to the working datastore If lnv_boattrib.ids_working.setTransObject(SQLCA) <= 0 Then inv_messaging.append( lnv_boattrib.ids_working.inv_messaging ) addError(METHOD_NAME, "Invalid setTransObject operation") Return -1 End If // Confirm that there are updates pending on the datastore If lnv_boattrib.ids_working.modifiedCount() <= 0 And lnv_boattrib.ids_working.deletedCount() <= 0 Then // Nothing was passed in to update inv_log.warningLog(METHOD_NAME, "Nothing to update after performing setChanges") Return 0 End If // If appropriate create the DataAccess object If isNull(inv_dataaccess) Or Not isValid(inv_dataaccess) Then // An specific DataAccess object was not requested If setDataAccess(is_dataaccessservice) <= 0 Then addError(METHOD_NAME, "Unexpected failure of setDataAccess() operation") Return -1 End If End If // Invoke the Start processing method ll_start_rc = this.updateStart(lnv_boattrib) If ll_start_rc <= 0 Then addError( METHOD_NAME, "Update failed! Update was cancelled by updateStart processing. returned rc=" + String(ll_start_rc) ) Return -1 End if // Perform the actual update (skipped if ll_start_rc =2) If ll_start_rc = 1 Then // Invoke the updateValidate processing method ll_rc = this.updateValidate(lnv_boattrib) If ll_rc <= -1 Then addError(METHOD_NAME, "Update Failed. Failure in validation processing.") this.setAbort() Return -1 ElseIf ll_rc = 0 Then addError(METHOD_NAME, "Update Failed. Validation criteria not met.") this.setAbort() Return -1 End if // Invoke the updatePrepare processing method ll_rc = this.updatePrepare(lnv_boattrib) If ll_rc = -1 Then addError(METHOD_NAME, "Update failed. Failure in update prepare processing.") this.setAbort() Return -1 End if // Report about the update about to take place inv_log.debuglog(METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, "About to request update:~r~n"+& " lnv_boattrib.ids_working.rowCount() = "+string(lnv_boattrib.ids_working.rowCount())+ "~r~n" +& " lnv_boattrib.ids_working.modifiedCount() = "+string(lnv_boattrib.ids_working.modifiedCount())+ "~r~n" +& " lnv_boattrib.ids_working.deletedCount() = "+string(lnv_boattrib.ids_working.deletedCount())+ "~r~n" +& " lnv_boattrib.ids_working.filteredCount() = "+string(lnv_boattrib.ids_working.filteredCount())) // Invoke the updateMain processing method ll_update_rc = this.updateMain(lnv_boattrib) If isNull(ll_update_rc) Or ll_update_rc <= 0 Then addError (METHOD_NAME, "Update failed. Update failed in updateMain() processing.") this.setAbort() Return -1 End If End If inv_log.debugLog(METHOD_NAME, inv_constants.MESSAGE_TYPE_EAF_DEBUG, "Executed inv_dataaccess.update() with rc="+String(ll_update_rc)) // Invoke the End processing method ll_end_rc = updateEnd(lnv_boattrib) If ll_end_rc < 0 Then addError(METHOD_NAME, "Update failed! Update was prevented by updateEnd processing.") this.setAbort() Return -1 End If // We need to send the updates back to the client so get the contents of lnv_boattrib.ids_working and put them back into the update buffers ll_rc = lnv_boattrib.ids_working.getfullstate(astr_mimedataset.data.state ) 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 inv_log.addError( METHOD_NAME, "Runtime Error: " + ls_runtimeerror, inv_messaging ) this.setAbort() return -1 finally //Place all messages onto the reference structure inv_messaging.toXML( ls_characterset, astr_mimedataset.messages ) if isValid( inv_dataaccess ) then inv_dataaccess.inv_messaging.reset() end if //Perform cleanup if isValid(lnv_boattrib) Then destroy lnv_boattrib end if end try Return ll_update_rc end function protected function long updateend (ref n_cst_businessobjectattrib anv_boattrib);//////////////////////////////////////////////////////////////// // Description: // Invoked by the Framework from the update(). // Occurs when the Update is complete. // Revisions // 3.0 - Initial version // Arguments: // anv_boattrib - attribute object containing all objects // Returns: // 1 - Success // -1 - Failure - Fail the update process //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "updateEnd ( REF n_cst_boattrib )" inv_log.traceLog (METHOD_NAME, "") Return 1 end function protected function long updatestart (ref n_cst_businessobjectattrib anv_boattrib);//////////////////////////////////////////////////////////////// // Description: // Invoked by the Framework from the update(). // Occurs when the Update is beginning. // Revisions // 3.0 - Initial version // Arguments: // anv_boattrib - attribute object containing all objects // Returns: // 2 - Success - Update has been performed (skip update process) // 1 - Success - Continue Action // 0 - Do not perform the update // -1 - Failure - Do not perform the update //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "updateStart ( REF n_cst_boattrib )" inv_log.traceLog (METHOD_NAME, "") Return 1 end function protected function long updateprepare (ref n_cst_businessobjectattrib anv_boattrib);//////////////////////////////////////////////////////////////// // Description: // Invoked by the Framework from the update(). // Occurs before the update is performed. // Revisions // 3.0 - Initial version // Arguments: // anv_boattrib - attribute object containing all objects // Returns: // 1 - Success - Preparation was met - continue update // 0 - Success - Preparation was NOT met - Prevent update operation // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "updatePrepare ( REF n_cst_boattrib )" inv_log.traceLog (METHOD_NAME, "") Return 1 end function protected function long updatemain (ref n_cst_businessobjectattrib anv_boattrib);//////////////////////////////////////////////////////////////// // Description: // Invoked by the Framework from the update(). // Occurs when the Update is complete. // Revisions // 3.0 - Initial version // Arguments: // anv_boattrib - attribute object containing all objects // Returns: // 1 - Success // -1 - Failure - Fail the update process //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "updateMain ( REF n_cst_boattrib )" inv_log.traceLog (METHOD_NAME, "(ads_working, astr_columninfo[], astr_extradata, ref as_result)") // Declare local variables long ll_rc long ll_sqldbcode n_cst_dataaccessattrib lnv_dataaccessattrib try lnv_dataaccessattrib = create n_cst_dataaccessattrib // Populate the DataAccess Attribute object lnv_dataaccessattrib.is_identifier = this.className() lnv_dataaccessattrib.ids_data = anv_boattrib.ids_working // Execute by calling on the dataaccess object ll_rc = inv_dataaccess.update(lnv_dataaccessattrib) If isNull(ll_rc) Or ll_rc <= 0 Then inv_messaging.append( inv_dataaccess.inv_messaging ) addError(METHOD_NAME, "Update failed" ) Return -1 End If finally destroy lnv_dataaccessattrib end try Return 1 end function protected function long updatevalidate (ref n_cst_businessobjectattrib anv_boattrib);//////////////////////////////////////////////////////////////// // Description: // Invoked by the Framework from the update(). // Validation logic belongs here. // Revisions // 3.0 - Initial version // Arguments: // anv_boattrib - attribute object containing all objects // Returns: // 1 - Success - Validation was met - continue update // 0 - Success - Validation was NOT met - Prevent update operation // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "updateValidate ( REF n_cst_boattrib )" string ls_errormessage inv_log.traceLog (METHOD_NAME, "") // Declare local variables long ll_rc // If apporpriate check for required fields If upperBound(is_dataobjectrequiredfields) > 0 Then // Invoke the assigment of the required fields If this.assignRequiredFields(anv_boattrib.ids_working) <= 0 Then addError(METHOD_NAME, "Operation assignRequiredFields() failed") Return -1 End if // Check for required fields missing ll_rc = checkRequiredFields(anv_boattrib.ids_working, ls_errormessage) If ll_rc <= -1 Then addError (METHOD_NAME, ls_errormessage) return -1 End If If ll_rc = 0 Then // Missing required field was encountered // 0 - Success - Validation was NOT met - Prevent update operation addError (METHOD_NAME, ls_errormessage) Return 0 End If End If Return 1 end function 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 protected function long assignrequiredfields (ref n_datastore ads_working);//////////////////////////////////////////////////////////////// // Description: // Sets any required fields // Invoked by the Framework from the update(). // Revisions // 1.0 - Initial version // Arguments: // ads_working - The information to update // Returns: // 1 - Success - Columns werre marked as required // -1 - Failure //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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 = "assignRequiredFields " inv_log.traceLog (METHOD_NAME, "(ref ads_working, astr_columninfo[])") // Declare local variables long ll_rc long ll_idx long ll_idx_inner string ls_editstyle string ls_column string ls_databasecolumn string ls_modifyexpression string ls_modifyresult // Validate arguments If isNull(ads_working) Or Not isValid(ads_working) Then addError (METHOD_NAME, "Invalid ads_working argument") Return -1 End If // Loop around making the appropriate fields required For ll_idx = 1 to Upperbound(is_dataobjectrequiredfields) // Get the dataobject column name ls_column = lower(trim(is_dataobjectrequiredfields[ll_idx])) ls_editstyle = Lower(ads_working.Describe(ls_column+".Edit.Style")) If isNull(ls_editstyle) Or ls_editstyle = '' Or ls_editstyle='!' Or ls_editstyle='?' Then addError(METHOD_NAME, "Invalid editstyle for column = "+ls_column) Return -1 End If // Build the appropriate modify expression Choose Case ls_editstyle Case 'dddw' ls_modifyexpression = ls_column + ".DDDW.Required" + ' = ' + "Yes" Case 'ddlb' ls_modifyexpression = ls_column + ".DDLB.Required" + ' = ' + "Yes" Case 'edit' ls_modifyexpression = ls_column + ".Edit.Required" + ' = ' + "Yes" Case 'editmask' ls_modifyexpression = ls_column + ".EditMask.Required" + ' = ' + "Yes" Case Else // All edit styles for this "object" should be "Edit" addError(METHOD_NAME, "Unsupported editstyle for column = "+ls_column) Return -1 End Choose // Execute the modify expression ls_modifyresult = ads_working.modify(ls_modifyexpression) If len(ls_modifyresult) > 0 Then addError(METHOD_NAME, "Attempt to make the column required failed. column = "+ls_column) Return -1 End If Next Return 1 end function on eaf_n_cst_businessobject.create call super::create end on on eaf_n_cst_businessobject.destroy call super::destroy end on event deactivate;call super::deactivate;//////////////////////////////////////////////////////////////// // Description: // Occurs when the object is deactivated // 1.0 - Initial version // Arguments: // None // Returns: //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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. //////////////////////////////////////////////////////////////// SetNull( is_sessionid ) Return end event event activate;call super::activate;//////////////////////////////////////////////////////////////// // Description: // Occurs when the object is activated from the pool // 1.0 - Initial version // Arguments: // None // Returns: //////////////////////////////////////////////////////////////// // Copyright © 2000 - 2007 Youngsoft Technology, 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. //////////////////////////////////////////////////////////////// // reset dataset name is_dataset = "" end event
File: eaf_n_cst_businessobject.sru
Size: 35903
Date: Tue, 22 Jan 2008 23:40:35 +0100
Size: 35903
Date: Tue, 22 Jan 2008 23:40:35 +0100
- n_cst_component eaf_n_cst_businessobject(sru)
- assignrequiredfields (ref n_datastore ads_working) returns long
- checkrequiredfields (ref n_datastore ads_working, ref string as_missingentrymessage) returns long
- getdataset () returns string
- setdataaccess (ref n_cst_dataaccessservice anv_dataaccess) returns long
- setdataaccess (string as_dataaccess) returns long
- setdataobject (string as_dataobject) returns long
- setdataobjectrequiredfields (string as_requiredfields[]) returns long
- setdatastore (string as_datastore) returns long
- setlanguageid (long al_languageid) returns long
- setusername (string as_username) returns long
- update (ref s_mimedataset astr_mimedataset) returns long
- updateend (ref n_cst_businessobjectattrib anv_boattrib) returns long
- updatemain (ref n_cst_businessobjectattrib anv_boattrib) returns long
- updateprepare (ref n_cst_businessobjectattrib anv_boattrib) returns long
- updatestart (ref n_cst_businessobjectattrib anv_boattrib) returns long
- updatevalidate (ref n_cst_businessobjectattrib anv_boattrib) returns long