BUG:Orika在DefaultFacetSearchConfigService中复制对象的子类失败

2020-09-18 16:35发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)在 DefaultFacetSe...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


在 DefaultFacetSearchConfigService.getConfiguration(String)中,它使用第三方Orika(https://github.com/orika-mapper/orika ),然后返回。 如果尝试使用子类复制集合,则会出现问题。

在以下单元测试中,我将使用orika-mapper以与DefaultFacetSearchConfigService相同的方式复制IndexedProperty。 我扩展了AbstractSolrFacetVisibilityRuleData并将其添加到IndexedProperty的facetVisibilityRules列表中。 复制后,复制的IndexedProperty的facetVisibilityRules不是扩展类,而是AbstractSolrFacetVisibilityRuleData。

这会在创建SolrFacetVisibilityRulePlugin的实现以评估可见性规则时引起问题。

  @Test
  公共无效testCopying()引发异常
  {
      IndexedProperty indexedProperty = new IndexedProperty();
      indexedProperty.setFacetVisibilityRules(Collections.singletonList(new OtherFacetSelectedSolrFacetVisibilityRuleData()));;
 
      ConfigurableMapper facetSearchConfigMapper = new ConfigurableMapper();
      IndexedProperty copyedIndexedProperty = facetSearchConfigMapper.map(indexedProperty,IndexedProperty.class);
 
      AbstractSolrFacetVisibilityRuleDataCopyedVisibilityRuleData = CopyedIndexedProperty.getFacetVisibilityRules()。iterator()。next();
      Assert.assertTrue(OtherFacetSelectedSolrFacetVisibilityRuleData.class.isInstance(copiedVisibilityRuleData));
  }



  
2条回答
大简至美
2020-09-18 17:07

这是我的答案类似的问题

https://answers.sap.com/questions/12755691/ facetsearchconfig-cache-issue.html

您应该为 AbstractSolrFacetVisibilityRuleData 的新子类型提供自定义映射器。 请看一下(我使用的是6.4版)

  de.hybris.platform.commercesearch.config.mapping.mappers.CategorySelectedFacetVisibilityRuleDataMapper
  

这里的重点是,您的自定义映射器的新bean类应使用以下注释进行注释

  de.hybris.platform.solrfacetsearch.config.mapping.FacetSearchConfigMapping
  

在这种情况下,它将由 DefaultFacetSearchConfigMapper 拾取。

一周热门 更多>