Skip to content

Commit

Permalink
Add javadoc and rename classes from Picking to Packageable
Browse files Browse the repository at this point in the history
imho this makes it easier to under stand the code..
before: left => Picking; right => pickingSlot
now: left => packageable; right => pickingSlot

518: Picking prototype (v6) 

Task-Url: #518
  • Loading branch information
metas-ts committed Jul 27, 2017
1 parent 29960be commit d379789
Show file tree
Hide file tree
Showing 10 changed files with 146 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,43 +48,55 @@
* #L%
*/

/**
* Rows shown in {@link PackageableView}. Each row basically represents one {@link I_M_Packageable_V}.
*
* @author metas-dev <dev@metasfresh.com>
*
*/
@ToString(exclude = "_fieldNameAndJsonValues")
public final class PickingRow implements IViewRow
public final class PackageableRow implements IViewRow
{
private final ViewId viewId;
private final DocumentId id;
private final IViewRowType type;
private final boolean processed;
private final DocumentPath documentPath;

@ViewColumn(widgetType = DocumentFieldWidgetType.Lookup, captionKey = I_M_Packageable_V.COLUMNNAME_M_Warehouse_ID, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 10)
})
@ViewColumn(widgetType = DocumentFieldWidgetType.Lookup, captionKey = I_M_Packageable_V.COLUMNNAME_M_Warehouse_ID, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 10)
})
private final LookupValue warehouse;

@ViewColumn(widgetType = DocumentFieldWidgetType.Lookup, captionKey = I_M_Packageable_V.COLUMNNAME_M_Product_ID, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 20)
})

@ViewColumn(widgetType = DocumentFieldWidgetType.Lookup, captionKey = I_M_Packageable_V.COLUMNNAME_M_Product_ID, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 20)
})
private final LookupValue product;

@ViewColumn(widgetType = DocumentFieldWidgetType.Quantity, captionKey = I_M_Packageable_V.COLUMNNAME_QtyToDeliver, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 30)
})

@ViewColumn(widgetType = DocumentFieldWidgetType.Quantity, captionKey = I_M_Packageable_V.COLUMNNAME_QtyToDeliver, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 30)
})
private final BigDecimal qtyToDeliver;

@ViewColumn(widgetType = DocumentFieldWidgetType.Quantity, captionKey = I_M_Packageable_V.COLUMNNAME_QtyPickedPlanned, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 35)
})

@ViewColumn(widgetType = DocumentFieldWidgetType.Quantity, captionKey = I_M_Packageable_V.COLUMNNAME_QtyPickedPlanned, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 35)
})
private final BigDecimal qtyPickedPlanned;

@ViewColumn(widgetType = DocumentFieldWidgetType.DateTime, captionKey = I_M_Packageable_V.COLUMNNAME_DeliveryDate, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 40)
})
@ViewColumn(widgetType = DocumentFieldWidgetType.DateTime, captionKey = I_M_Packageable_V.COLUMNNAME_DeliveryDate, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 40)
})
private final java.util.Date deliveryDate;

@ViewColumn(widgetType = DocumentFieldWidgetType.DateTime, captionKey = I_M_Packageable_V.COLUMNNAME_PreparationDate, layouts = {
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 50)
})

@ViewColumn(widgetType = DocumentFieldWidgetType.DateTime, captionKey = I_M_Packageable_V.COLUMNNAME_PreparationDate, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.grid, seqNo = 50)
})
private final java.util.Date preparationDate;

private final int shipmentScheduleId;
Expand All @@ -93,13 +105,13 @@ public final class PickingRow implements IViewRow

private transient ImmutableMap<String, Object> _fieldNameAndJsonValues;

public static PickingRow cast(final IViewRow row)
public static PackageableRow cast(final IViewRow row)
{
return (PickingRow)row;
return (PackageableRow)row;
}

