5

I've been trying to retrieve the metadata value of extended entity of KeywordModel on DXA 2.0.3 with no luck.

My component is called kennisitem with the following schema:

Kennisitem schema

Kennisitem has a metadata field called regeling. Regeling (CGH - Regeling) is a category that's created this way:

enter image description here

And this is the properties of one of regeling keywords.

enter image description here

As you can see, this keyword has Thema Metadata as metadata schema selected. The schema itself is pretty simple:

enter image description here

This schema contains a field called kleurvoorpagina that points to other category which is called Opmaak, and this contains keywords that I can select when assigning property of regeling.

In Java, I made an entity model class of Kennisitem component

@Data
@EqualsAndHashCode(callSuper = true)
@SemanticEntity("Kennisitem")
public class Kennisitem extends AbstractEntityModel {
    private List<Regeling> regeling;
}

and Regeling is a model class extending KeywordModel

@EqualsAndHashCode(callSuper = true)
@Data
@SemanticEntity("Regeling")
public class Regeling extends KeywordModel {
    @SemanticProperty("kleurvoorpagina")
    private String kleurvoorpagina;
}

The list of Regeling is populated, but the value of kleurvoorpagina is always null. What am I missing here? Both Regeling and Kennisitem are registered in module initializer.

Note: I tried to debug KeywordConverter@convert from dxa-tridion-provider and I can see that the metadata is in KeywordWrapper variable. However my kleurvoorpagina field is not populated.

1 Answer 1

2

In order for semantic mapping to work, your View Model types should map to your CM Schemas either implicitly (based on type name) or explicitly using SemanticEntity annotations.

In case of your Keyword Model, it has to map to the Keyword’s metadata Schema in CM. Since it’s a metadata Schema (and thus has no root element name), the mapping is done on the CM Schema’s title.

Your Keyword’s metadata Schema title is “Thema Metadata”. Therefore, the Keyword Model’s type name or SemanticEntity annotation should be ThemaMetadata (unless you would annotate the CM Schema with semantic type App Data, but let’s not go there).

For more info, see https://docs.sdl.com/LiveContent/content/en-US/SDL%20DXA-v12/GUID-C0AD6DCC-ED65-441F-B361-928A18B2896D

2
  • Thanks! That solved the problem
    – Chris
    Commented Jun 11, 2020 at 21:49
  • 1
    You’re welcome. So, for clarity: SemanticEntity or SemanticProperty annotations which just repeat the name of the type/property are redundant. Commented Jun 12, 2020 at 8:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.