Skip to content

Commit

Permalink
fix NPE, reduce visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 2, 2017
1 parent bf33c22 commit bb5bb72
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ public String getSqlCreateSelectionFrom( //
// SELECT ... FROM ... WHERE 1=1
{
IStringExpression sqlOrderBy = SqlDocumentOrderByBuilder.newInstance(this::getFieldOrderBy).buildSqlOrderBy(defaultOrderBys);
if (sqlOrderBy.isNullExpression())
if (sqlOrderBy == null || sqlOrderBy.isNullExpression())
{
sqlOrderBy = ConstantStringExpression.of(keyColumnNameFQ);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import org.adempiere.ad.expression.api.IExpressionEvaluator.OnVariableNotFound;
import org.adempiere.ad.expression.api.IStringExpression;
import org.adempiere.ad.expression.api.impl.CompositeStringExpression;
import org.adempiere.ad.security.IUserRolePermissions;
import org.adempiere.ad.security.UserRolePermissionsKey;
import org.adempiere.ad.security.impl.AccessSqlStringExpression;
import org.adempiere.exceptions.AdempiereException;
Expand Down Expand Up @@ -113,7 +112,7 @@ public String toString()
.toString();
}

public Evaluatee getEvaluationContext()
private Evaluatee getEvaluationContext()
{
if (_evaluationContext == null)
{
Expand Down Expand Up @@ -161,11 +160,6 @@ private String getPermissionsKey()
return UserRolePermissionsKey.toPermissionsKeyString(getCtx());
}

public IUserRolePermissions getPermissions()
{
return Env.getUserRolePermissions(getCtx());
}

public String getSql(final List<Object> outSqlParams)
{
final Evaluatee evalCtx = getEvaluationContext();
Expand All @@ -185,7 +179,7 @@ private IStringExpression getSql()
return _sqlExpr;
}

public List<Object> getSqlParams()
private List<Object> getSqlParams()
{
return _sqlParams;
}
Expand Down Expand Up @@ -215,7 +209,7 @@ private final void buildSql()
if (isSorting())
{
final IStringExpression sqlOrderBy = getSqlOrderByEffective();
if (!sqlOrderBy.isNullExpression())
if (sqlOrderBy != null && !sqlOrderBy.isNullExpression())
{
sqlBuilder.append("\n ORDER BY ").append(sqlOrderBy);
}
Expand Down Expand Up @@ -247,7 +241,7 @@ private IStringExpression getSqlSelectFrom()
return entityBinding.getSqlSelectAllFrom();
}

public IStringExpression getSqlWhere()
private IStringExpression getSqlWhere()
{
if (_sqlWhereExpr == null)
{
Expand All @@ -256,7 +250,7 @@ public IStringExpression getSqlWhere()
return _sqlWhereExpr;
}

public List<Object> getSqlWhereParams()
private List<Object> getSqlWhereParams()
{
if (_sqlWhereParams == null)
{
Expand Down Expand Up @@ -339,7 +333,7 @@ private void buildSqlWhereClause()
_sqlWhereParams = sqlParams;
}

public List<DocumentQueryOrderBy> getOrderBysEffective()
private List<DocumentQueryOrderBy> getOrderBysEffective()
{
if (noSorting)
{
Expand All @@ -355,18 +349,13 @@ public List<DocumentQueryOrderBy> getOrderBysEffective()
return entityBinding.getDefaultOrderBys();
}

public IStringExpression getSqlOrderByEffective()
private IStringExpression getSqlOrderByEffective()
{
final List<DocumentQueryOrderBy> orderBys = getOrderBysEffective();
return SqlDocumentOrderByBuilder.newInstance(entityBinding::getFieldOrderBy).buildSqlOrderBy(orderBys);
}

public SqlDocumentEntityDataBindingDescriptor getEntityBinding()
{
return entityBinding;
}

public List<DocumentFilter> getDocumentFilters()
private List<DocumentFilter> getDocumentFilters()
{
return documentFilters == null ? ImmutableList.of() : ImmutableList.copyOf(documentFilters);
}
Expand Down

0 comments on commit bb5bb72

Please sign in to comment.