SAP Cloud SDK VDM 生成器是否正确处理 EDMX 注释?



在我们的上下文中,我们在 S/4 端使用自定义 OData 接口,该接口是从 CDS 视图生成的,该视图再次具有注释。生成的 EDMX 具有以下结构:

<?xml version="1.0" encoding="UTF-8"?>
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="vdmerror">
<EntityType Name="TestEntity">
<Key>
<PropertyRef Name="TestEntityID"/>
</Key>
<Property Name="TestEntityID" Nullable="false" Type="Edm.String"/>
<Property Name="SomeField" Type="Edm.String"/>
</EntityType>
<EntityType Name="FieldValues">
<Key>
<PropertyRef Name="FieldValuesID"/>
</Key>
<Property Name="FieldValuesID" Nullable="false" Type="Edm.String"/>
<Property Name="SomeAdditionalProperty" Type="Edm.String"/>
</EntityType>
<EntityContainer Name="default" m:IsDefaultEntityContainer="true">
<EntitySet EntityType="vdmerror.TestEntity" Name="TestEntity" sap:searchable="true"/>
<EntitySet EntityType="vdmerror.FieldValues" Name="FieldValues" sap:searchable="true"/>
</EntityContainer>
<Annotations Target="vdmerror.TestEntity/SomeField" xmlns="http://docs.oasis-open.org/odata/ns/edm">
<Annotation Term="Common.ValueList">
<Record>
<PropertyValue Property="Label" String="Value Help for Field"/>
<PropertyValue Property="CollectionPath" String="FieldValues"/>
<PropertyValue Property="SearchSupported" Bool="true"/>
<PropertyValue Property="Parameters">
<Collection>
<Record Type="Common.ValueListParameterInOut">
<PropertyValue Property="LocalDataProperty" PropertyPath="FieldValuesID"/>
<PropertyValue Property="ValueListProperty" String="FieldValuesID"/>
</Record>
</Collection>
</PropertyValue>
</Record>
</Annotation>
</Annotations>
<atom:link rel="self" href="/api/odata/v2/vdmerror/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
<atom:link rel="latest-version" href="/api/odata/v2/vdmerror/$metadata" xmlns:atom="http://www.w3.org/2005/Atom" />
</Schema>
</edmx:DataServices>
</edmx:Edmx>

在 SDK 版本 <3.6 中,这工作正常,因为对于 ValueEntity 实体集,也生成了 FluentHelper。之后就没有了。在调试生成过程时,我们发现为生成 FluentHelper 而检查的允许函数在 AllowedFunctionsResolver 中标识,该解析器有两个不同的允许函数源:来自实体集上的注释或 sap 属性。

在我们的例子中,使用注释是因为它们存在。但不幸的是,它将允许的函数保留在映射中,因为键是从注释元素中的目标属性派生的(在我们的例子中,ValueField,请参阅 AllowedFunctionsResolver.readOdataSpecFromMetadataFile(...((。但是,在此过程的后期,当迭代实体集时,实体名称将用作在允许函数映射中查找的键,当然它找不到任何条目,也不会生成FluentHelper接口(s. NamespaceClassGenerator.processEntitySet(...((。

如果改用 CollectionPath 属性的 PropertyValue,这将起作用,因为它包含对实体集的引用。所以问题是目前的行为是否真的是预期的?

我们当前的解决方法是在生成之前从 EDMX 中删除注释,但这有点容易出错,尽管这当然也可以自动化。

SAPCloud SDK 版本 3.11.0 修复了此问题。

这意味着生成器现在可以更好地了解annotations块属于哪个实体(或不属于哪个实体,就像您的情况一样(。

最新更新