use of io.crnk.meta.model.MetaMapType in project crnk-framework by crnk-project.
the class QueryFilterBuilder method enhanceAttributePath.
public MetaAttributePath enhanceAttributePath(MetaAttributePath attrPath, Object value) {
MetaAttribute attr = attrPath.getLast();
MetaType valueType = attr.getType();
if (valueType instanceof MetaMapType) {
valueType = valueType.getElementType();
}
boolean anyType = AnyTypeObject.class.isAssignableFrom(valueType.getImplementationClass());
if (anyType) {
// we have and AnyType and do need to select the proper attribute of
// the embeddable
MetaAttribute anyAttr = AnyUtils.findAttribute((MetaDataObject) valueType, value);
return attrPath.concat(anyAttr);
} else {
return attrPath;
}
}
use of io.crnk.meta.model.MetaMapType in project crnk-framework by crnk-project.
the class JpaMetaProviderAttributeTest method testMapAttr.
@Test
public void testMapAttr() {
MetaEntity meta = metaProvider.discoverMeta(TestEntity.class);
MetaAttribute attr = meta.getAttribute(TestEntity.ATTR_mapValue);
Assert.assertFalse(attr.isAssociation());
Assert.assertEquals(TestEntity.ATTR_mapValue, attr.getName());
Assert.assertEquals(TestEntity.class.getName() + "." + TestEntity.ATTR_mapValue, attr.getId());
Assert.assertFalse(attr.isDerived());
Assert.assertFalse(attr.isVersion());
Assert.assertFalse(attr.isLazy());
Assert.assertNull(attr.getOppositeAttribute());
MetaMapType mapType = attr.getType().asMap();
Assert.assertTrue(mapType.isMap());
Assert.assertEquals(String.class, mapType.getKeyType().getImplementationClass());
Assert.assertEquals(String.class, mapType.getElementType().getImplementationClass());
Assert.assertEquals(String.class, attr.getType().getElementType().getImplementationClass());
}
Aggregations