Tabnine Logo
ProductQueryModel.productType
Code IndexAdd Tabnine to your IDE (free)

How to use
productType
method
in
io.sphere.sdk.products.queries.ProductQueryModel

Best Java code snippets using io.sphere.sdk.products.queries.ProductQueryModel.productType (Showing top 8 results out of 315)

origin: com.commercetools.sdk.jvm.core/commercetools-models

default ProductQuery byProductType(final Referenceable<ProductType> productType) {
  return withPredicates(m -> m.productType().is(productType));
}
origin: io.sphere.sdk.jvm/sphere-models

default ProductQuery byProductType(final Referenceable<ProductType> productType) {
  return withPredicates(m -> m.productType().is(productType));
}
origin: commercetools/commercetools-jvm-sdk

default ProductQuery byProductType(final Referenceable<ProductType> productType) {
  return withPredicates(m -> m.productType().is(productType));
}
origin: io.sphere.sdk.jvm/models

public QueryDsl<Product> byProductType(final Referenceable<ProductType> productType) {
  return withPredicate(model().productType().is(productType));
}
origin: io.sphere.sdk.jvm/products

public QueryDsl<Product> byProductType(final Referenceable<ProductType> productType) {
  return withPredicate(model().productType().is(productType));
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void useIdPredicateInsteadOfOffset() throws Exception {
  final ProductQuery seedQuery = ProductQuery.of()
      //the original predicate, which queries products for a certain product type
      //the idea works also for no predicate to get all products
      .withPredicates(m -> m.productType().is(productType))
      //important, we sort by id, otherwise id > $lastId would not make sense
      .withSort(m -> m.id().sort().asc())
      .withLimit(PAGE_SIZE)
      .withFetchTotal(false);//saves also resources and time
  final CompletionStage<List<Product>> resultStage = findNext(seedQuery, seedQuery, new LinkedList<>());
  final List<Product> actualProducts = resultStage.toCompletableFuture().join();
  assertThat(actualProducts).hasSize(createdProducts.size());
  //!!! the underlying database has a different algorithm to sort by ID, it is a UUID, which differs from String sorting
  final List<Product> javaSortedActual = actualProducts.stream().sorted(BY_ID_COMPARATOR).collect(toList());
  assertThat(javaSortedActual).isEqualTo(createdProducts);
}
origin: commercetools/commercetools-jvm-sdk

public static void deleteProductsProductTypeAndProductDiscounts(final BlockingSphereClient client, final ProductType productType) {
  client.executeBlocking(ProductDiscountQuery.of().withLimit(500L)).getResults()
      .forEach(discount -> client.executeBlocking(ProductDiscountDeleteCommand.of(discount)));
  if (productType != null) {
    QueryPredicate<Product> ofProductType = ProductQueryModel.of().productType().is(productType);
    ProductQuery productsOfProductTypeQuery = ProductQuery.of().withPredicates(ofProductType).withLimit(500L);
    do {
      final List<Product> products = client.executeBlocking(productsOfProductTypeQuery).getResults();
      final List<Product> unpublishedProducts = products.stream().map(
          product -> {
            if (product.getMasterData().isPublished()) {
              return client.executeBlocking(ProductUpdateCommand.of(product, Unpublish.of()));
            } else {
              return product;
            }
          }
      ).collect(toList());
      final List<CompletionStage<Product>> stages = new LinkedList<>();
      unpublishedProducts.forEach(
          product -> {
            final CompletionStage<Product> completionStage = client.execute(ProductDeleteCommand.of(product));
            stages.add(completionStage);
          }
      );
      stages.forEach(stage -> SphereClientUtils.blockingWait(stage, 30, TimeUnit.SECONDS));
      deleteProductType(client, productType);
    } while (client.executeBlocking(productsOfProductTypeQuery).getCount() > 0);
  }
}
origin: commercetools/commercetools-jvm-sdk

@AfterClass
@BeforeClass
public static void deleteProductsAndProductType() {
  final List<ProductType> productTypes = client().executeBlocking(ProductTypeQuery.of().byName(PRODUCT_TYPE_NAME)).getResults();
  if (!productTypes.isEmpty()) {
    final ProductQuery productQuery = ProductQuery.of()
        .withPredicates(m -> m.productType().isIn(productTypes))
        .withLimit(500L);
    client().executeBlocking(productQuery).getResults().forEach(p -> client().executeBlocking(ProductDeleteCommand.of(p)));
    productTypes.forEach(p -> client().executeBlocking(ProductTypeDeleteCommand.of(p)));
  }
}
io.sphere.sdk.products.queriesProductQueryModelproductType

Popular methods of ProductQueryModel

  • masterData
  • <init>
  • of
  • get
  • id
  • is
  • referenceModel
  • referenceOptionalModel
  • reviewRatingStatistics
  • state

Popular in Java

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • addToBackStack (FragmentTransaction)
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Selector (java.nio.channels)
    A controller for the selection of SelectableChannel objects. Selectable channels can be registered w
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • LogFactory (org.apache.commons.logging)
    Factory for creating Log instances, with discovery and configuration features similar to that employ
  • IsNull (org.hamcrest.core)
    Is the value null?
  • From CI to AI: The AI layer in your organization
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now