Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Filter by label (Content by label)
excerptType
showLabelsfalse
sorttitle
showSpacefalsesorttitle
excerpttrue
operatorAND
simplelabelsmodule,modelcqllabel = "module" and label = "model"

Structure

Name of defined entity must be unique within the plugin scope.

Default value of attribute "auditable" is "false" and the attribute itself is not mandatory. When it's "true" every entity in the database defined by the model will have standard predefined fields: createdate, updatedate, createuser and updateuser. These fields store information about who and when created and last edited the entity.

Code Block
theme
themeEclipse
languagexml
Eclipselinenumberstrue
<model name="sampleModel"
    auditable="true"
    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>

        // FIELD DEFINITIONS

    </fields>

    <hooks>

        // HOOK DEFINITIONS

    </hooks>

    // IDENTIFIER

</model>

Structure of field definition

Code Block
themeEclipse
languagexml
themeEclipse
linenumberstrue
<fieldType options />

or

Code Block
themeEclipse
languagexml
themeEclipse
linenumberstrue
<fieldType options>

    // VALIDATOR DEFINITIONS

</fieldType>

Field types

Insert excerpt
QCDMESDOC:Model FieldsQCDMESDOC:
Model Fields
nopaneltrue

Structure of validator definition

Validators are attached to fields.

Code Block
themeEclipse
languagexmlthemeEclipse
linenumberstrue
<validatorType validatorOptions />

Validator types

Insert excerpt
QCDMESDOC:Model ValidatorsQCDMESDOC:
Model Validators
nopaneltrue

...

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
theme
themeEclipse
languagexml
Eclipselinenumberstrue
<hookType hookOptions />

Hook types

Insert excerpt
QCDMESDOC:Model HooksQCDMESDOC:
Model Hooks
nopaneltrue

Identifier

Role of entity identifier is to convert entity defined in model to a simple text (see expressions overview). It is used for example when showing operation messages. If "expression" is givet it is used to evaluate identifier, otherwise "number" field will be taken.

Code Block
themeEclipse
languagexml
themeEclipse
linenumberstrue
<identifier expression="#number + ' - ' + #name"/>

...

These examples definies three simple entities.

Code Block
themeEclipse
languagexmlthemeEclipse
linenumberstrue
<?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
theme
themeEclipse
languagexml
Eclipselinenumberstrue
<?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
themeEclipse
languagexmlthemeEclipse
linenumberstrue
<?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>