diff --git a/org.adempiere.base/src/org/adempiere/base/ModelGeneratorApplication.java b/org.adempiere.base/src/org/adempiere/base/ModelGeneratorApplication.java index 63ef8e202f..192f7423b0 100644 --- a/org.adempiere.base/src/org/adempiere/base/ModelGeneratorApplication.java +++ b/org.adempiere.base/src/org/adempiere/base/ModelGeneratorApplication.java @@ -13,13 +13,18 @@ *****************************************************************************/ package org.adempiere.base; +import java.util.Map; + +import org.adempiere.util.ModelClassGenerator; import org.adempiere.util.ModelGeneratorDialog; +import org.adempiere.util.ModelInterfaceGenerator; import org.compiere.Adempiere; import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplicationContext; /** * @author hengsin + * @author tbayen - command line start * */ public class ModelGeneratorApplication implements IApplication { @@ -30,11 +35,25 @@ public class ModelGeneratorApplication implements IApplication { @Override public Object start(IApplicationContext context) throws Exception { Adempiere.startup(false); - ModelGeneratorDialog dialog = new ModelGeneratorDialog(); - dialog.setModal(true); - dialog.pack(); - dialog.setLocationRelativeTo(null); - dialog.setVisible(true); + 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(); + dialog.setModal(true); + dialog.pack(); + dialog.setLocationRelativeTo(null); + dialog.setVisible(true); + } return IApplication.EXIT_OK; } diff --git a/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java b/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java index 7d28198d13..f0455b41a5 100644 --- a/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java +++ b/org.adempiere.base/src/org/adempiere/util/ModelClassGenerator.java @@ -901,7 +901,11 @@ public class ModelClassGenerator .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append(" OR IsView='N')") .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); - sql.append(" AND TableName LIKE ").append(tableLike); + // Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ] + if (tableLike.indexOf(",") == -1) + 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(" ORDER BY TableName"); diff --git a/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java b/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java index 72de49ae62..74e5e57884 100644 --- a/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java +++ b/org.adempiere.base/src/org/adempiere/util/ModelInterfaceGenerator.java @@ -823,7 +823,11 @@ public class ModelInterfaceGenerator .append("WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')") // special views .append(" OR IsView='N')") .append(" AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' "); - sql.append(" AND TableName LIKE ").append(tableLike); + // Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ] + if (tableLike.indexOf(",") == -1) + 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(" ORDER BY TableName");