Idempiere 4168 (#40)

* IDEMPIERE-4168 Move Webstore out of core

Change EntityType of webstore table, column, field and menu from 'D' to
'WSTORE'

* IDEMPIERE-4168 Move Webstore out of core

Generate Model/Interface: filter column by EntityType. Update
AD_UserMail model class.

* IDEMPIERE-4168 Move Webstore out of core

Added optional column entity type filter.
This commit is contained in:
hengsin 2020-05-09 01:06:54 +08:00 committed by GitHub
parent e1090674a5
commit 9a74e18e40
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 182 additions and 63 deletions

View File

@ -0,0 +1,45 @@
SET SQLBLANKLINES ON
SET DEFINE OFF
-- IDEMPIERE-4168 Move Webstore out of core
-- May 3, 2020, 1:18:52 PM MYT
INSERT INTO AD_EntityType (EntityType,AD_Client_ID,AD_Org_ID,AD_EntityType_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Processing,AD_EntityType_UU) VALUES ('WSTORE',0,0,200015,'Y',TO_DATE('2020-05-03 13:18:51','YYYY-MM-DD HH24:MI:SS'),100,TO_DATE('2020-05-03 13:18:51','YYYY-MM-DD HH24:MI:SS'),100,'Web Store','N','74d37167-4cda-415c-b70c-719669a42418')
;
-- May 3, 2020, 1:37:47 PM MYT
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=13700
;
UPDATE AD_Field SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=13700
;
UPDATE AD_Table SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE TableName LIKE 'W\_%' AND EntityType='D'
;
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE EntityType='WSTORE' AND TableName LIKE 'W\_%')
;
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND ColumnName LIKE 'W\_%' AND AD_Reference_ID IN (18,19,30)
;
UPDATE AD_Field SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE EntityType = 'WSTORE')
;
UPDATE AD_Tab SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE EntityType='WSTORE')
;
UPDATE AD_Window SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Window_ID IN (SELECT AD_Window_ID FROM AD_Tab WHERE EntityType='WSTORE')
;
UPDATE AD_Menu SET EntityType='WSTORE',Updated=TO_DATE('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Window_ID IN (SELECT AD_Window_ID FROM AD_Window WHERE EntityType='WSTORE')
;
SELECT register_migration_script('202005032000_IDEMPIERE-4168.sql') FROM dual
;

View File

@ -0,0 +1,42 @@
-- IDEMPIERE-4168 Move Webstore out of core
-- May 3, 2020, 1:18:52 PM MYT
INSERT INTO AD_EntityType (EntityType,AD_Client_ID,AD_Org_ID,AD_EntityType_ID,IsActive,Created,CreatedBy,Updated,UpdatedBy,Name,Processing,AD_EntityType_UU) VALUES ('WSTORE',0,0,200015,'Y',TO_TIMESTAMP('2020-05-03 13:18:51','YYYY-MM-DD HH24:MI:SS'),100,TO_TIMESTAMP('2020-05-03 13:18:51','YYYY-MM-DD HH24:MI:SS'),100,'Web Store','N','74d37167-4cda-415c-b70c-719669a42418')
;
-- May 3, 2020, 1:37:47 PM MYT
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=13700
;
UPDATE AD_Field SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Column_ID=13700
;
UPDATE AD_Table SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE TableName LIKE 'W\_%' AND EntityType='D'
;
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE EntityType='WSTORE' AND TableName LIKE 'W\_%')
;
UPDATE AD_Column SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND ColumnName LIKE 'W\_%' AND AD_Reference_ID IN (18,19,30)
;
UPDATE AD_Field SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE EntityType = 'WSTORE')
;
UPDATE AD_Tab SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Table_ID IN (SELECT AD_Table_ID FROM AD_Table WHERE EntityType='WSTORE')
;
UPDATE AD_Window SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Window_ID IN (SELECT AD_Window_ID FROM AD_Tab WHERE EntityType='WSTORE')
;
UPDATE AD_Menu SET EntityType='WSTORE',Updated=TO_TIMESTAMP('2020-05-03 13:37:47','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE EntityType='D'
AND AD_Window_ID IN (SELECT AD_Window_ID FROM AD_Window WHERE EntityType='WSTORE')
;
SELECT register_migration_script('202005032000_IDEMPIERE-4168.sql') FROM dual
;

View File

@ -38,15 +38,18 @@ public class ModelGeneratorApplication implements IApplication {
Map<?, ?> args = context.getArguments(); Map<?, ?> args = context.getArguments();
// IDEMPIERE-1686 - GenerateModel does not take commandline arguments // IDEMPIERE-1686 - GenerateModel does not take commandline arguments
String commandlineArgs[] = (String[]) args.get("application.args"); String commandlineArgs[] = (String[]) args.get("application.args");
if (commandlineArgs.length == 4) { if (commandlineArgs.length >= 4) {
String folder = commandlineArgs[0]; String folder = commandlineArgs[0];
String packageName = commandlineArgs[1]; String packageName = commandlineArgs[1];
String entityType = commandlineArgs[2]; String entityType = commandlineArgs[2];
String tableName = commandlineArgs[3]; String tableName = commandlineArgs[3];
ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName); String columnEntityType = null;
ModelClassGenerator.generateSource(folder, packageName, entityType, tableName); if (commandlineArgs.length >= 5)
columnEntityType = commandlineArgs[4];
ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName, columnEntityType);
ModelClassGenerator.generateSource(folder, packageName, entityType, tableName, columnEntityType);
} else if (commandlineArgs.length != 0) { } else if (commandlineArgs.length != 0) {
System.out.println("usage: ModelGenerator folder packageName entityType tableName"); System.out.println("usage: ModelGenerator folder packageName tableEntityType tableName columnEntityType");
} else { } else {
ModelGeneratorDialog dialog = new ModelGeneratorDialog(); ModelGeneratorDialog dialog = new ModelGeneratorDialog();
dialog.setModal(true); dialog.setModal(true);

View File

@ -106,24 +106,25 @@ public class GenerateModel
System.err.println("No EntityType"); System.err.println("No EntityType");
System.exit(1); System.exit(1);
} }
StringBuilder sql = new StringBuilder("EntityType IN (") StringBuilder entityTypeFilter = new StringBuilder("EntityType IN (")
.append(entityType).append(")"); .append(entityType).append(")");
log.info(sql.toString()); log.info(entityTypeFilter.toString());
log.info("----------------------------------"); log.info("----------------------------------");
String tableLike = null; String tableLike = null;
tableLike = "'%'"; // All tables tableLike = "'%'"; // All tablesype
// tableLike = "'AD_OrgInfo', 'AD_Role', 'C_CashLine', 'C_Currency', 'C_Invoice', 'C_Order', 'C_Payment', 'M_InventoryLine', 'M_PriceList', 'M_Product', 'U_POSTerminal'"; // Only specific tables // tableLike = "'AD_OrgInfo', 'AD_Role', 'C_CashLine', 'C_Currency', 'C_Invoice', 'C_Order', 'C_Payment', 'M_InventoryLine', 'M_PriceList', 'M_Product', 'U_POSTerminal'"; // Only specific tables
if (args.length > 3) if (args.length > 3)
tableLike = args[3]; tableLike = args[3];
if (log.isLoggable(Level.INFO)) log.info("Table Like: " + tableLike); if (log.isLoggable(Level.INFO)) log.info("Table Like: " + tableLike);
// complete sql // complete sql
sql.insert(0, "SELECT AD_Table_ID " StringBuilder sql = new StringBuilder("SELECT AD_Table_ID "
+ "FROM AD_Table " + "FROM AD_Table "
+ "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views + "WHERE (TableName IN ('RV_WarehousePrice','RV_BPartner')" // special views
+ " OR IsView='N')" + " OR IsView='N')"
+ " AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' AND "); + " AND IsActive = 'Y' AND TableName NOT LIKE '%_Trl' AND ");
sql.append(entityTypeFilter);
// Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ] // Autodetect if we need to use IN or LIKE clause - teo_sarca [ 3020640 ]
if (tableLike.indexOf(",") == -1) if (tableLike.indexOf(",") == -1)
sql.append(" AND TableName LIKE ").append(tableLike); sql.append(" AND TableName LIKE ").append(tableLike);
@ -142,8 +143,8 @@ public class GenerateModel
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
new ModelInterfaceGenerator(rs.getInt(1), directory, packageName); new ModelInterfaceGenerator(rs.getInt(1), directory, packageName, entityTypeFilter.toString());
new ModelClassGenerator(rs.getInt(1), directory, packageName); new ModelClassGenerator(rs.getInt(1), directory, packageName, entityTypeFilter.toString());
count++; count++;
} }
} }

