use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ViewAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isViewPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class AddToSetAction method actionPerform.
@Override
public void actionPerform(Component component) {
MetaClass entityMetaClass;
if (target.getItems() instanceof EntityDataUnit) {
entityMetaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
} else {
throw new UnsupportedOperationException("Unsupported data unit " + target.getItems());
}
String query;
if (filter.getDatasource() != null) {
query = filter.getDatasource().getQuery();
} else {
query = filter.getDataLoader().getQuery();
}
String[] strings = ValuePathHelper.parse(CubaComponentsHelper.getFilterComponentPath(filter));
String componentId = ValuePathHelper.pathSuffix(strings);
Set ownerSelection = target.getSelected();
Map<String, Object> params = new HashMap<>();
params.put("entityType", entityMetaClass.getName());
params.put("items", ownerSelection);
params.put("componentPath", CubaComponentsHelper.getFilterComponentPath(filter));
params.put("componentId", componentId);
params.put("foldersPane", filterHelper.getFoldersPane());
params.put("entityClass", entityMetaClass.getJavaClass().getName());
params.put("query", query);
params.put("username", userSessionSource.getUserSession().getUser().getUsername());
Screens screens = ComponentsHelper.getScreenContext(filter).getScreens();
screens.create("saveSetInFolder", OpenMode.DIALOG, new MapScreenOptions(params)).show();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class AbstractDataGrid method setupPaginationDataSourceProvider.
public void setupPaginationDataSourceProvider() {
if (pagination == null) {
return;
}
DataUnit items = getItems();
PaginationDataBinder provider;
if (items instanceof ContainerDataUnit) {
provider = applicationContext.getBean(PaginationDataUnitBinder.class, items);
} else if (items instanceof EmptyDataUnit && items instanceof EntityDataUnit) {
provider = new PaginationEmptyBinder(((EntityDataUnit) items).getEntityMetaClass());
} else {
throw new IllegalStateException("Unsupported data unit type: " + items);
}
pagination.setDataBinder(provider);
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ChangePasswordAction method isPermitted.
@Override
protected boolean isPermitted() {
if (target == null || !(target.getItems() instanceof EntityDataUnit)) {
return false;
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
return true;
}
UiEntityContext entityContext = new UiEntityContext(metaClass);
accessManager.applyRegisteredConstraints(entityContext);
if (!entityContext.isEditPermitted()) {
return false;
}
return super.isPermitted();
}
use of io.jmix.ui.component.data.meta.EntityDataUnit in project jmix by jmix-framework.
the class ChangePasswordAction method execute.
/**
* Executes the action.
*/
@Override
public void execute() {
if (target == null) {
throw new IllegalStateException("Target is not set");
}
if (!(target.getItems() instanceof EntityDataUnit)) {
throw new IllegalStateException("Target dataSource is null or does not implement EntityDataUnit");
}
MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
if (metaClass == null) {
throw new IllegalStateException("Target is not bound to entity");
}
Object editedEntity = target.getSingleSelected();
if (editedEntity == null) {
throw new IllegalStateException("There is not selected item in ChangePassword target");
}
if (!(editedEntity instanceof UserDetails)) {
throw new IllegalStateException("Target does not implement a UserDetails");
}
UserDetails user = (UserDetails) editedEntity;
buildAndShowChangePasswordDialog(user);
}
Aggregations