Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design internal filter API #31

ctron opened this issue Feb 5, 2016 · 0 comments

Design internal filter API #31

ctron opened this issue Feb 5, 2016 · 0 comments


Copy link

@ctron 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
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.