@Override public State getState() { return masterDs.getState(); }
@Override public State getState() { return masterDs.getState(); }
@Override public BindingState getState() { if (datasource.getState() == Datasource.State.VALID && datasource.getItem() != null) { return BindingState.ACTIVE; } return BindingState.INACTIVE; }
@Override public Collection<T> getItems() { backgroundWorker.checkUIAccess(); if (masterDs.getState() == State.NOT_INITIALIZED) { return Collections.emptyList(); } else { Collection<T> items = getCollection(); if (items == null) { return Collections.emptyList(); } if (items.isEmpty()) { return Collections.emptyList(); } return Collections.unmodifiableCollection(items); } }
@Override public int size() { backgroundWorker.checkUIAccess(); if (masterDs.getState() == State.NOT_INITIALIZED) { return 0; } else { final Collection<T> collection = getCollection(); return collection == null ? 0 : collection.size(); } }
@Override public Collection<K> getItemIds() { backgroundWorker.checkUIAccess(); if (masterDs.getState() == State.NOT_INITIALIZED) { return Collections.emptyList(); } else { Collection<T> items = getCollection(); if (items == null) return Collections.emptyList(); else { List<K> ids = new ArrayList<>(items.size()); for (T item : items) { ids.add(item.getId()); } return ids; } } }
@Override public void committed(Set<Entity> entities) { super.committed(entities); if (State.VALID.equals(masterDs.getState())) { Collection<T> collection = getCollection(); if (item != null && collection != null) { for (T entity : collection) { if (entity.equals(item)) { item = entity; } } } } } }
@SuppressWarnings("unchecked") @Override public void committed(Set<Entity> entities) { if (!State.VALID.equals(masterDs.getState())) return;
@Override public BindingState getState() { if (metaPropertyPath == null) { return datasource.getState() == Datasource.State.VALID ? BindingState.ACTIVE : BindingState.INACTIVE; } else { Datasource master = ((NestedDatasource) datasource).getMaster(); boolean masterValid = master.getState() == Datasource.State.VALID; boolean masterEntitySpecified = master.getItem() != null; boolean nestedValid = datasource.getState() == Datasource.State.VALID; return masterValid && masterEntitySpecified && nestedValid ? BindingState.ACTIVE : BindingState.INACTIVE; } }
@Override public void committed(Set<Entity> entities) { super.committed(entities); if (State.VALID.equals(masterDs.getState())) { Collection<ReportInputParameter> collection = getCollection(); if (item != null && collection != null) { for (ReportInputParameter entity : collection) { if (entity.equals(item)) { item = entity; } } } } } }
protected void initDatasources(Window window, DsContext dsContext, @SuppressWarnings("unused") Map<String, Object> params) { ((LegacyFrame) window.getFrameOwner()).setDsContext(dsContext); for (Datasource ds : dsContext.getAll()) { if (Datasource.State.NOT_INITIALIZED.equals(ds.getState()) && ds instanceof DatasourceImplementation) { ((DatasourceImplementation) ds).initialized(); } } }
"datasource", dsName); if (datasource.getState() != State.VALID || datasource.getItem() == null) return null;
@Override public void committed(Set<Entity> entities) { if (!State.VALID.equals(masterDs.getState())) return; Collection<DataSet> collection = getCollection();
@SuppressWarnings("unchecked") protected void datasourceItemChanged(Datasource.ItemChangeEvent e) { if (e.getItem() != null && datasource.getState() == Datasource.State.VALID) { setState(BindingState.ACTIVE); } else { setState(BindingState.INACTIVE); } events.publish(InstanceChangeEvent.class, new InstanceChangeEvent(this, e.getPrevItem(), e.getItem())); }
/** * Set field's "required" flag to false if the value has been filtered by Row Level Security * This is necessary to allow user to submit form with filtered attribute even if attribute is required */ public static void handleFilteredAttributes(Field component, Datasource datasource, MetaPropertyPath mpp) { if (component.isRequired() && datasource.getState() == Datasource.State.VALID && datasource.getItem() != null && mpp.getMetaProperty().getRange().isClass()) { Entity targetItem = datasource.getItem(); MetaProperty[] propertiesChain = mpp.getMetaProperties(); if (propertiesChain.length > 1) { String basePropertyItem = Arrays.stream(propertiesChain) .limit(propertiesChain.length - 1) .map(MetadataObject::getName) .collect(Collectors.joining(".")); targetItem = datasource.getItem().getValueEx(basePropertyItem); } if (targetItem instanceof BaseGenericIdEntity) { String metaPropertyName = mpp.getMetaProperty().getName(); Object value = targetItem.getValue(metaPropertyName); BaseGenericIdEntity baseGenericIdEntity = (BaseGenericIdEntity) targetItem; String[] filteredAttributes = getFilteredAttributes(baseGenericIdEntity); if (value == null && filteredAttributes != null && ArrayUtils.contains(filteredAttributes, metaPropertyName)) { component.setRequired(false); } } } }
@Override public void setBeanLocator(BeanLocator beanLocator) { MetaClass metaClass = datasource.getMetaClass(); MetadataTools metadataTools = beanLocator.get(MetadataTools.NAME); MetaPropertyPath metaPropertyPath = metadataTools.resolveMetaPropertyPath(metaClass, property); checkNotNullArgument(metaPropertyPath, "Could not resolve property path '%s' in '%s'", property, metaClass); this.metaPropertyPath = metaPropertyPath; this.datasource.addStateChangeListener(this::datasourceStateChanged); this.datasource.addItemChangeListener(this::datasourceItemChanged); this.datasource.addItemPropertyChangeListener(this::datasourceItemPropertyChanged); if (datasource.getState() == Datasource.State.VALID) { setState(BindingState.ACTIVE); } }
if (datasource.getState() == State.VALID) { final Entity item = datasource.getItem(); if (elements.length > 1) {