D Default Template Example

This appendix contains an example that shows how to create two default templates for a ticketing connector and shows the completed templates:

Listed below are the steps that would be taken to create the templates.

  1. Study data in external ticketing application.

    The first step is to study the web service for the external ticketing application and determine what fields are available and what the data looks like in those fields.

    Study of the web service WSDL shows that the root element for create requests is createRequest and the root element for update requests is updateRequest. The namespace for both is http://samplecompany.com. The WSDL also shows that there are four required fields on a create. These fields are summary, description, severity, and assignment group. The severity field must be a numeric value from 1 to 5. Where 1 is the highest and 5 is the lowest. We have decided to just populate the required fields on the create request.

    For the update, only the identifier field and a history log field are required. We will be specifying those fields along with the severity field on update requests.

  2. Study data in Enterprise Manager.

    Now that we understand the data required to create/update tickets, we need to understand what data is available in Enterprise Manager and where it is located. Study of the data showed that all of the data that we need is located in the SystemAttributes element. There is a Summary element that has summary information and there is a SeverityCode field that can be used as well. Also included in the SystemAttributes element is target information that we would like to see in the ticket description. Some of the ticket fields will have to be hard coded because there is not sufficient information in the Enterprise Manager incident data.

  3. Determine number of templates and the mapping for each.

    We have decided to create two default templates for our connector. One will leave the ticket open and update the history log whenever the incident in Enterprise Manager is cleared, and the other template will close the ticket.

    The mappings to create the ticket are the same for both templates. Listed below are the mappings that have been identified for the create operation.

    • Summary will be set to the contents of the SystemAttributes/Summary field

    • Description will be set to the contents of the SystemAttributes/Summary field followed by the target information. The target information is located in the SystemAttributes/SourceInfo/TargetInfo element. The target fields that will be included are TargetName, TargetType, and TargetURL.

    • Severity will be set based on the contents of the SystemAttributes/SeverityCode field. If the field is set to FATAL, the severity will be set to 1. If the field is set to CRITICAL, the severity will be set to 2. If the field is set to WARNING, the severity will be set to 3. For all other values the severity will be set to 5.

    • Assignment Group will be hard coded to the Triage team.

    The mappings for a normal update (not cleared) will be the same for both templates as well. Listed below are the mappings that have been identified for the normal update operation.

    • Identifier will be set to the contents of the TicketID field

    • Severity will be set based on the contents of the SystemAttributes/SeverityCode field. The mapping used here will be the same as the create operation.

    • History Entry will be set based on the SystemAttributes/Severity field. The history entry will read "Updates from Enterprise Manager. The severity is now set to" followed by the SystemAttributes/Severity field.

    The mappings for a close operation will be different depending on the template. The template that is not closing the ticket, will use the same mapping as the normal update. The mapping for the template that will close the ticket is listed below.

    • Identifier will be set to the contents of the TicketID field

    • Status will be set to CLOSED

    • History Entry will be set to "Corresponding incident in Enterprise Manager has been cleared."

  4. Create the first template.

    The template that does not close the ticket will be simpler to implement; so, we will work with it first.

    We start the process by copying the contents of the template skeleton from Example 1-6, "Template Skeleton" into our editor. Then we develop the mapping for the create and update requests as shown in Create Mappings and Update Mappings.

    Completed First Template Example shows what the template looks like after we have added our mappings to the skeleton template. Also included in the section are the results of our testing using the sample transactions in Appendix F, "Sample Incident Data." It is important to test the first template thoroughly before using it as a baseline to create other templates.

  5. Create the second template.

    Most of the work was done when we created the first template. To create the second template, we made a copy of the MyApp_Default_Incident.xsl file and renamed the copied file to MyApp_Default_Incident_AutoClose.xsl.

    The only difference between the two templates is in the mapping for the close operation. The first field that needs to be mapped is the Identifier. Listed below is the mapping for the field.

    <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
    

    The next field to be set is the Status field. This will be hard coded to CLOSED.

    <Status>CLOSED</Status>
    

    The last field to set is the HistoryEntry field. This will be hard coded to indicate that the incident in Enterprise Manager has been cleared.

    <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
    

    We added a check to determine whether the update is a close or a normal update. If the SeverityCode is set to CLEAR then we know we need to close the ticket, otherwise we will handle it as a normal update. Listed below is the check that was added.

    <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CLEAR'">
    

    Completed Second Template Example shows what the template looks like after we have added our mappings to handle the ticket close. Also included in the section are the results of our testing using the sample close transaction in Appendix F, "Sample Incident Data."

D.1 Create Mappings

The first mapping that we will develop is for create requests. We will identify the translation logic required for one field at a time. The first field is the Summary field. Listed below is the translation logic required to map this field to the Summary field in the incident.

<Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>

The next field to map is the Description field. It will be comprised of the Summary followed by the target information. Listed below is the mapping for the Description field.

<Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/>
</Description>

The next field to map is the Severity field. Since it will be mapped for the create and update requests, it will be handled a little differently. A variable will be created to hold the mapped severity value and the variable will be used in both mappings. This way there will only be one place to change if the mapping ever changes.

<xsl:variable name="sev">
  <xsl:choose>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
    <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
    <xsl:otherwise>5</xsl:otherwise>
  </xsl:choose>
</xsl:variable>

<Severity><xsl:value-of select="$sev"/></Severity>

The last field to map is the AssigmentGroup field. This one is being hard coded since the incident does not have any information that can be used to determine the appropriate group in the external ticketing application.

<AssignmentGroup>Triage</AssignmentGroup>

D.2 Update Mappings

