STATE MODELS FOR MONITORING PROCESSES

Abstract: A system and method for preparing, using and displaying a state model of a process, as an industrial or business process, as a sequence of discrete steps. The state model defines the behavior of the logical objects making up a process model of the process as a set of permitted states and a set of permitted transitions between the permitted states. The method involves creating a state model (61) with certain parameters, a Create/Modify State Transition for a State Model (63) and Associate State Transition with Rules and Conditions (65). These rules are inputted into a graphical user interface which causes appropriate rules to be extracted from a database (67). They are assembled into a state machine execution engine (69) and implemented (70) to produce an enforced state model on targeted business objects (71) and the target business object is enabled (73).

Description: STATE MODELS FOR MONITORING PROCESSES FIELD OF THE INVENTION This invention relates to state models and state model development for defining and monitoring processes, more specifically, for monitoring industrial and business processes. BACKGROUND As the business environment becomes more complex, with multiple, overlapping channels, competing and complementary paradigms, providing customized products to large numbers of customers, it becomes absolutely essential for the enterprise to bring its business processes under control. Control of the business process must be accomplished in such a way as to provide management with accurate and current knowledge of the state of business, including deals in progress, and their progression through the enterprise. There is an especially strong need for a readily scalable and readily deployable development environment, including development tools, to allow end users to develop business applications customized to their needs and derived from supplied base classes, functions, subroutines, and the like. Likewise, in the industrial sector as industrial processes become longer and more complex, with parallel paths of discrete process steps, frequently carried out at different locations, leading to nodes, and to still further process steps. This has created a need for a readily scalable and readily deployable development environment to allow end users to develop industrial modeling applications derived from supplied classes, functions, routines, and subroutines. A particular need for programming tools is in the area of the representation of a process as a sequence of discrete, frequently parallel, steps, as in flow charts, and especially funnel charts. A further need exists for development tools for the development of pipeline models, as industrial, manufacturing or sales pipeline models. A still further need exists for development tools for assistant modules, as industrial, manufacturing or sales assistant modules used to guide personnel through manufacturing sequences and sales transactions. SUMMARY OF THE INVENTION Our invention relates to state models of "objects" and especially configurable state models of "objects." "Objects" which are referred to herein as "business objects" or as "objects" include sets of functions, and variables, characterized by permitted states and transitions, and prohibited states and transitions. The objects may model steps or states in a business process or in a manufacturing process. Objects may be called by an end-user, and incorporated into an end-user's programs, routines, subroutines, functions, and applets. According to our invention the "objects" are related to and/or are useful in one or more types of industrial and manufacturing processes, business transactions, and/or business processes, such as product fabrication, product assembly, warehousing, shipping, customer contacts, sales leads and referrals, orders, order configuration, and similar transactions. The invention provides a method of preparing a state model of a process, as an industrial or business process. The state model defines the behavior of logical industrial or business objects in an industrial or business process model of the industrial or business process as a set of permitted states and a set of permitted transitions between the permitted states. This is done through the steps of selecting a template for the state model; selecting industrial or business object components for the state model; selecting or defining state transitions for the state model; defining permitted state transitions from a "from state" to a "to state" with a State Transition Rule name; associating state transitions with state transition rules, names, and conditions; enumerating the state transition names and state transition rule names; and extracting the state transition rules from a database. The states, transitions, and extracted rules make up a state machine execution engine; and process the industrial and/or business model through the state machine execution engine. At least one of the state transition rules include prerequisites which must be met before the transition is permitted, and at least one of the state transition rules define authorized users for effecting a state transition. In one embodiment of the invention the business objects define a manufacturing or sales pipeline funnel model (here illustrated as a sales pipeline) of a set of industrial processes or business deals (here illustrated as business deals), where the sales pipeline funnel shows business deals being worked in different methodologies on a single sales pipeline graphic. The methodologies are chosen from the, for example, telesales process deals, strategic deals, and standard process deals. In this embodiment of the invention the business deals may be grouped by sales methodology, and classified as, for example, as qualifying deals, working deals, and closing deals. Similarly, industrial processes may be grouped by technology, physical processes, equipment, or the like. In the case of business models, the method of the invention is practiced by creating a sales opportunity, creating a sales method, breaking the sales method into sales cycles within the sales method, and breaking the sales cycles down into sales phases for each sales cycle. In the case of industrial models, the method of the invention is practiced by creating process flows, manufacturing steps, identifying manufacturing steps to manufacturing equipment or processes, and introducing testing and/or quality control steps. In carrying out the method of the invention a sales method is associated with a sales opportunity, and the sales opportunity is advanced based upon the associated sales method. Sales opportunities are sorted and grouped by at least one of sales methods, cycles, and phases. The deal data, grouped by one or more of sales method, sales cycle, and deal phase, to a charting engine, and from the charting engine to the Sales Pipeline Funnel Chart. An aspect of the method of the invention is monitoring the state of deal or product as it moves from state to state, for example, to determine additional actions with respect to the deal or product. Another aspect of the invention is assigning activity and assessment templates to a deal or product in process, for example, to assess the deal or manufacturing process flow using the assigned activity and assessment templates. A further embodiment of our invention is a system running on at least one computer (but frequently on more then one computer, as a client and a server, or a web client and a web server and one or more application servers) for preparing a state model of a process as described above. The state model defines the behavior of logical business or industrial objects in a business or industrial process model of the process as a set of permitted states and a set of permitted transitions between the permitted states. The system is configured to: select a template for the state model; select object components for the state model; select or define state transitions for the state model; define permitted state transitions from a "from state" to a "to state" with a State Transition Rule name; associate state transitions with state transition rules, names, and conditions; enumerate the state transition names and state transition rule names; extract the state transition rules from a database; wherein the states, transitions, and extracted rules comprise a state machine execution engine; and process a business model through the state machine execution engine. In the system and method of our invention we provide a unique integration, through a state model and state machine of several objects, as industrial or business objects, to provide graphical reports, such as a Multiple Method Sales Pipeline, a Funnel Chart Engine, and a set of reporting tools. As a result, data, including sales pipe line data and industrial work-in-progress data, can be reported graphically across multiple sales methods and industrial methods and locations using such techniques as funnel charting, sales pipelines, and customized reporting techniques. The invention described herein includes a method and a system for preparing and using a state model of an industrial or business process. The state model defines the behavior of the logical objects making up a business process model of the business process as (1) a set of permitted states and (2) a set of permitted transitions between the permitted states. The state model is created by selecting a template for the state model, and selecting industrial or business object components for the state model (for example, by using "OOP" or other programming paradigms and methods as described herein). The user then selects or defines state transitions for the state model, for example, by defining permitted state transitions from a "from state" to a "to state". This is the "configurability" aspect of the state model. The defined or selected state transition rules are identified to State Transition Rule names. That is, state transitions are associated to specific state transition rules, names, and conditions, and the state transition names and state transition rule names are enumerated. The specific state transition rules corresponding to the names are extracted from a database. The extracted states, transitions, and rules define the state machine execution engine. This state machine execution engine is used to process business models, as described herein. THE FIGURES The method and system of our invention may be understood with reference to the Figures. Figure 1 illustrates a flow chart of the Configurable State Module of the method and system of our invention. Figure 2 shows the relations of the state model, and specifically, the state model, the state, the state transitions, the state transitions and positions, and the positions. Figure 3 illustrates a screen shot of the State Model view of our invention. Figure 4 illustrates a funnel chart engine representation of the method and system of our invention. Figure 5 illustrates a flow chart of the method and system of the multi-method sales pipeline module of our invention. Figure 6 illustrates a flow chart of the Sales Assistant Module of the method and system of our invention. DETAILED DESCRIPTION OF THE INVENTION The system and method of our invention relate to "objects" including industrial and business objects, that are associated through a "configurable state model" having sets of permitted states and sets of permitted transitions to provide a manager with needed information, and with tools to extract, analyze, and display the information. This is accomplished through such business objects as an opportunity object, a sales method object, a multi-method sales pipeline object, and a funnel chart engine business object, as well as such industrial objects as manufacturing operations, manufacturing equipment, workflow, capacities, and the like. As pointed out above, "objects" include sets of functions, variables, routines, and subroutines and configurable state models. Objects may be called by an end-user, and incorporated into an end-user program, routines, and applets. According to our invention when the "objects" are business objects they related to and/or are useful in one or more types of business transactions and/or business processes, such as customer contacts, sales leads and referrals, orders, order configuration, and similar transactions. Similarly, when the "objects" are industrial objects they are related to and/or useful in one or more types of industrial, manufacturing, or warehousing processes. Our invention utilizes a configurable state model of processes. The configurable state model defines the behavior of the logical industrial or business objects, including functions and variables therein, making up an industrial or business process model of the industrial or business process as (1) a set of permitted states and (2) a set of permitted transitions between the permitted states. The Configurable State Model provides users with a data driven method for extending workflow control based on the status of an object. In order to make this work, users need to define the state model which consists of a set of acceptable states and state transitions. The state machine then ensures that these objects go tlirough the desired process defined by the state model. The configurable state model is created by selecting a template for the state model, and selecting business object components for the state model (for example, by using "OOP" methods, such as calling a member function with a calling object, using the C++ syntax Calling_Object.Member_Function (ArgumentJList) as described herein or the JAVA syntax, or by calling routines, subroutines, functions, and the like as in conventional programming paradigms, using, for example BASIC, FORTRAN, C, and the like). The user then selects or defines state transitions for the state model, for example, by defining permitted state transitions from a "from state" to a "to state", as by specifying arguments in the "ArgumentJList" of the called Member_Function. The defined or selected state transition rules are identified to State Transition Rule names. That is, state transitions are associated to specific state transition rules, names, and conditions, and the state transition names and state transition rule names are enumerated, using object oriented programming methodology. The specific state transition rules corresponding to the names are extracted from a database of state transition rules. The extracted states, transitions, and rules define the state machine execution engine. This state machine execution engine is used to process business models, as described herein. In the configurable state model and associated applications of the method and system of our invention, we provide a unique integration of several business objects with an interactive synergy therebetween through the configurable state model. For example, in the Funnel Chart application of our invention, multiple streams of sales transactions and customers at different levels of completion can be integrated and the resulting sales pipeline data can be reported graphically across multiple sales methods using funnel charting technique. Similarly the Funnel Chart application of our invention can be used to graphically report industrial processes similar to the "N Server- M Queue" models. The components that are associated in the system and method of the invention are: A state model which is a characterization of objects as a set of configurable state models, each configurable state model itself being a set of permitted states and permitted transitions between the permitted states, including permitted state transitions, prerequisites for transitions such that one cannot move into the next stage until the prerequisite is met, and actors that are permitted to move the process to a stage (e.g., only specific users may change the status of the object to "approved" or "closed."). A funnel chart engine, as shown in Figure 4, that, given specific charting instructions, generates graphical chart based on the sales pipeline and sales methods. As shown in Figure 4, the funnel chart engine breaks deals up into classes, for example, qualifying deals, working deals, and closing deals. Within each class are categories of deals, such as telesales process deals, strategic deals, and standard process deals. An opportunity object which is a business object that keep information about a sales opportunity A sales method object which is a business object that allows a user to create and store data related to sales methodology, including sales cycles and phases. Related objects for industrial processes can include shop orders, equipment and process flow chart and sequencing parameter data, capacities, and the like. Specific Components of the System and method State Model Returning to the state model, the state model is part of the system and method of our invention. A state model is an abstraction of digital device where the present state (output state) of the model is a function of its immediately preceding state (input state) and of a binary control signal (input control signal). In a state model, the output state of the model is a unique function of the input state and the input control signal (0, 1). According to the system and method of our invention, the "state model" works through a "state machine" with the business objects to define allowable state values, transitions, and paths. The state model defines the behavior of logical objects, as industrial or business objects, as a set of states and transitions between states. In addition to defining the universe of permitted values and transitions, the state model allows administrators to define prerequisites for transitions such that one cannot move into the next stage until the prerequisite is met. The state model also defines authorized "users" (by title or by security access or the like) that are permitted to move the state model of a transaction or workpiece to a state. Only specific users may change the state of the object, for example by advancing it to the next state, or to "approved" or "closed." Moreover, the authority or power to change the state of an object may be function of both the user and the present state. For example, a manager may have the power to "approve" or disapprove" a deal at the nth state, but not when the deal reaches the n+lth state. Similarly, a manufacturing technician can divert a workpiece from the nth tool to the n+lth tool, but can not divert the workpiece further once it has reached the n+lth tool. "Position" as shown in blocks 70 ("State Transition/Position") and 75 ("Position") of Figure 2 defines the "user." The state model is the blueprint of acceptable states and state transitions that the state machine will enforce. The state machine then ensures that these objects go through the desired process defined in the state model. A state machine is an engine that enforces the transitions between states for an object during its lifetime. A state represents the status of an object, such as Open, Closed, Pending, and so on. The state represents where the object is in its lifetime. The state machine can also control whether or not the data of that object can be modified or not. As an example, a Service Request that is in a Closed state may be considered "frozen", such that its attributes cannot be modified. A state transition defines the allowable migration of an object from one state to the next. For instance, a Service Request that has been closed but must be re-opened may go from the Closed state to an Open state, and may go from Open to Pending, but may not transition directly from Closed to Pending. The allowable migration of a Service Request from Closed to Open, or Open to Pending, represents defined state transitions. The state transition can also enforce other behavior. The state transition definition can verify that specific conditions have been met before the transition occurs. The state transition definition can also control what individuals or groups of individuals can initiate the transition. Configurable State Models - Technical Description The Configurable State Model module illustrated in Figure 1 provides users with a data driven method for extending workflow control based on the status of an object. In order to make this work, users need to define the state model, which consists of a set of acceptable states and permitted state transitions. The state machine then ensures that these objects go through the desired process defined by the state model. According to the system and method of our invention, the configurable state model is used in the context of logical business objects. Specifically, state model states and transitions are defined for business objects using an intuitive user interface, with limitations put upon those who can transition objects from one state to another state. Figure 3 is a screen shot of the State Model view of our invention. The State Model consists of the following components: State: The state is the status of an object. This can also refer to the value of an attribute where the attribute will change values over the life of the object. Value can be Boolean, alphanumeric, or numeric. State Transition: A state transition is a linkage or set of linkages between two states that define the allowable migration from one state to the next. We can add the rule validations to a state transition and the state machine will determine can if we advance to the next state or not at run time. Also we can define who has the privilege to advance to the next state by defining the authorized users. State Model: The state model is the set or blueprint of allowable states and state transitions that the state machine will enforce. State Machine. The State Machine is the engine that enforces the states and state transitions that an object may go through during its lifetime. As shown in Figures 1, 2, and 3, the first step in the method of our invention is to create a state model or modify an existing state model, block 61 of Figures 1 and 2 and block 62 of Figure 2 where certain parameters ("State Model ID," "Value," "Description"). This is illustrated in Figure 3 as the actions called for in the top block, that is, entering and/or selecting the "State Model," the "Business Component" of the "State Model", the "Field", and the activation and expiration dates. The next two steps are to "Create/Modify State Transition for a State Model" as illustrated in block 63 of Figures 1 and 2, and "Associate State Transition With Rules and Conditions" as shown in block 65. This is illustrated by block 65 of Figure 2 (where "State Model ID," "From State ID," "To State ID," "Field Name," "Operator," "Value," "Rule," "Public Flag," and "Description" are entered into the "State Transition" block) and the middle of the screen in Figure 3, which shows transitions, with each permitted transition having a "From State Name", a "To State Name", a "Public Flag", a "Rule Field Name" a "Rule Operator", and a "Rule". Typically, state machine and state model rules are expressed as "If present state is '0' and input is '0', then new state is '1', but if input is '1', then new state is '0'; and if present state is '1' and the input is '0', then the output is '0'. But if the input is '1', then the output is '1'. As shown in the next block of Figure 1, entering these rules into the graphical user interface of Figure 3 causes the appropriate rules to be extracted from the database, block 67, and, in the next block, assembled into a state machine execution engine, block 69 of Figure 1 and implemented as in block 70 of Figure 2. This produces an enforced state model on targeted business objects, block 71, and the target business object is enabled, as shown in block 73. The State Model Class Definition reproduced in Appendix A and the State Machine Source Code is reproduced in Appendix B. Multi-method Sales Pipeline The multi-method sales pipeline method and system of our invention is illustrated in Figure 4. Figure 4 shows a large funnel 1 and small funnels 11, 13, and 15 representing deals being worked in different methodologies on a single sales pipeline graphic. The small funnels, 11, 13, and 15, represent the sales pipelines of a group of deals being worked in a single methodology. The bigger funnel 1 at the top represents a way to combine the small ones and compare the value of all of the deals to the sales person's quota. As shown in Figure 4, the funnel chart engine breaks deals up into classes, for example, qualifying deals, 3, working deals, 5, and closing deals, 7. Within each class are categories of deals, such as telesales process deals, 11, strategic deals, 13, and standard process deals, 15. A flow chart of this embodiment of the system and method of our invention is shown in Figure 5. As shown in Figure 5, an opportunity is created on one side, block 21, and a sales method is created on the other side, block 31, which method is broken down into sales cycles within the sales method, block 33, and further broken down into sales phases, block 35, for each of the sales cycles, block 33. The processed sales method and the opportunity are brought together, as shown in block 37, and the sales method associated with a sales opportunity. The sales opportunity is then advanced based upon the sales method, as shown in block 39. The sales opportunities are then sorted and grouped by sales methods, cycles, and phases, as shown in block 41. The data, grouped by sales method, sales cycle, and deal phase, is then passed to a charting engine, as shown in block 43, and from the charting engine to the Sales Pipeline Funnel Chart of Figure 4, as shown in block 45 of Figure 5. Sales Assistant The sales assistant module of the system and method of our invention monitors the state of the deal as it is being worked and suggests, but need not require, specific actions and evaluations ("assessments") that should be performed based on the methodology employed for that specific deal. Using the state model, as deals move from stage to stage, the sales assistant module continues to monitor the deals to determine (based on the then current methodology) whether additional actions or assessments should be suggested. A flow chart for the Sales Assistant is shown in Figure 6. The Sales Assistant is a coaching tool. With the Sales Assistant, everyone in an organization can learn from each other, and especially from the most experienced sales reps. Activity Templates automatically list, schedule, and assign all of the activities that are needed to move sales opportunities quickly from one sales stage to the next. Assessments compare like opportunities with a "model" or "optimal" opportunity. As shown in the flow chart of Figure 6, templates, such as a Sales Assistant Activity Template, block 51, and a Sales Assistant Assessment Template, block 53, are created. These two templates are then manually assigned to Opportunities, Accounts, and Contacts, in block 55. Meanwhile, the templates are also associated with sales methods and opportunities, as shown in block 57 on the right hand side of Figure 6, and then associated with opportunity sales methods, block 59, and the sales cycles advanced, block 61. Sales cycles are advanced using the permitted states and the permitted transitions of the state model described herein above. The activity templates and assessment templates are then assigned, block 63, and the assessments and activity plans performed, block 65. The product or output of the assessment and activities function, block 65, is the suggestion of additional actions and assessments, based upon permitted states and state transitions, and the comparison of the deal with optimal deals. Sales Assistant Module Sales Assistants Module Technical Description: Sales Assistants provide a unique method to facilitate and to monitor the life cycle of a sales opportunity, account or a contact. The components included in a C++ exemplification of this method are: Activity Template Object - a business object that holds a set user definable actions that can be applied to an opportunity/ Account/contact. Assessment template object - a business object that holds a set of user definable assessment rules for evaluating the quality of an opportunity/account/contact. Sales Assistant Agent - a smart agent program that can assign Activity and Assessment to an opportunity/account/contact based on the sales methodology and cycles. It would, of course, be understood that the Sales Assistant methodology can be used for production planning and debottlenecking, among other industrial applications. The following Appendices are code listings for the methods described herein. APPENDIX A - STATE MODEL DEFINITION SOURCE CODE /////////////////////////////////////////////////////////////////////////////// // // bcstatem.h : State Model Business Component Class functions, types, and de initions // // Copyright (C) 1997, Siebel Systems, L.P., All rights reserved. // // FILE: bcstatem.h // $Revision: 1 $ // $Date: 8/10/99 6:25p $ // $Author: Hastings $ of last update // // CREATOR: Michael T. Yu // /////////////////////////////////////////////////////////////////////////////// #ifndef BCSTATEM_H__ #define BCSTATEM_H__ /////////////////////////////////////////////////////////////////////////////// // // CSSBCStateModel - CSSBCStateModel Object Class Definition // /////////////////////////////////////////////////////////////////////////////// class SS EXPORT CLASS CSSBCStateModel : public CSSBusComp { SS_DECLARE_DYNCREATE (CSSBCStateModel) // class member variable declarations private: // class member function declarations protected: CSSBCStateModel (void) ; virtual -CSSBCStateModel (void) ; virtual ErrCode SqlWriteRecord (void) public: protected: private : virtual ErrCode ValidateOverlappedActiveStateModel (void) }; /////////////////////////////////////////////////////////////////////////////// // // CSSBCStateModelState - CSSBCStateModelState Object Class Definition // /////////////////////////////////////////////////////////////////////////////// class SS_EXPORT_CLASS CSSBCStateModelState : public CSSBusComp SS_DECLARE_DYNCREATE (CSSBCStateModelState) // class member variable declarations private : 91 ddo SZ, oz. H waivisoa // JTP U3 # 99 • '{ : θ^BΛ αd 09 {sure Xsτad HlSDdl) 1003 xenr iτΛ :oτχqnd 09 (pτoΛ) uoτ3τs E_c θ 4 B3SDaSSD 9* suoτ3EJEχoap -Cθquiθtu ssEχo // : 33 ΛT xd suoτtj -CEx s θxqBτα Λ -tsquiθui ssBχo // sε JLHOdXa SS ssEχo 1111111 // oε /////// //////////////////////// : Θ^EΛTJ OS : s^DΘ 4 θα OsτT-f τad 3*duiODSnasSD '3ureβr θτad HJLSOdT) 5Sτii[Dτa3Θ3 θpoOJJta χBn:μr.τΛ .' (suiBNP sτad ttlSDdl) TOOH χEn3_ετΛ 91 : oτχqnd Jθ uraui ssEχo // Lszszmsn/±Dd sεzεε/oo OΛV LI (PfOΛ) X3 oW33E3S0aSSD : : iiiiiiimmmiiiiimiiiiiiiiimiiiiiiiiimmimiiiimiimimiimiii II tUiauoduioQ sssuτsna χθ o 33 4 soaSSD // // OZ, /////////////////////////////////////////////////////////////////////////////// jτpua# _ M3-I_θnaaα «au θuτjsp# ςg ■ ' ail- = []aτιa SIHX aαoo αasva_JBqo DT^ ^S aiia SIHX 3spun# onaaα 33P3 # suoτ^EΛBXDθp Bnqap // (duioosnasso 09 (duioosnassD (duioosnasso axvaaoNAd Nawai wi ss S 4 U3UIΘ 4 E3S oaovw // •'-TSTO-l = Enqsrjq 1008 oτ^B^s Sθ qετ BΛ oτ^B^s // ΛΓ Sθ qBταBΛ χBqoχ6 // suoτrpunj // SθχqBτ_CEΛ U-CS^ Θ // 9t ..αa vαdn sin α3χγαan_sι_do_T3s θuτ3ap# ii HlN XON Sin TION XON_SI_dO_l0S θuτgθp# Q -THIN Sin THIN SI dO 1US θuτgap# uosταBduioo // jτpus# ς „ifui33B 4 soq„ apnχour# H ~ Wa VXSDa ss ujτft jτpuθ# ,iiT_£qo-rbs„ θpnχouτ# Q£ H raoTos 3θpu?τ# 5fpua# iiH- Cqosnq,, θpnχou # H ~ aosna 33 ujτ# g jτpuθ# 02 n H'osτuifqo,, spnχouτ# H~Dsιwrao J3 ujτ# ..q-xjBp^s,, spnχouτ# gj /////////////////////////////////////////////////////////////////////////////// // nλ ' SBiTOjw :HOX 3HD // • paΛαsssj 3χτg uoτ 4 B 4 u : // t,s 8z/66SfiΛL3J sεzεε/oo OΛ\ EXPORT CSSBCStateModel : : -CSSBCStateModel (void) { i 1n0 "// CSSBCStateModel: : Sql riteRecord // // Purpose: // Before commit the change verify that there is no other overlapped // active state model defined for the same BusComp/Field 15 // ErrCode CSSBCStateModel :: SqlWriteRecord (void) { ErrCode err; 20 DO (ValidateOverlappedActiveStateModel ()); DO (CSSBusComp: : SqlWriteRecord ()); 25 ll_abort : return (err) ; 30 // // CSSBCStateModel: :ValidateOverlappedActiveStateModel // // Purpose: // Verify that there is no other overlapped active state model 35 // defined for the same BusComp/Field // ErrCode CSSBCStateModel: :ValidateOverlappedActiveStateModel (void) { 40 ErrCode err; CStringArray errParmArray; CSSObjectBase* pErrChild = NULL CSSBCStateModel* pBCStateModel = NULL CSSSqlBCDef* pSqlBCDef = NULL 45 CSSRecord* pRecord = NULL CString fieldData; CString Name ; CString searchSpec ; CSSDateTime dateTimel ; 50 CSSDateTime dateTime2 ; // create state model buscomp DOCHILD (m_pModel, GetSqlBCDef (m_busCompName, pSqlBCDef)); 55 m_pModel->ConstructBusComp (pSqlBCDef, m_pBusObj , (CSSBusComp*&) pBCStateModel) DO (GetErrorCode ()); 60 if (!pBCStateModel) { err = SSAOMErrConstrBusComp; goto ll_abort; 65 FindWorkSet (m_activeRow, pRecord) // // Construct the search spec for m_pBCStateModel 70 // The purpose of constructing this search spec is to ensure that // at any given period of time there can be only one active // state model against a business object field // 75 DOCHILD (m_pSqlObj, FieldValue (pRecord, "Id", Name)); AddQuotes (Name, • " ' ) ; searchSpec = "([Id] <> " + Name + ") AND "; DOCHILD (m_pSqlObj , FieldValue (pRecord, "BusComp Name", Name)); AddQuotes (Name, ' " ' ) ; searchSpec += "([BusComp Name] = " + Name + ") AND "; DOCHILD (m_pSqlObj, FieldValue (pRecord, "Field Name", Name)); AddQuotes (Name, ' " ' ) ; searchSpec += "([Field Name] = " + Name + ") AND " ; DOCHILD (m_pSqlObj , FieldValue (pRecord, "Activation Date/Time" , dateTimel)). DOCHILD (m_pSqlObj , FieldValue (pRecord, "Expiration Date/Time" , dateTime2) ) dateTimel .GetAsString (fieldData) ; AddQuotes (fieldData, '" ' ) ; searchSpec += " ( " ; searchSpec += " ( " ; searchSpec += "([Activation Date/Time] <= " + fieldData + ") AND " ; searchSpec += " ( " ; searchSpec += "([Expiration Date/Time] >= " + fieldData + ") OR "; searchSpec += " ( [Expiration Date/Time] IS NULL) " ; searchSpec += ")"; searchSpec += " ) OR " ; if (!dateTime2.IsNull ()) searchSpec += " ( " ; searchSpec += "([Activation Date/Time] >= " + fieldData + ")"; if (!dateTime2.IsNull ()) { dateTime2.GetAsString (fieldData) ; AddQuotes (fieldData, "" ) ; searchSpec += " AND " ; searchSpec += "([Activation Date/Time] <= " + fieldData + " ) " ; searchSpec += " ) " ; ' searchSpec += " ) " ; DOCHILD (pBCStateModel, SetNamedSearch ("State Model", searchSpec)); DOCHILD (pBCStateModel, Execute (FALSE, FALSE, TRUE)); DOCHILD (pBCStateModel, Home ( ) ) ; fieldData.Empty () ; for (err = pBCStateModel->CheckActiveRo () ; err == OK; err = pBCStateModel->NextRecord ()) { // Concatenate the overlapping state modle names DOCHILD (pBCStateModel, FieldValue ("Name", Name)) if (fieldData. IsEmpty ()) fieldData = "\t'" + Name + " ' " ■ else fieldData += "\n\t ' " + Name + " ' " ; if (err == SSAOMErrActiveRow) // No Active Row: means no overlap. return OK err = OK; } else if (err == SSASqlErrEOF) err = IDS_ERR_OVERLAPPED_ACTIVE_STATE_MODEL; errParmArray.Add (fieldData) ; } ll_abort : SetErrorMsg (err, errParmArray, pErrChild) ; if (pBCStateModel) { // do not call Released, it will break the connection of // the BusObj and the original BusComp and cause memory leak pBCStateModel->m_pBusObj = NULL; delete pBCStateModel; 10 } return (err) ; 15 /////////////////////////////////////////////////////////////////////////////// // // CSSBCStateModelState Business Component 20 /////////////////////////////////////////////////////////////////////////////// EXPORT CSSBCStateModelState: : CSSBCStateModelState (void) 25 EXPORT CSSBCStateModelState: : -CSSBCStateModelState (void) { } 30 // // CSSBCStateModelState: :HasPickList J " II Purpose: // Dynamically disable the PickList for 'State' field if // the state model field do not have a LOV PickList // 40 BOOL EXPORT CSSBCStateModelState : :HasPickList (LPCSTR pFieldName) { if (lstrcmpi (pFieldName, "State Name") == 0) { CString busCompName; 45 CString fieldName; CSSPickListDef* pPickListDef = NULL CSSSqlBCDef* pSqlBCDef = NULL CSSSqlFieldDef* pSqlFieldDef = NULL 50 if ( !m_pParentBusComp) return (FALSE) ; // Is parent BusComp "State Model" 55 if (m_pParentBusComp->m_busCompName != "State Model") return (FALSE) ; // Get the BusComp name defined for the state model 60 if (m_pParentBusComp->FieldValue ("BusComp Name", busCompName) != OK) return (FALSE) ; // BusComp name cannot be empty 65 if (busCompName. IsEmpty () ) return (FALSE) ; // Get the Field name defined for the state model 70 if (m_pParentBusComp->FieldValue ("Field Name", fieldName) != OK) return (FALSE) ; // Field name cannot be empty 75 if (fieldName. IsEmpty () ) return (FALSE) ; // Get BusComp definition if (m_pModel->GetSqlBCDef (busCompName, pSqlBCDef) != OK) return (FALSE) ; if (IpSqlBCDef) return (FALSE) ; 10 // Get Field definition if ( !pSqlBCDef->GetSqlFieldDef (fieldName, pSqlFieldDe ) return (FALSE) ; 15 if (IpSqlFieldDef) return (FALSE) ; if (pSqlFieldDef->m_pickListName. IsEmpty ()) return (FALSE) ; 20 // Get PickList definition if ( !m_pModel->GetPickListDef (pSqlFieldDef->m_pickListName, pPickListDef)) return (FALSE) ; 25 if ( IpPickListDef) return (FALSE) ; // Get PickList type value 30 if (pPickListDef->m_typeValue . IsEmpty ()) return (FALSE) ; // Get PickList 's BusComp definition 35 if (m_pModel->GetSqlBCDef (pPickListDef->m_busCompName, pSqlBCDef)) return (FALSE) ; if (IpSqlBCDef) 40 return (FALSE) ; // Is table name "S_LST_OF_VAL" if (pSqlBCDef->m_tableName != "S_LΞT_OF_VAL") 45 return (FALSE) ; m_typeValue = pPickListDef->m_typeValue; } 50 return (CSSBusComp: :HasPickList (pFieldName)); J -:J-; "// CSSBCStateModelState: :GetPickList // // Purpose: // Override CSSBusComp: :GetPickList in order to modify the // search spec for state field 60 // ErrCode CSSBCStateModelState: :GetPickList (LPCSTR pFieldName, CSSBusComp*& pPickList) 65 ErrCode err = OK; DO (CSSBusComp: :GetPickList (pFieldName, pPickList)); if (lstrcmpi (pFieldName, "State Name") == 0) 70 { CString searchSpec; if ( !m_typeValue . IsEmpty ( ) ) searchSpec = "[Type] = \"" + m_typeValue + "\"" ; 75 else searchSpec = "[Id] = \"Junk Row Id\""; pPickList->SetNamedSearch ("State Name Pick List", searchSpec); } ll_abort: 5 SetErrorMsg (err, NULL, NULL) ; return (err) ; } 0 /////////////////////////////////////////////////////////////////////////////// // // CSSBCStateTransition Business Component // /////////////////////////////////////////////////////////////////////////////// 5 EXPORT CSSBCStateTransition: : CSSBCStateTransition (void) { } 0 EXPORT CSSBCStateTransition: : -CSSBCStateTransition (void) 5 // // CSSBCStateTransition: :CanUpdate // // Purpose: 0 // If the "Rule Field Name" is empty do not let the user // edit the "Rule Operator" field // If the "Rule Operator" is empty, 'IS NULL', 'IS NOT NULL', or // 'IS UPDATED' do not let the user edit the "Rule Value" field // 5 BOOL CSSBCStateTransition: :CanUpdate (LPCSTR pFieldName) if (CString ("Rule Operator") == pFieldName) 0 // If the "Rule Field Name" is empty do not let the user // edit the "Rule Operator" field CString fieldData; 5 if (FieldValue ("Rule Field Name", fieldData) == OK && fieldData. IsEmpty ()) { return (FALSE) ; 50 } ' else if (CString ("Rule Value") == pFieldName) { // If the "Rule Operator" is empty, 'IS NULL 1 , 'IS NOT NULL', or // 'IS UPDATED' do not let the user edit the "Rule Value" field 55 CString fieldData; if ((FieldValue ("Rule Operator", fieldData) == OK) && (fieldData. IsEmpty 0 | | 60 fieldData == SQL_OP_IS_NULL | | fieldData == SQL_OP_IS_NOT_NULL | | fieldData == SQL OP_IS UPDATED) ) return (FALSE) 65 return (CSSBusComp: :CanUpdate (pFieldName)). 70 // - /7D-; "// CSSBCStateTransition: :SqlSetFieldValue // // Purpose: // If the "Rule Field Name" field is set to empty // then clear the "Rule Value" field // If the "Rule Operator" field is set to empty, // 'IS NULL', 'IS NOT NULL', or 'IS UPDATED' then // clear the "Rule Value" field // ErrCode CSSBCStateTransition: :SqlSetFieldValue (LPCSTR pFieldName, LPCSTR pFieldData) { ErrCode err; DO (CSSBusComp: :SqlSetFieldValue (pFieldName, pFieldData)); if (CString ("Rule Field Name") == pFieldName) // If the "Rule Field Name" field is set to empty // then clear the "Rule Value" field CString fieldData = pFieldData; if (fieldData. IsEmpty 0) CSSBusCom :: SetFieldValue ("Rule Operator", ""); CSSBusComp: :SetFieldValue ("Rule Value", else if (CString ("Rule Operator") == pFieldName) { // If the "Rule Operator" field is set to empty, // 'IS NULL', 'IS NOT NULL', or 'IS UPDATED' then // clear the "Rule Value" field CString fieldData = pFieldData; if (fieldData. IsEmpty () || fieldData == SQL_OP_IS_NULL | | fieldData == SQL_OP_IS_NOT_NULL | | fieldData == SQL_OP_IΞ_UPDATED) { CSSBusComp: : SetFieldValue ("Rule Value", } ll_abort: return (err) // // // CSSBCStateTransition: : SqlWriteRecord // Purpose: // If the "Rule Field Name" field is not empty then the // "Rule Operator" field can not be empty // If the "Rule Operator" field is not empty, 'IS NULL', // 'IS NOT NULL', and 'IS UPDATED' then the "Rule Value" // field can not be empty // ErrCode CSSBCStateTransition: :SqlWriteRecord (void) ErrCode err = OK; CString errParm; CString fieldData; CSSField* pField = NULL; CSSRecord* pCurRecord = NULL; FindWorkSet (m_activeRow, pCurRecord) ; DO (SqlFieldValue (pCurRecord, "Rule FieldName", fieldData)), // If the "Rule Field Name" field is not empty then the // "Rule Operator" field can not be empty if (IfieldData.IsEmpty ()) { if (GetFieldDef ("Rule Operator", pField) ) { DO (ΞqlFieldValue (pCurRecord, "Rule Operator", fieldData)) if (fieldData. IsEmpty ()) err = SSASqlErrReqField; errParm = pField->GetErrorName () ; goto ll_abort; } DO (SqlFieldValue (pCurRecord, "Rule Operator", fieldData)); // If the "Rule Operator" field is not empty, 'IS NULL', // 'IS NOT NULL', and 'IS UPDATED 1 then the "Rule Value" // field can not be empty if (IfieldData.IsEmpty () && ieldData = SQL_OP_IS_NULL && fieldData = SQL_OP_IS_NOT_NULL && fieldData = SQL_OP_IS_UPDATED) { if (GetFieldDef ("Rule Value", pField) ) DO (SqlFieldValue (pCurRecord, "Rule Value", ieldData); if (fieldData. IsEmpty ()) { err = SSASqlErrReqField; errParm = pField- >GetErrorName (); goto ll_abort; } DO (CSSBusComp: : SqlWriteRecord ()); ll_abort : SetErrorMsg (err, errParm, NULL) ; return (err) IL APPENDIX B - STATE MACHINE SOURCE CODE /////////////////////////////////////////////////////////////////////////////// // // CSSBCBase - CSSBCBase Object Class Definition // /////////////////////////////////////////////////////////////////////////////// class SS_EXPORT_COMMONBCCLASS CSSBCBase : public CSSBusComp { SS_DECLARE_DYNCREATE (CSSBCBase) // Other Functionality // State Model BOOL m_bStateModel ; CSSQuery* m_pRuleExpr; CSSBusObj * m_pBOStateModel CSSBusComp* m_pBCStateModel CSSBusComp* m_pBCTransition CMapStringToOb m_mapStateModel class StateModel { public: StateModel (void) { m bLOVPickList FALSE ; CString m_rowId; BOOL mjbLOVPickList; CString m_LOVTypeValue ; CMapStringToPtr m_mapStateRestriction; enum SMDeleteUpdate ( SMDeleteOrUpdate , SMDelete, SMUpdate // Private class for State Model read-only record feature, class StateRestriction { public: StateRestriction (void) { m_bRestrictDelete = FALSE m_bRestrictTransition = FALSE m_bRestrictUpdate = FALSE } BOOL m_bRestrictDelete ; BOOL m_bRestrictTransition; BOOL m_bRestrictUpdate ; // Other Functionality public : virtual BOOL CanDelete (void) ; virtual BOOL CanUpdate (LPCSTR pFieldName) ; virtual ErrCode GetPickList (LPCSTR pFieldName, CSΞBusComp*& pPickList) ; protected: CSSBCBase (void) ; virtual -CSSBCBase (void) ; virtual BOOL IsChildUpdateDisabled (LPCSTR pChildName) ; virtual ErrCode SqlCreate (CSSSqlBCDef* pSqlBCDef, CΞSBusObj * pBusObj , WORD busCompType , CSSSqlObj * pSqlObj ) ; virtual ErrCode SqlSetFieldValue (LPCSTR pFieldName, LPCSTR pFieldData) ; // State Model private: ErrCode ConstructStateModelPickListSearchSpec (LPCSTR pFieldName, CSSBusComp* pPickList) ; BOOL EvalBoolExpr (CString strExpr) ; ErrCode LoadStateModel (void) ; ErrCode VerifyStateModel (LPCSTR pFieldName, LPCSTR pFieldData) , void UnLoadStateModel (void) ; BOOL CanSMDeleteUpdate (SMDeleteUpdate type SMDeleteOrUpdate, LPCSTR pFieldName = NULL) BOOL IsRestrictTransition (LPCSTR pFieldName, CString strFieldData) ; CSSBCBase: : CSSBCBase (void) { // Other Functionality // State Model m_bStateModel FALSE ; m_pBOStateMode1 NULL; m_pBCStateModel NULL; m_pBCTransition NULL; m_pRuleExpr NULL; } CSSBCBase: : -CSSBCBase (void) { // Other Functionality // State Model UnLoadStateModel () ; // // Field-level user properties // // Other Functionality // // CSSBCBase ::CanDelete // // Purpose: // // Override CSSBusComp: : CanDelete in order to check if the record can be deleted // in the row's current state. // BOOL CSSBCBase :: CanDelete (void) { if (ICanSMDeleteUpdate (SMDelete) ) return (FALSE) ; // Other Functionality return (CSSBusComp: : CanDelete ()) BOOL CSSBCBase :: CanUpdate (LPCSTR pFieldName) { // Other Functionality if (ICanSMDeleteUpdate (SMUpdate, pFieldName) return (FALSE) ; // Other Functionality return (CSSBusComp: : CanUpdate (pFieldName)); } // II CSSBCBase: :GetPickList // // Purpose: // // Override CSSBusComp: :GetPickList in order to modify the // search spec for state model field // ErrCode CSSBCBase: :GetPickList (LPCSTR pFieldName, CSSBusComp*& pPickList) { ErrCode err = OK; DO (CSSBusComp: :GetPickList (pFieldName, pPickList)); // // Call ConstructStateModelPickListSearchSpec () to add the additional // search spec for this PickList if State Model is defined // DO (ConstructStateModelPickListSearchSpec (pFieldName, pPickList) ) ; ll_abort : SetErrorMsg (err, NULL, NULL) ; return (err) ; } BOOL CSSBCBase : IsChildUpdateDisabled (LPCSTR pChildName) { // Other Functionality if (ICanSMDeleteUpdate ()) return (TRUE) ; return (CSSBusComp: : IsChildUpdateDisabled (pChildName)), ErrCode CSSBCBase : :SqlCreate (CSΞSqlBCDef* pSqlBCDef, CSSBusObj J pBusObj , WORD busCompType, CSSΞqlObj pSqlOb ) // Other Functionality / // BASESM.CPP II Load State Model // DO (LoadStateModel ()); // Other Functionality ErrCode CSSBCBase: : SqlSetFieldValue (LPCSTR pFieldName, LPCSTR pFieldData) // Other Functionality // // Check if state transition is allowed // DO (VerifyStateModel (pFieldName, pFieldData)) // Other Functionality static char file_id[] = "$Header: /v60/src/clients/common/bc/basesm.cpp 2 9/10/99 5 18:22 Myu $"; /////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 1995 - 1998, Siebel Systems, L.P., All rights reserved. m i U " // FILE : basesm. cpp // $Revision: 2 $ // $Date: 9/10/99 18:22 $ // $Author: Myu $ of last update 1 10-: " II CREATOR: Michael T. Yu // // DESCRIPTION // Base Business Component Class for State Model implementation file 20 /////////////////////////////////////////////////////////////////////////////// #include "stdafx.h" tfifndef BCBASE_H 25 ffinclude "bcbase.h" #endif #ifndef _INC_STDLIB #include <stdlib.h> 30 #endif #ifndef _INC_STRING #include "string.h" #endif 35 ttifndef BUSOBJ_H__ #include "busobj .h" #endif 40 #ifndef OBJMISC_H__ #include "objmisc.h" #endif // extern variables 45 // extern functions // global variables 50 // static variables static BOOL bDebug = FALSE; // MACRO statements 55 // debug declarations #ifdef _DEBUG #undef THIS_FILE static char BASED_CODE THIS_FILE[] = FILE_ 60 #define new DEBUG_NEW #endif ^ O "// CSSBCBase: :LoadStateModel // // Purpose: // // Load the active state models belong to current BusComp 70 // ErrCode CSSBCBase :: LoadStateModel (void) { ErrCode err = OK; 75 CSSObject* pErrChild = NULL; CString value; CString searchSpec; CString fieldDatal; CString fieldData2; CSSDateTime dateTime ; CSSBool bFlag; CSSBusComp* pMvgBCSMState = NULL StateModel* pSM = NULL StateRestriction* pSR = NULL CSSPickListDef* pPickListDef = NULL CSSSqlBCDef* pSqlBCDef = NULL CSSSqlFieldDef* pSqlFieldDef = NULL CSSBCState state; // If user property "State Model" is not defined return OK // if (IGetUserProperty ((LPCSTR) "State Model", value)) return (OK) ; // // If user property "State Model" is not equal to "Y" return OK // if (value != "Y") return (OK) ; // // Get "State Model" BusObj // and "State Model" and "State Model - Transition" BusComps // If State Model is not ready return OK // if (m_pModel->GetBusObj ("State Model - Engine", m_pBOStateModel) != OK) return (OK) ; if (m_pBOStateModel->GetBusComp ("State Model", m_pBCStateModel) != OK) return (OK) ; if (m_pBOStateModel->GetBusComp ("State Model - Transition", m_pBCTransition) ! = OK) return (OK) ; // // Temporarily store the BusComp Name to fieldDatal // and add quotes to the begining and end of fieldDatal // fieldDatal = m_busCompName; AddQuotes (fieldDatal, "" ) ; // Get current time and add quotes to the begining and end of fieldData2 // dateTime . SetToNow ( ) ; dateTime.GetAsString (fieldData2) ; AddQuotes (fieldData2, "" ) ; // // Construct the search spec for m_pBCStateModel // searchSpec = " ( [BusComp Name] = " + fieldDatal + ") AND ([Activation Date/Time] <= " + fieldData2 + ") AND (([Expiration Date/Time] IS NULL) OR ([Expiration Date/Time] + fieldData2 + "))"; DOCHILD (m_pBCStateModel, SetNamedSearch ("State Model", searchSpec)); DOCHILD (m pBCStateModel, Execute (FALSE, FALSE, TRUE)); DOCHILD (m_pBCStateModel, Home ( ) ) ; (err = m_pBCStateModel->CheckActiveRow (); err == OK; err = m_pBCStateModel->NextRecord ()) // Store field name and row id into the m_mapStateModel pSM = new StateModel; DOCHILD (m_pBCΞtateModel, FieldValue ("Field Name", fieldDatal)) DOCHILD (m_pBCStateModel, GetldValue (pSM->m_rowId) ) ; // // Get the State field's PickList definition // If the PickList is a LOV PickList set // pSM->m_bLOVPickList to TRUE and // pSM->m_LOVTypeValue to the appropriate value. // if (m_pSqlBCDef->GetSqlFieldDef (fieldDatal, pSqlFieldDef)) if (! pSqlFieldDef->m_pickListName. IsEmpty 0) m_pModel->GetPickListDef (pSqlFieldDef->m_pickListName, pPickListDef) ; if (pPickListDef && IpPickListDef->m_typeValue. IsEmpty 0 ) { DOCHILD (m_pModel, GetSqlBCDef (pPickListDef->m_busCompName, pSqlBCDef) ) ; if (pSqlBCDef && pSqlBCDef- >m_tableName == "S_LST_OF_VAL" ) pSM->m_bLOVPickList = TRUE; pSM- >m_LOVTypeValue = pPickListDef- >m_typeValue ; } } // Load state restriction information DOCHILD (m_pBCStateModel, GetMvgBusComp ("State Name" , pMvgBCSMState)) // Save the state of "State Model - State" BusComp state.SaveBCState (pMvgBCSMState, ""); DOCHILD (pMvgBCSMState, Execute ()); DOCHILD (pMvgBCSMState, Home ()); for (; err == OK; err = pMvgBCSMState- >NextRecord ()) { pSR = new StateRestriction () ; DOCHILD (m_pBCStateModel, FieldValue ("State Name" value) ) ; DOCHILD (m_pBCStateModel, FieldValue ("State Restrict Delete Flag" bFlag) ) ; pSR->m_bRestrictDelete = bFlag; DOCHILD (m_pBCStateModel, FieldValue ("State Restrict Transition Flag", bFlag) pSR->m_bRestrictTransition = bFlag; DOCHILD (m_pBCStateModel, FieldValue ("State Restrict Update Flag" bFlag) ) ; pSR->m_bRestrictUpdate = bFlag; pSM->m_mapStateRestriction.SetAt (value, pSR) ; } m_mapStateModel.SetAt (fieldDatal, (CObject*) pSM) ; // Restore the state of "State Model - State" BusComp state. RestoreBCState (pMvgBCSMState) ; if ((err == SSAOMErrActiveRow) || (err = SSASqlErrEOF) ) err = OK; else { pErrChild = pMvgBCSMState; goto ll_abort; if (err == SΞAOMErrActiveRow) { // No Active Row: means no active state model defined for current BusComp err = OK; } else if (err == SΞASqlErrEOF) 10 m_bStateModel = TRUE; m_pRuleExpr = new CSSQuery; m_pRuleExpr->m_pSqlObj = m_pSqlObj ; err = OK; } 15 ll_abort : SetErrorMsg (err, NULL, pErrChild) 0 if (!m_bStateModel) UnLoadStateModel (); return (err) 5 void CSSBCBase: :UnLoadStateModel (void) 0 if (m_pBOStateModel) m_pBOStateModel->Release (); m_pBOStateModel = NULL m_pBCStateModel = NULL 5 m_pBCTransition = NULL if (m_pRuleExpr) delete m_pRuleExpr; 0 m_pRuleExpr = NULL; if (m_mapStateModel .GetCount () > 0) { POSITION posSM; 5 POSITION posSR; CString key; StateModel* pSM = NULL; StateRestriction* pSR = NULL; 50 for (posSM = m_mapStateModel.GetStartPosition (); posSM; ) { m_mapStateModel.GetNextAssoc (posSM, key, (CObject*&) pSM) ; for (posSR = pSM->m_mapΞtateRestriction.GetStartPosition (); posSR; ) 55 pSM->m_mapStateRestriction.GetNextAssoc (posSR, key, (void*&) pSR) ; delete pSR; } delete pSM; 60 } } 65 '/, II CSSBCBase: :ConstructStateModelPickListSearchSpec // // Purpose: ™ IV) " II modify the PickList search spec for state model field // ErrCode CSSBCBase: :ConstructStateModelPickListSearchSpec (LPCSTR pFieldName, CSSBusComp* pPickList) ErrCode err = OK; CSSObject* pErrChild = NULL; StateModel* pSM = NULL; if ( !m_bStateModel) return (OK) ; if (IsInQueryState ()) { DOCHILD (pPickList, SetNamedSearch ("State Pick List", " " ) ) , return (OK); } // // Locate the field name in the State Model Map // m_mapStateModel . Lookup (pFieldName, (CObject*&) pSM) ; // If no state model is defined for this field, // do not set the additional search spec // if (IpSM || pSM- >m_rowId . IsEmpty ()) return (OK) ; // // Locate the state model // if (m_pBCStateModel->PositionById (pΞM->m_rowId) == OK) BOOL bShowDefaultState = FALSE; CString fieldData; CString stateFieldData; CString searchSpec; CSSRecord* pRecord = NULL; // // Get the original field value (From State Name) // GetActiveRecord (pRecord) ; DO (m_pSqlObj->FieldValue (pRecord, pFieldName, stateFieldData)); if (stateFieldData. IsEmpty ()) bShowDefaultState = TRUE; if (!bShowDefaultState) { // // Check the "State Restrict Transition Flag" for this field // if ( I IsRestrictTransition (pFieldName, stateFieldData)) { DOCHILD (pPickList, SetNamedSearch ("State Pick List", "")) return (OK) ; } // // Construct the search spec for m_pBCTransition // fieldData = pSM->m_rowId; AddQuotes (fieldData, ' "' ) ; // ( [State Model Id] = fieldData searchSpec = " ( [State Model Id] = " + fieldData; if (pSM->m_bLOVPickList) { II Convert LOV Val to Name // DOCHILD (m_pModel, GetLovValName (stateFieldData, pSM->m_LOVTypeValue, fieldData)) e}lse fieldData = stateFieldData; AddQuotes (fieldData, "" ) ; // ) AND ( [From State Name] = fieldData searchSpec += ") AND ([From State Name] = " + fieldData; fieldData = GetPositionld ( ) ; AddQuotes (fieldData, "" ) ; // ) AND (([Public Flag] = "Y") OR (EXISTS ([Position Id] = fieldData))) searchSpec += ") AND (([Public Flag] = \"Y\")"; searchSpec += " OR (EXISTS ([Position Id] = " + fieldData + ")))"; // // Set Named Search // DOCHILD (m_pBCTransition, SetNamedSearch ("State Transition", searchSpec)); DOCHILD (m_pBCTransition, Execute (FALSE, FALSE, TRUE) ) ; DOCHILD (m_pBCTransition, Home ()); } if (bShowDefaultState | | m_pBCTransition->CheckActiveRow () == OK) int index; BOOL bFirst; CString pickListSearchField CString stateName; CSSPickMapDef* pPickMapDef // // Get the PickList field name used in the pick map // for (bFirst = TRUE; pPickList->EnumPickMapDefs (bFirst, pPickMapDef, index) bFirst = FALSE) if (pFieldName == pPickMapDef->m_fieldName) pickListSearchField = pPickMapDef->m_pickFieldName; break; searchSpec . Empty ( ) ; if (bShowDefaultState) DOCHILD (m_pBCStateModel, FieldValue ("State ame", stateName)); if (pSM->m_bLOVPickList) { // Convert LOV Name to Val // DOCHILD (m_pModel, GetLovNameVal (stateName, pSM->m LOVTypeValue, fieldData) } else fieldData = stateName; AddQuotes (fieldData, "" ) ; searchSpec += "[" + pickListSearchField + "] = " + fieldData; else { for ( ; err == OK; err = m_pBCTransition->NextRecord ()) { if (m_pBCTransition->FieldValue ("To State Name", stateName) == OK) { if (! searchSpec. IsEmpty 0) searchSpec += " OR " ; 10 if (pSM->m_bLOVPickList) { // // Convert LOV Name to Val 15 // DOCHILD (m_pModel , GetLovNameVal (stateName, pSM->m_LOVTypeValue, f ieldData) ) ; 0 else fieldData = stateName; AddQuotes (fieldData, "" ) ; 5 searchSpec += " [" + pickListSearchField + "] = " + fieldData; } } if (err == SSASqlErrEOF) err = OK; 30 } pPickLis ->SetNamedSearch ("State Pick List", searchSpec); } else 35 { // // Force the PickList bring up nothing // 40 pPickList->SetNamedSearch ("State Pick List", "[Id] = \"Junk Row Id\""); ll_abort : 45 SetErrorMsg (err, NULL, pErrChild) return (err) ; } 50 // // CSSBCBase: :VerifyStateModel // // Purpose: J -:J-: "// Validate the state transition // ErrCode CSSBCBase : :VerifyStateModel (LPCSTR pFieldName, LPCSTR pFieldData) 60 ErrCode err = OK; CStringArray errParmArray; CSSObject* pErrChild = NULL; StateModel* pSM = NULL; 65 II II If undo is in progress skip the validation II 70 if (IsUndoRedoInProgress 0) return (OK) ; // // If no state model is defined for this BusComp skip the validation 75 // if ( !m_bStateModel) return (OK) ; - // J // Locate the field name in the State Model Map // m_mapStateModel .Lookup (pFieldName, (CObject*&) pSM) ; 10 // // If no state model is defined for this field skip the validation // if (IpSM || pΞM->m_rowId. IsEmpty ()) 15 return (OK) ; // // Locate the state model // 0 if (m_pBCStateModel->PositionById (pSM->m_rowId) == OK) CString searchSpec ; CString searchSpecR ; 5 CString oldFieldData; CString newFieldData = pFieldData; CString fieldData; CString ruleExpr; CString stateName; 0 CSSRecord* pRecord = NULL; // // Get the original field value (From State Name) // 35 GetActiveRecord (pRecord) ; DO (m_pSqlObj->FieldValue (pRecord, pFieldName, oldFieldData)) if (oldFieldData. IsEmpty ()) 0 { // // If original field value is "" then the default state model state // is the only valid next state. // 45 DOCHILD (m_pBCStateModel , FieldValue ("State Name", stateName) if (pSM->m_bLOVPickList) 0 «n0 " II Convert LOV Name to Val // DOCHILD (m_pModel , GetLovNameVal (stateName, pSM->m_LOVTypeValue, fieldData) 55 } else fieldData = stateName; * OnU "// If we enter the default state return OK // if (newFieldData == fieldData) return (OK) ; 65 else #if 0 // Fixed bugs: 12-LNCGD and 12-LNCGF II Check the "State Restrict Transition Flag" for this field // if ( I IsRestrictTransition (pFieldName, oldFieldData)) return (OK) ; 75 #endif } // // Construct the search spec for m_pBCTransition: // verify the from and to states and the authorization // fieldData = pSM->m_rowId; AddQuotes (fieldData, '"'); // ([State Model Id] = fieldData searchSpec = " ( [State Model Id] = " + ieldData; if (pSM->m_bLOVPickList) // // Convert LOV Val to Name // DOCHILD (m_pModel, GetLovValName (oldFieldData, pSM->m_LOVTypeValue, fieldData)) else fieldData = oldFieldData; AddQuotes (fieldData, "" ) ; // ) AND ( [From State Name] = fieldData searchSpec += ") AND ([From State Name] = " + fieldData; if (pSM->m_bLOVPickList) { II Convert LOV Val to Name // DOCHILD (m_pModel, GetLovValName (newFieldData, pSM->m LOVTypeValue, fieldData) ) } else fieldData = newFieldData; AddQuotes (fieldData, "" ) ; // ) AND ( [To State Name] = fieldData searchSpec += ") AND ([To State Name] = " + fieldData; searchSpecRT = searchSpec + " ) " ; fieldData = GetPositionld () ; AddQuotes (fieldData, "" ) ; // ) AND (([Public Flag] = "Y") OR (EXISTS ([Position Id] = fieldData))) searchSpec += ") AND (([Public Flag] = \"Y\")"; searchSpec += " OR (EXISTS ([Position Id] = " + fieldData + ")))"; // // Set Named Search // DOCHILD (m_pBCTransition, SetNamedSearch ("State Transition", searchSpec); DOCHILD (m_pBCTransition, Execute (FALSE, FALSE, TRUE)); DOCHILD (m_pBCTransition, Home ()); if (m_pBCTransition->CheckActiveRow () == OK) { // // Valid transition, now validate the rule // // // Get the simple rule expression data // DOCHILD (m_pBCTransition, FieldValue ("Rule Expression - Simple", ruleExpr)); 5 if ( I ruleExpr. IsEmpty 0 && ! EvalBoolExpr (ruleExpr)) { err = IDS_ERR_STATE_TRANΞITION_RULE_VALIDATION; errParmArray.Add (ruleExpr) ; errParmArray.Add (oldFieldData) ; 10 errParmArray.Add (newFieldData) ; goto ll_abort; } ! 10-: " II Get the rule expression data // DOCHILD (m_pBCTransition, FieldValue ("Rule Expression", ruleExpr)); if (! ruleExpr .IsEmpty 0 && ! EvalBoolExpr (ruleExpr)) 20 { err = IDS_ERR_STATE_TRANSITION_RULE_VALIDATION; errParmArray.Add (ruleExpr) ; errParmArray.Add (oldFieldData) ; errParmArray.Add (newFieldData) ; 25 goto ll_abort; } } else 30 { // // Check the "State Restrict Transition Flag" for this field // if Restrict Transition is not checked this state then return OK; // Otherwise current transtion is a Invalid transition 35 if ( ! IsRestrictTransition (pFieldName, oldFieldData) ) { DOCHILD (m_pBCTransition, SetNamedSearch ("State Transition", searchSpecRT) ) ; 40 DOCHILD (m_pBCTransition, Execute (FALSE, FALSE, TRUE)); DOCHILD (m_pBCTransition, Home ()); if ( !m_pBCTransition->CheckActiveRow 0 == OK) return (OK) ; 45 else { DOCHILD (m_pBCTransition, FieldValue ("Public Flag", ieldData)); if (fieldData == "Y") return (OK) ; 50 } } // // Invalid transition 55 // err = IDS_ERR_STATE_TRANSITION_NO_PRIVILEGE; errParmArray.Add (oldFieldData) ; errParmArray.Add (newFieldData) ; 60 goto ll_abort; ll_abort : 65 SetErrorMsg (err, errParmArray, pErrChild) ; return (err) ; } 70 // // CSSBCBase :: EvalBoolExpr // // Purpose: n 10ι " II Returns TRUE if the logic of the expression is TRUE; Otherwise returns FALSE. // BOOL CSSBCBase: : EvalBoolExpr (CString strExpr) { ErrCode err = OK; CSSObject* pErrChild = NULL; CSSDatum* pDatum = NULL; // Evaluate () result CSSRecord* pRecord; GetActiveRecord (pRecord) ; DOCHILD (m_pRuleExpr, Parse (StrExpr) ) ; DOCHILD (m_pRuleExpr, Evaluate (pDatum, pRecord, NULL) ) ; if (pDatum->IsKindOf (RUNTIME_CLASS (CSSBool) ) ) return (*( (CSSBool*) pDatum)); ll_abort : SetErrorMsg (err, NULL, pErrChild) ; return (FALSE) ; } // CSSBCBase ::CanDeleteUpdate // // Purpose: // // Check if we can perform the Delete on this record or Update on this field. // BOOL CSSBCBase: :CanSMDeleteUpdate (SMDeleteUpdate type, LPCSTR pFieldName) ErrCode err = OK; CSSObject* pErrChild = NULL; if (ImJbStateModel) return (TRUE) ; if (m_mapStateModel.GetCount () > 0) POSITION posSM; CString strFieldName ; CString strStateName; CString StrFieldData; CString fieldData; StateModel* pSM = NULL; StateRestriction* pSR = NULL; if (type == SMUpdate) // // If current field is a state field then update is allowed // m_mapStateModel. Lookup (pFieldName, (CObject*&) pSM) ; if (pSM) return (TRUE) ; } for (posSM = mjnapStateModel.GetStartPosition (); posSM; ) m_mapStateModel.GetNextAssoc (posSM, strFieldName, (CObject*&) pSM) ; FieldValue (strFieldName, StrFieldData) ; if (pSM->m bLOVPickList) { // // Convert LOV Val to Name // DOCHILD (m_pModel, GetLovValName (strFieldData, pSM->m_LOVTypeValue, fieldData)), } else fieldData = strFieldData; pSM- m_mapStateRestriction. ookup (fieldData, (void*&) pSR) ; if (pSR) if (type == SMDelete) { if (pSR->m_bRestrictDelete) return (FALSE) ; else if (type == SMUpdate) { if (pSR->m_bRestrictUpdate) return (FALSE) ; else// if (type == SMDeleteOrUpdate) { if (pΞR- >m_bRestrictDelete | | pSR- >m_bRestrictUpdate) return (FALSE) ; } ll_abort : return (TRUE) ; // // CSSBCBase: : IsRestrictTransition // // Purpose: // // Is the Restrict Transition Flag set for this field. // BOOL CSSBCBase: : IsRestrictTransition (LPCSTR pFieldName, CString StrFieldData) { ErrCode err = OK; CSSObject* pErrChild = NULL; CString fieldData; if ( !m_bStateModel) return (FALSE) ; if (m_mapStateModel.GetCount () > 0) { StateModel* pSM = NULL; StateRestriction* pSR = NULL; // // Is the Restrict Transition Flag set for this field. // m_mapStateModel . Lookup (pFieldName, (CObject*&) pSM) ; if (pSM->m_bLOVPickList) { // // Convert LOV Val to Name DOCHILD (m_pModel, GetLovValName (strFieldData, pΞM->m_LOVTypeValue, fieldData); } else fieldData = strFieldData; pSM->m_mapStateRestπctιon Lookup (fieldData, (voιd*&) pSR) , if (pSR && pΞR->m_bRestrιctTrans tιon) return (TRUE) , ll_abort return (FALSE) , Appendix C - Sales Assistant Class Definition : /////////////////////////////////////////////////////////////////////////////// // // bcactplan h Activity Plan Business Component core class // definitions // // /////////////////////////////////////////////////////////////////////////////// #ιfndef BCACTPLAN H #defme BCACTPLAN_H #ιfndef BCBASE_H #mclude "bcbase h" #endιf class SΞ_EXPORT_CLAΞS CSSBCActivityPlan public CSSBCBase { SS_DECLARE_DYNCREATE (CSSBCActivityPlan) friend class CSSBusComp, friend class CSSBusOb 3 , protected CSSBCActivityPlan (void) , virtual -CSSBCActivityPlan (void) , virtual ErrCode ΞqlSetFieldValue (LPCSTR pFieldName, LPCSTR pFieldData) , virtual ErrCode GetPickList (LPCSTR pFieldName, CSSBusComp*& pPickList) , virtual ErrCode CopyActivityTemplate (LPCSTR pFieldData) , virtual ErrCode RescheduleActivities (LPCSTR pFieldName, LPCSTR pNewFieldValue = NULL) #endιf // BCACTPLAN_H_ minium III iiiiiiiiiiimiii iiiiiiiiiiiiimiiiiiiii i iiiiiiiiiim II II bcassess h Sales Assistants - Assessment // // FILE bcassess h // $Revιsιon 5 $ ///////////////////////////////////////////////////////////////////////////// #ιfndef BCASSEΞS_H #defme BCASSESS H #ιfndef BUSCOMP_H #mclude "buscomp h" #endιf #ιfndef BCBASE H #mclude "bcbase h" #endιf #ιfndef SQLOBJ_H_ #mclude "sqlob 3 h" #endιf class SS EXPORT CLASS CSSBCAssessValue public CSSBCBase { SS DECLARE DYNCREATE (CSSBCAssessValue) friend class CSSBusComp, friend class CSSBusOb] , protected CSSBCAssessValue (void) , virtual -CSSBCAssessValue (void) , private ErrCode ΞumScore (void) ; public: virtual ErrCode SqlWriteRecord (void) ; virtual ErrCode SqlUndoRecord (void) ; virtual ErrCode SqlDeleteRecord(CSSRecord* pRecord) } ; class SS_EXPORT_SSEBCCLASΞ CSSBCAssess : public CSSBusComp { SS DECLARE DYNCREATE (CSSBCAssess) friend class CSSBusComp; friend class CSSBusObj ; protected: CSSBCAssess (void) ; virtual -CSSBCAssess (void) ; private : ErrCode CopyAttributes (void) ; public : virtual ErrCode SqlWriteRecord (void) ; virtual BOOL CanUpdate (LPCSTR pFieldName) ; } ; #endif // __BCASΞESS_H__ While the invention has been described with respect to certain preferred embodiments and exemplifications, it is not intended to limit the scope of the invention thereby, but solely by the claims appended hereto.

