Configuring Smart Aliases
In SAP NetWeaver Developer Studio, choose
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
Choose the Java option.
In the screen that appears, select the Use Java Annotations for Aliases checkbox.
Enter the class name and alias name method in the relevant fields.
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;
}
}
Select the Use Pattern checkbox and enter valid patterns in the text box.
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.
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
Select the Use XSD Annotations as Aliases checkbox
In the Read XSD Annotation as section. do one of the following:
Choose Attribute and enter the attribute name in the relevant field.
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.
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 .
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>
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.