SAP Cloud SDK VDM 生成器是否正确处理 EDMX 注释?
Is the SAP Cloud SDK VDM Generator handling EDMX annotations correctly?
在我们的上下文中,我们在 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。后来就不行了。调试生成过程,我们发现在 AllowedFunctionsResolver 中标识了为生成 FluentHelper 而检查的允许函数,它有两个不同的允许函数来源:来自注释或实体集上的 sap 属性。
在我们的例子中,使用注释是因为它们存在。但不幸的是,它在映射中保留了允许的函数,因为键是从注释元素中的目标属性派生的(在我们的例子中是 ValueField,请参见 AllowedFunctionsResolver.readOdataSpecFromMetadataFile(...))。然而,在稍后的过程中,当遍历实体集时,实体名称用作在允许函数映射中查找的键,当然它找不到条目并且不生成 FluentHelper 接口(s。NamespaceClassGenerator.processEntitySet(...)).
如果改为使用 CollectionPath 属性的 PropertyValue,这将起作用,因为它包含对实体集的引用。所以问题是当前的行为是否真的是预期的行为?
我们目前的解决方法是在生成之前从 EDMX 中删除注释,但是这有点容易出错,当然这也可以自动化。
Version 3.11.0 的 SAP Cloud SDK 修复了这个问题。
这意味着生成器现在可以更好地理解 annotations
块属于哪个实体(或不属于哪个实体,就像您的情况一样)。
在我们的上下文中,我们在 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。后来就不行了。调试生成过程,我们发现在 AllowedFunctionsResolver 中标识了为生成 FluentHelper 而检查的允许函数,它有两个不同的允许函数来源:来自注释或实体集上的 sap 属性。
在我们的例子中,使用注释是因为它们存在。但不幸的是,它在映射中保留了允许的函数,因为键是从注释元素中的目标属性派生的(在我们的例子中是 ValueField,请参见 AllowedFunctionsResolver.readOdataSpecFromMetadataFile(...))。然而,在稍后的过程中,当遍历实体集时,实体名称用作在允许函数映射中查找的键,当然它找不到条目并且不生成 FluentHelper 接口(s。NamespaceClassGenerator.processEntitySet(...)).
如果改为使用 CollectionPath 属性的 PropertyValue,这将起作用,因为它包含对实体集的引用。所以问题是当前的行为是否真的是预期的行为?
我们目前的解决方法是在生成之前从 EDMX 中删除注释,但是这有点容易出错,当然这也可以自动化。
Version 3.11.0 的 SAP Cloud SDK 修复了这个问题。
这意味着生成器现在可以更好地理解 annotations
块属于哪个实体(或不属于哪个实体,就像您的情况一样)。