use of org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn in project jnosql-diana by eclipse.
the class AbstractGraphRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = RepositoryType.of(method);
Class<?> typeClass = getClassMapping().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
return findBy(method, args, typeClass);
case FIND_ALL:
return findAll(method, typeClass, args);
case DELETE_BY:
return executeDeleteMethod(method, args);
case OBJECT_METHOD:
return method.invoke(this, args);
case UNKNOWN:
case JNOSQL_QUERY:
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q)).withQueryConverter(q -> getTemplate().query(q)).build();
return methodReturn.execute();
default:
return Void.class;
}
}
use of org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn in project jnosql-diana by eclipse.
the class AbstractReactiveDocumentRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = ReactiveRepositoryType.of(method);
Class<?> typeClass = getClassMapping().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
DocumentQuery query = getQuery(method, args);
return executeQuery(method, args, typeClass, query);
case FIND_ALL:
DocumentQuery queryFindAll = select().from(getClassMapping().getName()).build();
return executeQuery(method, args, typeClass, getQuerySorts(args, queryFindAll));
case DELETE_BY:
DocumentDeleteQuery documentDeleteQuery = getDeleteQuery(method, args);
Iterable<Void> iterable = () -> {
getTemplate().delete(documentDeleteQuery);
return Collections.emptyIterator();
};
return ReactiveStreams.fromIterable(iterable).buildRs();
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q)).withQueryConverter(q -> getTemplate().query(q)).build();
return methodReturn.execute();
default:
return Void.class;
}
}
use of org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn in project jnosql-diana by eclipse.
the class AbstractReactiveKeyValueRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = ReactiveRepositoryType.of(method);
switch(type) {
case DEFAULT:
return method.invoke(getReactiveRepository(), args);
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
Class<?> typeClass = getEntityClass();
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q, typeClass)).withQueryConverter(q -> getTemplate().query(q, typeClass)).build();
return methodReturn.execute();
default:
throw new DynamicQueryException("Key Value repository does not support query method");
}
}
use of org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn in project jnosql-diana by eclipse.
the class AbstractDocumentRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = RepositoryType.of(method);
Class<?> typeClass = getClassMapping().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
DocumentQuery query = getQuery(method, args);
return executeQuery(method, args, typeClass, query);
case FIND_ALL:
DocumentQuery queryFindAll = select().from(getClassMapping().getName()).build();
return executeQuery(method, args, typeClass, getQuerySorts(args, queryFindAll));
case DELETE_BY:
DocumentDeleteQuery documentDeleteQuery = getDeleteQuery(method, args);
getTemplate().delete(documentDeleteQuery);
return null;
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q)).withQueryConverter(q -> getTemplate().query(q)).build();
return methodReturn.execute();
default:
return Void.class;
}
}
use of org.eclipse.jnosql.mapping.repository.DynamicQueryMethodReturn in project jnosql-diana by eclipse.
the class AbstractReactiveColumnRepositoryProxy method invoke.
@Override
public Object invoke(Object instance, Method method, Object[] args) throws Throwable {
RepositoryType type = ReactiveRepositoryType.of(method);
Class<?> typeClass = getClassMapping().getClassInstance();
switch(type) {
case DEFAULT:
return method.invoke(getRepository(), args);
case FIND_BY:
ColumnQuery query = getQuery(method, args);
return executeQuery(method, args, typeClass, query);
case FIND_ALL:
ColumnQuery queryFindAll = select().from(getClassMapping().getName()).build();
return executeQuery(method, args, typeClass, getQuerySorts(args, queryFindAll));
case DELETE_BY:
ColumnDeleteQuery columnDeleteQuery = getDeleteQuery(method, args);
Iterable<Void> iterable = () -> {
getTemplate().delete(columnDeleteQuery);
return Collections.emptyIterator();
};
return ReactiveStreams.fromIterable(iterable).buildRs();
case OBJECT_METHOD:
return method.invoke(this, args);
case JNOSQL_QUERY:
DynamicQueryMethodReturn methodReturn = DynamicQueryMethodReturn.builder().withArgs(args).withMethod(method).withTypeClass(typeClass).withPrepareConverter(q -> getTemplate().prepare(q)).withQueryConverter(q -> getTemplate().query(q)).build();
return methodReturn.execute();
default:
return Void.class;
}
}
Aggregations