作者: luckiejacky 時間: 2013-12-9 10:43 標題: 請問CHING明唔明databene是怎樣運作的
我follow佢個steps
但個xml是否我自己寫?
如果是,那同人手入有什麼分別?
http://databene.org/databene-benerator/tutorials/85-database-population-tutorial.html
thanks
作者: luckiejacky 時間: 2013-12-9 10:53
I understand now, but how can I generate the xml file from an existing
Schema? Vendor: JavaDB/Derby
作者: Jackass_TMxCK 時間: 2013-12-9 12:04
自己寫個script套資料入XML=.=
作者: luckiejacky 時間: 2013-12-9 17:02
本帖最後由 luckiejacky 於 2013-12-9 17:04 編輯
唔系好明點解Total Price = product[1] * db_order_item.number_of_items
Hardcoded? 這個是從Databene 個shop example抽出來的...
- <comment>create order items</comment>
- <generate type="db_order_item"
- count="{customer_count * orders_per_customer * items_per_order}" consumer="db">
- <variable name="product" source="db" selector=
- "select ean_code, price from db_product" distribution="cumulated" />
- <id name="id" generator="idGen" />
- <attribute name="number_of_items"
- min="1" max="27" distribution="cumulated" />
- <reference name="order_id" source="db"
- selector="select id from db_order where id > 1" cyclic="true" />
- <reference name="product_ean_code" script="product[0]" />
- <attribute name="total_price"
- script="product[1] * db_order_item.number_of_items" />
- </generate>
作者: luckiejacky 時間: 2013-12-9 19:52
本帖最後由 luckiejacky 於 2013-12-9 19:58 編輯
Does anyone know where the problem is? ahh.... extremely tired.
Please help
Thanks
- 19:46:31,900 ERROR (main) [DescriptorRunner] Error in Benerator execution
- org.databene.benerator.InvalidGeneratorSetupException: 'min' greater than max, '
- max' less than min
- <?xml version="1.0" encoding="iso-8859-1"?>
- <setup
- xmlns="http://databene.org/benerator/0.7.0"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://databene.org/benerator/0.7.0 http://databene.org/benerator-0.7.0.xsd">
- <comment>import stage and database specific properties</comment>
- <include uri="{ftl:cris.properties}" /> <!-- ftl: is the prefix used for scripting with FreeMarker Template Language -->
- <include uri="{ftl:cris.Derby.properties}" />
-
- <comment>define a database that will be referred by the id 'cris' subsequently</comment>
- <database id="cris" url="{dbUrl}" driver="{dbDriver}" schema="{dbSchema}"
- user="{dbUser}" password="{dbPassword}" batch="{dbBatch}" />
-
- <bean id="idGen" spec="new IncrementGenerator(1000)" />
-
- <import domains="customer, orders, order_details"
- platforms="fixedwidth"/>
-
- <generate type="customer" count="{customer_count}" consumer="cris">
- <variable name="person" generator="org.databene.domain.person.PersonGenerator" dataset="{country}" locale="{locale}"/>
- <id name="CustomerID" type="integer" generator="idGen"/>
- <attribute name="CustomerCode" type="string"
- pattern="CUS[0-9]{2}\-[0-9]{2}\-[0-9]{4}" unique="true"/>
- <attribute name="LastName" script="person.familyName" type="string" minLength="1" maxLength="2" />
- <attribute name="FirstName" script="person.givenName" type="string" minLength="1" maxLength="4" />
- <attribute name="Residence" type="integer" min="1" max="4"/>
- <attribute name="PREFERREDCONTACTMETHODID" type="integer" min="1" max="7"/>
- <attribute name="Sex" type="char" values="'M','F'"/>
- <attribute name="Address" type="string" minLength="3" maxLength="255"/>
- <attribute name="JobDutyID" type="integer" min="1" max="20"/>
- <attribute name="ConvenientContactTimeID" type="integer" min="1" max="6"/>
- <attribute name="IDCardNumber" type="string" minLength="19" maxLength="20"/>
- <attribute name="DOB" type="date"/>
- <attribute name="MobilePhoneNumber" type="string" pattern="[0-9]" minLength="11" maxLength="12"/>
- <attribute name="email" type="string" generator="org.databene.domain.person.EMailAddressGenerator"/>
- <attribute name="PostalCode" type="string" pattern="[0-9]" minLength="4" maxLength="5"/>
- <attribute name="QQ" type="string" pattern="[0-9]" minLength="11" maxLength="12"/>
- <attribute name="AgeGroupID" type="integer" min="1" max="5"/>
- <attribute name="OccupationID" type="integer" min="1" max="20"/>
- <attribute name="Weishun" type="string" pattern="[0-9]" minLength="11" maxLength="12"/>
- <attribute name="SalaryRangeID" type="integer" min="1" max="7"/>
- <attribute name="MemoryReasonID" type="integer" min="1" max="7"/>
- <attribute name="MemoryDate" type="date"/>
- <attribute name="EducationID" type="integer" min="1" max="5"/>
- <attribute name="BonusPoints" type="integer" selector="select sum(NetSales) from order_details od, orders o where (o.OrderCode = od.OrderCode) where OrderCode > 1" cyclic="true" />
- <attribute name="GMCustomer" type="boolean" values="0,1"/>
- <attribute name="BlackListed" type="boolean" values="0,1"/>
- <attribute name="RegisterDate" type="date"/>
- <attribute name="CreatePerson" type="string" script="person.familyName + ' ' + person.givenName" minLength="1" maxLength="20"/>
- <attribute name="CustomerCreationDate" type="date"/>
-
-
-
-
- </generate>
-
- <comment>create orders for random customers and random products</comment>
- <generate type="orders" count="{customer_count * orders_per_customer}" consumer="cris">
- <id name="OrderID" generator="idGen" />
- <attribute name="OrderCode" type="string"
- pattern="ORD[0-9]{2}\-[0-9]{2}\-[0-9]{4}" unique="true"/>
- <reference name="CustomerCode" source="cris" targetType="customer" cyclic="true" />
- <reference name="EmployeeCode" source="cris" targetType="Employee" cyclic="true" />
- <attribute name="PurchaseDateTime" type="Timestamp"/>
- <attribute name="PurchaseReason" type="string" minLength="1" maxLength="255" />
- </generate>
- <comment>create order items</comment>
- <generate type="order_details"
- count="{customer_count * orders_per_customer * items_per_order}" consumer="cris">
- <variable name="product" source="cris" selector="select categoryCode || SubCategoryCode || SKU AS SKU, UnitPrice from products" distribution="cumulated" />
- <id name="OrderDetailID" generator="idGen" />
- <reference name="OrderCode" source="cris" selector="select OrderCode from orders where OrderCode > 1" cyclic="true" />
- <reference name="SKU" script="SKU[0]" />
- <attribute name="Quantity" min="1" max="10" distribution="cumulated" />
- <attribute name="Price" type="bigdecimal" min="0.00" max="20000.00"/>
- <attribute name="NetSales" script="Price * cris.Quantity" />
- <attribute name="Weight" type="integer" min="1" max="100"/>
- </generate>
-
- </setup>
作者: KinChungE 時間: 2013-12-10 00:00
http://www.w3schools.com/xpath/
take a look at xpath (way to extract content from xml file)
作者: luckiejacky 時間: 2013-12-10 02:31
Thanks kin ching
作者: luckiejacky 時間: 2013-12-10 04:51
本帖最後由 luckiejacky 於 2013-12-10 08:01 編輯
What is this?
- 04:50:05,795 INFO (main) [TaskExecutor] Running task StateTrackingTaskProxy[Gen
- erateAndConsumeTask(CUSTOMER)] 100 times with page size 1 in a single thread
- 04:50:05,821 ERROR (main) [DescriptorRunner] Error in Benerator execution
- java.lang.RuntimeException: Error in persisting CUSTOMER[CustomerID=1000, Custom
- erCode=CUS10-10-3210, LastName=Day, FirstName=Mark, Residence=3, PREFERREDCONTAC
- TMETHODID=7, Sex=M, Address=DATZSNKXGSCKIDYFKOGMNARWGRWPHALBJHVLBTUVRFLMYCXKTOGX
- GHLIAJZOCVXTIDRXYFYOOLZJXPAMQGUZMZYMFZTFMCUBNESMRPQNAIKSJHHGTBFMONXNELSNNXCTEFCN
- PNEW, JobDutyID=8, ConvenientContactTimeID=5, IDCardNumber=3299777279508, DOB=19
- 93-09-13, MobilePhoneNumber=38601626092, email=mark.frederick@efj.org, PostalCod
- e=6441, QQ=34816821649, AgeGroupID=3, OccupationID=10, Weishun=82854997396, Sala
- ryRangeID=3, MemoryReasonID=4, MemoryDate=1998-11-27, EducationID=5, BonusPoints
- =78399408, GMCustomer=false, BlackListed=false, RegisterDate=1997-06-25, CreateP
- erson=Day Mark, CustomerCreationDate=2009-10-26T02:41:00]
- org.databene.benerator.InvalidGeneratorSetupException: Unable to create generato
- r for atomic dataset: HK:
