0 votes

ORM Designer 2.1.6.678

Please bring back the comfortable way of editing a custom property of type "list"! In ORMD1 you could add items in a popup ("Edit Values" dialog), in ORMD2 it is just a text input field with PHP short array syntax.

Maybe it's an issue of how the custom property is defined? The model is imported from ORMD1.

Below is the custom configuration we used for ORMD1. Does it need to be migrated?

<orm-designer-configuration>
    <orm-configuration name="Doctrine2">
        <attribute name="TABLE">
            <attribute name="traits" type="list" child-type="string"/>
        </attribute>
        <attribute name="COLUMN">
            <attribute name="persist" type="bool"/>
        </attribute>
    </orm-configuration>
</orm-designer-configuration>
asked in How To & Manuals by (3.5k points)
recategorized by

7 Answers

0 votes
Best answer

ORM Designer 2 has new data type system and data type definition elements. Also we're now using different root element type names. Instead "TABLE" please use "Entity".

Each element is now defined by it's type instead of common keyword . Keyword attribute is now used only to define scalar value type.

Default keywords are:
- struct define structure
- group define only container of inner elements without encapsuling element.
- attribute define scalar value
- unordered define set of values without any ordering
- ordered define list of values with ordering
- indexed define key-vale map. Key should be any string/integer

Each of container type (unordered/ordered/indexed) should hold scalar type or complex structure. Here are few examples:

Ordered list of string values

<ordered name='listSimple' type='string'/>

Unordered set of structs

<unordered name='setOfContacts'>
  <struct name='Contact'>
    <attribute name='name' type='string'/>
    <attribute name='age' type='string'/>
  </struct>
</unordered>

Ordered list of foreign type with and without encapsuling element

<attribute-types>
  <struct name='root'>
    <ordered name='ordered-group' type='/referenced-group'/>
    <ordered name='ordered-struct' type='/referenced-struct'/>
  </struct>
  <group name='referenced-group'>
    <attribute name='first-name-rg' type='string'/>
    <attribute name='second-name-rg' type='string'/>
  </group>
  <struct name='referenced-struct'>
    <attribute name='first-name-rs' type='string'/>
    <attribute name='second-name-rs' type='string'/>
  </struct>
</attribute-types>

Image caption

So in your case it's necessary to update your definitions to this format:

<attribute-types>
    <struct name="Entity">
        <ordered name="traits" type="string"/>
    </attribute>
</attribute-types>

For more examples please see ORM Designer2 configurations files located in OrmDesigner2/Configurations or to next posts.

answered by Skipper developer (133k points)
edited by

Wow, great! That's a detailed how-to.

Just one problem: Once I create a directory in %appdata%\OrmDesigner2\Configurations (as it says in the configuration), ORMD2 won't start. Regardless whether there are XML files in it or not.

Is there any error you get when ORM Designer is executed?

My configuration path for example is

C:\Users\ludek.vodicka\AppData\Roaming\OrmDesigner2\Configurations

so I tried to create CFG file

c:\Users\ludek.vodicka\AppData\Roaming\OrmDesigner2\Configurations\test.ormd2.cfg.xml 

and put following content inside:

<ormd2-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <orm-configuration name="test">
  </orm-configuration>
  <mvc-support-orm mvc-name="Without MVC" orm-name="test" />
</ormd2-configuration>

and everything works fine

enter image description here

Nope, no error. Just won't start. It works with your file, but extending the Doctrine2 config does not work:

<ormd2-configuration xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <orm-configuration name="Doctrine2">
        <attribute-types>
            <struct name="Entity">
                <ordered name="traits" type="string"/>
            </struct>
        <attribute-types>   
    </orm-configuration>

Edit: Try adding anything to orm-configuration in your XML. I commented out the attribute-types part and then ORMD2 will start. But I cannot define anything within the orm-configuration.

Found my mistake. The crash report that 680 generates pointed me in the right direction: The attribute-types tag was not closed! (second to last line in the XML code above)

Works like a charm now, thanks!!!

Oh, I missed your last comment about this error. I'm glad you find a solution!
I updated invalid sample in my original post.

0 votes

