Skipper - The ORM Designer Blog
  • Skipper - The ORM Designer
  • VsBuilds - Parallel building
  • Pulpo - Free Skipper CLI

Tag: #import-export

Execute another application from ORM Designer import/export script

In this short article I want to show you how to execute another application from ORM Designer script. Since the version 1.4.2 ORM Designer has built-in a new script command called “execute-file” serving to launch the foreign applications from script. (1.4.2 is now obsolete, please download latest version from //http://www.skipper18.com/en/download)

Execute-file command

As first, let me show you the simplest way how to use this command.

<uscript>
  <function name='Test'>
    <execute-file file='p:\ExternalUnitTestFiles\DataFormats\Bat\test.bat' params='unit-test'/>
  </function>
</uscript>

Using this snippet we defined a function called “Test” which launch our testing .bat file with parameter ‘unit-test’. Whole command syntax is defined in XML Schema file script.xsd and looks like this:

<xs:complexType name="sExecuteFile">
  <xs:attribute name="file" use="required" type="xs:string"/>
  <xs:attribute name="params" type="xs:string"/>
  <xs:attribute name="show" type="booleanEx" default="true"/>
  <xs:attribute name="working-dir" type="xs:string"/>
  <xs:attribute name="wait-for-exit" type="booleanEx" default="true"/>
</xs:complexType>

By using parameter “working-dir we can specify a working directory for executed command. If no param is passed,  the directory where executable file is located is used. Parameter “show serves to launch application in invisible mode and parameter “wait-for-exit” servers to wait until external application has finished its work and then continues with script.

Overloading export script

Now let me show you another new feature of ORM Designer 1.4.2. It can happen that you need to call your own executable when ORM Designer finishes export from model to ORM framework definition files. So we prepared new overloading points in export script, where you can write your own functions which will be called in this points.

Overloading basis

Method overloading in ORM Designer script is processed by method names and prefixes. The simplest way is by defining a function with specific name. ORM Designer runs this function when it is available.

Sometimes we need to distinguish functions for concrete type of ORM. In this case ORM Designer offers prefix overloading ability. ORM Designer tries to find several prefixes when searching for specific function.

These prefixes have fixed order and priority, so we can define a  specific version of some ORMs and one common function for the rest of ORMs.

Order and prefixes are defined in following list. At first ORM Designer tries to find the function with “MVC.ORM.” prefix. As next ORM Designer tries “ORM.” prefix, then “default.” and then without prefix.

ORM Designer stops the function search after a function with correspond name has been found .

${nameMvc}.${nameOrm}.${functionName}
${nameOrm}.${functionName}
default.${functionName}
${functionName}

So, when you have following definitions, if project using Doctrine ORM is being processed, the first function will be called. When processed project uses any other ORM, the second function is called:

<function name='Doctrine.Test'/>
<function name='Test'/>

Overloading in export script

Every export script has in its end a located fragment which enables us to call our overloaded function. This fragment looks like:

<call name='system.NotifyEvent'>
  <param name='projectID' value='${projectID}'/>
  <param name='functioName' value='onFinish.export'/>
</call>

Now, if you need to create a custom function which is called anytime when ORM Designer exports model to ORM Definitions, follow next steps. As first, we create a file onfinish-export.uscript.xml (or any other name with “.uscript.xml” extension) in user configuration directory (more about user configuration files). As next, enter following script snippet to the created file:

<?xml version="1.0" encoding="utf-8" standalone="no" ?>
<uscript>
  <!-- ==== Doctrine2.onFinish.Export ==== -->
  <function name='Doctrine.onFinish.export'>
    <execute-file file='test.bat' params='Doctrine'/>
  </function>
  <!-- ==== default.onFinish.Export ==== -->
  <function name='default.onFinish.export'>
    <execute-file file='test.bat' params='default'/>
  </function>
</uscript>

Now, every time when ORM Designer exports a model it will execute one of these functions, based on the project ORM type.

Conclusion

Currently, a support for user-callbacks in scripts is limited only to export scripts. In future, we would like to add more callbacks places depending on users’ requirements. If you have any questions about this topic, feel free to contact us.

12 Oct 2010

Posted by: Ludek Vodicka

Extending Skipper #import-export #extensions

First ORM Designer Doctrine 2 project screens

After serveral weeks of intensive work on ORM Designer we’re almost done finishing Doctrine 2 support. You can find two new screenshot bellow with correctly imported Doctrine 2 model. Used models can be found in Doctrine 2 unit tests.

First alpha version is almost ready to be released, we have to do some final touches to the user interface.

Screenshot of CMS testing project:

Screenshot of Navigation testing project:

Screenshot of import project screen in ORM Designer:

18 Jun 2010