use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaEntityTest 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 TSGeneratorRuntimeContextImpl method generate.
@Override
public void generate(Object meta) throws IOException {
MetaLookup metaLookup = (MetaLookup) meta;
TSGenerator gen = new TSGenerator(outputDir, metaLookup, config);
gen.run();
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaResourceRepositoryImpl method findOne.
@SuppressWarnings("unchecked")
@Override
public T findOne(String id, QuerySpec querySpec) {
MetaLookup lookup = lookupSupplier.get();
MetaElement metaElement = lookup.getMetaById().get(id);
Class<T> resourceClass = this.getResourceClass();
if (metaElement != null && resourceClass.isInstance(metaElement)) {
MetaElement wrappedElement = MetaUtils.adjustForRequest(lookup, metaElement);
if (wrappedElement != null) {
return (T) metaElement;
}
}
throw new ResourceNotFoundException(id);
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class MetaResourceRepositoryImpl method filterByType.
@SuppressWarnings("unchecked")
private Collection<T> filterByType(Collection<MetaElement> values) {
Collection<T> results = new ArrayList<>();
Class<T> resourceClass = this.getResourceClass();
MetaLookup lookup = lookupSupplier.get();
for (MetaElement element : values) {
if (resourceClass.isInstance(element)) {
MetaElement wrappedElement = MetaUtils.adjustForRequest(lookup, element);
if (wrappedElement != null) {
results.add((T) wrappedElement);
}
}
}
return results;
}
use of io.crnk.meta.MetaLookup in project crnk-framework by crnk-project.
the class AbstractJpaTest method clear.
public static void clear(final EntityManager em, JpaQueryFactory factory) {
factory.initalize(new JpaQueryFactoryContext() {
@Override
public EntityManager getEntityManager() {
return em;
}
@Override
public MetaPartition getMetaPartition() {
JpaMetaProvider jpaMetaProvider = new JpaMetaProvider(em.getEntityManagerFactory());
MetaLookup metaLookup = new MetaLookup();
metaLookup.addProvider(jpaMetaProvider);
metaLookup.initialize();
return jpaMetaProvider.getPartition();
}
});
clear(em, factory.query(OneToOneTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(ManyToManyTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(ManyToManyOppositeEntity.class).buildExecutor().getResultList());
clear(em, factory.query(TestSubclassWithSuperclassPk.class).buildExecutor().getResultList());
clear(em, factory.query(RelatedEntity.class).buildExecutor().getResultList());
clear(em, factory.query(TestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(OtherRelatedEntity.class).buildExecutor().getResultList());
clear(em, factory.query(CountryTranslationEntity.class).buildExecutor().getResultList());
clear(em, factory.query(CountryEntity.class).buildExecutor().getResultList());
clear(em, factory.query(LangEntity.class).buildExecutor().getResultList());
clear(em, factory.query(BasicAttributesTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(RenamedTestEntity.class).buildExecutor().getResultList());
clear(em, factory.query(UuidTestEntity.class).buildExecutor().getResultList());
em.flush();
em.clear();
}
Aggregations