Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » Form Generator based on DB Table layout(Form Generator based on DB Table layout)
Form Generator based on DB Table layout [message #899960] Fri, 03 August 2012 08:40 Go to next message
Tore Van Grembergen is currently offline Tore Van GrembergenFriend
Messages: 7
Registered: August 2012
Junior Member
Dear All,

I am quit new to Scout (just finished the examples) and please forgive me if I make a stupid question, or if the question has been answered a zillion times.

Does anybody know if there exists a form generator in scout that creates the basic CRUD we need for a table automagically ?

It would be nice e.g. that one could be able to select a table from the database and that automatically the outline, searchform, maintenance form and related SQL code is created for the table.
For the maintenance form e.g. based on the foreign keys, automatically the generator generates dropdown boxes.

The existance of this functionality would drastically improve the speed of application development.

I know that the result is never perfect and e.g. for the search form maybe to much fields would be included, but it is much faster to delete code than to insert code.

Kind regards

Tore
Re: Form Generator based on DB Table layout [message #900123 is a reply to message #899960] Sat, 04 August 2012 10:12 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 124
Registered: November 2010
Senior Member
Thanks for asking the question (I think it is the first time, that it is asked on this forum).

I totally agree with you, having a such generator, would be a great tool for eclipse scout scout (even if, as you said, it is only used for a first raw version). I am not aware of a such tool for the moment, but I can imagine, that we are not the first developers that wonder if this possible.

Personally, I really would like to have time to investigate Eclipse EMF. To my mind, it is the only good approach for a such generator. The Modeling Platform of Eclipse provides a lots of greats tools (model to model transformation, model to text generator, different editors, tools to query or represent the model ...). If you do not use their tools, you are reinventing the wheel or you get a collection of generation scripts that will only work ones (for a specific problem).

For the moment, I am lacking of time to investigate EMF (there is a steep learning curve). I also need to clarify the perimeter of my project (the idea is not to rewrite the whole scout application model, or to write Xpand template that will do exactly the same as the Scout SDK wizard).
Re: Form Generator based on DB Table layout [message #1431725 is a reply to message #900123] Fri, 26 September 2014 04:02 Go to previous messageGo to next message
barust Mising name is currently offline barust Mising nameFriend
Messages: 57
Registered: February 2014
Member
Very interesting topic, especially since the RAP and Eclipse Modeling pair create a very powerful argument in favor of increasing the productivity of developers team to create large projects. I think Scout community no less interested in the integration of these tools and I'm wondering if anyone tried any of the Scout community to use EMF?
Re: Form Generator based on DB Table layout [message #1431846 is a reply to message #1431725] Fri, 26 September 2014 08:15 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
EMF: I also believe that EMF is a really nice technology. Not enough known in the Java ecosystem. It would be nice to have a solution to use it with Eclipse Scout.

Tore Van Grembergen wrote on Fri, 03 August 2012 10:40
Does anybody know if there exists a form generator in scout that creates the basic CRUD we need for a table automagically ?

It would be nice e.g. that one could be able to select a table from the database and that automatically the outline, searchform, maintenance form and related SQL code is created for the table.
For the maintenance form e.g. based on the foreign keys, automatically the generator generates dropdown boxes.

The existance of this functionality would drastically improve the speed of application development.


I have given some updates on the topic scaffoling for Eclipse Scout on Stackoverflow. I hope we will have at least a proof of concept for this approach.
Re: Form Generator based on DB Table layout [message #1433352 is a reply to message #1431846] Sun, 28 September 2014 16:41 Go to previous messageGo to next message
nat Gross is currently offline nat GrossFriend
Messages: 10
Registered: July 2009
Junior Member
I think it would be much simpler to generate tables & forms from JPA annotated pojos. It gives you a level of abstraction compatible with all sql dialects.
You can also query & update using the JPA dialect without any concern of the backend db.
Imho, this would give Scout an enormous boost.
nat
Re: Form Generator based on DB Table layout [message #1433705 is a reply to message #899960] Mon, 29 September 2014 06:36 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie BressonFriend
Messages: 1252
Registered: October 2011
Senior Member
Thanks for your input.

The form of the model that we should use as input is not defined yet. A lot of people in the Eclipse community use EMF. JavaEE developers prefer JPA (annotated pojos). I am not sure to know if there is a big difference between what you can express with one or the other approach.

About scaffolding and JPA: I must say that I was impressed by a demonstration of JBoss Forge I saw lately. It is really impressive.

It is really nice to see everybody sharing ideas on the topic here. Please continue to do so.
Re: Form Generator based on DB Table layout [message #1433739 is a reply to message #1433352] Mon, 29 September 2014 07:30 Go to previous message
Dennis Geesen is currently offline Dennis GeesenFriend
Messages: 46
Registered: June 2014
Member
Hey,

I was also looking for something like that, but didn't found anything. I also investigated EMF, but in my opnion the handling was too complex for this scenario.

So, I've written some kind of a very simple tools to do some of the mentioned jobs:

a) A schema generator class, which is a description of the database schema. It automatically creates the sql statements including primary/foreign key constraints. This creates the tables into the database using simple "JDBC":
accounts = table("accounts",
        column("account_id", Type.INTEGER, true, true, true),
        column("name", Type.VARCHAR),
        column("type_id", Type.INTEGER));
    createTable(accounts);

    accountitem = table("accountitems",
        column("accountitem_id", Type.INTEGER, true, true, true),
        hasOne(accounts),
        column("amount", Type.DOUBLE),
        column("valid", Type.BOOL));
    createTable(accountitem);





b) Since I use ORMlite for my application, I have a second tool for creating the annotated ORM-classes (e.g. "Account" and "Accountitem") that are used by ORMlite. This also me to run the following in my scout service class (here for create):
@Override
  public AccountFormData create(AccountFormData formData) throws ProcessingException {
    if (!ACCESS.check(new CreateAccountPermission())) {
      throw new VetoException(TEXTS.get("AuthorizationFailed"));
    }
    try {
      Account account = new Account();
      account.setAccountId(formData.getNumber().getValue());
      account.setName(formData.getName().getValue());
      account.setType(formData.getType().getValue());
      account.create();
    }
    catch (SQLException e) {
      throw new ProcessingException(e.getMessage(), e);
    }
    return formData;
  }


Furthermore it creates some basic IDs and getters/setters to the model class to avoid misspelling in SQL-statements by using constants. A small statementbuilder can be used to create the SQL statements like here for the getTableData:
SelectBuilder sb = SQLBuilder.select(Account.getTable(), Account.ACCOUNT_ID_FIELD);
sb.select(Accountitem.getTable(), Accountitem.AMOUNT_FIELD, Accountitem.VALID_FIELD); 
sb.from(Account.getTable(), Accountitem.getTable());
Object[][] res = SQL.select(sb.toString(), formData);


c) then I have a third tool to create the contents of the CRUD-Methods in the service class. For this I define the form data class and a set of "possible matching" model classes like this:
 build(AccountFormData.class, Account.class, Accountitem.class);

Like the binding of scount SQL class, this tool uses the field ids of the form and tries to map them to the fields that are defined in the account. For example: the AccountFormData has a field "name". The tool looks into the account class if it has a field also called "name". If it is not found in "account", it searches in "accountitem".



As you might see, I do not have a 1 to 1 relationship between database tables and forms.
One reason was due to the following example: I have two tables (e.g. clients and admins) that use a third common table (e.g. user). Another reasong was the simple fact that I have a lot of forms that do not have a certain table, e.g. when I want to update some data.

I also tried out JPA (eclipse link) before, but I used ORMlite, because it is not so complex and the configuration is very simple. ORMlite reuses the connection from the AbstractSqlService, so that I only have one single JDBC-definition.

If someone is going to implement some of the "generation" stuff, I would really like to help!!!
Previous Topic:What is the idea behind ICodeRow / ILookupRow?
Next Topic:@InputValidation and validation rules
Goto Forum:
  


Current Time: Fri Mar 29 10:03:58 GMT 2024

Powered by FUDForum. Page generated in 0.03882 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top