@Override public MetaClass getMetaClass() { return datasource.getMetaClass(); } }
@Override public MetaClass getMetaClass() { return datasource.getMetaClass(); }
@Override public MetaClass getEntityMetaClass() { return datasource.getMetaClass(); }
@Override public MetaClass getEntityMetaClass() { return datasource.getMetaClass(); }
public OrderableItemMoveAction(String actionId, Direction direction, T listComponent, @Nullable String shortcut) { super(actionId, shortcut); if (!(OrderableEntity.class.isAssignableFrom(listComponent.getDatasource().getMetaClass().getJavaClass()))) { throw new UnsupportedOperationException("List component must contain datasource with entities type of OrderableEntity for ordering"); } this.direction = direction; this.listComponent = listComponent; }
/** * @return lookup screen id */ public String getWindowId() { if (windowId != null) { return windowId; } else { WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); MetaClass metaClass = target.getDatasource().getMetaClass(); return windowConfig.getAvailableLookupScreenId(metaClass); } }
@Override protected boolean isPermitted() { CollectionDatasource ownerDatasource = target.getDatasource(); boolean entityOpPermitted = security.isEntityOpPermitted(ownerDatasource.getMetaClass(), EntityOp.UPDATE); if (!entityOpPermitted) { return false; } return super.isPermitted(); } });
/** * @return editor screen identifier */ public String getWindowId() { if (windowId != null) { return windowId; } else { MetaClass metaClass = target.getDatasource().getMetaClass(); WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); return windowConfig.getEditorScreenId(metaClass); } }
@Nullable protected Object getItemId(CollectionDatasource datasource, String itemIdString) { MetaProperty pkProp = metadata.getTools().getPrimaryKeyProperty(datasource.getMetaClass()); if (pkProp != null) { Datatype<Object> datatype = pkProp.getRange().asDatatype(); try { return datatype.parse(itemIdString); } catch (ParseException e) { throw new RuntimeException("Error parsing item ID", e); } } return null; }
/** * @return editor screen identifier */ public String getWindowId() { if (windowId != null) { return windowId; } else { MetaClass metaClass = target.getDatasource().getMetaClass(); WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME); return windowConfig.getEditorScreenId(metaClass); } }
@Nullable public static String getInferredTestId(DataUnit dataUnit, String suffix) { if (dataUnit instanceof ContainerDataUnit) { ContainerDataUnit dcDataUnit = (ContainerDataUnit) dataUnit; MetaClass entityMetaClass = dcDataUnit.getEntityMetaClass(); return entityMetaClass.getName() + suffix; } else if (dataUnit instanceof DatasourceDataUnit) { DatasourceDataUnit dsDataUnit = (DatasourceDataUnit) dataUnit; MetaClass entityMetaClass = dsDataUnit.getDatasource().getMetaClass(); return entityMetaClass.getName() + suffix; } return null; } }
/** * Check permissions for Action */ @Override protected boolean isPermitted() { if (target == null || target.getDatasource() == null) { return false; } CollectionDatasource ownerDatasource = target.getDatasource(); boolean entityOpPermitted = security.isEntityOpPermitted(ownerDatasource.getMetaClass(), EntityOp.READ); if (!entityOpPermitted) { return false; } return super.isPermitted(); }
protected MetaClass getMetaClassForLocking(Entity item) { // lock original metaClass, if any, because by convention all the configuration is based on original entities MetaClass metaClass = AppBeans.get(ExtendedEntities.class).getOriginalMetaClass(item.getMetaClass()); if (metaClass == null) { metaClass = getTable().getDatasource().getMetaClass(); } return metaClass; }
protected void addDefaultRoles(User user) { LoadContext<Role> ctx = new LoadContext<>(Role.class); ctx.setQueryString("select r from sec$Role r where r.defaultRole = true"); List<Role> defaultRoles = dataSupplier.loadList(ctx); List<UserRole> newRoles = new ArrayList<>(); if (user.getUserRoles() != null) { newRoles.addAll(user.getUserRoles()); } MetaClass metaClass = rolesDs.getMetaClass(); for (Role role : defaultRoles) { UserRole userRole = dataSupplier.newInstance(metaClass); userRole.setRole(role); userRole.setUser(user); newRoles.add(userRole); } user.setUserRoles(newRoles); }
protected MetaClass getFilterMetaClass(Filter filter) { if (filter.getDataLoader() != null && filter.getDataLoader().getContainer() != null) { return filter.getDataLoader().getContainer().getEntityMetaClass(); } if (filter.getDatasource() != null) { return filter.getDatasource().getMetaClass(); } throw new IllegalStateException("No MetaClass related to a filter"); }
protected Collection<MetaPropertyPath> getAutowiredProperties(EntityTableItems<E> entityTableSource) { if (entityTableSource instanceof ContainerDataUnit) { CollectionContainer container = ((ContainerDataUnit) entityTableSource).getContainer(); return container.getView() != null ? // if a view is specified - use view properties metadataTools.getViewPropertyPaths(container.getView(), container.getEntityMetaClass()) : // otherwise use all properties from meta-class metadataTools.getPropertyPaths(container.getEntityMetaClass()); } if (entityTableSource instanceof DatasourceDataUnit) { CollectionDatasource datasource = ((DatasourceDataUnit) entityTableSource).getDatasource(); return datasource.getView() != null ? // if a view is specified - use view properties metadataTools.getViewPropertyPaths(datasource.getView(), datasource.getMetaClass()) : // otherwise use all properties from meta-class metadataTools.getPropertyPaths(datasource.getMetaClass()); } return Collections.emptyList(); }
protected Class<V> getLookupEntityClass() { Class<V> entityClass; ValueSource<Collection<V>> valueSource = getValueSource(); if (valueSource != null) { if (valueSource instanceof EntityValueSource) { //noinspection unchecked entityClass = ((EntityValueSource) valueSource).getMetaPropertyPath().getRangeJavaClass(); } else { entityClass = ((LegacyCollectionDsValueSource<V>) valueSource).getDatasource().getMetaClass().getJavaClass(); } } else if (getOptions() instanceof EntityOptions) { entityClass = ((EntityOptions<V>) getOptions()).getEntityMetaClass().getJavaClass(); } else { throw new RuntimeException("Unable to determine entity class to open lookup"); } return entityClass; }
@Override public void init(Map<String, Object> params) { executionsTable.addAction(new RefreshAction(executionsTable)); int maxResults = persistenceManager.getFetchUI(executionsDs.getMetaClass().getName()); executionsDs.setMaxResults(maxResults); setCaption(formatMessage("executionBrowseCaption", task.name())); } }
protected void printSelected(Set selected) { MetaClass metaClass; if (listComponent.getItems() instanceof ContainerDataUnit) { ContainerDataUnit unit = (ContainerDataUnit) listComponent.getItems(); InstanceContainer container = unit.getContainer(); metaClass = container.getEntityMetaClass(); } else { CollectionDatasource ds = listComponent.getDatasource(); metaClass = ds.getMetaClass(); } Window window = ComponentsHelper.getWindowNN(listComponent); openRunReportScreen(window.getFrameOwner(), selected, metaClass); }
@Override public void refreshState() { super.refreshState(); if (target == null || target.getDatasource() == null) return; if (!captionInitialized) { Messages messages = AppBeans.get(Messages.NAME); if (security.isEntityOpPermitted(target.getDatasource().getMetaClass(), EntityOp.UPDATE)) { setCaption(messages.getMainMessage("actions.Edit")); } else { setCaption(messages.getMainMessage("actions.View")); } } }