Results 1 to 6 of 6

Thread: Best practise to populate database after running Roo script

  1. #1
    Join Date
    Dec 2011
    Posts
    28

    Question Best practise to populate database after running Roo script

    I am having a quite extensive Roo script to set up a domain model.

    To use the application I need some initial data in the DB.

    Ideally Roo should be able to call an external (bash)-script or maybe execute an SQL file.

    How do you proceed if you need to automatically populate the DB after Roo ran its script?

  2. #2

    Default

    I know there's such an "addon-oscommands" addon to let you run OS commands from within the Roo shell.
    I guess commands can be run from within a script as well.

    Cheers,
    Vito

  3. #3
    Join Date
    Dec 2011
    Posts
    28

    Default

    Thanks for the hint, I found it here: http://code.google.com/p/spring-roo-os-commands/

    I will check it out.

  4. #4
    Join Date
    Oct 2011
    Posts
    6

    Default An alternative

    Not quite running an os script, but a possible alternative which is less OS dependent.

    What we did in this situation was to have a class which implements ApplicationListener<ContextRefreshedEvent>. This allows us to do whatever setup we need when the application is starting up. Two caveats though. It ends up running several times during the start-up process so you need to handle the case where the DB is already initialized. It runs when starting the integration tests, for us this caused some tests to fail so we have a check in place in the code that checks if junit is in the call stack and skips the initialization if it is.

    Hope that helps.

  5. #5
    Join Date
    Dec 2011
    Posts
    28

    Default

    Quote Originally Posted by angelog View Post
    Not quite running an os script, but a possible alternative which is less OS dependent.

    What we did in this situation was to have a class which implements ApplicationListener<ContextRefreshedEvent>. ...

    Hope that helps.
    Thanks for this hint. But since this is not possible with plain roo-script, I still believe it would be nice to have a roo-command like "call" or "run" or "exec" which lets you run an os command directly.

  6. #6
    Join Date
    Dec 2011
    Posts
    28

    Default

    Quote Originally Posted by Vito Meuli View Post
    I know there's such an "addon-oscommands" addon to let you run OS commands from within the Roo shell.
    I guess commands can be run from within a script as well.

    Cheers,
    Vito
    Actually the addon is described here: https://jira.springsource.org/browse/ROO-2457 (included on how to install it directly from the roo shell)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •