Fixed issue
32923: There was a NPE in the SelectorFieldPropertyCallout
There was a NullpointerException in the SelectorFieldPropertyCallout because
in the printPage method, there was not being taken into account the fact of
having a property of a computed column and the entity was not correctly retrieved.
This have been fixed checking if it is a computed column and generating the entity
correctly if so.
--- a/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorFieldPropertyCallout.java Wed May 11 21:13:35 2016 +0530
+++ b/modules/org.openbravo.userinterface.selector/src/org/openbravo/userinterface/selector/SelectorFieldPropertyCallout.java Mon May 16 15:57:17 2016 +0200
@@ -92,7 +92,7 @@
} else {
final String[] parts = property.split("\\.");
Entity currentEntity = entity;
- Property currentProperty;
+ Property currentProperty = null;
for (String part : parts) {
if (part.length() == 0) {
writeEmptyResult(response);
@@ -110,7 +110,13 @@
if (currentProperty.isPrimitive()) {
break;
}
- currentEntity = foundProperty.getTargetEntity();
+
+ if (Entity.COMPUTED_COLUMNS_PROXY_PROPERTY.equals(currentProperty.getName())) {
+ currentEntity = ModelProvider.getInstance().getEntity(
+ currentEntity.getName() + Entity.COMPUTED_COLUMNS_CLASS_APPENDIX);
+ } else {
+ currentEntity = foundProperty.getTargetEntity();
+ }
}
}
@@ -119,11 +125,18 @@
try {
// get the table
final Entity propertyEntity = foundProperty.getEntity();
- final Table propertyTable = OBDal
- .getInstance()
- .createQuery(Table.class,
- Table.PROPERTY_DBTABLENAME + "='" + propertyEntity.getTableName() + "'").list()
- .get(0);
+
+ String tableId = propertyEntity.getTableId();
+
+ if (propertyEntity.isVirtualEntity()) {
+ // If it is a virtual entity, that means that the variable tableId will be
+ // the id of the table concatenated to the "_CC" substring, this is why the
+ // tableId variable is get by removing the last three characters.
+ tableId = tableId.substring(0, tableId.length() - 3);
+ }
+
+ final Table propertyTable = OBDal.getInstance()
+ .createQuery(Table.class, Table.PROPERTY_ID + "='" + tableId + "'").list().get(0);
final OBCriteria<Column> columnCriteria = OBDal.getInstance().createCriteria(Column.class);
columnCriteria.add(Restrictions.and(Restrictions.eq(Column.PROPERTY_TABLE, propertyTable),