RWS / dxa-web-application-java

SDL Digital Experience Accelerator Java Spring MVC web application
25 stars 37 forks source link

DynamicList returns list of entities with null values #91

Open sudhakhayal opened 6 years ago

sudhakhayal commented 6 years ago

Originally, I had extended DynamicList<FAQs, SimpleBrokerQuery> from my custom model FAQsContentList where I want to execute a SimpleBrokerQuery on a few filterKeywords. In the logs I can see that I get query results but when it goes through the default Model Builder, the entity returns n results with null values. Originally I get a list of entity objects but with null values c.s.d.t.m.impl.DefaultModelBuilder - Expected class is pre-set to class com.sdl.dxa.modules.faqs.model.FAQs for model EntityModelData(id=4979, componentTemplate=null, linkUrl=null, content=null, binaryContent=null, externalContent=null)

Now, I get the another error (shown below) when I played around with the template, but the bottom issue is that I am not getting any field values. FAQs schema comes under module FAQs and my DynamicList is under another module ContentList.

The exception is .api.mapping.semantic.SemanticMappingException: Ambiguous semantic mapping for http://www.sdl.com/web/schemas/core:FAQs, found these mappings: [class com.sdl.dxa.modules.faqs.model.FAQs, class com.sdl.dxa.modules.faqs.model.FAQs] but there are no core schemas called FAQs

Caused by: com.sdl.webapp.common.exceptions.DxaException: Exception happened while creating a entity model from: EntityModelData(id=4560, componentTemplate=null, linkUrl=null, content=null, binaryContent=null, externalContent=null)     at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.buildEntityModel(DefaultModelBuilder.java:133)  at com.sdl.dxa.tridion.mapping.impl.ModelBuilderPipelineImpl.createEntityModel(ModelBuilderPipelineImpl.java:86)    at com.sdl.dxa.tridion.mapping.impl.DefaultContentProvider._convertEntities(DefaultContentProvider.java:120)    at com.sdl.dxa.tridion.mapping.impl.DefaultContentProvider.populateDynamicList(DefaultContentProvider.java:213)     ... 122 common frames omitted Caused by: com.sdl.webapp.common.exceptions.DxaException: Cannot get a view model tpe because of semantic mapping exception   at 

com.sdl.webapp.common.impl.model.ViewModelRegistryImpl.getMappedModelTypes(ViewModelRegistryImpl.java:109)

Caused by: com.sdl.webapp.common.api.mapping.semantic.SemanticMappingException: Ambiguous semantic mapping for http://www.sdl.com/web/schemas/core:FAQs, found these mappings: [class com.sdl.dxa.modules.faqs.model.FAQs, class com.sdl.dxa.modules.faqs.model.FAQs]
    at com.sdl.webapp.common.impl.mapping.SemanticMappingRegistryImpl.getEntityClassByFullyQualifiedName(SemanticMappingRegistryImpl.java:334)

To resolve the SemanticMappingException caused by Ambiguous semantic mapping, I then created a customTeaser which is mapped to my schema FAQs @SemanticEntity(entityName = "FAQs", vocabulary = SDL_CORE, prefix = "f") . In my custom ContentListController.enrichModel function, when it calls contentProvider.populateDynamicList(dynamicList, webRequestContext.getLocalization());, I can see from the logs that it calls my custom DynamicList and the DefaultModelBuilder that is called after this prints the following logs.

