Skip to content

Hybris commerce extension which translates lambda predicates to flexible search queries

Notifications You must be signed in to change notification settings

homik/flexiblelambda

Repository files navigation

Flexiblelambda

flexiblelambda is a Hybris platform extension capable of converting Java 8 lambdas to Flexible search queries.

It uses JaQue to parse lambda expressions and build flexible search queries of it.

Example

For example, the following code:

   @Resource
   LambdaFlexibleSearchService lambdaFlexibleSearchService;
    
   public List<OrderModel> getOrdersForUserUid(String uid) {
      final SerializablePredicate<OrderModel> pred = e -> e.getUser().getUid().equals(uid)
            || e.getUser().getName().equals("John");
      final LambdaFlexibleSearchQuery<OrderModel> query = new LambdaFlexibleSearchQuery<>(OrderModel.class)
	         .filter(pred);

      return lambdaFlexibleSearchService.getList(query);
   }

will execute following flexible search query:

  SELECT {this.PK} from {Order AS this
  LEFT JOIN User as thisuser on {this.user}={thisuser.PK}} 
  WHERE ({thisuser.uid} = ?a OR {thisuser.name} = ?b)"

With value of uid and "John" as parameters, allowing you to write readable queries in a type safe way.

See LambdaFlexibleSearchTranslationServiceImplUnitTest for more examples and supported cases.

About

Hybris commerce extension which translates lambda predicates to flexible search queries

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages