Skip to content

Commit

Permalink
feat(initial-commit): Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
THOREL Arnaud authored and THOREL Arnaud committed Nov 14, 2023
1 parent e486165 commit 92ff962
Show file tree
Hide file tree
Showing 35 changed files with 154 additions and 123 deletions.
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Java sources
*.java text diff=java
1 change: 1 addition & 0 deletions .github/badges/jacoco.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 23 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ name: Build

on:
push:
branches: [ $default-branch ]
branches: [ main ]
pull_request:
branches: [ $default-branch ]
branches: [ main ]

jobs:
build:
Expand All @@ -27,6 +27,25 @@ jobs:
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml
- uses: irongut/CodeCoverageSummary@v1.3.0
- name: Generate JaCoCo Badge
uses: cicirello/jacoco-badge-generator@v2
- name: Log coverage percentage
run: |
echo "coverage = ${{ steps.jacoco.outputs.coverage }}"
echo "branches = ${{ steps.jacoco.outputs.branches }}"
- name: Commit and push
if: ${{ github.event_name != 'pull_request' }}
run: |
cd .github/badges
if [[ `git status --porcelain *.svg` ]]; then
git config --global user.name 'github-actions'
git config --global user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add *.svg
git commit -m "Autogenerated JaCoCo coverage badge" *.svg
git push
fi
- name: Upload Jacoco coverage report
uses: actions/upload-artifact@v3
with:
filename: target/site/jacoco/jacoco.xml
name: jacoco-report
path: target/site/jacoco/
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Ouest-France/SIPA Tech

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
31 changes: 9 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
<div style="text-align:center;padding-top: 15px">
<div align="center" style="text-align:center;padding-top: 15px">
<img alt="logo-ouest-france" src="https://sipaui.sipaof.fr/downloads/logotheque/ouest-france-couleur.svg" height="100"/>
<h1 style="margin: 0;padding: 0">QueryDSL</h1>
</div>
<div align="center" style="text-align: center">

---
<div style="text-align: center">

