Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Each lifecycle configuration contains one or more state elements. More information on lifecycle configuration and the various elements in it, can be found in Configuring Lifecycles.The You can use client-side scripting support is available for the lifecycle state transition event . This can be done by adding something similar to the following under the state datamodel element.

Code Block

<js><data name="transitionScripts">
    <!--name - defines that this element contains the set of transition scripts. It is required to be set to 'transitionScripts'-->
        <js forEvent="">
            <!--forEvent - defines the event that this script block will execute-->
            <console promoteFunctionfunction="myFunction">
                <!--function - defines the name of the function-->
                <script type="text/javascript">
                    <!--contains the script-->
     myFunction = function() {        </script>
            <//console>
executable script           <server function="">
    }             <<script type="text/javascript"></script>
            </console>server>
        </js>
 </data>

Here Following is an example on how to add an alert for for the state transition from Initialize to Designed of how to make a redirection after a "Promote" is done in the default ServiceLifeCycle.

1. Edit the existing lifecycle by adding the configuration below.

Code Block

<aspect name="ServiceLifeCycle" class="org.wso2.carbon.governance.registry.extensions.aspects.ChecklistLifeCycle">.DefaultLifeCycle">
    <configuration type="literal">
        <lifecycle>
            <scxml xmlns="http://www.w3.org/2005/07/scxml"
                   version="1.0"
                   initialstate="Development">
            <configuration type    <state id="literal">
Development">
                    <datamodel>
                        <data name="checkItems">
           <lifecycle>                 <state<item name="Code Completed" forEvent="Initialize" location="/environment/init">">
                                <!--<permissions>
                                    <permission roles=""/>
                                </permissions>
                                <validations>
                                    <validation forEvent="" class="">
                                        <parameter <checkitem>Requirements Gathered</checkitem>name="" value=""/>
                                   <checkitem>Architecture Finalized</checkitem></validation>
                             <checkitem>High Level Design Completed</checkitem></validations>-->
                            </item>
      <js>                      <item name="WSDL, Schema <consoleCreated" promoteFunctionforEvent="myFunction">
                            </item>
                             <script type="text/javascript"><item name="QoS Created" forEvent="">
                            </item>
         myFunction = function() {            </data>
                        alert("Promoted Resource to Designed State");<!--<data name="transitionValidation">
                            <validation forEvent="" class="">
                                <parameter  }name="" value=""/>
                            </script>validation>
                        </console>data>
                        <data name="transitionPermission">
                            <permission  </js>forEvent="" roles=""/>
                        </state>data>-->
                       <state<data name="transitionScripts">
		                <js forEvent="Designed" location="/environment/design">"Promote">
		                    <console function="doPromote">
		                        <script type="text/javascript">
		                              doPromote = function() {
		                                window.location = unescape("../listService/service.jsp?region=region3%26item=governance_list_services_menu");
		                                        }
		                        </script>
		                     </console>
		                  </js>                            
		       <checkitem>Code Completed</checkitem></data>                   
                  <checkitem>WSDL, Schema Created<</checkitem>datamodel>
                    <transition <checkitem>QoS Created</checkitem>event="Promote" target="Tested"/>                  
                </state>
                <state nameid="Created" location="/environment/development">Tested">
                    <datamodel>
                        <data name="checkItems">
                            <item <checkitem>Effectivename="Effective Inspection Completed</checkitem> Completed" forEvent="">
                          <checkitem>Test Cases Passed</checkitem></item>
                            <checkitem>Smoke<item name="Test Passed</checkitem> Cases Passed" forEvent="">
                            </state>item>
                            <state<item name="TestedSmoke Test Passed" locationforEvent="/environment/qa">">
                            </item>
              <checkitem>Service Configuration</checkitem>          </data>
                    </state>datamodel>
                    <state<transition nameevent="DeployedPromote" locationtarget="Production"/environment/prod">
                    <transition <checkitem>Service Configuration</checkitem>event="Demote" target="Development"/>
                </state>
                <state nameid="Deprecated" location="/environment/support" />Production">  
                    <transition event="Demote" target="Tested"/>
             </lifecycle>   </state>                
            </scxml>
        </configuration>lifecycle>
    </configuration>
</aspect>

2. After saving this configuration (See see Adding Lifecycles), add the ServiceLifeCycle to a Service (or any other resource/collection). See Managing Lifecycle.

3. Tick Select all the check-boxes, and click on the "Promote" button. See Managing Lifecycle.

4. You will get an information dialog followed by the alert added.be redirected to the Service list. You can add any valid executable JavaScript that is capable of performing some task that to perform the task you require.

Excerpt
hiddentrue

Instructions on how to handle client-side scripting for lifecycles in the Governance Registry.