/* $RCSfile: activity.cxx,v $ * $Revision: 1.5 $ $Date: 2007/08/29 21:48:35 $ * Auth: Jeff Young (jyoung@steptools.com) * Auth: Dave Loffredo (loffredo@steptools.com) * * Copyright (c) 1991-2007 by STEP Tools Inc. * All Rights Reserved. * * Permission to use, copy, modify, and distribute this software and * its documentation is hereby granted, provided that this copyright * notice and license appear on all copies of the software. * * STEP TOOLS MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE * SUITABILITY OF THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING * BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. STEP TOOLS * SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY LICENSEE AS A * RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS * DERIVATIVES. */ #include #include #include #include "date_utils.h" // The ACTIVITY sample program explores the AP-203 design activity // information. The program creates data to document design activity for // a coffee cup product. We show four events in the life of the product. // First we request a new coffee cup design, then we release the initial // design. Next we request a change to the cup and issue the change // order against it. // // 1) Request new coffee cup design -- make_start_request() // 2) Release new coffee cup design -- make_start_order() // // 3) Request a change to the cup design -- make_change_request() // 4) Issue the change to the cup design -- make_change_order() // // The file "activity_out.stp" contains sample output from this program. // // The activity program will create the AP-203 data set and save it as a // Part 21 file called "output_file.stp". This is a text file, so you // can look at it with a text editor or the STEP Part 21 file browser to // see how the information is represented. void make_design_activity(); stp_start_request * make_start_request( stp_product_definition_formation_with_specified_source * part_version, stp_approval * start_approval, stp_person_and_organization * initiator, stp_person_and_organization * receiver, stp_date_and_time * issue_date ); stp_start_work * make_start_order ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * start_approval, stp_start_request * start_req, stp_date_and_time * issue_date ); stp_change_request * make_change_request ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * approval, stp_person_and_organization * initiator, stp_person_and_organization * receiver, stp_date_and_time * issue_date ); stp_change * make_change_order ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * change_approval, stp_change_request * change_req, stp_date_and_time * issue_date ); stp_approval * make_approval ( stp_person_and_organization * approver, stp_date_and_time * approval_date ); int main(int argc, char* argv[]) { /* Force optimizing linkers to bring in all C++ classes */ stp_schema_force_load(); rose_p28_init(); // support xml read/write /* Create a RoseDesign to hold the design activity data */ const char * output_name = "output_file"; RoseDesign * design = new RoseDesign (output_name); /* Give the design some Part 21 header information */ design-> initialize_header(); design-> header_name()-> originating_system ("AP203 Activity Demo"); design-> header_description()-> description ()-> add ("AP-203 Design Activity Sample File"); /* Set as current design. Objects created with pnew go here. */ ROSE.useDesign(design); /* Populate the design with design activity data */ make_design_activity(); // Uncomment the following to write as zip compressed P28 XML // rather than Part 21 ASCII. Change the string "p28-raw" to // write uncompressed XML. The default is "p21". // // design-> format ("p28"); design-> save(); return 0; } void make_design_activity() { // This program shows the AP-203 data used to document some design // activity for a new coffee cup. We show four events in the life // of the product. First we request a new coffee cup design, then // we release the initial design. Next we request a change to the // cup and issue the change order against it. // // SET UP SOME HOUSEKEEPING INFORMATION -- The design activities // must be requested and approved by people, so we create entries // for two people Tom Jones and Sam Smith of the Foo Company. // stp_person_and_organization * tom_jones; stp_person_and_organization * sam_smith; stp_person* pers; stp_organization* org; // Create a couple of people to act as the initiator and the // reciever of the requests. pers = pnew stp_person(); pers-> id("2222"); pers-> first_name("Tom"); pers-> last_name("Jones"); // The organization. org = pnew stp_organization(); org-> name("Foo Co."); org-> description("Foo Co., a fictional company."); // Relate the person to the organization. tom_jones = pnew stp_person_and_organization(); tom_jones-> the_person(pers); tom_jones-> the_organization(org); // Create another person to act as the reciever of these things. // This person will work for the same company as the initiator. pers = pnew stp_person(); pers-> id("3333"); pers-> first_name("Sam"); pers-> last_name("Smith"); // Relate the person to the organization. sam_smith = pnew stp_person_and_organization(); sam_smith-> the_person(pers); sam_smith-> the_organization(org); // CREATE THE PART AND VERSION DATA -- The design activity // information must be associated with a product (part) and // product definition formation (part version). Create a general // coffee cup product and two versions: an initial cup version and // a revised cup version. // // An AP-203 rule requires that the subtype 'product definition // formation with specified source' be used. It is not conformant // to use just a product_definition_formation. stp_product * cup; stp_product_definition_formation_with_specified_source * initial_cup; stp_product_definition_formation_with_specified_source * revised_cup; // Fill in the part number, name, and description. cup = pnew stp_product(); cup-> id ("Cup"); cup-> name ("CoffeeMaster 2000"); cup-> description ("A Coffee Cup"); initial_cup = pnew stp_product_definition_formation_with_specified_source(); initial_cup-> id ("Cup-001"); initial_cup-> description ("initial cup design"); initial_cup-> make_or_buy (stp_source_made); initial_cup-> of_product (cup); revised_cup = pnew stp_product_definition_formation_with_specified_source(); revised_cup-> id ("Cup-002"); revised_cup-> description ("revised cup design"); revised_cup-> make_or_buy (stp_source_made); revised_cup-> of_product (cup); // CREATE A DATE AND TIME -- Many of the design activity things // are associated with a date and time. We create one here for // the current time and reuse it in all of the requests and // approvals. // stp_date_and_time * now = make_current_date_and_time(); // CREATE AN APPROVAL -- The design activities must be approved by // someone. Sam Smith will approve them all. Approvals require a // number of different objects, so we have packaged up the code in // a function for simplicity. // stp_approval * cup_approval = make_approval (sam_smith, now); // ADDITIONAL DATA -- This program only creates a partial AP-203 // data set. For a fully conforming data set, we need additional // information such as an application contexts, product category, // owner, security classification, and a product definition. // // Refer to the AP-203 CC1 sample program to see examples of how // this is done. // DOCUMENT THE DESIGN ACTIVITY -- First we request the coffee cup // design, then we release the initial design. Next we request a // change to the cup and issue the change order against it. // stp_start_request * cup_req; stp_start_work * cup_release; stp_change_request * cup_mod_req; stp_change * cup_mod; // REQUEST NEW COFFEE CUP DESIGN -- cup_req = make_start_request ( initial_cup, // version to be produced cup_approval, // approval for request tom_jones, // requests the cup design sam_smith, // recieves the request now // date of request ); // RELEASE NEW COFFEE CUP DESIGN -- Release the initial design of // the cup. The release order must be tied back to the original // request. cup_release = make_start_order ( initial_cup, // version that was produced cup_approval, // approval for the release cup_req, // original request now // date of issue ); // REQUEST A CHANGE TO THE COFFEE CUP DESIGN -- cup_mod_req = make_change_request ( initial_cup, // version to be changed cup_approval, // approval for request tom_jones, // requests the cup change sam_smith, // recieves the request now // date of request ); // ISSUE THE CHANGE TO THE COFFEE CUP DESIGN -- cup_mod = make_change_order ( revised_cup, // updated version cup_approval, // approval for change release cup_mod_req, // original request now // date of change ); } //====================================================================== // REQUEST A NEW DESIGN -- Generates a start_request for a part // version // stp_start_request * make_start_request( stp_product_definition_formation_with_specified_source * part_version, stp_approval * start_approval, stp_person_and_organization * initiator, stp_person_and_organization * receiver, stp_date_and_time * issue_date ) { // Create the base start_request entity. stp_start_request * start_req = pnew stp_start_request; // RELATE TO A PART VERSION -- A start request is related to the // part version that will result from the request. This somewhat // circular logic, since a record of the version must exist before // we can request that it be designed. There is some indication // that this requirement may be eliminated in future versions of // the AP. The pdfwss is passed into this function. // stp_start_request_item *sri = pnew stp_start_request_item; sri-> _product_definition_formation (part_version); if (!start_req->items()) start_req->items(pnew SetOfstp_start_request_item); start_req->items()->add(sri); // EXPLAIN DETAILS OF THE REQUEST -- The versioned action request // explains details, such as the purpose and expected outcome from // the request. The description explains the work to be done to // develop the design of the part. The purpose explains why the // request has been issued. // stp_versioned_action_request *work_req = pnew stp_versioned_action_request; work_req-> id ("Design Request #12345"); work_req-> version ("original request"); work_req-> description ("Design a coffee mug"); work_req-> purpose ("Produce a cup that satisfies coffee drinkers"); // Tie the details to the start request start_req-> assigned_action_request (work_req); // SPECIFY REQUEST DATE -- Associate a date with the role of // "request_date" to indicate when the request was issued. // stp_cc_design_date_and_time_assignment *ccddnta = pnew stp_cc_design_date_and_time_assignment; ccddnta-> assigned_date_and_time (issue_date); ccddnta-> role (pnew stp_date_time_role ("request_date")); stp_date_time_item *dti = pnew stp_date_time_item; dti-> _start_request (start_req); if (!ccddnta->items()) ccddnta-> items (pnew SetOfstp_date_time_item); ccddnta->items()->add(dti); // SPECIFY REQUEST STATUS -- The status specifies the current // level of completion of the start request. Valid values for the // status of a start request are: proposed, in-work, issued, and // hold. stp_action_request_status *ars = pnew stp_action_request_status; ars-> status ("issued"); ars-> assigned_request (work_req); // SPECIFY A POTENTIAL RESOLUTION -- It is not clear whether we // need to include action methods for the request. Usually, the // only action method is "go design the part". If desired, this // can be included as shown with the change requests. // APPROVE THE REQUEST -- Each work request needs exactly one // approval. An approval hooked to the request by an approved // item and cc_design_approval. One approval can be applied to // many things. The approval assignment ties the approval to the // start request. The approval is passed into the function. // stp_approved_item *ai = pnew stp_approved_item; ai-> _start_request (start_req); // If we wanted to minimize the number of objects, we could search // for an existing ccda for this approval. Here we just create a // new one to be simple. stp_cc_design_approval *ccda = pnew stp_cc_design_approval; ccda-> assigned_approval (start_approval); if (!ccda->items()) ccda->items(pnew SetOfstp_approved_item); ccda->items()->add(ai); // INDICATE PEOPLE WHO MADE/RECIEVE THE REQUEST -- We need to // indicate either a person who initiated the change request or a // person who recieves the request. We will add both, although // only one is necessary. The people are passed into this // function. // create person_organization assignments that tie the initiator // and reciever back to the start request. stp_cc_design_person_and_organization_assignment *ccdpaoa; // these assignments refer to the start request. stp_person_organization_item *poi = pnew stp_person_organization_item; poi-> _start_request (start_req); // REQUEST INITIATOR -- Tom Jones initiated the request ccdpaoa = pnew stp_cc_design_person_and_organization_assignment; ccdpaoa-> assigned_person_and_organization (initiator); ccdpaoa-> role (pnew stp_person_and_organization_role("initiator")); if (!ccdpaoa->items()) ccdpaoa->items (pnew SetOfstp_person_organization_item); ccdpaoa-> items()-> add (poi); // REQUEST RECIPIENT -- Sam Smith is notified of the request ccdpaoa = pnew stp_cc_design_person_and_organization_assignment; ccdpaoa-> assigned_person_and_organization (receiver); ccdpaoa-> role (pnew stp_person_and_organization_role("request_recipient")); if (!ccdpaoa->items()) ccdpaoa->items(pnew SetOfstp_person_organization_item); ccdpaoa-> items()->add(poi); // return the start request object return start_req; } //====================================================================== // RELEASE A DESIGN -- Generates a start_order for the part version // stp_start_work * make_start_order ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * start_approval, stp_start_request * start_req, stp_date_and_time * issue_date ) { // Create the base start_order entity. stp_start_work * start_order = pnew stp_start_work; // RELATE TO THE RELEASED VERSION -- The start order is related to // at least one product definition formation. This is the part // version that was created due to the original request and // subsequent work. The version is passed into the function. // stp_work_item * wi = pnew stp_work_item; wi->_product_definition_formation (part_version); if (!start_order->items()) start_order->items (pnew SetOfstp_work_item); start_order->items()->add(wi); // DETAIL HOW THE REQUEST WAS SATISFIED -- The start order // references a directed_action that details how the request is // satisfied. This ties the action directive to the method used // to fulfil it. It describes WHAT we want to do (action // directive) and HOW we want to do it (action_method). // // It is unclear whether a method is required for a start order, // so we leave this field empty. // stp_directed_action * work_order = pnew stp_directed_action; start_order-> assigned_action (work_order); // ORDER THE RELEASE -- The action directive identifies the formal // documentation supporting release of the design. The comment // field has statements that support the release of the design. // Analysis identifies the results of any assessment that was // performed to validate the design requests. // stp_action_directive *ad = pnew stp_action_directive; ad-> name("Document C123"); ad-> comment ("This is a great coffee cup"); ad-> analysis ("Report #XYX123 (assessment of the design)"); // Tie the action directive to the original action request so that // we can see why this was done and who asked for it. if (!ad->requests()) ad->requests(pnew Set(stp_versioned_action_request)); ad-> requests()-> add (start_req-> assigned_action_request()); // Tie the action directive to the work order work_order->directive (ad); // ADOPT A SOLUTION -- As noted in the start request code, it is // not clear whether an action method is meaningful for a start // order. If you create one for "design the part", hook it into // the chosen_method field of the directed action. See the change // order for a real example. // SPECIFY THE DATE -- A start order must indicate the date that // work begins. This is done using a date and time assign with a // role of "start_date". We can optionally indicate when the work // is complete, using a date with the role of "release_date". // stp_cc_design_date_and_time_assignment *ccddnta = pnew stp_cc_design_date_and_time_assignment; ccddnta-> assigned_date_and_time (issue_date); ccddnta-> role (pnew stp_date_time_role ("start_date")); stp_date_time_item *dti = pnew stp_date_time_item; dti-> _start_work (start_order); if (!ccddnta->items()) ccddnta->items(pnew SetOfstp_date_time_item); ccddnta-> items()-> add (dti); // PROVIDE AN APPROVAL -- The start order needs an approval. As // with the start request, the approval is related by an approved // item in a cc_design_approval object. One approval can be // applied to many things. The approval assignment ties the // approval to the start request. The approval is passed into the // function. // stp_approved_item *ai = pnew stp_approved_item; ai-> _start_work (start_order); // If we wanted to minimize the number of objects, we could search // for an existing ccda for this approval. Here we just create a // new one to be simple. stp_cc_design_approval *ccda = pnew stp_cc_design_approval; ccda-> assigned_approval (start_approval); if (!ccda->items()) ccda-> items (pnew SetOfstp_approved_item); ccda-> items()-> add(ai); // return the start order return start_order; } // ====================================================================== // REQUEST A CHANGE TO THE COFFEE CUP DESIGN -- // stp_change_request * make_change_request ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * change_approval, stp_person_and_organization * initiator, stp_person_and_organization * receiver, stp_date_and_time * issue_date ) { // Create the base change_request entity. stp_change_request *change_req = pnew stp_change_request; // RELATE TO A PART VERSION -- A change request refers to the // original part versions that require the change. The part // version is passed into this function. // stp_change_request_item *sri = pnew stp_change_request_item; sri-> _product_definition_formation (part_version); if (!change_req->items()) change_req->items(pnew SetOfstp_change_request_item); change_req->items()->add(sri); // EXPLAIN THE REQUEST DETAILS -- The versioned action request // explains details, such as the purpose and expected outcome from // the request. This is used for both requests for new designs // (start requests) and requests for changes to an existing design // (change requests) // // The description explains the work to be done to develop the // design of the part. The purpose explains why the request has // been issued. The version applied to the request itself and is // used to identify reissued change requests. // stp_versioned_action_request *work_req = pnew stp_versioned_action_request; work_req-> id ("Revision Request #12345"); work_req-> version ("original request"); work_req-> description ("Modify into a three-handled coffee mug"); work_req-> purpose ("Produce a cup that satisfies three-armed customers"); // Tie the details to the change request change_req->assigned_action_request(work_req); // SPECIFY REQUEST DATE -- The date when the request was issued. // stp_cc_design_date_and_time_assignment *ccddnta = pnew stp_cc_design_date_and_time_assignment; ccddnta-> assigned_date_and_time (issue_date); ccddnta-> role (pnew stp_date_time_role ("request_date")); stp_date_time_item *dti = pnew stp_date_time_item; dti->_change_request(change_req); if (!ccddnta->items()) ccddnta->items (pnew SetOfstp_date_time_item); ccddnta-> items()-> add (dti); // SPECIFY REQUEST STATUS -- The status specifies the current // level of completion of the start request. Valid values for the // status of a start request are: proposed, in-work, issued, and // hold. stp_action_request_status *ars = pnew stp_action_request_status; ars-> status ("issued"); ars-> assigned_request (work_req); // SPECIFY A POTENTIAL RESOLUTION -- Attatch methods that would // satisfy the requirements described in the change request. A // change request may have more than one recommended_solution. // // The action method name refers to formal documentation for the // proposed solution. The description, consequences, and purpose // describe the method in more detail since a single method could // be used to satisfy many requests. // stp_action_method * fix_method = pnew stp_action_method; fix_method-> name ("Mechanical Attachment"); fix_method-> description ("Attatch two extra handles using big bolts"); fix_method-> consequence ("The original item will no longer be watertight"); fix_method-> purpose ("Add extra handles"); // Attatch the proposed solution method to the original request. stp_action_request_solution * arsol = pnew stp_action_request_solution; arsol-> method (fix_method); arsol-> request (work_req); // APPROVE THE REQUEST -- A work request needs exactly one // approval. The approval is related to the request by an // approved item in a cc_design_approval object. One approval can // be applied to many things. The approval assignment ties the // approval to the start request. The approval is passed into the // function. // stp_approved_item *ai = pnew stp_approved_item; ai->_change_request(change_req); // If we wanted to minimize the number of objects, we could search // for an existing ccda for this approval. Here we just create a // new one to be simple. stp_cc_design_approval *ccda = pnew stp_cc_design_approval; ccda-> assigned_approval (change_approval); if (!ccda->items()) ccda->items(pnew SetOfstp_approved_item); ccda->items()->add(ai); // INDICATE PEOPLE WHO MADE/RECIEVE THE REQUEST -- We need to // indicate either a person who initiated the change request or a // person who recieves the request. We will add both, although // only one is necessary. The people are passed into this // function. // create person_organization assignments that tie the initiator // and reciever back to the change request. stp_cc_design_person_and_organization_assignment *ccdpaoa; // these assignments refer to the start request. stp_person_organization_item *poi = pnew stp_person_organization_item; poi->_change_request(change_req); // REQUEST INITIATOR -- Tom Jones initiated the request ccdpaoa = pnew stp_cc_design_person_and_organization_assignment; ccdpaoa-> assigned_person_and_organization (initiator); ccdpaoa-> role (pnew stp_person_and_organization_role ("initiator")); if (!ccdpaoa->items()) ccdpaoa->items(pnew SetOfstp_person_organization_item); ccdpaoa-> items()->add(poi); // REQUEST RECIPIENT -- Sam Smith is notified of the request ccdpaoa = pnew stp_cc_design_person_and_organization_assignment; ccdpaoa-> assigned_person_and_organization (receiver); ccdpaoa-> role (pnew stp_person_and_organization_role ("request_recipient")); if (!ccdpaoa->items()) ccdpaoa->items(pnew SetOfstp_person_organization_item); ccdpaoa-> items()->add(poi); // return the change request return change_req; } // ====================================================================== // ISSUE A CHANGE TO THE COFFEE CUP DESIGN -- // stp_change * make_change_order ( stp_product_definition_formation_with_specified_source * part_version, stp_approval * change_approval, stp_change_request * request, stp_date_and_time * issue_date ) { // Create the base start_order entity. stp_change * change_order = pnew stp_change; // RELATE TO THE REVISED VERSION -- The change order refers to the // resulting part versions. The updated part version is passed in // as a parameter to this function. // stp_work_item *wi = pnew stp_work_item; wi-> _product_definition_formation (part_version); if (!change_order->items()) change_order-> items (pnew SetOfstp_work_item); change_order->items()-> add (wi); // DETAIL HOW THE REQUEST WAS SATISFIED -- The change order // references a directed_action that details how the request is // satisfied. This ties the action directive to the method used // to fulfil it. It describes WHAT we want to do // (action_directive) and HOW we want to do it (action_method). // stp_directed_action * work_order = pnew stp_directed_action; change_order-> assigned_action (work_order); // ORDER THE RELEASE -- The action directive identifies the formal // documentation that says to release the change. The comment // includes any pertinent commentary that supports the release of // the change. The analysis identifies any assessment that was // performed to validate the change request. // stp_action_directive *ad = pnew stp_action_directive; ad->name("Document #123"); ad->comment ("The bolted on handles work sufficiently well"); ad->analysis ("Report #ABC (extra handle study)"); // Tie the action directive to the original action request so that // we can see why this was done and who asked for it. if (!ad->requests()) ad-> requests (pnew Set(stp_versioned_action_request)); ad-> requests()-> add (request-> assigned_action_request()); // Tie the action directive back to the work order work_order-> directive (ad); // ADOPT A SOLUTION -- A change request can recommend many // different solutions. The change order must pick one of these // as the adopted solution. We search through the database and // pick one the first solution we find. Obviously, in a real // application, we would choose a solution with more care. // RoseObject * obj; RoseDesignCursor objects; // Look at all of the action request solutions objects.traverse (ROSE.design()); objects.domain (ROSE_DOMAIN(stp_action_request_solution)); while (obj = objects.next()) { stp_action_request_solution * sol = ROSE_CAST (stp_action_request_solution,obj); // the action request solution is associated with our original // change request, select it as our chosen method and move on. // if (sol->request() == request->assigned_action_request()) { work_order-> chosen_method (sol->method()); break; } } if (!work_order->chosen_method()) printf ("Could not find a recommended solution for this change\n"); // SPECIFY THE DATE -- A start order must indicate the date that // work begins. This is done using a date and time assign with a // role of "start_date". We can optionally indicate when the work // is complete, using a date with the role of "release_date". // // Note that the AP-203 mapping tables incorrectly say that a // change requires a 'change_date'. This should be ignored. The // AP-203 global rule 'change_requires_date_time' clearly states // that the role should be 'start_date'. // stp_cc_design_date_and_time_assignment *ccddnta = pnew stp_cc_design_date_and_time_assignment; ccddnta-> assigned_date_and_time (issue_date); ccddnta-> role (pnew stp_date_time_role ("start_date")); stp_date_time_item *dti = pnew stp_date_time_item; dti-> _change (change_order); if (!ccddnta->items()) ccddnta->items(pnew SetOfstp_date_time_item); ccddnta-> items()-> add (dti); // PROVIDE AN APPROVAL -- The change needs an approval. The // approval object is passed into the function. // stp_approved_item *ai = pnew stp_approved_item; ai-> _change (change_order); // If we wanted to minimize the number of objects, we could search // for an existing ccda for this approval. Here we just create a // new one to be simple. stp_cc_design_approval *ccda = pnew stp_cc_design_approval; ccda-> assigned_approval (change_approval); if (!ccda->items()) ccda-> items(pnew SetOfstp_approved_item); ccda-> items()-> add(ai); // done return change_order; } // CREATE AN APPROVAL -- Create an approval and all of the supporting // information that must go along with it. // stp_approval * make_approval ( stp_person_and_organization * approver, stp_date_and_time * approval_date ) { stp_approval * app = pnew stp_approval(); // Assign an approval level - there's no standard mapping for this // perhaps your organization has different kinds of approvals which // might be specified here. Otherwise, leave it empty. app-> level ("approved for release"); // assign an approval status - this is restricted to approved, // not_yet_approved, disapproved, or withdrawn by a rule in AP-203. stp_approval_status* app_stat = pnew stp_approval_status(); app_stat-> name ("approved"); app-> status (app_stat); // An approval requires an approval_person_organization to // identify the person responsible for approving the various // items. Sam Smith approves these items. stp_approval_person_organization* app_po = pnew stp_approval_person_organization(); stp_person_organization_select* po_select = pnew stp_person_organization_select(); po_select-> _person_and_organization (approver); app_po-> person_organization (po_select); app_po-> authorized_approval (app); // The approval_person_organization has a role which can be used to // specify different roles in the approval process. If there is no // special role, approver is recommended. app_po-> role (pnew stp_approval_role ("approver")); // The approval_person_organization should have a // cc_design_date_and_time_assignment to signify when the person // acted in the role specified by the approval_person_organization // on a particular date. Here the date with the // role of sign_off_date. stp_cc_design_date_and_time_assignment* sign_off_date = pnew stp_cc_design_date_and_time_assignment(); sign_off_date-> role (pnew stp_date_time_role ("sign_off_date")); sign_off_date-> assigned_date_and_time (approval_date); stp_date_time_item * dti = pnew stp_date_time_item(); dti->_approval_person_organization(app_po); sign_off_date-> items (pnew SetOfstp_date_time_item()); sign_off_date-> items()-> add(dti); // In addition to dating the approval_person_organization, the // approval itself needs to be dated. This date is the date of the // most recent activity. If there are multiple steps in the // approval process, many approval_person_organizations will exists, // each with its own date. However, this date will record the most // recent change to approval status. Note that date_time is a // select. stp_approval_date_time * app_dt = pnew stp_approval_date_time(); stp_date_time_select * dt_select = pnew stp_date_time_select(); dt_select-> _date_and_time (approval_date); app_dt-> date_time (dt_select); app_dt-> dated_approval (app); return app; }