[![Build Status](https://github.com/Ouest-France/querydsl/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/PostgREST/postgrest/actions?query=branch%3Amain)
[![Coverage Status](https://img.shields.io/codecov/c/github/postgrest/postgrpostgrest/main)](https://app.codecov.io/gh/PostgREST/postgrest)
[![Hackage docs](https://img.shields.io/hackage/v/postgrest.svg?label=hackage)](http://hackage.haskell.org/package/postgrest)
[![Build Status](https://github.com/Ouest-France/querydsl/actions/workflows/build.yml/badge.svg)](https://github.com/Ouest-France/querydsl/actions/workflows/build.yml)
![Coverage](https://raw.githubusercontent.com/Ouest-France/querydsl/main/.github/badges/jacoco.svg)

</div>
QueryDSL is a unpostgrified annotation based DSL for querying multiple datasource

## Getting Started
QueryDSL is a unified annotation based DSL for querying multiple datasource

---
## Getting Started

QueryDSL is a **Domain Specific Language** based on annotation processing to transform java classes to dedicated query for a specific datasource.
You can write your own connector implementation by adding this library to your code
Expand All @@ -42,8 +38,6 @@ implementation 'fr.ouestfrance.querydsl:querydsl:${querydsl.version}'

## How does it work

---

QueryDSL transforms annotations from your search object to filterModel that you can map to a specific connector.

**Search object using annotations**
Expand All @@ -68,7 +62,7 @@ class UserSearch {
**Concrete query using PostgREST**

```properties
GET /users?name=like.Jean%20Doe
GET /users?name=like.John%20Doe
&service=eq.CIA
&startDate=lte.2023-12-12
&or=(endDate.eq.null, endDate.gte.2023-12-12)
Expand All @@ -85,7 +79,6 @@ AND (endDate is null OR endDate > "2023-12-12")

### Create your mappers

---

To achieve the transformations between annotation based and concrete source, you have to write Mappers

Expand Down Expand Up @@ -153,8 +146,6 @@ public class InMapper extends Mapper<String> {

### Create a processor Service

---

You have to bind your mappers to a processorService

```java
Expand All @@ -176,10 +167,9 @@ public class PostgrestQueryProcessorService implements QueryDslProcessorService<
then you can add it to an abstract repository usage and reduce the amount of condition on your code

```java
import fr.ouestfrance.shared.querydsl.service.ext.QueryDslProcessorService;
import fr.ouestfrance.querydsl.service.ext.QueryDslProcessorService;

import java.util.List;
import java.util.stream.Collectors;

public abstract class PostgrestRepository<T> {

Expand All @@ -192,24 +182,21 @@ public abstract class PostgrestRepository<T> {
List<String> queryStrings = processorService.process(criteria);
return webClient.get(resourceUrl() + "?" + String.join("&", queryStrings));
}

abstract String resourceUrl();
}
```

## Need Help ?

---
If you need help with the library please start a new thread QA / Issue on github

## Contributing

---
If you want to request a feature or report a bug, please create a GitHub Issue

If you want to make a contribution to the project, please create a PR

## License

---
The QueryDSL is licensed under [MIT License](https://opensource.org/license/mit/)
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>

<groupId>fr.ouestfrance.querydsl</groupId>
<artifactId>library-java-querydsl</artifactId>
<artifactId>querydsl</artifactId>
<version>1.0.0-SNAPSHOT</version>

<properties>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl;
package fr.ouestfrance.querydsl;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl;
package fr.ouestfrance.querydsl;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl;
package fr.ouestfrance.querydsl;

/**
* Type of operations
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.ouestfrance.shared.querydsl.model;
package fr.ouestfrance.querydsl.model;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.FilterOperation;
import lombok.AllArgsConstructor;
import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl.model;
package fr.ouestfrance.querydsl.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.ouestfrance.shared.querydsl.service;
package fr.ouestfrance.querydsl.service;

import fr.ouestfrance.shared.querydsl.model.FilterFieldModel;
import fr.ouestfrance.shared.querydsl.service.scanner.FilterFieldAnnotationScanner;
import fr.ouestfrance.querydsl.model.FilterFieldModel;
import fr.ouestfrance.querydsl.service.scanner.FilterFieldAnnotationScanner;

import java.util.List;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.ouestfrance.shared.querydsl.service.ext;
package fr.ouestfrance.querydsl.service.ext;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.model.FilterFieldInfoModel;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.model.FilterFieldInfoModel;

/**
* Interface that allow to transform operation to concrete filter objet depending on the connector source
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package fr.ouestfrance.shared.querydsl.service.ext;
package fr.ouestfrance.querydsl.service.ext;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.model.FilterFieldModel;
import fr.ouestfrance.shared.querydsl.service.FilterFieldAnnotationProcessorService;
import fr.ouestfrance.shared.querydsl.utils.ReflectUtils;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.model.FilterFieldModel;
import fr.ouestfrance.querydsl.service.FilterFieldAnnotationProcessorService;
import fr.ouestfrance.querydsl.utils.ReflectUtils;

import java.lang.reflect.Method;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package fr.ouestfrance.shared.querydsl.service.scanner;
package fr.ouestfrance.querydsl.service.scanner;

import fr.ouestfrance.shared.querydsl.FilterField;
import fr.ouestfrance.shared.querydsl.FilterFields;
import fr.ouestfrance.shared.querydsl.model.FilterFieldInfoModel;
import fr.ouestfrance.shared.querydsl.model.FilterFieldModel;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldConstraintException;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldValidatorService;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldViolation;
import fr.ouestfrance.shared.querydsl.utils.ReflectUtils;
import fr.ouestfrance.querydsl.FilterField;
import fr.ouestfrance.querydsl.FilterFields;
import fr.ouestfrance.querydsl.model.FilterFieldInfoModel;
import fr.ouestfrance.querydsl.model.FilterFieldModel;
import fr.ouestfrance.querydsl.service.validators.FilterFieldConstraintException;
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidatorService;
import fr.ouestfrance.querydsl.service.validators.FilterFieldViolation;
import fr.ouestfrance.querydsl.utils.ReflectUtils;

import java.lang.reflect.Field;
import java.lang.reflect.Method;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl.service.validators;
package fr.ouestfrance.querydsl.service.validators;

import lombok.Getter;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl.service.validators;
package fr.ouestfrance.querydsl.service.validators;

/**
* Validator interface
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package fr.ouestfrance.shared.querydsl.service.validators;
package fr.ouestfrance.querydsl.service.validators;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.model.FilterFieldModel;
import fr.ouestfrance.shared.querydsl.service.validators.impl.EqualsValidator;
import fr.ouestfrance.shared.querydsl.service.validators.impl.GreaterLessValidator;
import fr.ouestfrance.shared.querydsl.service.validators.impl.InValidator;
import fr.ouestfrance.shared.querydsl.service.validators.impl.LikeValidator;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.model.FilterFieldModel;
import fr.ouestfrance.querydsl.service.validators.impl.EqualsValidator;
import fr.ouestfrance.querydsl.service.validators.impl.GreaterLessValidator;
import fr.ouestfrance.querydsl.service.validators.impl.InValidator;
import fr.ouestfrance.querydsl.service.validators.impl.LikeValidator;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package fr.ouestfrance.shared.querydsl.service.validators;
package fr.ouestfrance.querydsl.service.validators;

/**
* FilterFieldViolation represent the error on a field with its declarative message
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package fr.ouestfrance.shared.querydsl.service.validators;
package fr.ouestfrance.querydsl.service.validators;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.FilterOperation;

import java.lang.annotation.*;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.ouestfrance.shared.querydsl.service.validators.impl;
package fr.ouestfrance.querydsl.service.validators.impl;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.shared.querydsl.service.validators.ValidatedBy;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.querydsl.service.validators.ValidatedBy;

/**
* Validator that handle filter operations giving equalities (EQ, NEQ)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.ouestfrance.shared.querydsl.service.validators.impl;
package fr.ouestfrance.querydsl.service.validators.impl;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.shared.querydsl.service.validators.ValidatedBy;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.querydsl.service.validators.ValidatedBy;

/**
* Validator that handle filter operations comparable (GT,GTE, LT, LTE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.ouestfrance.shared.querydsl.service.validators.impl;
package fr.ouestfrance.querydsl.service.validators.impl;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.shared.querydsl.service.validators.ValidatedBy;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.querydsl.service.validators.ValidatedBy;

import java.util.Collection;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package fr.ouestfrance.shared.querydsl.service.validators.impl;
package fr.ouestfrance.querydsl.service.validators.impl;

import fr.ouestfrance.shared.querydsl.FilterOperation;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.shared.querydsl.service.validators.ValidatedBy;
import fr.ouestfrance.querydsl.FilterOperation;
import fr.ouestfrance.querydsl.service.validators.FilterFieldValidator;
import fr.ouestfrance.querydsl.service.validators.ValidatedBy;

/**
* Validator that handle filter operations giving like (LIKE)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fr.ouestfrance.shared.querydsl.utils;
package fr.ouestfrance.querydsl.utils;

import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldConstraintException;
import fr.ouestfrance.shared.querydsl.service.validators.FilterFieldViolation;
import fr.ouestfrance.querydsl.service.validators.FilterFieldConstraintException;
import fr.ouestfrance.querydsl.service.validators.FilterFieldViolation;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

Expand Down
Loading

0 comments on commit 92ff962

Please sign in to comment.