public static CrudAdminRepository getDomainClass(PagingAndSortingRepository<?, ?> repo) { try { Class<?>[] classes = repo.getClass().getInterfaces(); Class<?> repoClass = classes[0]; DefaultRepositoryMetadata metadata = new DefaultRepositoryMetadata(repoClass); CrudAdminRepository repoAdmin = new CrudAdminRepository(repo, metadata); return repoAdmin; } catch (Exception ex) { throw new RuntimeException(ex); } }
private GcloudDatastoreQueryCreator createCreator(Class<?> repositoryClass, Method method, Object... values) { QueryMethod queryMethod = new QueryMethod(method, new DefaultRepositoryMetadata(repositoryClass), new SpelAwareProxyProjectionFactory()); return new GcloudDatastoreQueryCreator( new PartTree(method.getName(), queryMethod.getResultProcessor().getReturnedType() .getDomainType()), new ParametersParameterAccessor(queryMethod.getParameters(), values), DatastoreOptions.getDefaultInstance()); }
@Test(dataProvider = "queryMethods", expectedExceptions = {NullPointerException.class, IllegalArgumentException.class}) public void testCreateAggregateQuery(String methodName) throws Exception { AggregateQuerySupportingRepositoryFactory factory = new AggregateQuerySupportingRepositoryFactory(mongoOperations, queryExecutor); QueryLookupStrategy lookupStrategy = factory.getQueryLookupStrategy(CREATE_IF_NOT_FOUND, evaluationContextProvider); Method method = TestAggregateRepository22.class.getMethod(methodName); RepositoryMetadata repositoryMetadata = new DefaultRepositoryMetadata(TestAggregateRepository22.class); ProjectionFactory projectionFactory = new SpelAwareProxyProjectionFactory(); RepositoryQuery query = lookupStrategy.resolveQuery(method, repositoryMetadata, projectionFactory, null); assertNotNull(query); Object object = query.execute(new Object[0]); assertNull(object); }
public CrudAdminRepository(PagingAndSortingRepository<?, ?> repository, DefaultRepositoryMetadata defaultRepositoryMetadata) { this.repository = repository; this.defaultRepositoryMetadata = defaultRepositoryMetadata; }
public DefaultRepositoryMetadata getDefaultRepositoryMetadata() { return defaultRepositoryMetadata; }
public void setDefaultRepositoryMetadata(DefaultRepositoryMetadata defaultRepositoryMetadata) { this.defaultRepositoryMetadata = defaultRepositoryMetadata; }
private SolrQueryMethod getQueryMethodByName(String name, Class<?>... parameters) throws Exception { Method method = Repo1.class.getMethod(name, parameters); return new SolrQueryMethod(method, new DefaultRepositoryMetadata(Repo1.class), creator); }
private RepositoryMetadata getMetadata(Class versionedInterface) { return DefaultRepositoryMetadata.getMetadata(versionedInterface); }