@Builder
private PickingRow(
private PackageableRow(
@NonNull final DocumentId id,
@NonNull final ViewId viewId,
final IViewRowType type,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,35 +60,37 @@
*/

/**
* Picking editor view
* Picking editor's view left-hand side view which lists one or more {@link PackageableRow} records to be picked.
* <p>
* Note that technically this view also contains the right-hand side {@link PickingSlotView}.
*
* @author metas-dev <dev@metasfresh.com>
*
*/
public class PickingView implements IView
public class PackageableView implements IView
{
private final PickingCandidateCommand pickingCandidateCommand;
public static PickingView cast(final IView view)

public static PackageableView cast(final IView view)
{
return (PickingView)view;
return (PackageableView)view;
}

private final ViewId viewId;
private final ITranslatableString description;
private final ExtendedMemorizingSupplier<Map<DocumentId, PickingRow>> rowsSupplier;
private final ExtendedMemorizingSupplier<Map<DocumentId, PackageableRow>> rowsSupplier;

private final ConcurrentHashMap<DocumentId, PickingSlotView> pickingSlotsViewByRowId = new ConcurrentHashMap<>();

@Builder
private PickingView(@NonNull final ViewId viewId,
private PackageableView(@NonNull final ViewId viewId,
@NonNull final ITranslatableString description,
@NonNull final Supplier<List<PickingRow>> rowsSupplier,
@NonNull final Supplier<List<PackageableRow>> rowsSupplier,
@NonNull final PickingCandidateCommand pickingCandidateCommand)
{
this.viewId = viewId;
this.description = description != null ? description : ITranslatableString.empty();
this.rowsSupplier = ExtendedMemorizingSupplier.of(() -> Maps.uniqueIndex(rowsSupplier.get(), PickingRow::getId));
this.rowsSupplier = ExtendedMemorizingSupplier.of(() -> Maps.uniqueIndex(rowsSupplier.get(), PackageableRow::getId));
this.pickingCandidateCommand = pickingCandidateCommand;
}

Expand Down Expand Up @@ -127,14 +129,14 @@ public ViewId getParentViewId()
{
return null;
}

@Override
public DocumentId getParentRowId()
{
return null;
}

private final Map<DocumentId, PickingRow> getRows()
private final Map<DocumentId, PackageableRow> getRows()
{
return rowsSupplier.get();
}
Expand All @@ -160,7 +162,7 @@ public void close()
public void invalidateAll()
{
rowsSupplier.forget();

ViewChangesCollector.getCurrentOrAutoflush()
.collectFullyChanged(this);
}
Expand All @@ -180,7 +182,7 @@ public boolean isQueryLimitHit()
@Override
public ViewResult getPage(final int firstRow, final int pageLength, final List<DocumentQueryOrderBy> orderBys)
{
final List<PickingRow> pageRows = getRows().values().stream()
final List<PackageableRow> pageRows = getRows().values().stream()
.skip(firstRow >= 0 ? firstRow : 0)
.limit(pageLength > 0 ? pageLength : 30)
.collect(ImmutableList.toImmutableList());
Expand All @@ -189,9 +191,9 @@ public ViewResult getPage(final int firstRow, final int pageLength, final List<D
}

@Override
public PickingRow getById(final DocumentId rowId) throws EntityNotFoundException
public PackageableRow getById(final DocumentId rowId) throws EntityNotFoundException
{
final PickingRow row = getRows().get(rowId);
final PackageableRow row = getRows().get(rowId);
if (row == null)
{
throw new EntityNotFoundException("Row not found").setParameter("rowId", rowId);
Expand Down Expand Up @@ -282,7 +284,7 @@ public <T> List<T> retrieveModelsByIds(final DocumentIdsSelection rowIds, final
@Override
public Stream<? extends IViewRow> streamByIds(final DocumentIdsSelection rowIds)
{
if(rowIds.isAll())
if (rowIds.isAll())
{
return getRows().values().stream();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,27 @@
* #L%
*/

/**
* Factory class for {@link PackageableView} intances.
*
* @author metas-dev <dev@metasfresh.com>
*
*/
@ViewFactory(windowId = PickingConstants.WINDOWID_PickingView_String, viewTypes =
{ JSONViewDataType.grid, JSONViewDataType.includedView })
public class PickingViewFactory implements IViewFactory
public class PackageableViewFactory implements IViewFactory
{
private final PickingViewRepository pickingViewRepo;
private final PackageableViewRepository pickingViewRepo;

private final PickingCandidateCommand pickingCandidateCommand;

/**
*
* @param pickingViewRepo
* @param pickingCandidateCommand when a new view is created, this stateless instance is given to that view
*/
public PickingViewFactory(
@NonNull final PickingViewRepository pickingViewRepo,
public PackageableViewFactory(
@NonNull final PackageableViewRepository pickingViewRepo,
@NonNull final PickingCandidateCommand pickingCandidateCommand)
{
this.pickingViewRepo = pickingViewRepo;
Expand All @@ -82,7 +88,7 @@ public ViewLayout getViewLayout(
.setHasIncludedViewSupport(true)
.setHasIncludedViewOnSelectSupport(true)
//
.addElementsFromViewRowClass(PickingRow.class, viewDataType)
.addElementsFromViewRowClass(PackageableRow.class, viewDataType)
//
.build();
}
Expand Down Expand Up @@ -110,9 +116,9 @@ public IView createView(@NonNull final CreateViewRequest request)
final ViewId viewId = ViewId.random(PickingConstants.WINDOWID_PickingView);

final Set<DocumentId> rowIds = request.getFilterOnlyIds().stream().map(DocumentId::of).collect(ImmutableSet.toImmutableSet());
final Supplier<List<PickingRow>> rowsSupplier = () -> pickingViewRepo.retrieveRowsByIds(viewId, rowIds);
final Supplier<List<PackageableRow>> rowsSupplier = () -> pickingViewRepo.retrieveRowsByIds(viewId, rowIds);

return PickingView.builder()
return PackageableView.builder()
.viewId(viewId)
.description(ITranslatableString.empty())
.rowsSupplier(rowsSupplier)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@
* #L%
*/

/**
* Class to retrieve the rows shown in {@link PackageableView}.
*
* @author metas-dev <dev@metasfresh.com>
*
*/
@Component
public class PickingViewRepository
public class PackageableViewRepository
{
private final Supplier<LookupDataSource> warehouseLookup;
private final Supplier<LookupDataSource> productLookup;

public PickingViewRepository()
public PackageableViewRepository()
{
// creating those LookupDataSources requires DB access. so to allow this component to be initialized early during startup
// and also to allow it to be unit-tested (when the lookups are not part of the test), I use those suppliers
// creating those LookupDataSources requires DB access. So, to allow this component to be initialized early during startup
// and also to allow it to be unit-tested (when the lookups are not part of the test), I use those suppliers.

warehouseLookup = Suppliers.memoize(() -> LookupDataSourceFactory.instance.getLookupDataSource(SqlLookupDescriptor.builder()
.setColumnName(I_M_Packageable_V.COLUMNNAME_M_Warehouse_ID)
Expand All @@ -73,7 +79,7 @@ public PickingViewRepository()
.provideForScope(LookupScope.DocumentField)));
}

public List<PickingRow> retrieveRowsByIds(final ViewId viewId, final Collection<DocumentId> rowIds)
public List<PackageableRow> retrieveRowsByIds(final ViewId viewId, final Collection<DocumentId> rowIds)
{
final Set<Integer> shipmentScheduleIds = rowIds.stream().map(DocumentId::toInt).collect(ImmutableSet.toImmutableSet());
if (shipmentScheduleIds.isEmpty())
Expand All @@ -90,11 +96,11 @@ public List<PickingRow> retrieveRowsByIds(final ViewId viewId, final Collection<
.collect(ImmutableList.toImmutableList());
}

private PickingRow createPickingRow(final ViewId viewId, final I_M_Packageable_V packageable)
private PackageableRow createPickingRow(final ViewId viewId, final I_M_Packageable_V packageable)
{
final DocumentId rowId = DocumentId.of(packageable.getM_ShipmentSchedule_ID());
final DocumentPath documentPath = DocumentPath.rootDocumentPath(PickingConstants.WINDOWID_PickingView, rowId);
return PickingRow.builder()
return PackageableRow.builder()
.documentPath(documentPath)
.viewId(viewId)
.id(rowId)
Expand Down
49 changes: 29 additions & 20 deletions src/main/java/de/metas/ui/web/picking/PickingSlotRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@
* #L%
*/

/**
* Rows shown in {@link PickingSlotView}. One row can represent a picking slot, a TU or a picked good (CU).
*
* @author metas-dev <dev@metasfresh.com>
*
*/
@ToString
public final class PickingSlotRow implements IViewRow
{
Expand All @@ -65,8 +71,7 @@ public static PickingSlotRow cast(final IViewRow row)

private final PickingSlotRowId id;
private final IViewRowType type;



private final DocumentPath documentPath;

//
Expand All @@ -83,31 +88,35 @@ public static PickingSlotRow cast(final IViewRow row)

//
// HU
@ViewColumn(captionKey = "HUCode", widgetType = DocumentFieldWidgetType.Text, layouts = {
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 10)
})
@ViewColumn(captionKey = "HUCode", widgetType = DocumentFieldWidgetType.Text, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 10)
})
private final String huCode;
// @ViewColumn(captionKey = "Processed", widgetType = DocumentFieldWidgetType.YesNo, layouts = {
// @ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 20)
// })

// @ViewColumn(captionKey = "Processed", widgetType = DocumentFieldWidgetType.YesNo, layouts = {
// @ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 20)
// })
// this is the "standard" processed flag which every IViewRow has-.
// TODO: decide whether to display it or not
private final boolean processed;

@ViewColumn(captionKey = "M_Product_ID", widgetType = DocumentFieldWidgetType.Lookup, layouts = {
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 30)
})
@ViewColumn(captionKey = "M_Product_ID", widgetType = DocumentFieldWidgetType.Lookup, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 30)
})
private final JSONLookupValue huProduct;

@ViewColumn(captionKey = "M_HU_PI_Item_Product_ID", widgetType = DocumentFieldWidgetType.Text, layouts = {
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 40)
})
@ViewColumn(captionKey = "M_HU_PI_Item_Product_ID", widgetType = DocumentFieldWidgetType.Text, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 40)
})
private final String huPackingInfo;

@ViewColumn(captionKey = "QtyCU", widgetType = DocumentFieldWidgetType.Quantity, layouts = {
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 50)
})
@ViewColumn(captionKey = "QtyCU", widgetType = DocumentFieldWidgetType.Quantity, layouts =
{
@ViewColumnLayout(when = JSONViewDataType.includedView, seqNo = 50)
})
private final BigDecimal huQtyCU;

private transient ImmutableMap<String, Object> _fieldNameAndJsonValues;
Expand Down Expand Up @@ -270,7 +279,7 @@ public Optional<PickingSlotRow> findIncludedRowById(final PickingSlotRowId id)
{
return Optional.of(this);
}

// Direct children
{
final PickingSlotRow row = includedHURows.get(id);
Expand Down Expand Up @@ -337,7 +346,7 @@ public boolean isHURow()
{
return !isPickingSlotRow();
}

public int getPickingSlotWarehouseId()
{
return pickingSlotWarehouse != null ? pickingSlotWarehouse.getIdAsInt() : -1;
Expand Down
Loading

0 comments on commit d379789

Please sign in to comment.