Search in sources :

Example 6 with MetaElement

use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.

the class MetaDefaultLimitIntTest method limitShouldNotAffectRelationshipsWithMetaElement.

@Test
public void limitShouldNotAffectRelationshipsWithMetaElement() {
    ResourceRepositoryV2<MetaElement, Serializable> elementRepository = client.getRepositoryForType(MetaElement.class);
    QuerySpec querySpec = new QuerySpec(MetaElement.class);
    querySpec.includeRelation(Arrays.asList("attributes"));
    querySpec.addFilter(new FilterSpec(Arrays.asList("id"), FilterOperator.EQ, "resources.tasks"));
    ResourceList<MetaElement> list = elementRepository.findAll(querySpec);
    Assert.assertEquals(1, list.size());
    MetaResource taskMeta = (MetaResource) list.get(0);
    List<? extends MetaAttribute> attributes = taskMeta.getAttributes();
    Assert.assertTrue(attributes.size() > 5);
}
Also used : Serializable(java.io.Serializable) MetaElement(io.crnk.meta.model.MetaElement) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) FilterSpec(io.crnk.core.queryspec.FilterSpec) Test(org.junit.Test)

Example 7 with MetaElement

use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.

the class MetaRelationshipRepositoryImplTest method findManyTargetReturnsResult.

@Test
public void findManyTargetReturnsResult() {
    MetaResource resource = resourceProvider.getMeta(Task.class);
    ResourceList<MetaElement> children = repo.findManyTargets(resource.getId(), "children", new QuerySpec(MetaElement.class));
    Assert.assertNotEquals(0, children.size());
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 8 with MetaElement

use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.

the class MetaRelationshipRepositoryImpl method getSource.

private MetaElement getSource(String sourceId) {
    MetaLookup lookup = lookupSupplier.get();
    MetaElement source = lookup.getMetaById().get(sourceId);
    if (source == null) {
        throw new ResourceNotFoundException(sourceId);
    }
    return source;
}
Also used : MetaLookup(io.crnk.meta.MetaLookup) MetaElement(io.crnk.meta.model.MetaElement) ResourceNotFoundException(io.crnk.core.exception.ResourceNotFoundException)

Example 9 with MetaElement

use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.

the class MetaDataObjectProvider method onInitialized.

@Override
public void onInitialized(MetaElement element) {
    if (element instanceof MetaAttribute && element.getParent().getClass() == getMetaClass()) {
        MetaAttribute attr = (MetaAttribute) element;
        MetaDataObject parent = attr.getParent();
        Type implementationType = PropertyUtils.getPropertyType(parent.getImplementationClass(), attr.getName());
        MetaElement metaType = context.allocate(implementationType);
        attr.setType(metaType.asType());
    }
}
Also used : Type(java.lang.reflect.Type) MetaElement(io.crnk.meta.model.MetaElement) MetaDataObject(io.crnk.meta.model.MetaDataObject) MetaAttribute(io.crnk.meta.model.MetaAttribute)

Example 10 with MetaElement

use of io.crnk.meta.model.MetaElement in project crnk-framework by crnk-project.

the class MetaModuleTest method testTransitiveRegistrationOfProviderDependencies.

@Test
public void testTransitiveRegistrationOfProviderDependencies() {
    MetaProvider testProvider = Mockito.mock(MetaProvider.class);
    Mockito.when(testProvider.getDependencies()).thenReturn((Collection) Arrays.asList(new ResourceMetaProvider()));
    metaModuleConfig = new MetaModuleConfig();
    metaModuleConfig.addMetaProvider(testProvider);
    metaModule = MetaModule.createServerModule(metaModuleConfig);
    setupBoot();
    Set<Class<? extends MetaElement>> metaClasses = metaModule.collectMetaClasses();
    // meta classes out of testProvider dependency (resource meta provider)
    Assert.assertTrue(metaClasses.contains(MetaResource.class));
    Assert.assertTrue(metaClasses.contains(MetaResourceRepository.class));
}
Also used : MetaElement(io.crnk.meta.model.MetaElement) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) MetaResourceRepository(io.crnk.meta.model.resource.MetaResourceRepository) MetaResource(io.crnk.meta.model.resource.MetaResource) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) MetaProvider(io.crnk.meta.provider.MetaProvider) Test(org.junit.Test)

Aggregations

MetaElement (io.crnk.meta.model.MetaElement)28 MetaDataObject (io.crnk.meta.model.MetaDataObject)6 Test (org.junit.Test)6 MetaResource (io.crnk.meta.model.resource.MetaResource)5 ResourceField (io.crnk.core.engine.information.resource.ResourceField)3 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)3 MetaLookup (io.crnk.meta.MetaLookup)3 MetaAttribute (io.crnk.meta.model.MetaAttribute)3 ResourceNotFoundException (io.crnk.core.exception.ResourceNotFoundException)2 QuerySpec (io.crnk.core.queryspec.QuerySpec)2 TSMetaTransformationContext (io.crnk.gen.typescript.transform.TSMetaTransformationContext)2 Type (java.lang.reflect.Type)2 ArrayList (java.util.ArrayList)2 ResourceFieldType (io.crnk.core.engine.information.resource.ResourceFieldType)1 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)1 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)1 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 ReadOnlyResourceRepositoryBase (io.crnk.core.repository.ReadOnlyResourceRepositoryBase)1 Supplier (io.crnk.core.utils.Supplier)1 TSContainerElement (io.crnk.gen.typescript.model.TSContainerElement)1