Explain Model in Hybris multi-channel suite ? Define Model in Hybris ?

Model are the way to represents item in Hybris ie. each of item is represented by in Model Class. So Model class is just like POJO class
which contain all item attributes
For every item type after build Hybris framework that create class with suffix Model and configuration file i.e. for product type item model class
will create with name ProductModel

Suppose you have define below item type in items.xml
<itemtype
  generate="true"
  code="ContactRequest"
  jaloclass="de.hybris.springmvcdemo.jalo.ContactRequest"
  extends="GenericItem"
  autocreate="true"
  >
    <attributes>
      <attribute qualifier="message" type="java.lang.String">
        <persistence type="property"/>
      </attribute>
    </attributes>
</itemtype>

Then generated model class will be

package de.hybris.springmvcdemo.model;

import de.hybris.platform.core.model.ItemModel;

/**
 * Generated Model class for type ContactRequest first defined at extension {literal}springmvcdemo{literal}
 */
@SuppressWarnings("all")
public class ContactRequestModel extends ItemModel
{
    /** <i>Generated type code constant.</i>*/
    public final static String _TYPECODE = "ContactRequest";
   
    /**
         * <i>Generated constant</i> - Attribute key of <code>ContactRequest.message</code> attribute defined
         * at extension <code>springmvcdemo</code>.
         */
    public static final String MESSAGE = "message";
   
   
    /** <i>Generated variable</i> - Variable of <code>ContactRequest.message</code> attribute defined
         * at extension <code>springmvcdemo</code>.
         */
    private String _message;
   
   
    /**
     * <i>Generated constructor</i> - for all mandatory attributes.
     * @deprecated Since 4.1.1 Please use the default constructor without parameters
     */
    @Deprecated
    public ContactRequestModel()
    {
        super();

    }
   
    /**
     * <i>Generated constructor</i> - for all mandatory and initial attributes.
     * @deprecated Since 4.1.1 Please use the default constructor without parameters
     * @param _owner initial attribute declared by type <code>Item</code> at extension <code>core</code>
     */
    @Deprecated
    public ContactRequestModel(final ItemModel _owner)
    {
        super(
            _owner
        );

    }
   
   
    /**
     * <i>Generated method</i> - Getter of the <code>ContactRequest.message</code> attribute defined
         * at extension <code>springmvcdemo</core>.
     * @return the message
     */
    public String getMessage()
    {
        if( !isAttributeLoaded(MESSAGE))
        {
          this._message = getAttributeProvider() == null ? null : (String) getAttributeProvider().getAttribute(MESSAGE);
          getValueHistory().loadOriginalValue(MESSAGE, this._message);
        }
        throwLoadingError(MESSAGE);
        return this._message;
    }
   
    /**
     * <i>Generated method</i> - Setter of <code>ContactRequest.message</code> attribute defined
         * at extension <code>springmvcdemo</code>.
     *
     * @param value the message
     */
    public void setMessage(final String value)
    {
        this._message = value;
        markDirty(MESSAGE);
    }
   
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.