Design internal filter API #31

ctron opened this Issue Feb 5, 2016 · 0 comments


None yet
1 participant

ctron commented Feb 5, 2016

Package Drone needs an internal filter API. Internal at least for now. The core use cases for this filter API is to filter for artifacts based on a single channel or a set of artifacts.

There are many use cases. First of old the long standing request for filling features based on a sub-set of the channel (see ctron/package-drone#66), a global search function (see ctron/package-drone#114) could also benefit from such an API and the cleanup aspect could also benefit from having a filter.

Now the requirements to such a filter API are:

  • Provide a type safe model of the filter
  • Have the possibility to serialized and deserialize the filter to a string (query string)
  • Be easy to write in Java source as well as query string

So I would like to see something in the source code that looks like this:

MetaKey MY_KEY = new MetaKey ( "ns", "key" );
ArtifactLocator al = …; ( Filters.equals ( MY_KEY, "foo-bar" ) ); ( Filters.or ( Filters.equals ( MY_KEY, "foo-bar" ), Filters.equals ( MY_KEY, "bar-foo") );

// using import static ( equals ( MY_KEY, "foo-bar" ) ); ( or ( equals ( MY_KEY, "foo-bar" ), equals ( MY_KEY, "bar-foo") );

// with a query string ( Filters.parse ( "foo:bar = foo-bar or foo:bar = bar-foo" ) ); ( Filters.parse ( "foo:bar = 'foo-bar' or foo:bar = 'bar-foo'" ) );

With a search method like:

List<ArtifactInformation> result = ( predicate);
List<ArtifactInformation> result = ( predicate, options );

Of course it would be possible to use Java 8 stream on the interface, and I guess it might be a good idea to use them for implementing the ArtifactLocator for some channel types. But considering the possibility that there might be a database or some sort of index being involved some time in the future, I would like to use a filter model which is a real model which can then be transformed in e.g. a stream setup, but also to some sort of JPA query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment