Skip to content

Commit

Permalink
more helper methods on ViewRowIdsOrderedSelection
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed May 3, 2017
1 parent ed132de commit f2309d8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.util.Collection;
import java.util.List;

import org.adempiere.ad.dao.IQueryFilter;
import org.adempiere.ad.security.IUserRolePermissions;
import org.adempiere.ad.security.IUserRolePermissionsDAO;
import org.adempiere.ad.security.UserRolePermissionsKey;
Expand Down Expand Up @@ -138,7 +139,7 @@ public ViewRowIdsOrderedSelection addRowIdsToSelection(final ViewRowIdsOrderedSe
// Add
boolean hasChanges = false;
final String selectionId = selection.getSelectionId();
for(final DocumentId rowId : rowIds)
for (final DocumentId rowId : rowIds)
{
final List<Object> sqlParams = new ArrayList<>();
final String sqlAdd = newSqlViewSelectionQueryBuilder().buildSqlAddRowIdsFromSelection(sqlParams, selectionId, rowId);
Expand All @@ -147,10 +148,10 @@ public ViewRowIdsOrderedSelection addRowIdsToSelection(final ViewRowIdsOrderedSe
{
continue;
}

hasChanges = true;
}
if(!hasChanges)
if (!hasChanges)
{
// nothing changed
return selection;
Expand Down Expand Up @@ -196,7 +197,7 @@ public ViewRowIdsOrderedSelection removeRowIdsFromSelection(final ViewRowIdsOrde
.setSize(size)
.build();
}

private final int retrieveSize(final String selectionId)
{
final List<Object> sqlParams = new ArrayList<>();
Expand All @@ -205,11 +206,16 @@ private final int retrieveSize(final String selectionId)
return size <= 0 ? 0 : size;
}

public boolean containsAnyOfRowIds(ViewRowIdsOrderedSelection defaultSelection, final Collection<DocumentId> rowIds)
public boolean containsAnyOfRowIds(final String selectionId, final Collection<DocumentId> rowIds)
{
final List<Object> sqlParams = new ArrayList<>();
final String sqlCount = newSqlViewSelectionQueryBuilder().buildSqlCount(sqlParams, defaultSelection.getSelectionId(), rowIds);
int count = DB.executeUpdateEx(sqlCount, sqlParams.toArray(), ITrx.TRXNAME_ThreadInherited);
final String sqlCount = newSqlViewSelectionQueryBuilder().buildSqlCount(sqlParams, selectionId, rowIds);
final int count = DB.executeUpdateEx(sqlCount, sqlParams.toArray(), ITrx.TRXNAME_ThreadInherited);
return count > 0;
}

public <T> IQueryFilter<T> createQueryFilter(final String selectionId)
{
return newSqlViewSelectionQueryBuilder().buildInSelectionQueryFilter(selectionId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public long getSize()
return size;
}

ImmutableList<DocumentQueryOrderBy> getOrderBys()
public ImmutableList<DocumentQueryOrderBy> getOrderBys()
{
return orderBys;
}
Expand Down

0 comments on commit f2309d8

Please sign in to comment.