IDEMPIERE-4607 Cannot export windows via 2pack if any field has a Fie… (#483)

* IDEMPIERE-4607 Cannot export windows via 2pack if any field has a Field Group

* IDEMPIERE-4607 Implement changes discussed in JIRA - Add a new isList method to DisplayType

* IDEMPIERE-4607 Fixed typo

* IDEMPIERE-4607 Implement default method to return false by default - PR CarlosRuiz
This commit is contained in:
Diego Ruiz 2020-12-26 16:35:50 +01:00 committed by GitHub
parent 9093f31709
commit da6d6b83aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 55 additions and 18 deletions

View File

@ -29,6 +29,9 @@ public interface IDisplayTypeFactory {
public Integer getDefaultPrecision(int displayType);
public boolean isText(int displayType);
public boolean isDate (int displayType);
public default boolean isList (int displayType) {
return false;
}
public boolean isLookup(int displayType);
public boolean isLOB (int displayType);
public DecimalFormat getNumberFormat(int displayType, Language language, String pattern);

View File

@ -609,7 +609,7 @@ public class CreateAdempiere
values.append("NULL");
}
else if (DisplayType.isText(dt) || dt == DisplayType.YesNo
|| dt == DisplayType.List || dt == DisplayType.Button
|| DisplayType.isList(dt) || dt == DisplayType.Button
|| columnName.equals("AD_Language"))
{
String s = rs.getString(columnName);

View File

@ -800,7 +800,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
foreignTable = "AD_Org";
else if ("C_ProjectType_ID".equalsIgnoreCase(getColumnName()))
foreignTable = "C_ProjectType";
} else if (DisplayType.List == refid || DisplayType.Payment == refid) {
} else if (DisplayType.isList(refid) || DisplayType.Payment == refid) {
foreignTable = "AD_Ref_List";
} else if (DisplayType.Location == refid) {
foreignTable = "C_Location";
@ -941,7 +941,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
if (!column.isKey() && !column.getColumnName().equals(PO.getUUIDColumnName(table.getTableName())) && !column.isVirtualColumn())
{
int refid = column.getAD_Reference_ID();
if (refid != DisplayType.List && refid != DisplayType.Payment)
if (!DisplayType.isList(refid) && refid != DisplayType.Payment)
{
String referenceTableName = column.getReferenceTableName();
if (referenceTableName != null)
@ -1153,7 +1153,7 @@ public class MColumn extends X_AD_Column implements ImmutablePOSupport
return "";
int refid = column.getAD_Reference_ID();
if (refid != DisplayType.List && refid != DisplayType.Payment)
if (!DisplayType.isList(refid) && refid != DisplayType.Payment)
{
String referenceTableName = column.getReferenceTableName();
if (referenceTableName != null)

View File

@ -188,7 +188,7 @@ public class MLookupFactory
MLookupInfo info = null;
boolean needToAddSecurity = true;
// List
if (AD_Reference_ID == DisplayType.List || AD_Reference_ID == DisplayType.ChosenMultipleSelectionList || AD_Reference_ID == DisplayType.RadiogroupList) // 17
if (DisplayType.isList(AD_Reference_ID)) // 17
{
info = getLookup_List(language, AD_Reference_Value_ID);
needToAddSecurity = false;
@ -925,7 +925,7 @@ public class MLookupFactory
displayColumn.append("(").append(embeddedSQL).append(")");
}
// List
else if (ldc.DisplayType == DisplayType.List)
else if (DisplayType.isList(ldc.DisplayType))
{
String embeddedSQL = getLookup_ListEmbed(language, ldc.AD_Reference_ID, ldc.ColumnName);
if (embeddedSQL != null)

View File

@ -348,7 +348,7 @@ public class MProcessPara extends X_AD_Process_Para implements ImmutablePOSuppor
if (rt != null)
foreignTable = rt.getAD_Table().getTableName();
}
} else if (DisplayType.List == getAD_Reference_ID()) {
} else if (DisplayType.isList(getAD_Reference_ID())) {
foreignTable = "AD_Ref_List";
}

View File

@ -456,7 +456,7 @@ public class DataEngine
}
// -- List or Button with ReferenceValue --
else if (AD_Reference_ID == DisplayType.List
else if (DisplayType.isList(AD_Reference_ID)
|| (AD_Reference_ID == DisplayType.Button && AD_Reference_Value_ID != 0))
{
if (ColumnSQL.length() > 0)

View File

@ -121,7 +121,7 @@ public class RColumn
else if (displayType == DisplayType.Integer)
m_colClass = Integer.class;
// List
else if (displayType == DisplayType.List)
else if (DisplayType.isList(displayType))
{
Language language = Language.getLanguage(Env.getAD_Language(ctx));
m_colSQL = "(" + MLookupFactory.getLookup_ListEmbed(

View File

@ -364,6 +364,35 @@ public final class DisplayType
return false;
} // isDate
/**
* Returns true if DisplayType is a List.
* (stored as Text)
* @param displayType Display Type
* @return true if List
*/
public static boolean isList(int displayType)
{
if (DisplayType.List == displayType || DisplayType.RadiogroupList == displayType
|| DisplayType.ChosenMultipleSelectionList == displayType)
return true;
IServiceReferenceHolder<IDisplayTypeFactory> cache = s_displayTypeFactoryCache.get(displayType);
if (cache != null) {
IDisplayTypeFactory service = cache.getService();
if (service != null)
return service.isList(displayType);
}
Optional<IServiceReferenceHolder<IDisplayTypeFactory>> found = getDisplayTypeFactories().stream()
.filter(e -> e.getService() != null && e.getService().isList(displayType))
.findFirst();
if (found.isPresent()) {
s_displayTypeFactoryCache.put(displayType, found.get());
return true;
}
return false;
} // isList
/**
* Returns true if DisplayType is a VLookup (List, Table, TableDir, Search).
* (stored as Integer)

View File

@ -197,7 +197,7 @@ public class PackRollProcess extends SvrProcess {
if (v_AD_Reference_ID == DisplayType.String
|| v_AD_Reference_ID == DisplayType.Text
|| v_AD_Reference_ID == DisplayType.Memo
|| v_AD_Reference_ID == DisplayType.List
|| DisplayType.isList(v_AD_Reference_ID)
// Carlos Ruiz globalqss, special
// treatment for EntityType
// it's a Table reference but must

View File

@ -255,7 +255,7 @@ public class PoExporter {
tableName = columnName.substring(0, columnName.length() - 3);
}
addTableReference(columnName, tableName, new AttributesImpl());
} else if (DisplayType.List == displayType) {
} else if (DisplayType.isList(displayType)) {
add(columnName, "", new AttributesImpl());
} else if (DisplayType.isLookup(displayType)) {
String tableName = null;

View File

@ -546,7 +546,7 @@ public class WWFActivity extends ADForm implements EventListener<Event>
}
fAnswerList.setVisible(true);
}
else if (dt == DisplayType.List)
else if (DisplayType.isList(dt))
{
ValueNamePair[] values = MRefList.getList(Env.getCtx(), m_column.getAD_Reference_Value_ID(), false);
for(int i = 0; i < values.length; i++)
@ -680,7 +680,7 @@ public class WWFActivity extends ADForm implements EventListener<Event>
// Do we have an answer?
int dt = m_column.getAD_Reference_ID();
String value = fAnswerText.getText();
if (dt == DisplayType.YesNo || dt == DisplayType.List)
if (dt == DisplayType.YesNo || DisplayType.isList(dt))
{
ListItem li = fAnswerList.getSelectedItem();
if(li != null) value = li.getValue().toString();

View File

@ -1412,7 +1412,7 @@ public class DB_Oracle implements AdempiereDatabase
&& ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1
{
if (DisplayType.isText(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.List
|| DisplayType.isList(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.YesNo
// Two special columns: Defined as Table but DB Type is String
|| column.getColumnName().equals("EntityType") || column.getColumnName().equals("AD_Language")
@ -1485,7 +1485,7 @@ public class DB_Oracle implements AdempiereDatabase
&& ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1
{
if (DisplayType.isText(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.List
|| DisplayType.isList(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.YesNo
|| column.getAD_Reference_ID() == DisplayType.Payment
// Two special columns: Defined as Table but DB Type is String

View File

@ -1313,7 +1313,7 @@ public class DB_PostgreSQL implements AdempiereDatabase
&& ( ! (DisplayType.isID(column.getAD_Reference_ID()) && defaultValue.equals("-1") ) ) ) // not for ID's with default -1
{
if (DisplayType.isText(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.List
|| DisplayType.isList(column.getAD_Reference_ID())
|| column.getAD_Reference_ID() == DisplayType.YesNo
// Two special columns: Defined as Table but DB Type is String
|| column.getColumnName().equals("EntityType") || column.getColumnName().equals("AD_Language")

View File

@ -40,6 +40,11 @@ public class FakeDisplayTypeFactory implements IDisplayTypeFactory {
return false;
}
@Override
public boolean isList(int displayType) {
return false;
}
@Override
public boolean isLookup(int displayType) {
return false;

View File

@ -1095,7 +1095,7 @@ public class ModelADServiceImpl extends AbstractService implements ModelADServic
AD_Reference_ID = ((MLookup)lookup).getDisplayType();
}
if(AD_Reference_ID==DisplayType.List)
if(DisplayType.isList(AD_Reference_ID))
{
if (lookup.getSize() == 0)
lookup.refresh();

View File

@ -543,7 +543,7 @@ public class Process {
Object value = valueString;
if (valueString != null && valueString.length() == 0)
value = null;
if (value != null && (DisplayType.List == displayType ||
if (value != null && (DisplayType.isList(displayType) ||
DisplayType.TableDir== displayType ||
DisplayType.Table== displayType)&& value.equals("-1"))
value= null;