c.s.d.t.m.impl.DefaultModelBuilder - Expected class is pre-set to class com.sdl.dxa.modules.contentlist.model.ContentTeaser for model EntityModelData(id=4560, componentTemplate=null, linkUrl=null, content=null, binaryContent=null, externalContent=null)
09:33:37.128 [ajp-nio-8214-exec-1] DEBUG o.s.c.a.AnnotationCacheOperationSource - Adding cacheable method 'getMappedModelTypes' with attribute: [Builder[public java.lang.Class com.sdl.webapp.common.impl.model.ViewModelRegistryImpl.getMappedModelTypes(java.util.Set,java.lang.Class) throws com.sdl.webapp.common.exceptions.DxaException] caches=[defaultCache] | key='' | keyGenerator='localizationAwareKeyGenerator' | cacheManager='' | cacheResolver='' | condition='' | unless='' | sync='false']
09:33:37.128 [ajp-nio-8214-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'localizationAwareKeyGenerator'
09:33:37.128 [ajp-nio-8214-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'cacheManager'
09:33:37.138 [ajp-nio-8214-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'genericSemanticModelDataConverter'
09:33:37.138 [ajp-nio-8214-exec-1] DEBUG o.s.b.f.s.DefaultListableBeanFactory - Returning cached instance of singleton bean 'r2modelBuilder'
09:33:37.139 [ajp-nio-8214-exec-1] DEBUG c.s.d.t.m.i.DefaultSemanticFieldDataProvider - No data is found for path FieldPath(head=question, tail=null) for semantic field
09:33:37.145 [ajp-nio-8214-exec-1] DEBUG c.s.d.t.m.i.DefaultSemanticFieldDataProvider - No data is found for path FieldPath(head=answer, tail=null) for semantic field
09:33:37.152 [ajp-nio-8214-exec-1] DEBUG c.s.d.t.m.i.DefaultSemanticFieldDataProvider - No data is found for path FieldPath(head=faqsByTopic, tail=null) for semantic field
09:33:37.155 [ajp-nio-8214-exec-1] DEBUG c.s.d.t.m.i.DefaultSemanticFieldDataProvider - No data is found for path FieldPath(head=active, tail=null) for semantic field
majiccode commented 6 years ago

Hi, I'm looking into this issue and was wondering if you could give me a few more details regarding your actual code, schema & models. If possible could you supply the schemas/models you are using and the code you are using. Such as your DynamicList<,> implementation, browser query and usage of these. I'm trying to set up an environment to reproduce these issues so this would save a lot of time if you could supply this.

Many thanks Paul.

sudhakhayal commented 6 years ago

Hi Paul,

Sorry for the delay.

I have attached a document with screenshots of the schema, models and controller we are using. Let me know if you need anything else.

-- Thanks and regards, Sudha Mathew

On 4/6/2018 11:13 AM, Paul Adams wrote:

Hi, I'm looking into this issue and was wondering if you could give me a few more details regarding your actual code, schema & models. If possible could you supply the schemas/models you are using and the code you are using. Such as your DynamicList<,> implementation, browser query and usage of these. I'm trying to set up an environment to reproduce these issues so this would save a lot of time if you could supply this.

Many thanks Paul.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sdl/dxa-web-application-java/issues/91#issuecomment-379181651, or mute the thread https://github.com/notifications/unsubscribe-auth/ARZcyB9kDKQJRlgyOqU4XX8ZF3SMdIflks5tlyOsgaJpZM4TIQSK.

majiccode commented 6 years ago

Hi Sudha, Maybe you forgot to attach them ? :) Paul.

sudhakhayal commented 6 years ago

Hi,

Did you receive my email. Do you think it is getting blocked somehow.

-- Thanks and regards, Sudha Mathew

On 4/10/2018 9:05 AM, Sudha wrote:

Hi Paul,

Sorry for the delay.

I have attached a document with screenshots of the schema, models and controller we are using. Let me know if you need anything else. -- Thanks and regards, Sudha Mathew

On 4/6/2018 11:13 AM, Paul Adams wrote:

Hi, I'm looking into this issue and was wondering if you could give me a few more details regarding your actual code, schema & models. If possible could you supply the schemas/models you are using and the code you are using. Such as your DynamicList<,> implementation, browser query and usage of these. I'm trying to set up an environment to reproduce these issues so this would save a lot of time if you could supply this.

Many thanks Paul.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/sdl/dxa-web-application-java/issues/91#issuecomment-379181651, or mute the thread https://github.com/notifications/unsubscribe-auth/ARZcyB9kDKQJRlgyOqU4XX8ZF3SMdIflks5tlyOsgaJpZM4TIQSK.