您的位置:首页 > 其它

hybris new data model

2016-01-15 16:02 465 查看
数据模型中的每部分的<扩展>-items.xml文件中定义。从本质上讲数据实体(称为的hybris“项目”)与元素的ItemType定义,而项目之间的关系与关系中的元素定义。例如,打开cuppy/资源/ cuppy-items.xml并仔细看看它指的是Cuppy数据模型的众多关系而itemtype定义。采用hybris构建系统提取\* - 位于所有扩展item's.xml文件,并生成每一个的ItemType一些Java源代码文件,以支持访问这些实体在采用hybris框架内(尤其是在服务层通过Java调用以及通过REST风格的URI)。下面的红色类图中显示了在cuppy-items.xml播放机的ItemType创建的文件。从它们所来源的类示于黄色。注意:从itemType生成的类可分为三类1、在鼓励合作伙伴开发自己的业务逻辑的服务层,创建模型类。2 Web服务相关的类被创建,他基于REST URI来支持CRUD逻辑。当配置中包括可选的扩展platformwebservices才会产生这些类。Low-levelJalo classes. We will not address these classes as their use is discouraged.3、低级Jalo类,既然他们不被鼓励使用,我们就不会用。我们需要做的就是: 加入cuppytrail-items.xml一个新的项目,定义新的数据实体Stadium。加入cuppytrail-items.xml一个关系,在Stadium和matchs之间创建1对多的关系加入cuppytrail-items.xml一个新的枚举类型,创造了StadiumStype和StadiumAccess,我们创建两个。在cuppytrail-items.xml添加默认值给创建的类型加默认值

在CuppyTrail和 Cuppy之间添加一个依赖关系:

Tell Eclipse that the Cuppytrail extensiondepends on the Cuppy extension: right click on cuppytrail - build path - configure buildpathTell the hybris build framework that the Cuppytrail extensiondepends on the Cuppy extension. Open 
cuppytrail/extensioninfo.xml
 andadd
<requires-extension name="cuppy"/>
注意:作为第一个元素

Add Stadium to cuppytrail-items.xml:

Replace 
cuppytrail/resources/cuppytrail-items.xml 
withthe following XML declarations describing the new Stadium itemtype and its attributes,
<?xml version="1.0" encoding="ISO-8859-1"?>
<!--
[y] hybris Platform

Copyright (c) 2000-2013 hybris AG
All rights reserved.

This software is the confidential and proprietary information of hybris
("Confidential Information"). You shall not disclose such Confidential
Information and shall use it only in accordance with the terms of the
license agreement you entered into with hybris.

-->

<items   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="items.xsd">

<itemtypes>
<itemtype code="Stadium" generate="true" autocreate="true">
<deployment table="CuppyTrailStadium" typecode="10123" />
<attributes>
<attribute qualifier="code" type="java.lang.String" >
<persistence type="property"/>
<modifiers optional="false" unique="true"/>
</attribute>
<attribute qualifier="capacity" type="java.lang.Integer">
<description>Capacity</description>
<persistence type="property" />
</attribute>
</attributes>
</itemtype>
</itemtypes>
</items>
Save this file run ant all.Refresh Eclipse workspace (all projects)Key points to note are that the code
itemtype code=Stadium generate=true autocreate=true
defines a new type 
Stadium
 which implicitly extends from 
GenericItem
autocreate=true
 indicates that 
Stadium
 is a new type
generate=true
 creates required sourcecode (not the model class) for the type
deployment table=CuppyTrailStadium typecode=10123
specifies how the new type is mapped to the database
table
 defines the database table
typecode
 is used internally e.g. to create item pks. Typecodes between 0 and 10000 are reserved by hybris. Nevertheless there are some exceptions you can read about here: Specifyinga Deployment for hybris Platform Types
attribute qualifier=code type=java.lang.String
creates a new attr145ccibute 
code
 by using the atomic type 
java.lang.String
 persistence type=property
Defines how item are stored. 
property
 reflects the normal persistent behaviour
 modifiers ... /
advanced settings like read and write access

Relations:

Stadium和 Match之间通过relation 标签定义一个新的关系[b]StadiumMatchRelation 。[/b]Add this code above itemtypes inside 
cuppytrail/resources/cuppytrail-items.xml之中。
Enumtypes:在relations标签之前添加下面代码在:
cuppytrail/resources/cuppytrail-items.xml之中。
cuppytrail-items.xml

Default values:

打开文件: 
cuppytrail/resources/cuppytrail-items.xml并添加
属性StadiumType 到两个已经存在的属性里面 并定义默认值为openair:cuppytrail/resources/cuppytrail-items.xml
Save this file run ant all.Refresh Eclipse workspace (all projects)刷新cuppttrail project,看
platform/bootstrap/gensrc/de/hybris/platform/cuppytrail/model/StadiumModel.java文件
注意:当我们改变了数据模型(通过更改items.xml文件),我们必须update System,将更改的内容同步到数据库中,type definitions should involve type system localizationcuppy数据实体包括的相关项目users: Player, ProfilePicture, PlayerPreferences, Countryfootball teams: Country, Team, Newstournaments: Competition, Match, Groupbets: MatchBetcountries: Country, Country Flagadministration: TimePointStatistic, OverallStatistic, UpdateCompetitionCronJob
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: