use of org.openlmis.stockmanagement.i18n.MessageKeys.ERROR_EVENT_ORDERABLE_LOT_DUPLICATION in project openlmis-stockmanagement by OpenLMIS.
the class OrderableLotDuplicationValidator method validate.
@Override
public void validate(StockEventDto stockEventDto) {
// duplication is not allow in physical inventory, but is allowed in adjustment
if (!stockEventDto.hasLineItems() || !stockEventDto.isPhysicalInventory()) {
return;
}
Set<OrderableLotIdentity> nonDuplicates = new HashSet<>();
Set<OrderableLotIdentity> duplicates = stockEventDto.getLineItems().stream().map(OrderableLotIdentity::identityOf).filter(lotIdentity -> !nonDuplicates.add(lotIdentity)).collect(toSet());
if (duplicates.size() > 0) {
throw new ValidationMessageException(new Message(ERROR_EVENT_ORDERABLE_LOT_DUPLICATION, duplicates));
}
}
Aggregations