Claims: We claim: 1. A method of preparing a state model defining the behavior of logical objects in a process model as a set of permitted states and a set of permitted transitions between the permitted states, and comprising the steps of: (1) selecting a template for the state model; (2) selecting business object components for the state model; (3) selecting or defining state transitions for the state model; (4) defining permitted state transitions from a "from state" to a "to state" with a State Transition Rule name; (5) associating state transitions with state transition rules, names, and conditions; (6) enumerating the state transition names and state transition rule names; and (7) extracting the state transition rules from a database; wherein said states, transitions, and extracted rules comprise a state machine execution engine; and (8) processing a model through said state machine execution engine. 2. The method of claim 1 wherein at least one of said state transition rules include prerequisites which must be met before the transition is permitted. 3. The method of claim 1 wherein at least one of said state transition rules define authorized users for effecting a state transition. 4. The method of claim 1 wherein said objects are business objects that define a sales pipeline funnel model of a set of business deals. 5. The method of claim 4 wherein said sales pipeline funnel shows business deals being worked in different methodologies on a single sales pipeline graphic. 6. The method of claim 5 wherein said methodologies are chosen from the group consisting of telesales process deals, strategic deals, and standard process deals. 7. The method of claim 5 comprising grouping business deals by sales methodology. 8. The method of claim 5 comprising classifying deals. 9. The method of claim 8 comprising classifying deals as qualifying deals, working deals, and closing deals. 10. The method of claim 5 comprising creating a sales opportunity. 11. The method of claim 10 comprising creating a sales method. 12. The method of claim 11 comprising breaking the sales method into sales cycles within the sales method. 13. The method of claim 12 comprising breaking the sales cycles down into sales phases for each sales cycle. 14. The method of claim 11 comprising associating a sales method with a sales opportunity. 15. The method of claim 14 comprising advancing the sales opportunity based upon the associated sales method. 16. The method of claim 15 comprising sorting sales opportunities. 17. The method of claim 16 comprising sorting and grouping sales opportunities by at least one of sales methods, cycles, and phases. 18. The method of claim 17 comprising passing the data, grouped by one or more of sales method, sales cycle, and deal phase, to a charting engine, and from the charting engine to the Sales Pipeline Funnel Chart. 19. The method of claim 1 further comprising monitoring the state of deal as it moves from state to state. 20. The method of claim 19 comprising monitoring the state of a deal to determine additional actions with respect to the deal. 21. The method of claim 19 comprising assigning activity and assessment templates to a deal in process. 22. The method of claim 21 comprising assessing the deal using the assigned activity and assessment templates. 23. A system running on at least one computer for preparing a state model defining the behavior of logical objects in a process as a set of permitted states and a set of permitted transitions between the permitted states, and said system configured to: (1) select a template for the state model; (2) select object components for the state model; (3) select or define state transitions for the state model; (4) define permitted state transitions from a "from state" to a "to state" with a State Transition Rule name; (5) associate state transitions with state transition rules, names, and conditions; (6) enumerate the state transition names and state transition rule names; and (7) extract the state transition rules from a database; wherein said states, transitions, and extracted rules comprise a state machine execution engine; and (8) process a model through said state machine execution engine. 24. The system of claim 23 wherein at least one of said state transition rules include prerequisites which must be met before the transition is permitted. 25. The system of claim 23 wherein at least one of said state transition rules define authorized users for effecting a state transition. 26. The system of claim 23 wherein said objects are business objects defining a sales pipeline funnel model of a set of business deals. 27. The system of claim 26 wherein said sales pipeline funnel shows business deals being worked in different methodologies on a single sales pipeline graphic. 28. The system of claim 27 wherein said methodologies are chosen from the group consisting of telesales process deals, strategic deals, and standard process deals. 29. The system of claim 27 wherein the system is configured to grouping business deals by sales methodology. 30. The system of claim 27 wherein the system is configured to classify deals. 31. The system of claim 30 wherein the system is configured to classify deals as qualifying deals, working deals, and closing deals. 32. The system of claim 27 wherein the system is configured to create a sales opportunity. 33. The system of claim 32 wherein the system is configured to create a sales method. 34. The system of claim 33 wherein the system is configured to break the sales method into sales cycles within the sales method. 35. The system of claim 34 wherein the system is configured to break the sales cycles down into sales phases for each sales cycle. 36. The system of claim 33 wherein the system is configured to associate a sales method with a sales opportunity. 37. The system of claim 36 wherein the system is configured to advance the sales opportunity based upon the associated sales method. 38. The system of claim 37 wherein the system is configured to sort sales opportunities. 39. The system of claim 38 wherein the system is configured to sort and group sales opportunities by at least one of sales methods, cycles, and phases. 40. The system of claim 39 wherein the system is configured to pass the data, grouped by one or more of sales method, sales cycle, and deal phase, to a charting engine, and from the charting engine to the Sales Pipeline Funnel Chart. 41 The system of claim 26 wherein the system is configured to monitor the state of deal as it moves from state to state. 42. The system of claim 41 wherein the system is configured to monitor the state of a deal to determine additional actions with respect to the deal. 43. The system of claim 41 wherein the system is configured to assign activity and assessment templates to a deal in process. 44. The system of claim 43 wherein the system is configured to assess the deal using the assigned activity and assessment templates.

Inventors: BRODERSEN KAREN, GROVES BRIAN, YU JAI-JEIN, YU MICHAEL, BRODERSEN, KAREN, GROVES, BRIAN, YU, JAI-JEIN, YU, MICHAEL
Applicants: BRODERSEN KAREN, GROVES BRIAN, SIEBEL SYSTEMS INC, YU JAI JEIN, YU MICHAEL, BRODERSEN, KAREN, GROVES, BRIAN, SIEBEL SYSTEMS, INC., YU, JAI-JEIN, YU, MICHAEL
Application year: 1999
Main classification: G06F153
IPC codes: G05B19, G06F9, G06N5, G06Q10