Tuesday 19 April 2016

Hybris:   Data Modeling:

Type System
Attributes
Examples

Type System Definitions

                Type system definitions in an extension are defined by the content of items.xml file in XML format. The items.xml file is located in the extension's resources directory. The name of this file is always defined accordingly: $extension-items.xml where $extension is the name of an extension.

                The Type System is one of the most important concepts of the hybris Multichannel Suite. Every object stored in the platform is one type or another, depending on the kind of object. A type is a template for objects, it defines the product data the object may carry and what other objects the object is related to. Types also make product data persistent by categorizing the data and relating it to database fields.
                Models are generated from the hybris Commerce Suite type system. Furthermore, they are similar to POJOs (Plain Old Java Objects) and are used without any storage facility.


Basic Structure:

<items   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="items.xsd">
    <atomictypes>
    ...
    </atomictypes>
    <collectiontypes>
    ...
    </collectiontypes>
    <enumtypes>
    ...
    </enumtypes>
    <maptypes>
    ...
    </maptypes>
    <relations>
    ...
    </relations>
    <itemtypes>
    ...
    </itemtypes>
</items>

Example:


<itemtype
   code="Book"
   jaloclass="de.hybris.platform.print.jalo.Book"
   extends="GenericItem"
   generate="true"
   autocreate="true">
   <deployment table="Book" typecode="12232"/>
         <attributes>
            <attribute qualifier="code" type="java.lang.String">
               <modifiers optional="false" />
               <persistence type="property"/>
            </attribute>
            <attribute qualifier="sourceCatalogVersion" type="CatalogVersion">
               <persistence type="property"/>
            </attribute>
            <attribute qualifier="Book" type="BookCollection">
               <modifiers write="false" search="false"/>
               <persistence type="jalo"/>
            </attribute>
    </attributes>
</itemtype>

4 comments: