Source:
<code>private String createZoomOriginQueryWhereClause(final IZoomSource zoomOrigin) { final ITableRecordIdDAO tableRecordIdDAO = Services.get(ITableRecordIdDAO.class); final StringBuilder queryWhereClause = new StringBuilder(); final ITableRefInfo refTable = getTarget().getTableRefInfo(); final String targetTableName = zoomOrigin.getTableName(); final String originTableName = refTable.getTableName(); final String whereClause = refTable.getWhereClause(); if (isTableRecordIdTarget) { String originRecordIdName = null; final List<TableRecordIdDescriptor> tableRecordIdDescriptors = tableRecordIdDAO.getTableRecordIdReferences(originTableName); for (final TableRecordIdDescriptor tableRecordIdDescriptor : tableRecordIdDescriptors) { if (targetTableName.equals(tableRecordIdDescriptor.getTargetTableName())) { originRecordIdName = tableRecordIdDescriptor.getRecordIdColumnName(); break; } } if (originRecordIdName != null) { final String tableIdColumnName = Services.get(IColumnBL.class).getTableIdColumnName(originTableName, originRecordIdName).orElse(null); Check.assumeNotEmpty(tableIdColumnName, "The table must have an AD_Table_ID column", originTableName); queryWhereClause .append(zoomOrigin.getAD_Table_ID()) .append(" = ") .append(originTableName) .append(".") .append(tableIdColumnName) .append(" AND ") .append(zoomOrigin.getRecord_ID()) .append(" = ") .append(originTableName) .append(".") .append(originRecordIdName); <START> if (whereClause != null) <END> { queryWhereClause.append(" AND ").append(whereClause); } } else { queryWhereClause.append(" 1=2 "); } } else { final String refTableWhereClause = whereClause; if (!Check.isEmpty(refTableWhereClause)) { queryWhereClause.append(parseWhereClause(zoomOrigin, refTableWhereClause, true)); } else { throw new AdempiereException("RefTable " + refTable + " has no whereClause, so RelationType " + this + " needs to be explicit"); } } return queryWhereClause.toString(); }</code><technical_language>suggestion if (Check.isNotBlank(whereClause)) ...with de.metas.util.Check...this takes care of e.g. " "</technical_language>

Target:
private String createZoomOriginQueryWhereClause(final IZoomSource zoomOrigin) { final ITableRecordIdDAO tableRecordIdDAO = Services.get(ITableRecordIdDAO.class); final StringBuilder queryWhereClause = new StringBuilder(); final ITableRefInfo refTable = getTarget().getTableRefInfo(); final String targetTableName = zoomOrigin.getTableName(); final String originTableName = refTable.getTableName(); final String whereClause = refTable.getWhereClause(); if (isTableRecordIdTarget) { String originRecordIdName = null; final List<TableRecordIdDescriptor> tableRecordIdDescriptors = tableRecordIdDAO.getTableRecordIdReferences(originTableName); for (final TableRecordIdDescriptor tableRecordIdDescriptor : tableRecordIdDescriptors) { if (targetTableName.equals(tableRecordIdDescriptor.getTargetTableName())) { originRecordIdName = tableRecordIdDescriptor.getRecordIdColumnName(); break; } } if (originRecordIdName != null) { final String tableIdColumnName = Services.get(IColumnBL.class).getTableIdColumnName(originTableName, originRecordIdName).orElse(null); Check.assumeNotEmpty(tableIdColumnName, "The table must have an AD_Table_ID column", originTableName); queryWhereClause .append(zoomOrigin.getAD_Table_ID()) .append(" = ") .append(originTableName) .append(".") .append(tableIdColumnName) .append(" AND ") .append(zoomOrigin.getRecord_ID()) .append(" = ") .append(originTableName) .append(".") .append(originRecordIdName); if (Check.isNotBlank(whereClause)) { queryWhereClause.append(" AND ").append(whereClause); } } else { queryWhereClause.append(" 1=2 "); } } else { final String refTableWhereClause = whereClause; if (!Check.isEmpty(refTableWhereClause)) { queryWhereClause.append(parseWhereClause(zoomOrigin, refTableWhereClause, true)); } else { throw new AdempiereException("RefTable " + refTable + " has no whereClause, so RelationType " + this + " needs to be explicit"); } } return queryWhereClause.toString(); }