BF [ 2528434 ] ModelInterfaceGenerator: generate getters for common fields
This commit is contained in:
parent
334bd2b27a
commit
be56d8e4c7
|
@ -64,6 +64,7 @@ import org.compiere.util.Env;
|
||||||
* <li>BF [ 1787833 ] ModelInterfaceGenerator: don't write timestamp
|
* <li>BF [ 1787833 ] ModelInterfaceGenerator: don't write timestamp
|
||||||
* <li>FR [ 1803309 ] Model generator: generate get method for Search cols
|
* <li>FR [ 1803309 ] Model generator: generate get method for Search cols
|
||||||
* <li>FR [ 2343096 ] Model Generator: Improve Reference Class Detection
|
* <li>FR [ 2343096 ] Model Generator: Improve Reference Class Detection
|
||||||
|
* <li>BF [ 2528434 ] ModelInterfaceGenerator: generate getters for common fields
|
||||||
* @author Victor Perez, e-Evolution
|
* @author Victor Perez, e-Evolution
|
||||||
* <li>FR [ 1785001 ] Using ModelPackage of EntityType to Generate Model Class
|
* <li>FR [ 1785001 ] Using ModelPackage of EntityType to Generate Model Class
|
||||||
*/
|
*/
|
||||||
|
@ -229,11 +230,11 @@ public class ModelInterfaceGenerator
|
||||||
+ " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey " // 13..17
|
+ " c.Name, c.Description, c.ColumnSQL, c.IsEncrypted, c.IsKey " // 13..17
|
||||||
+ "FROM AD_Column c "
|
+ "FROM AD_Column c "
|
||||||
+ "WHERE c.AD_Table_ID=?"
|
+ "WHERE c.AD_Table_ID=?"
|
||||||
+ " AND c.ColumnName <> 'AD_Client_ID'"
|
// + " AND c.ColumnName <> 'AD_Client_ID'"
|
||||||
// + " AND c.ColumnName <> 'AD_Org_ID'"
|
// + " AND c.ColumnName <> 'AD_Org_ID'"
|
||||||
+ " AND c.ColumnName <> 'IsActive'"
|
// + " AND c.ColumnName <> 'IsActive'"
|
||||||
+ " 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'"
|
||||||
+ " ORDER BY c.ColumnName";
|
+ " ORDER BY c.ColumnName";
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
@ -324,12 +325,14 @@ public class ModelInterfaceGenerator
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer();
|
StringBuffer sb = new StringBuffer();
|
||||||
|
|
||||||
// Create Java Comment
|
if (isGenerateSetter(columnName))
|
||||||
generateJavaComment("Set", Name, Description, sb);
|
{
|
||||||
|
// Create Java Comment
|
||||||
// public void setColumn (xxx variable)
|
generateJavaComment("Set", Name, Description, sb);
|
||||||
sb.append("\tpublic void set").append(columnName).append(" (")
|
// public void setColumn (xxx variable)
|
||||||
.append(dataType).append(" ").append(columnName).append(");");
|
sb.append("\tpublic void set").append(columnName).append(" (")
|
||||||
|
.append(dataType).append(" ").append(columnName).append(");");
|
||||||
|
}
|
||||||
|
|
||||||
// ****** Get Comment ******
|
// ****** Get Comment ******
|
||||||
generateJavaComment("Get", Name, Description, sb);
|
generateJavaComment("Get", Name, Description, sb);
|
||||||
|
@ -346,13 +349,9 @@ public class ModelInterfaceGenerator
|
||||||
sb.append("();");
|
sb.append("();");
|
||||||
//
|
//
|
||||||
|
|
||||||
if (DisplayType.isID(displayType) && !IsKey)
|
if (isGenerateModelGetter(columnName) && DisplayType.isID(displayType) && !IsKey)
|
||||||
{
|
{
|
||||||
if ("AD_Org_ID".equalsIgnoreCase(columnName))
|
if (displayType == DisplayType.TableDir
|
||||||
{
|
|
||||||
; // do nothing
|
|
||||||
}
|
|
||||||
else if (displayType == DisplayType.TableDir
|
|
||||||
|| (displayType == DisplayType.Search && AD_Reference_ID == 0))
|
|| (displayType == DisplayType.Search && AD_Reference_ID == 0))
|
||||||
{
|
{
|
||||||
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
String referenceClassName = "I_"+columnName.substring(0, columnName.length()-3);
|
||||||
|
@ -360,7 +359,8 @@ public class ModelInterfaceGenerator
|
||||||
String tableName = columnName.substring(0, columnName.length()-3);
|
String tableName = columnName.substring(0, columnName.length()-3);
|
||||||
|
|
||||||
MTable table = MTable.get(Env.getCtx(), tableName);
|
MTable table = MTable.get(Env.getCtx(), tableName);
|
||||||
if (table != null) {
|
if (table != null)
|
||||||
|
{
|
||||||
String entityType = table.getEntityType();
|
String entityType = table.getEntityType();
|
||||||
if (!"D".equals(entityType))
|
if (!"D".equals(entityType))
|
||||||
{
|
{
|
||||||
|
@ -567,6 +567,37 @@ public class ModelInterfaceGenerator
|
||||||
return dataType;
|
return dataType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnName
|
||||||
|
* @return true if a setter method should be generated
|
||||||
|
*/
|
||||||
|
public boolean isGenerateSetter(String columnName)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
!"AD_Client_ID".equals(columnName)
|
||||||
|
//&& !"AD_Org_ID".equals(columnName)
|
||||||
|
//&& !"IsActive".equals(columnName)
|
||||||
|
&& !"Created".equals(columnName)
|
||||||
|
&& !"CreatedBy".equals(columnName)
|
||||||
|
&& !"Updated".equals(columnName)
|
||||||
|
&& !"UpdatedBy".equals(columnName)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param columnName
|
||||||
|
* @return true if a model getter method should be generated
|
||||||
|
*/
|
||||||
|
public boolean isGenerateModelGetter(String columnName)
|
||||||
|
{
|
||||||
|
return
|
||||||
|
!"AD_Client_ID".equals(columnName)
|
||||||
|
&& !"AD_Org_ID".equals(columnName)
|
||||||
|
&& !"CreatedBy".equals(columnName)
|
||||||
|
&& !"UpdatedBy".equals(columnName)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* String representation
|
* String representation
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue