@Test public void shouldQueryActiveProductsByCodesWithoutKits() throws Exception { createSeveralProducts(); List<Product> queriedProducts = productRepository.queryActiveProductsByCodesWithKits(Arrays.asList("08A01", "08A02", "08A03", "08A04"), false); assertEquals(2, queriedProducts.size()); }
public List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit) throws LMISException { return dbUtil.withDao(Product.class, dao -> { Where<Product, String> queryBuilder = dao.queryBuilder() .where().in("code", productCodes) .and().eq("isActive", true) .and().eq("isArchived", false); if (!isWithKit) { queryBuilder.and().eq("isKit", false); } return queryBuilder.query(); }); }
ProductRepository { public List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit) throws LMISException { return dbUtil.withDao(Product.class, dao -> { Where<Product, String> queryBuilder = dao.queryBuilder() .where().in("code", productCodes) .and().eq("isActive", true) .and().eq("isArchived", false); if (!isWithKit) { queryBuilder.and().eq("isKit", false); } return queryBuilder.query(); }); } }
ProductRepository { public List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit) throws LMISException { return dbUtil.withDao(Product.class, dao -> { Where<Product, String> queryBuilder = dao.queryBuilder() .where().in("code", productCodes) .and().eq("isActive", true) .and().eq("isArchived", false); if (!isWithKit) { queryBuilder.and().eq("isKit", false); } return queryBuilder.query(); }); } @Inject  ProductRepository(Context context); }
ProductRepository { public List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit) throws LMISException { return dbUtil.withDao(Product.class, dao -> { Where<Product, String> queryBuilder = dao.queryBuilder() .where().in("code", productCodes) .and().eq("isActive", true) .and().eq("isArchived", false); if (!isWithKit) { queryBuilder.and().eq("isKit", false); } return queryBuilder.query(); }); } @Inject  ProductRepository(Context context); List<Product> listActiveProducts(final Product.IsKit isKit); List<Product> listBasicProducts(); List<Product> listProductsArchivedOrNotInStockCard(); void save(final List<Product> products); void batchCreateOrUpdateProducts(final List<Product> productList); void createOrUpdate(Product product); void updateProduct(Product product); List<KitProduct> queryKitProductByKitCode(final String kitCode); Product getByCode(final String code); Product getProductById(final long id); List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit); List<KitProduct> queryKitProductByProductCode(final String productCode); List<String> listArchivedProductCodes(); List<Product> queryProductsByProductIds(final List<Long> productIds); List<Product> queryActiveProductsInVIAProgramButNotInDraftVIAForm(); List<Product> listNonBasicProducts(); List<Product> getProductsByCodes(final List<String> codes); }
ProductRepository { public List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit) throws LMISException { return dbUtil.withDao(Product.class, dao -> { Where<Product, String> queryBuilder = dao.queryBuilder() .where().in("code", productCodes) .and().eq("isActive", true) .and().eq("isArchived", false); if (!isWithKit) { queryBuilder.and().eq("isKit", false); } return queryBuilder.query(); }); } @Inject  ProductRepository(Context context); List<Product> listActiveProducts(final Product.IsKit isKit); List<Product> listBasicProducts(); List<Product> listProductsArchivedOrNotInStockCard(); void save(final List<Product> products); void batchCreateOrUpdateProducts(final List<Product> productList); void createOrUpdate(Product product); void updateProduct(Product product); List<KitProduct> queryKitProductByKitCode(final String kitCode); Product getByCode(final String code); Product getProductById(final long id); List<Product> queryActiveProductsByCodesWithKits(final List<String> productCodes, final boolean isWithKit); List<KitProduct> queryKitProductByProductCode(final String productCode); List<String> listArchivedProductCodes(); List<Product> queryProductsByProductIds(final List<Long> productIds); List<Product> queryActiveProductsInVIAProgramButNotInDraftVIAForm(); List<Product> listNonBasicProducts(); List<Product> getProductsByCodes(final List<String> codes);  }