The first field to map is the Identifier field. It will be set to the incident TicketID field. Listed below is the mapping for this field.

<Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>

The next field to map is the Severity field. Since the sev variable was created earlier, it will just require setting the field to the variable contents.

<Severity><xsl:value-of select="$sev"/></Severity>

The last field is the HistoryEntry field. Notice that it is using Severity instead of SeverityCode. The SeverityCode field is an internal representation of the severity values and has fixed values. The Severity field in the incident data is locale specific so the value in this field will vary depending on the locale. The SeverityCode field should be used when checking for certain severity values and the Severity field should be used when displaying the severity.

<HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>

D.3 Completed Templates

The following examples show a completed template:

D.3.1 Completed First Template Example

Listed below is the completed template using the mappings shown earlier in this section. The filename for the template is MyApp_Default_Incident.xsl.

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
 
  <xsl:template match="emcf:EMIncident">
    <xsl:variable name="sev">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
        <xsl:otherwise>5</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
 
    <xsl:choose>
      <xsl:when test="normalize-space(emcf:TicketID) = ''">
 
        <!-- CREATE Request -->
        <createRequest xmlns="http://samplecompany.com">
          <Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>
          <Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></Description>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <AssignmentGroup>Triage</AssignmentGroup>
        </createRequest>
 
      </xsl:when>
      <xsl:otherwise>
 
        <!-- UPDATE Request -->
        <updateRequest xmlns="http://samplecompany.com">
          <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>
        </updateRequest>
 
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

Listed below is the output from the template using the "Sample Create Transaction" data from Appendix F, "Sample Incident Data," as input.

<?xml version="1.0" encoding="UTF-8"?>
<createRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xmlns.mycompany.com/sysman/connector">
   <Summary>Memory Utilization is 70.518%, crossed warning (20) or critical (30) threshold.</Summary>
   <Description>Incident created in Enterprise Manager: Memory Utilization is 70.518%, crossed warning (20) or critical (30) threshold.
Target information:
      Target Type: host
      Target Name: target1.mycompany.com
      Target URL: https://mytarget1.mycompany.com:5416/em/redirect?pageType=TARGET_HOMEPAGE&amp;targetName=target1.mycompany.com&amp;targetType=host</Description>
   <Severity>2</Severity>
   <AssignmentGroup>Triage</AssignmentGroup>
</createRequest>

Listed below is the output from the template using the "Sample Update Transaction" data from Appendix F, "Sample Incident Data," as input.

<?xml version="1.0" encoding="UTF-8"?>
<updateRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xml.mycompany.com/sysman/connector">
   <Identifier>CASD-000002 (cr:0000002)</Identifier>
   <Severity>3</Severity>
   <HistoryEntry>Updates from Enterprise Manager. The severity is now set to Warning</HistoryEntry>
</updateRequest>

D.3.2 Completed Second Template Example

Listed below is the completed second template. Notice the addition of the Closed section.

<?xml version='1.0' encoding='UTF-8'?>
<xsl:stylesheet version="1.0" 
              xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
              xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
 
  <xsl:template match="emcf:EMIncident">
    <xsl:variable name="sev">
      <xsl:choose>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'FATAL'">1</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CRITICAL'">2</xsl:when>
        <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'WARNING'">3</xsl:when>
        <xsl:otherwise>5</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
 
    <xsl:choose>
      <xsl:when test="normalize-space(emcf:TicketID) = ''">
 
        <!-- CREATE Request -->
        <createRequest xmlns="http://samplecompany.com">
          <Summary><xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/></Summary>
          <Description>Incident created in Enterprise Manager: <xsl:value-of select="emcf:SystemAttributes/emcf:Summary"/>
Target information:
      Target Type: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetType"/>
      Target Name: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetName"/>
      Target URL: <xsl:value-of select="emcf:SystemAttributes/emcf:SourceInfo/emcf:TargetInfo/emcf:TargetURL"/></Description>
          <Severity><xsl:value-of select="$sev"/></Severity>
          <AssignmentGroup>Triage</AssignmentGroup>
        </createRequest>
 
      </xsl:when>
      <xsl:otherwise>
 
       <!-- An update is being performed. Need to determine if this is a close or a normal update. -->
 
        <xsl:choose>
          <xsl:when test="emcf:SystemAttributes/emcf:SeverityCode = 'CLEAR'">
 
            <!-- CLOSE Request -->
            <updateRequest xmlns="http://samplecompany.com">
              <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
              <Status>CLOSED</Status>
              <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
            </updateRequest>
 
          </xsl:when>
          <xsl:otherwise>
 
            <!-- Normal UPDATE Request -->
            <updateRequest xmlns="http://samplecompany.com">
              <Identifier><xsl:value-of  select="emcf:TicketID"/></Identifier>
              <Severity><xsl:value-of select="$sev"/></Severity>
              <HistoryEntry>Updates from Enterprise Manager. The severity is now set to <xsl:value-of select="emcf:SystemAttributes/emcf:Severity"/></HistoryEntry>
            </updateRequest>
 
          </xsl:otherwise>
        </xsl:choose>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>
</xsl:stylesheet>

Listed below is the output from the template using the "Sample Close Transaction" data from Appendix F, "Sample Incident Data," as input.

<?xml version="1.0" encoding="UTF-8"?>
<updateRequest xmlns="http://samplecompany.com" xmlns:emcf="http://xmlns.oracle.com/sysman/connector">
   <Identifier>CASD-000002 (cr:0000002)</Identifier>
   <Status>CLOSED</Status>
   <HistoryEntry>Corresponding incident in Enterprise Manager has been cleared.</HistoryEntry>
</updateRequest>