Search in sources :

Example 11 with MetaKey

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

the class JpaCriteriaQueryBackend method getParentIdExpression.

private Expression<?> getParentIdExpression(MetaAttribute parentAttr) {
    MetaEntity parentEntity = (MetaEntity) parentAttr.getParent();
    MetaKey primaryKey = parentEntity.getPrimaryKey();
    List<MetaAttribute> elements = primaryKey.getElements();
    PreconditionUtil.assertFalse("composite primary keys not supported yet", elements.size() != 1);
    MetaAttribute primaryKeyAttr = elements.get(0);
    return parentFrom.get(primaryKeyAttr.getName());
}
Also used : MetaKey(io.crnk.meta.model.MetaKey) MetaEntity(io.crnk.jpa.meta.MetaEntity) MetaAttribute(io.crnk.meta.model.MetaAttribute)

Example 12 with MetaKey

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

the class MetaRelationshipRepositoryImplTest method findOneTargetReturnsResult.

@Test
public void findOneTargetReturnsResult() {
    MetaResource resource = resourceProvider.getMeta(Task.class);
    MetaKey key = (MetaKey) repo.findOneTarget(resource.getId(), "primaryKey", new QuerySpec(MetaElement.class));
    Assert.assertNotNull(key);
    Assert.assertEquals("id", key.getUniqueElement().getName());
}
Also used : MetaKey(io.crnk.meta.model.MetaKey) MetaResource(io.crnk.meta.model.resource.MetaResource) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

MetaKey (io.crnk.meta.model.MetaKey)12 MetaAttribute (io.crnk.meta.model.MetaAttribute)7 Test (org.junit.Test)6 MetaEntity (io.crnk.jpa.meta.MetaEntity)3 MetaResource (io.crnk.meta.model.resource.MetaResource)3 QuerySpec (io.crnk.core.queryspec.QuerySpec)2 MetaLookup (io.crnk.meta.MetaLookup)2 FilterSpec (io.crnk.core.queryspec.FilterSpec)1 TSField (io.crnk.gen.typescript.model.TSField)1 TSIndexSignature (io.crnk.gen.typescript.model.TSIndexSignature)1 TSInterfaceType (io.crnk.gen.typescript.model.TSInterfaceType)1 TSModule (io.crnk.gen.typescript.model.TSModule)1 AbstractJpaJerseyTest (io.crnk.jpa.AbstractJpaJerseyTest)1 JpaResource (io.crnk.jpa.annotations.JpaResource)1 MetaJpaDataObject (io.crnk.jpa.meta.MetaJpaDataObject)1 MethodAnnotatedEntity (io.crnk.jpa.model.MethodAnnotatedEntity)1 MetaDataObject (io.crnk.meta.model.MetaDataObject)1 MetaElement (io.crnk.meta.model.MetaElement)1