IDEMPIERE-1686 GenerateModel does not take commandline arguments

This commit is contained in:
Thomas Bayen 2014-04-02 10:22:20 -05:00
parent d75a1cb722
commit 036f065d70
3 changed files with 34 additions and 7 deletions

View File

@ -13,13 +13,18 @@
*****************************************************************************/ *****************************************************************************/
package org.adempiere.base; package org.adempiere.base;
import java.util.Map;
import org.adempiere.util.ModelClassGenerator;
import org.adempiere.util.ModelGeneratorDialog; import org.adempiere.util.ModelGeneratorDialog;
import org.adempiere.util.ModelInterfaceGenerator;
import org.compiere.Adempiere; import org.compiere.Adempiere;
import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.app.IApplicationContext;
/** /**
* @author hengsin * @author hengsin
* @author tbayen - command line start
* *
*/ */
public class ModelGeneratorApplication implements IApplication { public class ModelGeneratorApplication implements IApplication {
@ -30,11 +35,25 @@ public class ModelGeneratorApplication implements IApplication {
@Override @Override
public Object start(IApplicationContext context) throws Exception { public Object start(IApplicationContext context) throws Exception {
Adempiere.startup(false); Adempiere.startup(false);
Map<?, ?> args = context.getArguments();
// IDEMPIERE-1686 - GenerateModel does not take commandline arguments
String commandlineArgs[] = (String[]) args.get("application.args");
if (commandlineArgs.length == 4) {
String folder = commandlineArgs[0];
String packageName = commandlineArgs[1];
String entityType = commandlineArgs[2];
String tableName = commandlineArgs[3];
ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName);
ModelClassGenerator.generateSource(folder, packageName, entityType, tableName);
} else if (commandlineArgs.length != 0) {
System.out.println("usage: ModelGenerator folder packageName entityType tableName");
} else {
ModelGeneratorDialog dialog = new ModelGeneratorDialog(); ModelGeneratorDialog dialog = new ModelGeneratorDialog();
dialog.setModal(true); dialog.setModal(true);
dialog.pack(); dialog.pack();
dialog.setLocationRelativeTo(null); dialog.setLocationRelativeTo(null);
dialog.setVisible(true); dialog.setVisible(true);
}
return IApplication.EXIT_OK; return IApplication.EXIT_OK;
} }

View File

@ -901,7 +901,11 @@ public class ModelClassGenerator
.append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views
.append(" OR IsView='N')") .append(" OR IsView='N')")
.append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' ");
// Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ]
if (tableLike.indexOf(",") == -1)
sql.append(" AND TableName LIKE ").append(tableLike); sql.append(" AND TableName LIKE ").append(tableLike);
else
sql.append(" AND TableName IN (").append(tableLike).append(")"); // only specific tables
sql.append(" AND ").append(entityTypeFilter.toString()); sql.append(" AND ").append(entityTypeFilter.toString());
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");

View File

@ -823,7 +823,11 @@ public class ModelInterfaceGenerator
.append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views
.append(" OR IsView='N')") .append(" OR IsView='N')")
.append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' ");
// Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ]
if (tableLike.indexOf(",") == -1)
sql.append(" AND TableName LIKE ").append(tableLike); sql.append(" AND TableName LIKE ").append(tableLike);
else
sql.append(" AND TableName IN (").append(tableLike).append(")"); // only specific tables
sql.append(" AND ").append(entityTypeFilter.toString()); sql.append(" AND ").append(entityTypeFilter.toString());
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");