了解Hybris中的Impex语法声明

sag*_*gar 2 java sap spring-mvc hybris

您好我正在尝试学习Hybris,因为我无法访问Wiki网站,所以我很难理解代码背后的基础知识.有人可以帮助我理解主页中"欢迎使用主页"文本的以下Impex语句.

我的问题来自以下代码:实际上,我有更多,但不想放置负担,但如果你能在Impex声明的大多数基础知识中帮助我,我将非常感激.

1)在某些地方使用了多个分号,为什么?
2)什么是uid?
3)似乎在开始中定义的参数值在每个语句中的两个分号(;;)之后开始,让我知道我是正确的?

INSERT_UPDATE CMSParagraphComponent;$contentCV[unique=true];uid[unique=true];name;&componentRef;;;;content;
;;welcomeInfoComponent;Welcome information;welcomeInfoComponent;;;;welcome to home page;

INSERT_UPDATE ContentSlotName;name[unique=true];template(uid,$contentCV)[unique=true][default='LandingPage2Template'];validComponentTypes(code);compTypeGroup(code)
;welcomeInfo;;;wide

INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];name;active
;;welcomeInfoSlot;welcome info slot;true

INSERT_UPDATE ContentSlotForTemplate;$contentCV[unique=true];uid[unique=true];position[unique=true];pageTemplate(uid,$contentCV)[unique=true][default='LandingPage2Template'];contentSlot(uid,$contentCV)[unique=true];allowOverwrite
;;WelcomeInfo-LandingPage2;welcomeInfo;;welcomeInfoSlot;true

INSERT_UPDATE ContentSlot;$contentCV[unique=true];uid[unique=true];cmsComponents(uid,$contentCV)
;;welcomeInfoSlot;welcomeInfoComponent
Run Code Online (Sandbox Code Playgroud)

Hyb*_*elp 5

什么是uid?

uid是CMSItem中定义为唯一的属性.大多数CMS项目都扩展了CMSItem.因此,您必须为Impex中的所有记录提供唯一值.此外,uid已被用于将CMSItem声明为目录感知.

<itemtype code="CMSItem" jaloclass="de.hybris.platform.cms2.jalo.contents.CMSItem" extends="GenericItem" autocreate="true"
    generate="true" abstract="true">
    <custom-properties>
        <property name="catalogItemType">
            <value>java.lang.Boolean.TRUE</value>
        </property>
        <property name="catalogVersionAttributeQualifier">
            <value>"catalogVersion"</value>
        </property>
        <property name="uniqueKeyAttributeQualifier">
            <value>"uid"</value>
        </property>
    </custom-properties>
    <attributes>
        <attribute qualifier="uid" generate="true" autocreate="true" type="java.lang.String">
            <persistence type="property" />
            <modifiers optional="false" unique="true" />
        </attribute>
        <attribute qualifier="name" generate="true" autocreate="true" type="java.lang.String">
            <persistence type="property" />
        </attribute>
        <attribute qualifier="catalogVersion" type="CatalogVersion">
            <modifiers optional="false" unique="true" />
            <persistence type="property" />
        </attribute>
    </attributes>
</itemtype>
Run Code Online (Sandbox Code Playgroud)

似乎在开始中定义的参数值在每个语句中的两个分号(;;)之后开始,让我知道我是正确的?

让我首先格式化你的impex,这样你就可以得到这个想法

INSERT_UPDATE CMSParagraphComponent ; $contentCV[unique=true] ; uid[unique=true]     ; name                ; &componentRef        ;  ;  ;  ; content              ;  
                                    ;                         ; welcomeInfoComponent ; Welcome information ; welcomeInfoComponent ;  ;  ;  ; welcome to home page ;  
Run Code Online (Sandbox Code Playgroud)

这里

  • INSERT_UPDATE是你的impex的模式
  • CMSParagraphComponent是ItemType
  • 然后你必须把; (分号),这只是值分隔符.从这里开始,您可以开始声明属性/列名称(例如uid,name等)以及修饰符(例如[unique = true]).
  • 现在你的值应该在第一行中的列定义下面(作为标题调用).对于某些列,您不需要声明值,或者您想要声明空值,然后您只需将其保留为空白,就像我们为$ contentCV所做的那样
  • 这里是$ contentCV是提供catalogVersion属性值的宏,它主要定义在文件的顶部.在导入期间,将解析这些宏,并将宏名称替换为宏值.所以我们保持空白,因为我们不需要为每个值行赋予它的值.

在某些地方使用了多个分号,为什么?

只是为了您的文件的可读性,您可以在标题中添加任意数量的分号,并在值行中添加相同的分号.如果你删除那些额外的; 即使你的Impex会运行

INSERT_UPDATE CMSParagraphComponent ; $contentCV[unique=true] ; uid[unique=true]     ; name                ; &componentRef        ;  content              ;  
                                    ;                         ; welcomeInfoComponent ; Welcome information ; welcomeInfoComponent ;  welcome to home page ;  
Run Code Online (Sandbox Code Playgroud)