Skip to content

Commit

Permalink
Another fix related to "If no HU matches, then do *not* show every HU"
Browse files Browse the repository at this point in the history
Also PPOrderLinesView: minor

557: Picking Window: Open HU Selection window filtering 
Task-Url: #557
  • Loading branch information
metas-ts committed Sep 11, 2017
1 parent f5f5da9 commit b8b0144
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
31 changes: 27 additions & 4 deletions src/main/java/de/metas/ui/web/handlingunits/HUIdsFilterHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,12 +84,15 @@ public static HUIdsFilterData newEmpty()
}

/**
* Important: {@code null} means "no restriction" (i.e. we can select allHUs) whereas empty means that no HU matches the filter.
* Important: {@code null} means "no restriction" (i.e. we can select all HUs) whereas empty means that no HU matches the filter.
*/
private final ImmutableSet<Integer> initialHUIds;

private final IHUQueryBuilder initialHUQuery;

/**
* Empty list means "no restricton".
*/
private final Set<Integer> mustHUIds;
private final Set<Integer> shallNotHUIds;

Expand Down Expand Up @@ -244,15 +247,15 @@ public static boolean isHighVolume(final List<DocumentFilter> stickyFilters)
}

final Set<Integer> huIds = huIdsFilterData.getInitialHUIds();
if(huIds == null)
if (huIds == null)
{
// null means no restrictions, so we might have a lot of HUs
return true; // high volume
}
else if (huIds.isEmpty())
{
// no HUs will be allowed
return false; // not high volume
return false; // not high volume
}
else
{
Expand All @@ -274,7 +277,27 @@ private HUIdsSqlDocumentFilterConverter()
public String getSql(final SqlParamsCollector sqlParamsOut, final DocumentFilter filter)
{
final HUIdsFilterData huIdsFilter = extractFilterData(filter);
final ImmutableList<Integer> onlyHUIds = ImmutableList.copyOf(Iterables.concat(huIdsFilter.getInitialHUIds(), huIdsFilter.getMustHUIds()));
final ImmutableList<Integer> onlyHUIds;

final boolean mustHuIdsSpecified = huIdsFilter.getMustHUIds() != null && !huIdsFilter.getMustHUIds().isEmpty();
final boolean initialHuIdsSpecified = huIdsFilter.getInitialHUIds() != null;

if (initialHuIdsSpecified && mustHuIdsSpecified)
{
onlyHUIds = ImmutableList.copyOf(Iterables.concat(huIdsFilter.getInitialHUIds(), huIdsFilter.getMustHUIds()));
}
else if (initialHuIdsSpecified)
{
onlyHUIds = ImmutableList.copyOf(huIdsFilter.getInitialHUIds()); // huIdsFilter.getMustHUIds() == null
}
else if (mustHuIdsSpecified)
{
onlyHUIds = ImmutableList.copyOf(huIdsFilter.getMustHUIds());
}
else
{
onlyHUIds = null;
}

if (onlyHUIds == null && !huIdsFilter.hasInitialHUQuery())
{
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/de/metas/ui/web/pporder/PPOrderLinesView.java
Original file line number Diff line number Diff line change
Expand Up @@ -380,8 +380,8 @@ public OpenIncludedViewAction actionOpenViewForHUsToIssue(final DocumentIdsSelec
{
throw new IllegalStateException("Row processed");
}

final IHUQueryBuilder huIdsToAvailableToIssueQuery = Services.get(IHUPPOrderBL.class).createHUsAvailableToIssueQuery(selectedRow.getM_Product_ID());
final IHUPPOrderBL huppOrderBL = Services.get(IHUPPOrderBL.class);
final IHUQueryBuilder huIdsToAvailableToIssueQuery = huppOrderBL.createHUsAvailableToIssueQuery(selectedRow.getM_Product_ID());

final IViewsRepository viewsRepo = Adempiere.getSpringApplicationContext().getBean(IViewsRepository.class); // TODO dirty workaround
final IView husToIssueView = viewsRepo.createView(CreateViewRequest.builder(WEBUI_HU_Constants.WEBUI_HU_Window_ID, JSONViewDataType.includedView)
Expand Down

0 comments on commit b8b0144

Please sign in to comment.