Show TOC

Setting Smart AliasesLocate this document in the navigation structure

Prerequisites

Configuring Smart Aliases

  1. In SAP NetWeaver Developer Studio, choose Start of the navigation path Window Next navigation step Preferences End of the navigation path

  2. In the dialog box that appears, on the left hand side, expand the Rules Composer node, the Smart Aliases node.

    You should see the Java and XSD options under the Smart Aliases node.

To use Java annotations for aliases

  1. Choose the Java option.

  2. In the screen that appears, select the Use Java Annotations for Aliases checkbox.

  3. Enter the class name and alias name method in the relevant fields.

    Example

    Annotation Class Name = com.sap.annotation.MyAlias

    Annotation Alias Name Method = aliasName for the following example.

    Annotation Class:

    package ;

    @RetentionPolicy(RetentionPolicy.RUNTIME)

    public @interface {

    String aliasName();

    Sample Class:

    package com.sap.sample;

    @ ( ="Employee Object")

    public class Employee {

    private String name;

    @ ( ="Employee's Global Id")

    public String GLOBAL_ID = "I047312";

    @ ( ="New Employee")

    public Employee(){

    }

    @ ( ="Employee's Name")

    public String getName() {

    return name;

    }

    }

  4. Select the Use Pattern checkbox and enter valid patterns in the text box.

    Note

    Examples of few valid patterns:

    • {MemberName} of {ClassName}

    • A {ClassName} has a {PropertyName}

    • {ClassName}.{MemberName} (This is similar to default aliases)

    Keywords

    {PropertyName} is a place holder for properties. The property names are derived from the member names of the class.

    {ClassName} is a place holder for Java class name or Definition name.

    {MemberName} is a place holder for properties. The property names are derived from the member names of the class.

Note
  • Set Smart Aliases button is disabled (and are not generated) for the following classes.

    • com.sap.brms.pubutils.FunctionsUtil

    • com.sap.brms.pubutils.TimeUnit

  • If you select both Use Java Annotations for Aliases and Use Pattern checkboxes, Java annotations will be first considered for generating aliases. In case there are some issues with annotations, patterns will be considered. If the issue persists, the default aliases will remain unchanged.

To use XSD annotations as aliases

  1. Select the Use XSD Annotations as Aliases checkbox

  2. In the Read XSD Annotation as section. do one of the following:

    • Choose Attribute and enter the attribute name in the relevant field.

      Example

      Attribute Name = aliasname for the following sample schema:

      http://www.w3.org/2001/XMLSchema

      xmlns:ns4="http://demo.sap.com/samples"

      xmlns="xmlsc.xsd" targetNamespace="xmlsc.xsd"

      elementFormDefault="qualified" attributeFormDefault="qualified">

      <xsd:element name="students" type="studentsType"/>

      <xsd:complexType name="studentsType"/>

      <xsd:sequence maxOccurs="unbounded">

      <xsd:element name="student" type="studentType" />

      </xsd:sequence>

      </xsd:complexType>

      <xsd:complexType name="studentType">

      <xsd:sequence>

      <xsd:element name="rollNo" type="xsd string">

      <xsd:annotation>

      <xsd:appinfo ns4: =Student Roll Number />

      </xsd:annotation>

      </xsd:element>

      </xsd:sequence>

      </xsd:complexType>

      </xsd:schema>

    • Choose Element with "source" URI and enter a valid source URI in the relevant field.

      Example

      Source URI = com.sap.brms.alias for the following sample schema:

      http://www.w3.org/2001/XMLSchema

      xmlns:ns4="http://demo.sap.com/samples"

      xmlns="xmlsc.xsd" targetNamespace="xmlsc.xsd"

      elementFormDefault="qualified" attributeFormDefault="qualified">

      <xsd:element name="students" type="studentsType"/>

      <xsd:complexType name="studentsType">

      <xsd:sequence maxOccurs="unbounded">

      <xsd:element name="student" type="studentType"/>

      </xsd:sequence>

      </xsd:complexType>

      <xsd:complexType name="studentType">

      <xsd:sequence>

      <xsd:element name="rollNo" type="xsd string">

      <xsd:annotation>

      <xsd:appinfo source=" ">

      Student Roll Number

      </xsd:appinfo>

      </xsd:annotation>

      </xsd:element>

      </xsd:sequence>

      </xsd:complexType>

      </xsd:schema>

    • Choose Element without "source" URI .

      Example

      Sample XSD Element with annotation defined as an attribute without source URI:

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns4="http://demo.sap.com/samples" xmlns="xmlsc.xsd" targetNamespace="xmlsc.xsd" elementFormDefault="qualified" attributeFormDefault="qualified">

      <xsd:element name="students" type="studentsType" />

      <xsd:complexType name="studentsType">

      <xsd:sequence maxOccurs="unbounded">

      <xsd:element name="student" type="studentType" />

      </xsd:sequence>

      </xsd:complexType>

      <xsd:complexType name="studentType">

      <xsd:sequence>

      <xsd:annotation>

      <xsd: >

      Student Roll Number

      </xsd: >

      </xsd:annotation>

      </xsd:element>

      </xsd:sequence>

      </xsd:complexType>

      </xsd:schema>

Context

The data model you use to write rules are based on either Java classes or XML schemas. The aliases are generated for the members of the model from Java classes or XML schemas. These aliases may not be user friendly. You can manually assign meaningful names to aliases by manually renaming each alias. However this can be tedious.

By setting smart aliases you can automatically generate meaningful alias names using annotations in Java classes and XML schemas.

Procedure

  1. Locate the Project Resources node ( Where is the Project Resources node? ) and double-click the node.
  2. In the Project Resources editor, choose the Aliases tab.
  3. In the aliases editor, choose the Java Class or XSD element for which you have set preferences.
  4. Choose the Set Smart Aliases button.

    In the dialog box that appears you should see the generated smart alias names.

    Note

    You can also manually edit the alias names in the dialog box.

  5. Choose Finish .

    You should see the existing alias names get replaced with the smart alias names.

    Note
    • The alias names do not get replaced with smart alias names when:

      • The pattern name is wrong or invalid

      • The method in annotation is inaccurate

      • The class name or method name in the annotation is empty

    • Once the smart aliases are generated you cannot revert to default aliases name directly

    • You need to either manually edit each of the aliases or reload the class or XSD