10007---Trail ~ Populating the Data Model



Motivation

After creating a data model, we will populate it with some sample data we can use for testing.
Populating a data model can be done either manually using the hMC, an appropriate cockpit,

or automatically using hybris' Import-Export Data Framework called ImpEx.

Enter data via the hMC

First, we will create data manually in the hMC:

  1. Start hybris and navigate to the hmc http://localhost:9001/hmc/hybris
  2. Browse to Stadium, click New and enter the data below. Click Create to save the new Stadium

Add some matches to the Stadium created above. 

  1. Make sure you have entered the Cuppy, CuppyTrail and CuppyTrailhmc extensions in your localextensions.xml file. You can check that they've been included in the build by looking at the platform - extensions page in the hAC.
  2. Assign some matches to the newly created stadiums
    • Right-click on the matches field to get a context menu - select + Add Match
    • In the new search window, click on the search button
    • In the results area, select some matches by clicking anywhere in the match row except the little blue button
    • Then click the use button
    • This will return the selected matches to the stadium

In this use case we have added Matches to the Stadium which illustrates how the hMC handles relationships defined in the items.xml file.

ImpEx by Convention

As an alternative to populate the data model, we will use the ImpEx approach - "ImpEx By Convention" to define and import several stadiums rather than doing this manually in the hMC. The ImpEx Convention states that:

  • by default any files named essentialdata*.impex and projectdata*.impex that reside in <extension>/resources/impex will be imported during essential and project data creation  
  • Alternatively, we could choose to use the "ImpEx by Configuration" approach; this would require us to provide hybris with a filename pattern for ImpEx files (in config/local.properties). If you would like to do so, please read ImpEx Import for Essential and Project Data.
Create an ImpEx File

Create the file cuppytrail/resources/impex/projectdataStadium.impex:

cuppytrail/resources/impex/projectdataStadium.impex

INSERT_UPDATE Stadium;code[unique=true];capacity
;Emirates;60361
;VillaPark;42788
 
UPDATE Match;id[unique=true];group(competition(code),code)[unique=true];stadium(code)
;1;wc2010:A;Emirates
;2;wc2010:A;Emirates
;3;wc2010:B;Emirates
;4;wc2010:B;VillaPark
 
$START_USERRIGHTS
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
UserGroup;cuppyadmins;;;;;;;;
;;;;Stadium;+;+;+;+;-
$END_USERRIGHTS

The projectdata part of the file name is  case-sensitive  

Using Convention-based ImpEx will only work if the filenameadheres to the pattern. For example: naming the file projectDataStadium.impex (with a uppercase D) will result in the file being ignored.

  • This ImpEx contains a header row with a SQL Table Command and columns, stating that we want to update the table Stadium, in particular the columns code (whose values must be unique), capacity and matches whose ids will be specified below. This is followed by several rows containing the data to import.
  • We are specifying two stadiums and several matches to import
  • The code attribute needs to be unique: unique=true. 
  • The USERRIGHTS section sets access rights for cuppyadmins-usergroup on Stadium type.

Invoke the ImpEx from within hybris

  • Navigate to Platform/Update
  • Check only cuppytrail in Project data settings, then click on Update
  • Output both in the console and browser will display Creating project data for cuppytrail ... notifying you that the ImpEx has executed for CuppyTrail
  • Now, if you've completed the sidetrail: Trail ~ Integration in the hMC, then:
    • Open the hMC and select the imported Stadium (i.e., after performing an unrestricted Search of all stadiums, double-click on Emirates in the search results) to see if ImpEx completed successfully

===

===

Alternatively you can: Invoke the ImpEx using the hMC import wizard

  • Log into the hMC
  • Open the node System -> Tools -> Import
  • Set the import file name
  • Start the import: Click on the Start icon




  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值