...
All model entites used by system are defined in XML files. Every plugin has one directory model which contains xml files with definition of entities used by this plugin.
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<model name="sampleModel"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schema.qcadoo.org/model"
xsi:schemaLocation="http://schema.qcadoo.org/model http://schema.qcadoo.org/model.xsd">
<fields>
// HERE YOU PUT FIELD DEFINITIONS
</fields>
<hooks>
// HERE YOU PUT HOOK DEFINITIONS
</hooks>
// HERE YOU PUT IDENTIFIER
</model>
|
...
Structure of field definition
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<fieldType options />
|
or
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<fieldType options>
// HERE YOU PUT VALIDATORS
</fieldType>
|
...
Validators are attached to fields.
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<validatorType validatorOptions />
|
...
You can create custom event hook and attach it to defined model. To do it first you must create custom method (see this link).
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<eventName class="className" method="methodName" />
|
...
If not defined, system will use field 'number' of defined entity.
Code Block |
---|
language | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<identifier expression="#number + ' - ' + #name"/> |
...
These examples definies three simple entities.
Code Block |
---|
langlanguage | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<model name="product"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schema.qcadoo.org/model"
xsi:schemaLocation="http://schema.qcadoo.org/model http://schema.qcadoo.org/model.xsd">
<fields>
<string name="number" required="true" unique="true">
<validatesLength max="40" />
</string>
<string name="name" required="true" />
<enum name="typeOfMaterial" values="01component,02intermediate,03product,04waste" required="true" />
<string name="ean" />
<dictionary name="category" dictionary="categories" />
<dictionary name="unit" dictionary="units" required="true" />
<string name="batch">
<validatesLength max="255" />
</string>
<string name="lastUsedBatch">
<validatesLength max="255" />
</string>
<boolean name="genealogyBatchReq" />
<hasMany name="substitutes" model="substitute" joinField="product" cascade="delete" copyable="true" />
<hasMany name="technologies" model="technology" joinField="product" />
<hasMany name="orders" model="order" joinField="product" />
<hasMany name="operationProductInComponents" model="operationProductInComponent" joinField="product" />
<hasMany name="operationProductOutComponents" model="operationProductOutComponent" joinField="product" />
<hasMany name="substituteComponents" model="substituteComponent" joinField="product" />
</fields>
<hooks />
<identifier expression="#number + ' - ' + #name"/>
</model> |
Code Block |
---|
langlanguage | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<model name="substitute"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schema.qcadoo.org/model"
xsi:schemaLocation="http://schema.qcadoo.org/model http://schema.qcadoo.org/model.xsd">
<fields>
<string name="number" required="true" unique="true">
<validatesLength max="40" />
</string>
<string name="name" required="true" />
<belongsTo name="product" model="product" lazy="false" required="true" />
<hasMany name="components" model="substituteComponent" joinField="substitute" cascade="delete" copyable="true" />
<priority name="priority" scope="product" />
</fields>
<hooks>
<validatesWith class="com.qcadoo.mes.products.ProductService" method="checkIfProductIsNotRemoved" />
</hooks>
<identifier expression="#number + ' - ' + #name" />
</model> |
Code Block |
---|
langlanguage | xml |
---|
theme | Eclipse |
---|
linenumbers | true |
---|
|
<?xml version="1.0" encoding="UTF-8"?>
<model name="substituteComponent"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schema.qcadoo.org/model"
xsi:schemaLocation="http://schema.qcadoo.org/model http://schema.qcadoo.org/model.xsd">
<fields>
<belongsTo name="product" model="product" lookupField="name" required="true" />
<belongsTo name="substitute" model="substitute" required="true" />
<decimal name="quantity" required="true">
<validatesRange from="0" exclusively="true" />
<validatesPrecision max="7" />
<validatesScale max="3" />
</decimal>
</fields>
<hooks>
<validatesWith class="com.qcadoo.mes.products.ProductService" method="checkIfSubstituteIsNotRemoved" />
<validatesWith class="com.qcadoo.mes.products.ProductService" method="checkSubstituteComponentUniqueness" />
</hooks>
<identifier expression="#product['number'] + ' - ' + #product['name']"/>
</model> |