Skip to content

Commit

Permalink
Handling Unit Barcode selection 1:1 #313
Browse files Browse the repository at this point in the history
  • Loading branch information
teosarca committed Apr 24, 2017
1 parent 1935d17 commit 53f3576
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public static HUDocumentViewSelection cast(final IDocumentViewSelection view)
private final CopyOnWriteArraySet<Integer> huIds;
private final HUDocumentViewLoader documentViewsLoader;
private final ExtendedMemorizingSupplier<IndexedDocumentViews> _recordsSupplier = ExtendedMemorizingSupplier.of(() -> retrieveRecords());

private final ViewActionDescriptorsList actions;

private HUDocumentViewSelection(final Builder builder)
Expand All @@ -104,7 +104,7 @@ private HUDocumentViewSelection(final Builder builder)
documentViewsLoader = builder.createDocumentViewsLoader();

referencingDocumentPaths = builder.getReferencingDocumentPaths();

this.actions = builder.actions;
}

Expand Down Expand Up @@ -203,14 +203,13 @@ public HUDocumentView getById(final DocumentId documentId) throws EntityNotFound
{
return getRecords().getById(documentId);
}

@Override
public List<HUDocumentView> getByIds(final Set<DocumentId> documentIds)
{
return streamByIds(documentIds).collect(ImmutableList.toImmutableList());
}


@Override
public LookupValuesList getFilterParameterDropdown(final String filterId, final String filterParameterName, final Evaluatee ctx)
{
Expand Down Expand Up @@ -297,28 +296,28 @@ public void addHUAndInvalidate(final I_M_HU hu)
huIds.add(hu.getM_HU_ID());
invalidateAll();
}

public void removesHUsAndInvalidate(final Collection<I_M_HU> husToRemove)
{
if(husToRemove == null || husToRemove.isEmpty())
if (husToRemove == null || husToRemove.isEmpty())
{
return;
}

huIds.removeAll(extractHUIds(husToRemove));
invalidateAll();
}

private static final Set<Integer> extractHUIds(final Collection<I_M_HU> hus)
{
if (hus == null || hus.isEmpty())
{
return ImmutableSet.of();
}

return hus.stream().map(I_M_HU::getM_HU_ID).collect(Collectors.toSet());
}

@Override
public void notifyRecordsChanged(final Set<TableRecordReference> recordRefs)
{
Expand All @@ -341,7 +340,7 @@ public void notifyRecordsChanged(final Set<TableRecordReference> recordRefs)
{
return;
}

invalidateAll();
}

Expand Down Expand Up @@ -399,7 +398,7 @@ public <T> List<T> retrieveModelsByIds(final Collection<DocumentId> documentIds,
public SelectViewRowsAction actionSelectHUsByBarcode( //
@ViewActionParam(caption = "Barcode", widgetType = DocumentFieldWidgetType.Text) final String barcode //
, final Set<DocumentId> selectedDocumentIds //
)
)
{
// Search for matching rowIds by barcode
final Set<DocumentId> matchingRowIds = streamAllRecursive()
Expand All @@ -414,7 +413,7 @@ public SelectViewRowsAction actionSelectHUsByBarcode( //
// Join matching rowIds with currently selected ones
final Set<DocumentId> rowIds = ImmutableSet.<DocumentId> builder()
.addAll(matchingRowIds)
.addAll(selectedDocumentIds)
// .addAll(selectedDocumentIds) // don't keep the previously selected ones (see https://github.com/metasfresh/metasfresh-webui-api/issues/313 )
.build();

return SelectViewRowsAction.builder()
Expand Down Expand Up @@ -561,16 +560,16 @@ public ViewId getViewId()
{
return viewId;
}

public Builder setHUIds(final Collection<Integer> huIds)
{
this.huIds = huIds;
return this;
}

private Collection<Integer> getHUIds()
{
if(huIds == null || huIds.isEmpty())
if (huIds == null || huIds.isEmpty())
{
return ImmutableSet.of();
}
Expand All @@ -596,7 +595,7 @@ private Set<DocumentPath> getReferencingDocumentPaths()
{
return referencingDocumentPaths == null ? ImmutableSet.of() : ImmutableSet.copyOf(referencingDocumentPaths);
}

public Builder setActions(@NonNull final ViewActionDescriptorsList actions)
{
this.actions = actions;
Expand Down

0 comments on commit 53f3576

Please sign in to comment.