The entity container parsed by SAP UI5 Fiori Elements annotation

AnnotationParser.jsThe annotation parsed by the SAP UI5 framework implementation code :

The first of these is the entity Container.

This entity container metadata.xmlcan be found in the file:

EntityContainer contains EntitySet:

Contents of the Annotations area in metadata:

Parsed by AnnotationParser.js as follows:

SAP Fiori Elements is a framework from SAP to create SAP Fiori applications. The framework provides a structured approach to create user interfaces and describe application behavior based on Open Data Model (OData) services and SAP annotations. SAP Fiori Elements applications are based on the SAPUI5 library and OData services, which use annotations to define and extend behavior.

In SAP Fiori Elements applications, annotations are metadata used to describe the data model and business logic. They can be defined in service definitions (CDS views or SEGW items) or metadata extensions (MDE). Annotations are resolved at runtime and the user interface is rendered based on the value of the annotation.

Entity Container is part of the OData model, which is a container for entity sets (Entity Sets) and single entities (Singletons). Entity sets are collections in the data model, such as customers, orders, or products. Whereas Singletons are single data objects, such as the current user or system settings.

In SAP Fiori Elements application, Entity Container is used to define all Entity Sets and Singletons available in OData service. For example, you might have an entity set called "SalesOrder" that contains all of your sales orders.

The definition of Entity Container is usually found in the metadata document of the OData service. It is defined as follows:

<EntityContainer Name="MyServiceContainer" m:IsDefaultEntityContainer="true">
  <EntitySet Name="SalesOrder" EntityType="MyNamespace.SalesOrder" />
  <Singleton Name="CurrentUser" Type="MyNamespace.User" />
</EntityContainer>

In this example, we define an Entity Container named "MyServiceContainer" that contains an EntitySet named "SalesOrder" and a Singleton named "CurrentUser".

In SAP Fiori Elements application, we can use annotations to change the behavior of entity sets and Singletons in Entity Container. For example, we can use @UI.headerInfoannotations to define the header information of the entity set, or use @Search.searchableannotations to define whether the entity set can be searched.

Annotations can be defined directly in the service definition, or in metadata extensions. For example, the following is an example of using annotations to define header information:

@UI.headerInfo: { 
  typeName: 'Sales Order', 
  typeNamePlural: 'Sales Orders', 
  title: { value: 'orderNumber' } 
}
Entity SalesOrder {
  key orderNumber: String;
  customerName: String;
  totalAmount: Decimal;
}

In this example, we use @UI.headerInfoannotations to define the header information of the sales order. The header will use the order number as the value.

By using Entity Containers and annotations, SAP Fiori Elements provides a powerful way to define and extend the behavior of OData services. This allows developers to focus on business logic rather than user interface development.

Guess you like

Origin blog.csdn.net/i042416/article/details/131896547