Scalar types

    <struct name='root'>
      <attribute name='attr1' type='string' help-text='first attribute' help-url='http://www.inventic.eu'/>
      <attribute name='attr2' type='bool' help-text='second-attribute' />
      <attribute name='attr3' type='decimal' help-text='attr with url' help-url='http://www.orm-designer.com'/>
      <attribute name='attr4' type='float'/>
      <attribute name='attr1_e' type='string'/>
      <attribute name='attr2_e' type='bool'/>
      <attribute name='attr3_e' type='decimal'/>
      <attribute name='attr4_e' type='float'/>
    </struct>

Image caption

answered by Skipper developer (133k points)
0 votes

Structures

<struct name='root'>
  <struct name='structHe'> 
    <attribute name='name' type='string'/>
    <attribute name='age' type='decimal'/>
  </struct>
  <struct name='structShe'> 
    <attribute name='name' type='string'/>
    <attribute name='age' type='decimal'/>
  </struct>
  <struct name='structIt'> 
    <attribute name='name' type='string'/>
    <struct name='params'> 
      <attribute name='length' type='decimal'/>
    </struct>
  </struct>
</struct>

Image caption

answered by Skipper developer (133k points)
0 votes

Containers

<struct name='root'>
  <struct name='cntUnordered'>
    <unordered name='setEmpty'><attribute name='value' type='string'/></unordered>
    <unordered name='setFilled'><attribute name='value' type='string'/></unordered>
    <unordered name='setSimple' type='string'/>
  </struct>
  <struct name='cntOrdered'>
    <ordered name='list'><attribute name='value' type='string'/></ordered>
    <ordered name='listFilled'><attribute name='value' type='string'/></ordered>
    <ordered name='listSimple' type='string'/>
  </struct>
  <struct name='cntIndexed'>
    <indexed name='map'><attribute name='value' type='string'/></indexed>
    <indexed name='mapFilled'><attribute name='value' type='string'/></indexed>
    <indexed name='mapSimple' type='string'/>
  </struct>
</struct>

Image caption

answered by Skipper developer (133k points)
0 votes

Multi level container

<struct name='root'>
  <unordered name='set1'>
    <struct name='set-item'>
      <attribute name='val' type='string'/>
      <unordered name='set2'>
        <struct name='inner-set-item'>
          <attribute name='value' type='string'/>
        </struct>
      </unordered>
    </struct>
  </unordered>
</struct>

Image caption

answered by Skipper developer (133k points)
0 votes

Enum values

There are two types of enum values in ORM Designer. One type should defined in ORM Designer configuration file by using keyword "enum-values" and values are spearated by char |. The second type is callback enum which automatically fill values based on object context. Currently there are following enum callbacks:

  • entity - list of all entities in model
  • field - list of all fields in current entity
  • entityChildren list of all entities connected with current entity by association as child
  • entityParent list of all entities connected with current entity by association as parent

Different between type enum and enumEditable is in possibility update/modify enum attribute to any non-listed value.

Example of attribute definition:

<struct name='root'>
  <struct name='enums'>
    <attribute name='enum-simple' type='enumEditable' enum-values='a|b|c|d'/>
    <attribute name='enum-simple-RO' type='enum' enum-values='a|b|c|d'/>
  </struct>
  <struct name='callbacks'>
    <attribute name='cb-entity' type='entity'/>
    <attribute name='cb-field' type='field'/>
    <attribute name='cb-entityChildren' type='entityChildren'/>
   <attribute name='cb-entityParent' type='entityParent'/>
  </struct>
</struct>

Image caption

answered by Skipper developer (133k points)
0 votes

Type reference

<attribute-types>
  <struct name='root'>
    <ordered name='ordered-group' type='/referenced-group'/>
    <ordered name='ordered-struct' type='/referenced-struct'/>
    <struct name='empty-name-group' type='/referenced-group'/>
    <struct name='empty-name-struct' type='/referenced-struct'/>
  </struct>
  <group name='referenced-group'>
    <attribute name='first-name-rg' type='string'/>
    <attribute name='second-name-rg' type='string'/>
  </group>
  <struct name='referenced-struct'>
    <attribute name='first-name-rs' type='string'/>
   <attribute name='second-name-rs' type='string'/>
  </struct>
</attribute-types>

Image caption

answered by Skipper developer (133k points)