Add rest client + domain module
All checks were successful
Maven build / build (push) Successful in 4m18s
All checks were successful
Maven build / build (push) Successful in 4m18s
This commit is contained in:
36
domain/pom.xml
Normal file
36
domain/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>fr.codeanddata.semrack</groupId>
|
||||
<artifactId>semrack-bom</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<relativePath>../bom/pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>semrack</artifactId>
|
||||
<name>Semrack</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.quarkus</groupId>
|
||||
<artifactId>quarkus-arc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
13
domain/src/main/java/fr/codeanddata/semrack/Index.java
Normal file
13
domain/src/main/java/fr/codeanddata/semrack/Index.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import fr.codeanddata.semrack.models.IndexSearchResult;
|
||||
import fr.codeanddata.semrack.models.Search;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
|
||||
public interface Index {
|
||||
Uni<Long> count(Search request);
|
||||
Uni<Boolean> exist(Search query);
|
||||
Uni<Void> index(String documentId);
|
||||
Uni<IndexSearchResult> search(Search search);
|
||||
Uni<Void> clear(String documentId);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import jakarta.enterprise.inject.spi.CDI;
|
||||
|
||||
public interface LookupExpression<T> {
|
||||
String apply(Object params);
|
||||
|
||||
default T convert(Object params) {
|
||||
return CDI.current().select(ObjectMapper.class).get().convertValue(params, new TypeReference<T>() {});
|
||||
}
|
||||
|
||||
default T convert(Object params, Class<T> clazz) {
|
||||
return CDI.current().select(ObjectMapper.class).get().convertValue(params, clazz);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import fr.codeanddata.semrack.models.ReadContext;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
|
||||
public interface ReadInterceptor {
|
||||
Uni<Void> interceptSemdocRead(ReadContext context);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import fr.codeanddata.semrack.models.SearchContext;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
|
||||
public interface SearchInterceptor {
|
||||
Uni<Void> interceptSemdocSearch(SearchContext context);
|
||||
}
|
||||
13
domain/src/main/java/fr/codeanddata/semrack/Storage.java
Normal file
13
domain/src/main/java/fr/codeanddata/semrack/Storage.java
Normal file
@@ -0,0 +1,13 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import fr.codeanddata.semrack.models.Document;
|
||||
import fr.codeanddata.semrack.models.StorageGet;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface Storage {
|
||||
Uni<Document> get(String uid, StorageGet request);
|
||||
Uni<List<Document>> get(List<String> uids, StorageGet request);
|
||||
Uni<Document> storeDocument(Document document);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package fr.codeanddata.semrack;
|
||||
|
||||
import fr.codeanddata.semrack.models.WriteContext;
|
||||
import io.smallrye.mutiny.Uni;
|
||||
|
||||
public interface WriteInterceptor {
|
||||
Uni<Void> interceptSemdocWrite(WriteContext context);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package fr.codeanddata.semrack.enums;
|
||||
|
||||
public enum PathTypes {
|
||||
UNKNOWN,
|
||||
STRING,
|
||||
NUMBER,
|
||||
BOOLEAN,
|
||||
LIST,
|
||||
OBJECT
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package fr.codeanddata.semrack.enums;
|
||||
|
||||
public enum SortDirection {
|
||||
asc, desc
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package fr.codeanddata.semrack.exceptions;
|
||||
|
||||
public class SemrackException extends Exception {
|
||||
public SemrackException() {
|
||||
}
|
||||
|
||||
public SemrackException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SemrackException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public SemrackException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package fr.codeanddata.semrack.exceptions;
|
||||
|
||||
public class SemrackRuntimeException extends RuntimeException {
|
||||
public SemrackRuntimeException() {
|
||||
}
|
||||
|
||||
public SemrackRuntimeException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public SemrackRuntimeException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public SemrackRuntimeException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@RegisterForReflection(serialization = true)
|
||||
public class Document {
|
||||
|
||||
/**
|
||||
* L'identifiant unique du document.
|
||||
*/
|
||||
String uid;
|
||||
|
||||
/**
|
||||
* Les annotations sont créées par le système, au travers des extensions. Elles sont en lecture seule.
|
||||
* Elles ont pour vocation d'aider au classement et à la recherche du document (tags, catégories, date de création, etc.).
|
||||
*/
|
||||
Map<String, Object> annotations;
|
||||
|
||||
/**
|
||||
* Le contenu du document.
|
||||
*/
|
||||
Map<String, Object> metadata;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
Map<String, Object> fields;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class IndexSearchResult {
|
||||
List<String> uids;
|
||||
PaginationInfo pagination;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Pagination {
|
||||
Integer page;
|
||||
Integer size;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PaginationInfo {
|
||||
long page;
|
||||
long size;
|
||||
long total;
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class PushDocument {
|
||||
/**
|
||||
* L'identifiant unique du document.
|
||||
*/
|
||||
String uid;
|
||||
|
||||
/**
|
||||
* Les directives sont les paramètres d'extensions.
|
||||
* Elles ont pour vocation de générer des actions sur les documents, comme le publish, etc...
|
||||
*/
|
||||
Map<String, Object> directives;
|
||||
|
||||
/**
|
||||
* Le contenu du document.
|
||||
*/
|
||||
Map<String, Object> metadata;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class ReadContext {
|
||||
Document currentDocument;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Search {
|
||||
Map<String, Object> filter;
|
||||
List<Sort> sort;
|
||||
Pagination paginate;
|
||||
Boolean annotations;
|
||||
Boolean metadata;
|
||||
Map<String, String> fields;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class SearchContext {
|
||||
|
||||
Map<String, Object> search;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class SearchResult {
|
||||
List<Document> documents;
|
||||
PaginationInfo pagination;
|
||||
}
|
||||
14
domain/src/main/java/fr/codeanddata/semrack/models/Sort.java
Normal file
14
domain/src/main/java/fr/codeanddata/semrack/models/Sort.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import fr.codeanddata.semrack.enums.SortDirection;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Sort {
|
||||
String field;
|
||||
SortDirection direction;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class StorageGet {
|
||||
Boolean metadataSource;
|
||||
Boolean annotationsSource;
|
||||
Map<String, String> fields;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import fr.codeanddata.semrack.enums.PathTypes;
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class TraverserPath {
|
||||
PathTypes type;
|
||||
String fullPath;
|
||||
Object value;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package fr.codeanddata.semrack.models;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WriteContext {
|
||||
|
||||
/**
|
||||
* Previous stored document
|
||||
*/
|
||||
Document currentDocument;
|
||||
|
||||
/**
|
||||
* Document to be store. It initialized with :
|
||||
* - the currentDocument uid if exists, or a new one
|
||||
* - the metadata to be persisted
|
||||
*/
|
||||
Document nextDocument;
|
||||
|
||||
/**
|
||||
* The directives to be applied
|
||||
*/
|
||||
Map<String, Object> directives;
|
||||
}
|
||||
Reference in New Issue
Block a user