Search in sources :

Example 1 with GraphTemplate

use of org.eclipse.jnosql.mapping.graph.GraphTemplate 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);
}
Also used : Repository(jakarta.nosql.mapping.Repository) Graph(org.apache.tinkerpop.gremlin.structure.Graph) GraphTemplate(org.eclipse.jnosql.mapping.graph.GraphTemplate) Converters(jakarta.nosql.mapping.Converters) GraphConverter(org.eclipse.jnosql.mapping.graph.GraphConverter) ClassMappings(org.eclipse.jnosql.mapping.reflection.ClassMappings)

Example 2 with GraphTemplate

use of org.eclipse.jnosql.mapping.graph.GraphTemplate in project jnosql-diana by eclipse.

the class DefaultGraphRepositoryProducer method get.

@Override
public <T, K, R extends Repository<T, K>> R get(Class<R> repositoryClass, Graph manager) {
    Objects.requireNonNull(repositoryClass, "repository class is required");
    Objects.requireNonNull(manager, "manager class is required");
    GraphTemplate template = producer.get(manager);
    GraphRepositoryProxy<R, K> handler = new GraphRepositoryProxy(template, classMappings, repositoryClass, manager, converter, converters);
    return (R) Proxy.newProxyInstance(repositoryClass.getClassLoader(), new Class[] { repositoryClass }, handler);
}
Also used : GraphTemplate(org.eclipse.jnosql.mapping.graph.GraphTemplate)

Example 3 with GraphTemplate

use of org.eclipse.jnosql.mapping.graph.GraphTemplate in project jnosql-diana by eclipse.

the class GraphTemplateConverterTest method shouldReturnTemplate.

@Test
public void shouldReturnTemplate() {
    final String prefix = UUID.randomUUID().toString();
    System.setProperty(prefix, prefix);
    System.setProperty(prefix + ".settings.key", "value");
    System.setProperty(prefix + ".settings.key2", "value2");
    System.setProperty(prefix + ".provider", GraphConfigurationMock.class.getName());
    System.setProperty(prefix + ".database", "bucket");
    final GraphTemplate template = config.getValue(prefix, GraphTemplate.class);
    Assertions.assertNotNull(template);
    System.clearProperty(prefix);
    System.clearProperty(prefix + ".settings.key");
    System.clearProperty(prefix + ".settings.key2");
    System.clearProperty(prefix + ".provider");
    System.clearProperty(prefix + ".database");
}
Also used : GraphTemplate(org.eclipse.jnosql.mapping.graph.GraphTemplate) Test(org.junit.jupiter.api.Test)

Aggregations

GraphTemplate (org.eclipse.jnosql.mapping.graph.GraphTemplate)3 Converters (jakarta.nosql.mapping.Converters)1 Repository (jakarta.nosql.mapping.Repository)1 Graph (org.apache.tinkerpop.gremlin.structure.Graph)1 GraphConverter (org.eclipse.jnosql.mapping.graph.GraphConverter)1 ClassMappings (org.eclipse.jnosql.mapping.reflection.ClassMappings)1 Test (org.junit.jupiter.api.Test)1