use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class JpaMetaProviderAttributeTest method setup.
@Before
public void setup() {
metaProvider = new JpaMetaProvider(Collections.<Class>emptySet());
MetaLookup lookup = new MetaLookup();
lookup.addProvider(metaProvider);
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class ValidationMetaProviderTest method setup.
private void setup(boolean addValidationProvider) {
CrnkBoot boot = new CrnkBoot();
boot.addModule(new JaxrsModule(null));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock", new SampleJsonServiceLocator()));
boot.boot();
resourceMetaProvider = new ResourceMetaProvider();
lookup = new MetaLookup();
lookup.setModuleContext(boot.getModuleRegistry().getContext());
lookup.addProvider(resourceMetaProvider);
if (addValidationProvider) {
lookup.addProvider(new ValidationMetaProvider());
}
lookup.initialize();
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class JpaModule method setupModule.
@Override
public void setupModule(ModuleContext context) {
this.context = context;
Set<Class> jpaTypes = new HashSet<>();
if (config != null) {
for (JpaRepositoryConfig<?> config : config.getRepositories()) {
jpaTypes.add(config.getEntityClass());
}
}
jpaMetaProvider = new JpaMetaProvider(jpaTypes);
jpaMetaLookup = new MetaLookup();
jpaMetaLookup.addProvider(jpaMetaProvider);
jpaMetaLookup.setModuleContext(context);
jpaMetaLookup.initialize();
if (config != null) {
initQueryFactory();
}
context.addResourceInformationBuilder(getResourceInformationProvider(context.getPropertiesProvider()));
context.addExceptionMapper(new OptimisticLockExceptionMapper());
context.addExceptionMapper(new PersistenceExceptionMapper(context));
context.addExceptionMapper(new PersistenceRollbackExceptionMapper(context));
addHibernateConstraintViolationExceptionMapper();
addTransactionRollbackExceptionMapper();
context.addRepositoryDecoratorFactory(new JpaRepositoryDecoratorFactory());
if (em != null) {
metaEnricher = new JpaMetaEnricher();
// enrich resource meta model with JPA information where incomplete
MetaModuleExtension metaModuleExtension = new MetaModuleExtension();
metaModuleExtension.addProvider(metaEnricher.getProvider());
context.addExtension(metaModuleExtension);
setupTransactionMgmt();
}
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class AbstractOperationsTest method clear.
public static void clear(final EntityManager em, JpaQueryFactory factory) {
factory.initalize(new JpaQueryFactoryContext() {
@Override
public MetaPartition getMetaPartition() {
MetaLookup metaLookup = new MetaLookup();
JpaMetaProvider metaProvider = new JpaMetaProvider(em.getEntityManagerFactory());
metaLookup.addProvider(metaProvider);
metaLookup.initialize();
return metaProvider.getPartition();
}
@Override
public EntityManager getEntityManager() {
return em;
}
});
clear(em, factory.query(MovieEntity.class).buildExecutor().getResultList());
clear(em, factory.query(PersonEntity.class).buildExecutor().getResultList());
em.flush();
em.clear();
}
Aggregations