了解Hybris中的Impex语法语句

时间:2018-10-08 20:01:57

标签: java spring-mvc sap 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

1 个答案:

答案 0 :(得分: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>
  

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

让我先格式化您的展示次数,这样您就可以了

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

这里

  • INSERT_UPDATE 是您的Impex模式
  • CMSParagraphComponent 是ItemType
  • 然后您必须输入; (分号),它只是值分隔符。从这里您可以开始声明属性/列名称(例如uid,名称等)以及修饰符(例如[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 ;