Skip to content

Commit

Permalink
ProductDAO add retrieveProductCategoryIdByCategoryValueOrNull
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBestPessimist committed Nov 20, 2019
1 parent 527d950 commit 748acbb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
20 changes: 14 additions & 6 deletions de.metas.business/src/main/java/de/metas/product/IProductDAO.java
Expand Up @@ -61,12 +61,10 @@ public interface IProductDAO extends ISingletonService
I_M_Product_Category retrieveDefaultProductCategory(Properties ctx);

/**
*
*
* @param productId
* @param orgId
* @return the product of the given <code>org</code> that is mapped to the given <code>product</code> or <code>null</code> if the given product references no mapping, or the mapping is not active
* or if there is no pendant in the given <code>org</code>.
* or if there is no pendant in the given <code>org</code>.
* @task http://dewiki908/mediawiki/index.php/09700_Counter_Documents_%28100691234288%29
*/
ProductId retrieveMappedProductIdOrNull(ProductId productId, OrgId orgId);
Expand All @@ -81,17 +79,25 @@ public interface IProductDAO extends ISingletonService

I_M_Product retrieveProductByValue(String value);

@Nullable
ProductId retrieveProductIdByValue(String value);

ProductId retrieveProductIdBy(ProductQuery query);

@Nullable
ProductCategoryId retrieveProductCategoryIdByCategoryValueOrNull(String categoryValue);

@Value
public static class ProductQuery
{
/** Applied if not empty. {@code AND}ed with {@code externalId} if given. At least one of {@code value} or {@code externalId} needs to be given. */
/**
* Applied if not empty. {@code AND}ed with {@code externalId} if given. At least one of {@code value} or {@code externalId} needs to be given.
*/
String value;

/** Applied if not {@code null}. {@code AND}ed with {@code value} if given. At least one of {@code value} or {@code externalId} needs to be given. */
/**
* Applied if not {@code null}. {@code AND}ed with {@code value} if given. At least one of {@code value} or {@code externalId} needs to be given.
*/
ExternalId externalId;

OrgId orgId;
Expand Down Expand Up @@ -121,7 +127,9 @@ private ProductQuery(

Stream<I_M_Product> streamAllProducts();

/** @return product category or null */
/**
* @return product category or null
*/
ProductCategoryId retrieveProductCategoryByProductId(ProductId productId);

ProductAndCategoryId retrieveProductAndCategoryIdByProductId(ProductId productId);
Expand Down
Expand Up @@ -113,6 +113,7 @@ public I_M_Product retrieveProductByValue(@NonNull final String value)
return productId != null ? getById(productId) : null;
}

@Nullable
@Override
public ProductId retrieveProductIdByValue(@NonNull final String value)
{
Expand Down Expand Up @@ -177,6 +178,20 @@ public ProductId retrieveProductIdBy(@NonNull final ProductQuery query)
return ProductId.ofRepoIdOrNull(productRepoId);
}

@Nullable
@Override
public ProductCategoryId retrieveProductCategoryIdByCategoryValueOrNull(final String categoryValue)
{
final int productCategoryRepoId = queryBL
.createQueryBuilder(I_M_Product_Category.class)
.addOnlyActiveRecordsFilter()
.addEqualsFilter(I_M_Product_Category.COLUMNNAME_Value, categoryValue)
.create()
.firstIdOnly();

return ProductCategoryId.ofRepoIdOrNull(productCategoryRepoId);
}

@Override
public Stream<I_M_Product> streamAllProducts()
{
Expand Down

0 comments on commit 748acbb

Please sign in to comment.