protected void handleEditorCommit(Entity editorItem, Entity rowItem, String columnId) { MetaPropertyPath mpp = rowItem.getMetaClass().getPropertyPath(columnId); if (mpp == null) { throw new IllegalStateException(String.format("Unable to find metaproperty %s for class %s", columnId, rowItem.getMetaClass())); } if (mpp.getRange().isClass()) { DatasourceImplementation ds = ((DatasourceImplementation) table.getDatasource()); boolean modifiedInTable = ds.getItemsToUpdate().contains(rowItem); boolean ownerDsModified = ds.isModified(); rowItem.setValueEx(columnId, null); rowItem.setValueEx(columnId, editorItem); // restore modified for owner datasource // remove from items to update if it was not modified before setValue if (!modifiedInTable) { ds.getItemsToUpdate().remove(rowItem); } ds.setModified(ownerDsModified); } else { //noinspection unchecked table.getDatasource().updateItem(editorItem); } }
modifiedRoles.addAll(rolesDsImpl.getItemsToUpdate()); rolesDsImpl.committed(Collections.emptySet()); for (UserRole userRole : modifiedRoles) {
protected CommitContext createCommitContext(DataSupplier dataservice, Map<DataSupplier, Collection<Datasource<Entity>>> commitData) { CommitContext context = new CommitContext(); context.setDiscardCommitted(discardCommitted); for (Datasource<Entity> datasource : commitData.get(dataservice)) { if (datasource instanceof DatasourceImplementation) { DatasourceImplementation<Entity> implementation = (DatasourceImplementation) datasource; boolean listenersEnabled = implementation.enableListeners(false); try { for (Entity entity : implementation.getItemsToCreate()) { addToContext(entity, datasource, context.getCommitInstances(), context.getViews()); } for (Entity entity : implementation.getItemsToUpdate()) { addToContext(entity, datasource, context.getCommitInstances(), context.getViews()); } for (Entity entity : implementation.getItemsToDelete()) { addToContext(entity, datasource, context.getRemoveInstances(), context.getViews()); } } finally { implementation.enableListeners(listenersEnabled); } } } repairReferences(context); return context; }
nonModifiedInTable = !ownerDs.getItemsToUpdate().contains( ((EntityValueSource) getValueSource()).getItem()); ownerDsModified = ownerDs.isModified(); ownerDs.getItemsToUpdate().remove(getDatasource().getItem());
&& !parentDs.getItemsToCreate().contains(item) && !parentDs.getItemsToUpdate().contains(item) && parentDs instanceof CollectionDatasource && ((CollectionDatasource) parentDs).containsItem(item.getId())