{"id":15044917,"url":"https://github.com/marthym/juery","last_synced_at":"2025-04-10T00:42:54.731Z","repository":{"id":41871241,"uuid":"360977980","full_name":"Marthym/juery","owner":"Marthym","description":"Juery is a tiny Java library to manage search and filter query from user to database.","archived":false,"fork":false,"pushed_at":"2024-06-26T09:03:44.000Z","size":276,"stargazers_count":10,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-10T00:42:48.431Z","etag":null,"topics":["http-requests","java","jooq","rest"],"latest_commit_sha":null,"homepage":"https://marthym.github.io/juery/","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Marthym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-23T18:49:39.000Z","updated_at":"2025-03-26T19:30:52.000Z","dependencies_parsed_at":"2024-09-28T23:21:02.152Z","dependency_job_id":"27a98444-1ebb-4dfc-bf61-a089de32de00","html_url":"https://github.com/Marthym/juery","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fjuery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fjuery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fjuery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marthym%2Fjuery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marthym","download_url":"https://codeload.github.com/Marthym/juery/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137998,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["http-requests","java","jooq","rest"],"created_at":"2024-09-24T20:51:13.647Z","updated_at":"2025-04-10T00:42:54.711Z","avatar_url":"https://github.com/Marthym.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Juery [![](https://img./github/release/Marthym/juery.svg)](https://GitHub.com/Marthym/juery/releases/) [![GitHub license](https://img.shields.io/github/license/Marthym/juery.svg)](https://github.com/Marthym/juery/blob/master/LICENSE)\n\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Marthym_juery\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=Marthym_juery)\n[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Marthym_juery\u0026metric=coverage)](https://sonarcloud.io/dashboard?id=Marthym_juery)\n[![Maintainability Rating](https://sonarcloud.io/api/project_badges/measure?project=Marthym_juery\u0026metric=sqale_rating)](https://sonarcloud.io/dashboard?id=Marthym_juery)\n\n**Juery** is a tiny Java library to manage search and filter query from user to database. **api** and **basic** packages \nhave no dependencies. They contain everything you need to use Juery. The **jooq** package contains useful tools for \nprojects using the jOOQ DSL.\n\n## Installation\n\nUse the package manager [maven](https://maven.apache.org/) to install juery.\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003ejuery-api\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003ejuery-basic\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n\u003cdependency\u003e\n    \u003cgroupId\u003efr.ght1pc9kc\u003c/groupId\u003e\n    \u003cartifactId\u003ejuery-jooq\u003c/artifactId\u003e\n    \u003cversion\u003eVERSION\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nfor gradle\n\n```groovy\ncompile \"fr.ght1pc9kc:juery-api:VERSION\"\ncompile \"fr.ght1pc9kc:juery-basic:VERSION\"\ncompile \"fr.ght1pc9kc:juery-jooq:VERSION\"\n```\n\n## Usage\n\n### Create Criteria and PageRequest manually\n\n```java\nimport fr.ght1pc9kc.juery.api.Criteria;\n\nCriteria.property(\"jedi\").eq(\"Obiwan\")\n    .and(Criteria.property(\"age\").gt(40)\n    .or(Criteria.property(\"age\").lt(20)));\n```\n\n```java\nimport fr.ght1pc9kc.juery.api.PageRequest;\nimport fr.ght1pc9kc.juery.api.pagination.Direction;\nimport fr.ght1pc9kc.juery.api.pagination.Order;\nimport fr.ght1pc9kc.juery.api.pagination.Sort;\n\nPageRequest.builder()\n    .page(2).size(100)\n    .filter(Criteria.property(\"profile\").eq(\"jedi\").and(Criteria.property(\"job\").eq(\"master\")))\n    .sort(Sort.of(new Order(Direction.ASC, \"name\"), new Order(Direction.DESC, \"email\")))\n    .build();\n```\n\n### Parsing a query string\n\nInto the controller.\n\n```java\nimport fr.ght1pc9kc.juery.basic.QueryStringParser;\n\n@GetMapping\npublic Flux\u003cFeed\u003e list(@RequestParam Map\u003cString, String\u003e queryStringParams) {\n        return feedService.list(QueryStringParser.withDefaultConfig().parse(queryStringParams))\n        .onErrorMap(BadCriteriaFilter.class, e -\u003e new ResponseStatusException(HttpStatus.BAD_REQUEST, e.getLocalizedMessage()));\n}\n```\n\n`QueryStringParser` will transform the query string into a` PageRequest` which contains a `Criteria`. \nDepending on your architecture, the object will traverse layers until persistence. \nIt can be enriched in the process by `with` methods which create a new enriched object. **All the API is strictly immutable**.\n\n*Since 1.2.0*: You can now, configure the `QueryStringParser` to customize the querystring parameters used :\n\n```java\nimport fr.ght1pc9kc.juery.basic.ParserConfiguration;\n        \nParserConfiguration config = ParserConfiguration.builder()\n        .page(\"_pg\")\n        .size(\"_sz\")\n        .from(\"_fr\")\n        .to(\"_to\")\n        .sort(\"_st\")\n        .maxPageSize(20)\n        .build();\n\nQueryStringParser.withConfig(config).parse(queryStringParams);\n```\n\n### Filtering\n\nIn the persistence layer we will be able to use `Visitors` as follows.\n\n```java\nimport fr.ght1pc9kc.juery.jooq.filter.JooqConditionVisitor;\n\nprivate static final JooqConditionVisitor JOOQ_CONDITION_VISITOR =\n        new JooqConditionVisitor(PropertiesMappers.FEEDS_PROPERTIES_MAPPING::get);\n```\n\nThe `JooqConditionVisitor` implementation takes as input a `Function \u003cString, Field \u003c?\u003e\u003e` which will allow to transform\nthe properties of your criteria, into jOOQ `Field` objects corresponding to columns of your tables.\n\n```java\nimport fr.ght1pc9kc.juery.api.Criteria;\nimport fr.ght1pc9kc.juery.api.PageRequest;\n\n// transforms the Criteria present in pageRequest into Condition\nCondition conditions = pageRequest.filter.visit(JOOQ_CONDITION_VISITOR);\n\n// Execute query with the conditions generated by the visitor \nCursor\u003cRecord\u003e cursor = dsl\n    .select(FEEDS.fields()).select(FEEDS_USERS.FEUS_TAGS)\n        .from(FEEDS)\n        .leftJoin(FEEDS_USERS).on(FEEDS_USERS.FEUS_FEED_ID.eq(FEEDS.FEED_ID))\n        .where(conditions).fetchLazy();\n```\n\n### Pagination\n\nThe `PageRequest` object contains the data necessary for pagination. You can implement it yourself, \nbut for jOOQ users, the `JooqPagination` helper makes it easier.\n\n```java\nimport fr.ght1pc9kc.juery.api.Criteria;\nimport fr.ght1pc9kc.juery.api.PageRequest;\n\n// transforms the Criteria present in pageRequest into Condition\nCondition conditions = pageRequest.filter.visit(NEWS_CONDITION_VISITOR);\n\n// Apply pagination parameters to the query\nfinal Select\u003cRecord\u003e query = JooqPagination.apply(pageRequest, PropertiesMappers.FEEDS_PROPERTIES_MAPPING, dsl\n    .select(FEEDS.fields()).select(FEEDS_USERS.FEUS_TAGS)\n        .from(FEEDS)\n        .leftJoin(FEEDS_USERS).on(FEEDS_USERS.FEUS_FEED_ID.eq(FEEDS.FEED_ID))\n        .where(conditions)\n);\n\nCursor\u003cRecord\u003e cursor = query.fetchLazy();\n```\n\nWe find the `PropertiesMappers.FEEDS_PROPERTIES_MAPPING`, optional, which allows to make the link between the sort \ncriteria and the table fields.\n\n### PropertiesMappers example\n\nAs an example to illustrate what is `PropertiesMappers.FEEDS_PROPERTIES_MAPPING` in the context of using jOOQ as DSL.\n\n```java\npublic static final Map\u003cString, Field\u003c?\u003e\u003e FEEDS_PROPERTIES_MAPPING = Map.of(\n        \"id\", FEEDS.FEED_ID,\n        \"name\", FEEDS.FEED_NAME,\n        ...\n);\n```\n\n`FEEDS` was a jOOQ Table generated before compilation with `jooq-codegen-maven` Maven Plugin. `\"id\"` and `\"name\"` was properties\nused in `Criteria`.\n\n```java\nimport fr.ght1pc9kc.juery.api.Criteria;\n\nCriteria.property(\"id\").eq(\"F0042\")\n    .and(Criteria.property(\"name\").eq(\"H2G2\"));\n```\n\n## Contributing\nPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.\n\nPlease make sure to update tests as appropriate.\n\n## License\n\n[MIT](https://choosealicense.com/licenses/mit/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthym%2Fjuery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarthym%2Fjuery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarthym%2Fjuery/lists"}