Lifecycle Sample
As an example let's take software development lifecycle process.
Assumptions:
We assume that the following user roles are in the system:
- Team Lead
- Software Developer
- QA Lead
- Project Manager
- End users
So in this example scenario, the Software Developer does the following tasks.
- Complete the code
- Create WSDL, Schema
- Create QoS
Once above tasks are completed, the Team Lead should verify the Development status. Subsequently, once the Team Lead has verified the status, the changes can be moved to the Testing environment.
To run this lifecycle sample:
The Lifecycle starts off in the Development state and it can be defined as follows:
<state id="Development"> </state>
Once the Development state is complete, it is moved to the Testing state. So the Lifecycle configuration XML file is updated as follows:
<state id="Development"> <transition event="Promote" target="Tested"/> </state>
Here the target state is the Testing state and it is listed as "Tested". The Lifecycle configuration file is updated as follows:<state id="Development"> <transition event="Promote" target="Tested"/> </state> <state id="Tested"> </state>
In the above sample scenario, identify that the Developer's tasks (checking activities) are "Code Completed", "WSDL, Schema Created" and "QoS Created". These items can be defined as shown below.Â
These checkItems are displayed as check boxes.
<datamodel> <data name="checkItems"> <item name="Code Completed" forEvent=""></item> <item name="WSDL, Schema Created" forEvent=""></item> <item name="QoS Created" forEvent=""></item> </data> </datamodel>
If we need to restrict moving from the Development phase to the Testing phase after all developer events are completed, we can add the "forEvent" value. The "forEvent" value is a transition event which is defined in step 2. After applying the forEvent value, and once all the check boxes are checked, the Transition event related button displays.
<datamodel> <data name="checkItems"> <item name="Code Completed" forEvent="Promote"></item> <item name="WSDL, Schema Created" forEvent="Promote"></item> <item name="QoS Created" forEvent="Promote"></item> </data> </datamodel>
The final state configuration is as follows:
<state id="Development"> <datamodel> <data name="checkItems"> <item name="Code Completed" forEvent="Promote"></item> <item name="WSDL, Schema Created" forEvent="Promote"></item> <item name="QoS Created" forEvent="Promote"></item> </data> </datamodel> <transition event="Promote" target="Tested"/> </state>
The next step is to restrict the lifecycle state transition until the required approval vote is granted. The lifecycle approval process can be defined under the "datamodel" element. The "forEvent" value is a transition event and vote values are required. In this example, lifecycle transition vote is restricted to the Team Lead role and the Development to QA transition requires two votes from the Team Lead role.Â
<data name="transitionApproval"> <approval forEvent="Promote" roles="lead" votes="2"/> </data>
After this modification, the lifecycle configuration file is as follows:
<state id="Development"> <datamodel> <data name="checkItems"> <item name="Code Completed" forEvent="Promote"></item> <item name="WSDL, Schema Created" forEvent="Promote"></item> <item name="QoS Created" forEvent="Promote"></item> </data> <data name="transitionApproval"> <approval forEvent="Promote" roles="lead" votes="2"/> </data> </datamodel> <transition event="Promote" target="Tested"/> </state> <state id="Tested"> </state>
- In the Testing state, the QA lead verifies the following activities:Â
- Effective Inspection Completed
- Test Cases Passed
- Smoke Test Passed
Further to this, there are two lifecycle transition states in the QA environment. If the required functionality is not working, it is demoted to Development or if it is working fine, it can be moved to the Production environment. Once QA tasks are completed, the QA Lead needs to vote it into the required lifecycle transition. The Testing state is defined as follows:
<state id="Development"> </state> <state id="Tested"> <datamodel> <data name="checkItems"> <item name="Effective Inspection Completed" forEvent=""></item> <item name="Test Cases Passed" forEvent=""></item> <item name="Smoke Test Passed" forEvent=""></item> </data> <data name="transitionApproval"> <approval forEvent="Promote" roles="qalead" votes="2"/> </data> </datamodel> <transition event="Demote" target="Development"/> <transition event="Promote" target="Production"/> </state> <state id="Production"> </state>
Once the product is in the Production environment, the Project Manager or one with a similar role can move this resource to Development or retire it. It is defined as follows:
<state id="Production"> <datamodel> <data name="transitionPermission"> <permission forEvent="Demote" roles="pro-manager">Â </permission> </data> </datamodel> <transition event="Demote" target="Tested"/> </state>
The final lifecycle configuration file is as follows:
<aspect name="ServiceLifeCycle" class="org.wso2.carbon.governance.registry.extensions.aspects.DefaultLifeCycle"> <configuration type="literal"> <lifecycle> <scxml xmlns="http://www.w3.org/2005/07/scxml" version="1.0" initialstate="Development"> <state id="Development"> <datamodel> <data name="checkItems"> <item name="Code Completed" forEvent="Promote"></item> <item name="WSDL, Schema Created" forEvent="Promote"></item> <item name="QoS Created" forEvent="Promote"></item> </data> <data name="transitionApproval"> <approval forEvent="Promote" roles="lead" votes="2"/> </data> </datamodel> <transition event="Promote" target="Tested"/> </state> <state id="Tested"> <datamodel> <data name="checkItems"> <item name="Effective Inspection Completed" forEvent=""> </item> <item name="Test Cases Passed" forEvent=""> </item> <item name="Smoke Test Passed" forEvent=""> </item> </data> <data name="transitionApproval"> <approval forEvent="Promote" roles="qalead" votes="2"/> </data> </datamodel> <transition event="Promote" target="Production"/> <transition event="Demote" target="Development"/> </state> <state id="Production"> <datamodel> <data name="transitionPermission"> <permission forEvent="Demote" roles="pro-manager"> </permission> </data> </datamodel> <transition event="Demote" target="Tested"/> </state> </scxml> </lifecycle> </configuration> </aspect>