use of io.crnk.meta.model.MetaAttribute 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());
}
}
use of io.crnk.meta.model.MetaAttribute in project crnk-framework by crnk-project.
the class MetaMetaTest method testMetaElementImmutable.
@Test
public void testMetaElementImmutable() {
MetaResource dataMeta = resourceProvider.getMeta(MetaDataObject.class);
Assert.assertFalse(dataMeta.isUpdatable());
Assert.assertFalse(dataMeta.isInsertable());
Assert.assertFalse(dataMeta.isDeletable());
Assert.assertNotEquals(0, dataMeta.getAttributes().size());
for (MetaAttribute attr : dataMeta.getAttributes()) {
Assert.assertFalse(attr.isUpdatable());
Assert.assertFalse(attr.isInsertable());
}
}
use of io.crnk.meta.model.MetaAttribute in project crnk-framework by crnk-project.
the class MetaMetaTest method testMetaDataObjectMeta.
@Test
public void testMetaDataObjectMeta() {
MetaResource meta = resourceProvider.getMeta(MetaDataObject.class);
MetaAttribute elementTypeAttr = meta.getAttribute("elementType");
Assert.assertNotNull(elementTypeAttr);
Assert.assertNotNull(elementTypeAttr.getType());
Assert.assertEquals("resources.meta.type.elementType", elementTypeAttr.getId());
MetaAttribute attrsAttr = meta.getAttribute("attributes");
Assert.assertNotNull(attrsAttr.getType());
MetaAttribute childrenAttr = meta.getAttribute("children");
Assert.assertEquals("resources.meta.element.children", childrenAttr.getId());
Assert.assertEquals("resources.meta.element$list", childrenAttr.getType().getId());
}
use of io.crnk.meta.model.MetaAttribute in project crnk-framework by crnk-project.
the class MetaMetaTest method testMetaNaming.
@Test
public void testMetaNaming() {
MetaResource taskMeta = resourceProvider.getMeta(Task.class);
MetaAttribute metaInformation = taskMeta.getAttribute("metaInformation");
MetaType type = metaInformation.getType();
Assert.assertEquals(type.getId(), "resources.tasks$meta");
Assert.assertEquals(type.getName(), "TaskMeta");
}
use of io.crnk.meta.model.MetaAttribute in project crnk-framework by crnk-project.
the class MetaDataObjectProviderBase method createAttribute.
protected MetaAttribute createAttribute(T metaDataObject, String name) {
MetaAttribute attr = new MetaAttribute();
attr.setName(MetaUtils.firstToLower(name));
attr.setParent(metaDataObject, true);
attr.setFilterable(true);
attr.setSortable(true);
return attr;
}
Aggregations