View File

@ -41,6 +41,7 @@ import org.compiere.model.MTable;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Util;
/** /**
* Generate Model Classes extending PO. * Generate Model Classes extending PO.
@ -72,14 +73,15 @@ public class ModelClassGenerator
* @param AD_Table_ID table id * @param AD_Table_ID table id
* @param directory directory * @param directory directory
* @param packageName package name * @param packageName package name
* @param entityTypeFilter entity type filter for columns
*/ */
public ModelClassGenerator (int AD_Table_ID, String directory, String packageName) public ModelClassGenerator (int AD_Table_ID, String directory, String packageName, String entityTypeFilter)
{ {
this.packageName = packageName; this.packageName = packageName;
// create column access methods // create column access methods
StringBuilder mandatory = new StringBuilder(); StringBuilder mandatory = new StringBuilder();
StringBuilder sb = createColumns(AD_Table_ID, mandatory); StringBuilder sb = createColumns(AD_Table_ID, mandatory, entityTypeFilter);
// Header // Header
String className = createHeader(AD_Table_ID, sb, mandatory, packageName); String className = createHeader(AD_Table_ID, sb, mandatory, packageName);
@ -268,9 +270,10 @@ public class ModelClassGenerator
* Create Column access methods * Create Column access methods
* @param AD_Table_ID table * @param AD_Table_ID table
* @param mandatory init call for mandatory columns * @param mandatory init call for mandatory columns
* @param entityTypeFilter
* @return set/get method * @return set/get method
*/ */
private StringBuilder createColumns (int AD_Table_ID, StringBuilder mandatory) private StringBuilder createColumns (int AD_Table_ID, StringBuilder mandatory, String entityTypeFilter)
{ {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3 String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
@ -281,6 +284,7 @@ public class ModelClassGenerator
+ "WHERE c.AD_Table_ID=?" + "WHERE c.AD_Table_ID=?"
+ " AND c.ColumnName NOT IN ('AD_Client_ID', 'AD_Org_ID', 'IsActive', 'Created', 'CreatedBy', 'Updated', 'UpdatedBy')" + " AND c.ColumnName NOT IN ('AD_Client_ID', 'AD_Org_ID', 'IsActive', 'Created', 'CreatedBy', 'Updated', 'UpdatedBy')"
+ " AND c.IsActive='Y'" + " AND c.IsActive='Y'"
+ (!Util.isEmpty(entityTypeFilter) ? " AND c." + entityTypeFilter : "")
+ " ORDER BY c.ColumnName"; + " ORDER BY c.ColumnName";
boolean isKeyNamePairCreated = false; // true if the method "getKeyNamePair" is already generated boolean isKeyNamePairCreated = false; // true if the method "getKeyNamePair" is already generated
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
@ -842,8 +846,9 @@ public class ModelClassGenerator
* @param packageName * @param packageName
* @param entityType * @param entityType
* @param tableLike * @param tableLike
* @param columnEntityType
*/ */
public static void generateSource(String sourceFolder, String packageName, String entityType, String tableName) public static void generateSource(String sourceFolder, String packageName, String entityType, String tableName, String columnEntityType)
{ {
if (sourceFolder == null || sourceFolder.trim().length() == 0) if (sourceFolder == null || sourceFolder.trim().length() == 0)
throw new IllegalArgumentException("Must specify source folder"); throw new IllegalArgumentException("Must specify source folder");
@ -922,6 +927,25 @@ public class ModelClassGenerator
} }
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");
// //
StringBuilder columnFilterBuilder = new StringBuilder();
if (!Util.isEmpty(columnEntityType, true))
{
columnFilterBuilder.append("EntityType IN (");
StringTokenizer tokenizer = new StringTokenizer(columnEntityType, ",");
int i = 0;
while(tokenizer.hasMoreTokens()) {
StringBuilder token = new StringBuilder().append(tokenizer.nextToken().trim());
if (!token.toString().startsWith("'") || !token.toString().endsWith("'"))
token = new StringBuilder("'").append(token).append("'");
if (i > 0)
columnFilterBuilder.append(",");
columnFilterBuilder.append(token);
i++;
}
columnFilterBuilder.append(")");
}
String columnFilter = columnFilterBuilder.length() > 0 ? columnFilterBuilder.toString() : null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -930,7 +954,7 @@ public class ModelClassGenerator
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
new ModelClassGenerator(rs.getInt(1), directory.toString(), packageName); new ModelClassGenerator(rs.getInt(1), directory.toString(), packageName, columnFilter);
} }
} }
catch (SQLException e) catch (SQLException e)

