使用 SAP Cloud SDK 对扩展实体执行筛选

所以这可能很简单,但我不知何故无法理解它。我正在尝试使用 SAP Cloud SDK 通过电子邮件地址查找业务合作伙伴。


这是我到目前为止所拥有的:


final List<BusinessPartner> businessPartners = new DefaultBusinessPartnerService()

                        .getAllBusinessPartner()

                        .select(BusinessPartner.BUSINESS_PARTNER,

                                BusinessPartner.TO_BUSINESS_PARTNER_ADDRESS

                                        .select(BusinessPartnerAddress.TO_EMAIL_ADDRESS

                                                .select(AddressEmailAddress.SEARCH_EMAIL_ADDRESS)))

                        .filter(AddressEmailAddress.SEARCH_EMAIL_ADDRESS.eq(email)) //something like this?

                        .top(10)

                        .execute();

现在,如何对展开的实体执行筛选操作AddressEmailAddress?我想出的那个显然没有。我在使用流畅的 API 导航到扩展实体时遇到问题。


有任何想法吗?


慕桂英4014372
浏览 84回答 1
1回答

富国沪深

因为我的建议对你有用。让我将评论改写为答案。不幸的是,无法过滤SAP OData V2 服务端点的扩展实体。回退策略是直接查询实体集合 ( leaf ) 中的“已过滤”项目并运行额外的 OData 请求以遍历到您的原始实体 ( root )。在您的情况下,我建议直接查询, 以通过AddressIdAddressEmailAddress解析BusinessPartnerAddress。下一步是通过businessPartner字段来解析,例如BusinessPartnerpublic List<BusinessPartner> getBusinessPartnersByEmail(&nbsp; &nbsp; @Nonnull BusinessPartnerService service,&nbsp; &nbsp; @Nonnull String email)&nbsp; &nbsp; throws ODataException{&nbsp; &nbsp; List<AddressEmailAddress> emailAddresses = service&nbsp; &nbsp; &nbsp; &nbsp; .getAllAddressEmailAddress()&nbsp; &nbsp; &nbsp; &nbsp; .filter(AddressEmailAddress.SEARCH_EMAIL_ADDRESS.eq(email))&nbsp; &nbsp; &nbsp; &nbsp; .execute();&nbsp; &nbsp; List<BusinessPartnerAddress> addresses = new LinkedList<>();&nbsp; &nbsp; for( AddressEmailAddress emailAddress : emailAddresses ) {&nbsp; &nbsp; &nbsp; &nbsp; addresses.addAll(&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; service&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .getAllBusinessPartnerAddress()&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .filter(BusinessPartnerAddress.ADDRESS_ID.eq(emailAddress.getAddressID()))&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; .execute());&nbsp; &nbsp; }&nbsp; &nbsp; List<BusinessPartner> businessPartners = new LinkedList<>();&nbsp; &nbsp; for( BusinessPartnerAddress address : addresses ) {&nbsp; &nbsp; &nbsp; &nbsp; businessPartners.add(service.getBusinessPartnerByKey(address.getBusinessPartner()).execute());&nbsp; &nbsp; }&nbsp; &nbsp; return businessPartners;}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java