use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class ScreenFacetImpl method createScreen.
protected S createScreen(FrameOwner frameOwner) {
S screen;
Screens screens = UiControllerUtils.getScreenContext(frameOwner).getScreens();
if (screenId != null) {
screen = (S) screens.create(screenId, openMode, getScreenOptions());
} else if (screenClass != null) {
screen = screens.create(screenClass, openMode, getScreenOptions());
} else {
throw new DevelopmentException("Unable to open screen because no screen id or screen class are specified");
}
return screen;
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class DatasourceImpl method __setItem.
protected void __setItem(T item) {
if (this.item != null) {
detachListener(this.item);
}
if (item != null) {
final MetaClass aClass = metadata.getClass(item);
if (!aClass.equals(metaClass) && !metaClass.getDescendants().contains(aClass)) {
throw new DevelopmentException(String.format("Invalid item metaClass '%s'", aClass), ParamsMap.of("datasource", getId(), "metaClass", aClass));
}
attachListener(item);
}
this.item = item;
this.modified = false;
clearCommitLists();
if (item != null && PersistenceHelper.isNew(item)) {
itemsToCreate.add(item);
this.modified = true;
}
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class DsContextLoader method loadGroupDatasource.
protected Datasource loadGroupDatasource(Element element) {
MetaClass metaClass = loadMetaClass(element);
if (metaClass == null)
throw new DevelopmentException("'class' attribute is not set for the datasource");
initCollectionDatasourceAttributes(element, metaClass);
GroupDatasource datasource = builder.setDsClass(getDatasourceClass(element)).buildGroupDatasource();
if (datasource instanceof CollectionDatasource.Suspendable)
((CollectionDatasource.Suspendable) datasource).setSuspended(true);
loadQuery(element, datasource);
loadDatasources(element, datasource);
return datasource;
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class WebDataGrid method addGeneratedColumn.
@Override
public io.jmix.ui.component.DataGrid.Column<E> addGeneratedColumn(String columnId, GenericColumnGenerator<E, ?> generator) {
io.jmix.ui.component.DataGrid.Column<E> column = getColumn(columnId);
if (column == null) {
throw new DevelopmentException("Unable to set ColumnGenerator for non-existing column: " + columnId);
}
Class<? extends Renderer> rendererType = null;
Renderer renderer = column.getRenderer();
if (renderer != null) {
Class<?>[] rendererInterfaces = renderer.getClass().getInterfaces();
rendererType = (Class<? extends Renderer>) Arrays.stream(rendererInterfaces).filter(Renderer.class::isAssignableFrom).findFirst().orElseThrow(() -> new DevelopmentException("Renderer should be specified explicitly for generated column: " + columnId));
}
io.jmix.ui.component.DataGrid.Column<E> generatedColumn = addGeneratedColumn(columnId, new ColumnGenerator<E, Object>() {
@Override
public Object getValue(ColumnGeneratorEvent<E> event) {
return generator.getValue(event);
}
@Override
public Class<Object> getType() {
return ((DataGrid.Column) column).getGeneratedType();
}
});
if (renderer != null) {
generatedColumn.setRenderer(createRenderer(rendererType));
}
return column;
}
use of io.jmix.core.DevelopmentException in project jmix by jmix-framework.
the class DataManagerTest method testNonEntityResults.
@Test
public void testNonEntityResults() throws Exception {
// fails on aggregates
LoadContext context = LoadContext.create(Server.class).setQuery(LoadContext.createQuery("select count(s) from test$Server s"));
try {
dataManager.load(context);
fail();
} catch (Exception e) {
assertTrue(e instanceof DevelopmentException);
}
// fails on single attributes
context = LoadContext.create(Server.class).setQuery(LoadContext.createQuery("select s.name from test$Server s"));
try {
dataManager.load(context);
fail();
} catch (Exception e) {
assertTrue(e instanceof DevelopmentException);
}
}
Aggregations