Easy Map Types
A map can be created at runtime by defining the map type in the Easy type manifest file easytypes.json
.
This document describes, how Easy Map types can be configured in your Easy Extension.
Defining an easy map type
An easy map type definition can be created in easytypes.json
manifest file. The manifest allows to define the following for an easy enumeration type:
Code of the easy map type
Localized name of easy map type
Argument Type for easy map type
Return type for easy map type
For example: the blow definition defines an easy map type of argument type as String and return type as String. This means that an instance of this mao would represent a set of key-value pairs where key and value both are of String type.
{
"maptypes":[
{
"code": "TestEasyMap",
"name" : [
{
"lang" : "en",
"value" : "Test Easy Map"
}
],
"argumentType" : "java.lang.String",
"returntype" :"java.lang.String"
}
]
}
Using an easy map type in an easy item type
While defining the easy item type definition for the easy item type, the attribute (of type easy map type) definition must use the code of the easy map type as the type of the attribute.
For example: the blow definition defines a new easy item type EasyItem having an attribute of type TestEasyMap. This means that the EasyItem holds a set of key-value pairs in attribute mapAttribute.
{
"itemtypes" : [
{
"code" : "EasyItem",
"name" : [
{
"lang" : "en",
"value" : "Easy Item"
}
],
"autocreate" : "true",
"generate": "true",
"superType" : "GenericItem",
"deployment" : {
"table" : "easyitems",
"typecode" : "25000",
"propstable" : "easyitemprops"
},
"attributes" : [
{
"qualifier" : "code",
"type" : "java.lang.String",
"name" : [
{
"lang" : "en",
"value" : "Code"
}
],
"persistence" : {
"type" : "property",
"column" : "p_code"
},
"modifiers" : {
"unique" : "true",
"initial" : "true",
"optional" : "false",
"write" : "false",
"partof" : "false"
}
},
{
"qualifier" : "name",
"type" : "localized:java.lang.String",
"name" : [
{
"lang" : "en",
"value" : "Name"
}
],
"persistence" : {
"type" : "property",
"column" : "p_name"
},
"modifiers" : {
"unique" : "false",
"initial" : "false",
"optional" : "true",
"write" : "true",
"partof" : "false"
}
},
{
"qualifier" : "description",
"type" : "localized:java.lang.String",
"name" : [
{
"lang" : "en",
"value" : "Description"
}
],
"persistence" : {
"type" : "property",
"column" : "p_locprop"
},
"modifiers" : {
"unique" : "false",
"initial" : "false",
"optional" : "true",
"write" : "true",
"partof" : "false"
}
},
{
"qualifier" : "usage",
"type" : "EasyUsageEnum",
"name" : [
{
"lang" : "en",
"value" : "Usage"
}
],
"persistence" : {
"type" : "property",
"column" : "p_usage"
}
},
{
"qualifier" : "mapAttribute",
"type" : "TestEasyMap",
"name" : [
{
"lang" : "en",
"value" : "Map Attribute"
}
],
"persistence" : {
"type" : "property",
"column" : "p_mapAttribute"
}
}
]
}
]
}
Defining the model class for an item having an attribute of easy map type
While defining the model class of an easy item type that has an attribute of type easy map type, must ensure to define the gettter and setter of the attribute with return/argument type as defined in the easy map type definition.
For example: The model class definition below defined the getter and setter for the property customers having the return/argument types as Map<String, String>
package com.sap.cx.boosters.easy.extension.easytype.model
import de.hybris.bootstrap.annotations.Accessor
import de.hybris.platform.core.model.ItemModel
import de.hybris.platform.servicelayer.model.ItemModelContext
import com.sap.cx.boosters.easy.extension.easytype.enums.EasyUsageEnum
import java.util.Map
class EasyItemModel extends ItemModel{
public static final String _TYPECODE = "EasyItem"
public static final String CODE = "code"
public static final String NAME = "name"
public static final String DESCRIPTION = "description"
public static final String USAGE = "usage"
public static final String MAPATTRIBUTE = "mapAttribute"
EasyItemModel(){
super()
}
EasyItemModel(final ItemModelContext ctx)
{
super(ctx)
}
@Accessor(qualifier = CODE, type = Accessor.Type.GETTER)
String getCode()
{
return getPersistenceContext().getPropertyValue(CODE)
}
@Accessor(qualifier = CODE, type = Accessor.Type.SETTER)
void setCode(final String value)
{
getPersistenceContext().setPropertyValue(CODE, value)
}
@Accessor(qualifier = NAME, type = Accessor.Type.GETTER)
String getName()
{
return getName(null)
}
@Accessor(qualifier = NAME, type = Accessor.Type.GETTER)
String getName(final Locale loc)
{
return getPersistenceContext().getLocalizedValue(NAME, loc)
}
@Accessor(qualifier = NAME, type = Accessor.Type.SETTER)
void setName(final String value)
{
setName(value, null)
}
@Accessor(qualifier = NAME, type = Accessor.Type.SETTER)
void setName(final String value, final Locale loc)
{
getPersistenceContext().setLocalizedValue(NAME, loc, value)
}
@Accessor(qualifier = DESCRIPTION, type = Accessor.Type.GETTER)
String getDescription()
{
return getDescription(null)
}
@Accessor(qualifier = DESCRIPTION, type = Accessor.Type.GETTER)
String getDescription(final Locale loc)
{
return getPersistenceContext().getLocalizedValue(DESCRIPTION, loc)
}
@Accessor(qualifier = DESCRIPTION, type = Accessor.Type.SETTER)
void setDescription(final String value)
{
setDescription(value, null)
}
@Accessor(qualifier = DESCRIPTION, type = Accessor.Type.SETTER)
void setDescription(final String value, final Locale loc)
{
getPersistenceContext().setLocalizedValue(DESCRIPTION, loc, value)
}
@Accessor(qualifier = USAGE, type = Accessor.Type.GETTER)
EasyUsageEnum getUsage()
{
return getPersistenceContext().getPropertyValue(USAGE)
}
@Accessor(qualifier = USAGE, type = Accessor.Type.SETTER)
void setUsage(final EasyUsageEnum value)
{
getPersistenceContext().setPropertyValue(USAGE, value)
}
@Accessor(qualifier = MAPATTRIBUTE, type = Accessor.Type.GETTER)
Map<String, String> getMapAttribute()
{
return getPersistenceContext().getPropertyValue(MAPATTRIBUTE)
}
@Accessor(qualifier = USAMAPATTRIBUTEGE, type = Accessor.Type.SETTER)
void setMapAttribute(final Map<String, String> value)
{
getPersistenceContext().setPropertyValue(MAPATTRIBUTE, value)
}
}
Limitations with Easy Map Types
While the easy map types can be defined at runtime, following points must be of the consideration while creating the Easy map types:
Last modified: 18 August 2025