use of jakarta.nosql.mapping.Converters in project jnosql-diana by eclipse.
the class RepositoryGraphBean method create.
@Override
public Repository create(CreationalContext<Repository> creationalContext) {
ClassMappings classMappings = getInstance(ClassMappings.class);
GraphTemplate repository = provider.isEmpty() ? getInstance(GraphTemplate.class) : getInstance(GraphTemplate.class, DatabaseQualifier.ofGraph(provider));
GraphConverter converter = getInstance(GraphConverter.class);
Graph graph = provider.isEmpty() ? getInstance(Graph.class) : getInstance(Graph.class, DatabaseQualifier.ofGraph(provider));
Converters converters = getInstance(Converters.class);
GraphRepositoryProxy handler = new GraphRepositoryProxy(repository, classMappings, type, graph, converter, converters);
return (Repository) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
use of jakarta.nosql.mapping.Converters in project jnosql-diana by eclipse.
the class SelectQueryConverterTest method shouldRunQuery9.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeLessThanOrderByNameDesc" })
public void shouldRunQuery9(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { 100 });
List<Vertex> vertices = converter.apply(queryMethod, null).collect(Collectors.toList());
List<Object> names = vertices.stream().map(v -> v.value("name")).collect(Collectors.toList());
assertEquals(3, vertices.size());
MatcherAssert.assertThat(names, Matchers.contains("Poliana", "Otavio", "Ada"));
}
use of jakarta.nosql.mapping.Converters in project jnosql-diana by eclipse.
the class RepositoryDocumentBean method create.
@Override
public Repository create(CreationalContext<Repository> context) {
ClassMappings classMappings = getInstance(ClassMappings.class);
DocumentTemplate template = provider.isEmpty() ? getInstance(DocumentTemplate.class) : getInstance(DocumentTemplate.class, DatabaseQualifier.ofDocument(provider));
Converters converters = getInstance(Converters.class);
DocumentRepositoryProxy handler = new DocumentRepositoryProxy(template, classMappings, type, converters);
return (Repository) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
use of jakarta.nosql.mapping.Converters in project jnosql-diana by eclipse.
the class ReactiveRepositoryColumnBean method create.
@Override
public ReactiveRepository<?, ?> create(CreationalContext<ReactiveRepository<?, ?>> context) {
ClassMappings classMappings = getInstance(ClassMappings.class);
ColumnTemplate template = provider.isEmpty() ? getInstance(ColumnTemplate.class) : getInstance(ColumnTemplate.class, DatabaseQualifier.ofDocument(provider));
ReactiveColumnTemplateProducer reactiveProducer = getInstance(ReactiveColumnTemplateProducer.class);
final ReactiveColumnTemplate reactiveTemplate = reactiveProducer.get(template);
Converters converters = getInstance(Converters.class);
ReactiveColumnRepositoryProxy<?> handler = new ReactiveColumnRepositoryProxy<>(reactiveTemplate, template, converters, classMappings, type);
return (ReactiveRepository<?, ?>) Proxy.newProxyInstance(type.getClassLoader(), new Class[] { type }, handler);
}
use of jakarta.nosql.mapping.Converters in project jnosql-diana by eclipse.
the class SelectQueryConverterTest method shouldRunQuery10.
@ParameterizedTest(name = "Should parser the query {0}")
@ValueSource(strings = { "findByAgeLessThanOrderByNameDescAgeAsc" })
public void shouldRunQuery10(String methodName) {
Method method = Stream.of(PersonRepository.class.getMethods()).filter(m -> m.getName().equals(methodName)).findFirst().get();
graph.addVertex(T.label, "Person", "name", "Otavio", "age", 30);
graph.addVertex(T.label, "Person", "name", "Ada", "age", 40);
graph.addVertex(T.label, "Person", "name", "Poliana", "age", 25);
ClassMapping mapping = mappings.get(Person.class);
GraphQueryMethod queryMethod = new GraphQueryMethod(mapping, graph.traversal().V(), converters, method, new Object[] { 100 });
List<Vertex> vertices = converter.apply(queryMethod, null).collect(Collectors.toList());
List<Object> names = vertices.stream().map(v -> v.value("name")).collect(Collectors.toList());
assertEquals(3, vertices.size());
MatcherAssert.assertThat(names, Matchers.contains("Poliana", "Otavio", "Ada"));
}
Aggregations