Skip to content

Instantly share code, notes, and snippets.

View schleichardt's full-sized avatar

Michael Schleichardt schleichardt

  • eHealth Experts GmbH
View GitHub Profile
@schleichardt
schleichardt / CorrelationIdSphereClient.java
Created July 17, 2017 14:34
wrap a SphereClient to send a correlation ID
import io.sphere.sdk.client.*;
import java.util.UUID;
import java.util.concurrent.CompletionStage;
public class CorrelationIdSphereClient extends SphereClientDecorator {
public CorrelationIdSphereClient(SphereClient delegate) {
super(delegate);
}
├── A
│ ├── A-1
│ │ ├── A-1-1
│ │ ├── A-1-2
│ │ └── A-1-3
│ ├── A-2
│ │ ├── A-2-1
│ │ ├── A-2-2
│ │ └── A-2-3
│ └── A-3
ProductQueryImpl{predicate=[Predicate[masterData(current(masterVariant(sku in ("1000", "2000", "3000", "4000")) or variants(sku in ("1000", "2000", "3000", "4000"))))]], sort=[], expand=[], additionalQueryParameters=[], limit=null, offset=null, endpoint='/products', resultMapper=io.sphere.sdk.queries.MetaModelQueryDslBuilder$$Lambda$126/1732589709@c72f2b8, readablePath=/products?where=masterData(current(masterVariant(sku in ("1000", "2000", "3000", "4000")) or variants(sku in ("1000", "2000", "3000", "4000")))), request=HttpRequestIntent[httpMethod=GET,path=/products?where=masterData%28current%28masterVariant%28sku+in+%28%221000%22%2C+%222000%22%2C+%223000%22%2C+%224000%22%29%29+or+variants%28sku+in+%28%221000%22%2C+%222000%22%2C+%223000%22%2C+%224000%22%29%29%29%29,headers={},body=<null>], withTotal=null}
sphere readable predicate
masterData(current(masterVariant(sku in ("1000", "2000", "3000", "4000")) or variants(sku in ("1000", "2000", "3000", "4000"))))
final List<String> skus = Arrays.asList("1000", "2000", "3000", "4000");
final ProductQuery productQuery = ProductQuery.of()
.withPredicates(m -> m.masterData().current().allVariants()
.where(variant -> variant.sku().isIn(skus)));
System.err.println(productQuery);
System.err.println("sphere readable predicate");
System.err.println(productQuery.predicates().get(0).toSphereQuery());
{
"id": "8665d91a-eab0-45a8-a378-e6603d66d084",
"version": 4,
"productType": {
"typeId": "product-type",
"id": "c6af7304-4e35-48d6-8687-66ca2dab5dbb"
},
"name": {
"en": "GIRLS HARTBREAK CREW"
},
{
"offset": 0,
"count": 5,
"total": 5,
"results": [
{
"id": "8665d91a-eab0-45a8-a378-e6603d66d084",
"version": 4,
"productType": {
"typeId": "product-type",
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/"
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-cluster" % "2.2.3",
"com.typesafe.akka" %% "akka-slf4j" % "2.2.3",
"com.typesafe.akka" %% "akka-testkit" % "2.2.3",
"ch.qos.logback" % "logback-classic" % "1.0.13",
"com.typesafe.play" %% "play-json" % "2.2.2",
"junit" % "junit" % "4.11" % "test",
/**
* Answer for https://groups.google.com/forum/?fromgroups=#!topic/play-framework/MF_cQ743vv4
*/
package controllers;
import com.typesafe.config.ConfigFactory;
import play.*;
import play.libs.Crypto;
import play.mvc.*;
package controllers;
import play.api.libs.ws.Response;
import play.api.libs.ws.WS$;
import play.libs.F;
import play.libs.WS;
import play.mvc.*;
public class Application extends Controller {
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "so13921168"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(