Search in sources :

Example 1 with IProductBOMDAO

use of org.eevolution.api.IProductBOMDAO in project metasfresh-webui-api by metasfresh.

the class CableSalesOrderLineQuickInputProcessor method getBOMProductId.

private ProductId getBOMProductId(ICablesOrderLineQuickInput quickInputModel) {
    final ProductId plugProduct1Id = ProductId.ofRepoId(quickInputModel.getPlug1_Product_ID());
    final ProductId plugProduct2Id = ProductId.ofRepoId(quickInputModel.getPlug2_Product_ID());
    final ProductId cableProductId = ProductId.ofRepoId(quickInputModel.getCable_Product_ID());
    final IProductBOMDAO productBOMsRepo = Services.get(IProductBOMDAO.class);
    final List<I_PP_Product_BOM> boms = productBOMsRepo.retrieveBOMsContainingExactProducts(plugProduct1Id.getRepoId(), cableProductId.getRepoId(), plugProduct2Id.getRepoId());
    if (boms.isEmpty()) {
        throw new AdempiereException("@NotFound@ @PP_Product_BOM_ID@");
    } else if (boms.size() > 1) {
        final String bomValues = boms.stream().map(I_PP_Product_BOM::getValue).collect(Collectors.joining(", "));
        throw new AdempiereException("More than one BOMs found: " + bomValues);
    } else {
        final I_PP_Product_BOM bom = boms.get(0);
        return ProductId.ofRepoId(bom.getM_Product_ID());
    }
}
Also used : I_PP_Product_BOM(org.eevolution.model.I_PP_Product_BOM) AdempiereException(org.adempiere.exceptions.AdempiereException) IProductBOMDAO(org.eevolution.api.IProductBOMDAO) ProductId(de.metas.product.ProductId)

Aggregations

ProductId (de.metas.product.ProductId)1 AdempiereException (org.adempiere.exceptions.AdempiereException)1 IProductBOMDAO (org.eevolution.api.IProductBOMDAO)1 I_PP_Product_BOM (org.eevolution.model.I_PP_Product_BOM)1