View File

@ -52,6 +52,7 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
private JCheckBox fGenerateInterface; private JCheckBox fGenerateInterface;
private JCheckBox fGenerateClass; private JCheckBox fGenerateClass;
private JTextField fEntityType; private JTextField fEntityType;
private JTextField fColumnEntityType;
public ModelGeneratorDialog() { public ModelGeneratorDialog() {
super(); super();
@ -62,7 +63,7 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
this.getContentPane().add(confirmPanel, BorderLayout.SOUTH); this.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
Panel mainPanel = new Panel(); Panel mainPanel = new Panel();
this.getContentPane().add(mainPanel, BorderLayout.CENTER); this.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.setLayout(new GridLayout(5, 2)); mainPanel.setLayout(new GridLayout(6, 2));
Panel filePanel = new Panel(); Panel filePanel = new Panel();
filePanel.setLayout(new BorderLayout()); filePanel.setLayout(new BorderLayout());
@ -84,16 +85,24 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
fTableName = new JTextField("AD_ReplaceThis%"); fTableName = new JTextField("AD_ReplaceThis%");
mainPanel.add(fTableName); mainPanel.add(fTableName);
mainPanel.add(new JLabel("Entity Type")); mainPanel.add(new JLabel("Table Entity Type"));
fEntityType = new JTextField("D"); fEntityType = new JTextField("D");
mainPanel.add(fEntityType); mainPanel.add(fEntityType);
mainPanel.add(new JLabel("Column Entity Type"));
fColumnEntityType = new JTextField("");
mainPanel.add(fColumnEntityType);
Panel chkPanel = new Panel();
chkPanel.setLayout(new GridLayout(1, 2));
mainPanel.add(new JLabel(""));
mainPanel.add(chkPanel);
fGenerateInterface = new JCheckBox("Generate Interface"); fGenerateInterface = new JCheckBox("Generate Interface");
fGenerateInterface.setSelected(true); fGenerateInterface.setSelected(true);
mainPanel.add(fGenerateInterface); chkPanel.add(fGenerateInterface);
fGenerateClass = new JCheckBox("Generate Class"); fGenerateClass = new JCheckBox("Generate Class");
fGenerateClass.setSelected(true); fGenerateClass.setSelected(true);
mainPanel.add(fGenerateClass); chkPanel.add(fGenerateClass);
bGenerate = new JButton("Generate Source"); bGenerate = new JButton("Generate Source");
confirmPanel.add(bGenerate); confirmPanel.add(bGenerate);
@ -130,12 +139,13 @@ public class ModelGeneratorDialog extends JDialog implements ActionListener {
JOptionPane.showMessageDialog(this, "Must select at least one of generate interface or generate class", "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(this, "Must select at least one of generate interface or generate class", "Error", JOptionPane.ERROR_MESSAGE);
return; return;
} }
String columnEntityType = fColumnEntityType.getText();
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR)); this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (fGenerateInterface.isSelected()) { if (fGenerateInterface.isSelected()) {
ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName); ModelInterfaceGenerator.generateSource(folder, packageName, entityType, tableName, columnEntityType);
} }
if (fGenerateClass.isSelected()) { if (fGenerateClass.isSelected()) {
ModelClassGenerator.generateSource(folder, packageName, entityType, tableName); ModelClassGenerator.generateSource(folder, packageName, entityType, tableName, columnEntityType);
} }
this.dispose(); this.dispose();
} else if (e.getSource() == bCancel) { } else if (e.getSource() == bCancel) {

View File

@ -52,6 +52,7 @@ import org.compiere.util.CLogger;
import org.compiere.util.DB; import org.compiere.util.DB;
import org.compiere.util.DisplayType; import org.compiere.util.DisplayType;
import org.compiere.util.Env; import org.compiere.util.Env;
import org.compiere.util.Util;
/** /**
* @author Trifon Trifonov * @author Trifon Trifonov
@ -106,11 +107,18 @@ public class ModelInterfaceGenerator
/** Logger */ /** Logger */
private static final CLogger log = CLogger.getCLogger(ModelInterfaceGenerator.class); private static final CLogger log = CLogger.getCLogger(ModelInterfaceGenerator.class);
public ModelInterfaceGenerator(int AD_Table_ID, String directory, String packageName) { /**
*
* @param AD_Table_ID
* @param directory
* @param packageName
* @param entityTypeFilter entity type filter for column
*/
public ModelInterfaceGenerator(int AD_Table_ID, String directory, String packageName, String entityTypeFilter) {
this.packageName = packageName; this.packageName = packageName;
// create column access methods // create column access methods
StringBuilder mandatory = new StringBuilder(); StringBuilder mandatory = new StringBuilder();
StringBuilder sb = createColumns(AD_Table_ID, mandatory); StringBuilder sb = createColumns(AD_Table_ID, mandatory, entityTypeFilter);
// Header // Header
String tableName = createHeader(AD_Table_ID, sb, mandatory); String tableName = createHeader(AD_Table_ID, sb, mandatory);
@ -232,9 +240,10 @@ public class ModelInterfaceGenerator
* *
* @param AD_Table_ID table * @param AD_Table_ID table
* @param mandatory init call for mandatory columns * @param mandatory init call for mandatory columns
* @param entityTypeFilter
* @return set/get method * @return set/get method
*/ */
private StringBuilder createColumns(int AD_Table_ID, StringBuilder mandatory) { private StringBuilder createColumns(int AD_Table_ID, StringBuilder mandatory, String entityTypeFilter) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3 String sql = "SELECT c.ColumnName, c.IsUpdateable, c.IsMandatory," // 1..3
+ " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7 + " c.AD_Reference_ID, c.AD_Reference_Value_ID, DefaultValue, SeqNo, " // 4..7
@ -249,6 +258,7 @@ public class ModelInterfaceGenerator
// + " AND c.ColumnName NOT LIKE 'Created%'" // + " AND c.ColumnName NOT LIKE 'Created%'"
// + " AND c.ColumnName NOT LIKE 'Updated%' " // + " AND c.ColumnName NOT LIKE 'Updated%' "
+ " AND c.IsActive='Y'" + " AND c.IsActive='Y'"
+ (!Util.isEmpty(entityTypeFilter) ? " AND c." + entityTypeFilter : "")
+ " ORDER BY c.ColumnName"; + " ORDER BY c.ColumnName";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
@ -759,8 +769,9 @@ public class ModelInterfaceGenerator
* @param packageName * @param packageName
* @param entityType * @param entityType
* @param tableLike * @param tableLike
* @param columnEntityType
*/ */
public static void generateSource(String sourceFolder, String packageName, String entityType, String tableName) public static void generateSource(String sourceFolder, String packageName, String entityType, String tableName, String columnEntityType)
{ {
if (sourceFolder == null || sourceFolder.trim().length() == 0) if (sourceFolder == null || sourceFolder.trim().length() == 0)
throw new IllegalArgumentException("Must specify source folder"); throw new IllegalArgumentException("Must specify source folder");
@ -840,6 +851,25 @@ public class ModelInterfaceGenerator
sql.append(" ORDER BY TableName"); sql.append(" ORDER BY TableName");
// //
StringBuilder columnFilterBuilder = new StringBuilder();
if (!Util.isEmpty(columnEntityType, true))
{
columnFilterBuilder.append("EntityType IN (");
StringTokenizer tokenizer = new StringTokenizer(columnEntityType, ",");
int i = 0;
while(tokenizer.hasMoreTokens()) {
StringBuilder token = new StringBuilder().append(tokenizer.nextToken().trim());
if (!token.toString().startsWith("'") || !token.toString().endsWith("'"))
token = new StringBuilder("'").append(token).append("'");
if (i > 0)
columnFilterBuilder.append(",");
columnFilterBuilder.append(token);
i++;
}
columnFilterBuilder.append(")");
}
String columnFilter = columnFilterBuilder.length() > 0 ? columnFilterBuilder.toString() : null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try
@ -848,7 +878,7 @@ public class ModelInterfaceGenerator
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while (rs.next()) while (rs.next())
{ {
new ModelInterfaceGenerator(rs.getInt(1), directory.toString(), packageName); new ModelInterfaceGenerator(rs.getInt(1), directory.toString(), packageName, columnFilter);
} }
} }
catch (SQLException e) catch (SQLException e)

View File

@ -255,17 +255,4 @@ public interface I_AD_UserMail
* User who updated this records * User who updated this records
*/ */
public int getUpdatedBy(); public int getUpdatedBy();
/** Column name W_MailMsg_ID */
public static final String COLUMNNAME_W_MailMsg_ID = "W_MailMsg_ID";
/** Set Mail Message.
* Web Store Mail Message Template
*/
public void setW_MailMsg_ID (int W_MailMsg_ID);
/** Get Mail Message.
* Web Store Mail Message Template
*/
public int getW_MailMsg_ID();
} }

View File

@ -30,7 +30,7 @@ public class X_AD_UserMail extends PO implements I_AD_UserMail, I_Persistent
/** /**
* *
*/ */
private static final long serialVersionUID = 20200413L; private static final long serialVersionUID = 20200508L;
/** Standard Constructor */ /** Standard Constructor */
public X_AD_UserMail (Properties ctx, int AD_UserMail_ID, String trxName) public X_AD_UserMail (Properties ctx, int AD_UserMail_ID, String trxName)
@ -316,27 +316,4 @@ public class X_AD_UserMail extends PO implements I_AD_UserMail, I_Persistent
{ {
return (String)get_Value(COLUMNNAME_Subject); return (String)get_Value(COLUMNNAME_Subject);
} }
/** Set Mail Message.
@param W_MailMsg_ID
Web Store Mail Message Template
*/
public void setW_MailMsg_ID (int W_MailMsg_ID)
{
if (W_MailMsg_ID < 1)
set_ValueNoCheck (COLUMNNAME_W_MailMsg_ID, null);
else
set_ValueNoCheck (COLUMNNAME_W_MailMsg_ID, Integer.valueOf(W_MailMsg_ID));
}
/** Get Mail Message.
@return Web Store Mail Message Template
*/
public int getW_MailMsg_ID ()
{
Integer ii = (Integer)get_Value(COLUMNNAME_W_MailMsg_ID);
if (ii == null)
return 0;
return ii.intValue();
}
} }