Giter Club home page Giter Club logo

flexiblelambda's Introduction

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.

flexiblelambda's People

Contributors

0xflotus avatar homik avatar

Stargazers

 avatar

Watchers

 avatar

flexiblelambda's Issues

Support `IN` clause for `Collection.contains` calls

Hi,

I'm using your project (slightly modified to translate to JPQL) in my project (spot-next.io). So far it works great. But yesterday I saw that something like this doesn't work:

.filter(p -> catalogService.getSessionCatalogVersions().contains(p.getCatalogVersion()) && p.getCategories().contains(category));

It is not translated to a WHERE catalogVersions IN (...) clause. It should be possible to implement this in with jaque. Any idea how?

Btw, cool project :-)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.