protected void addToContext(Entity entity, Datasource<Entity> datasource, Collection<Entity> entities, Map<Object, View> views) { if (datasource instanceof NestedDatasource) { replaceMasterCopies(entity, ((NestedDatasource) datasource)); } entities.add(entity); views.put(entity, datasource.getView()); }
@Override public View getView() { final ViewProperty property = masterDs.getView().getProperty(metaProperty.getName()); return property == null ? null : metadata.getViewRepository().getView(getMetaClass(), property.getView().getName()); }
/** * Returns an entity reloaded with the view of the target datasource if it is wider than the set of attributes * that is loaded in the given entity instance. The entity is also reloaded if the target datasource requires * dynamic attributes and the entity instance does not contain them. */ public Entity reloadEntityIfNeeded(Entity entity, Datasource targetDatasource) { boolean needDynamicAttributes = false; boolean dynamicAttributesAreLoaded = true; if (entity instanceof BaseGenericIdEntity) { BaseGenericIdEntity e = (BaseGenericIdEntity) entity; dynamicAttributesAreLoaded = e.getDynamicAttributes() != null; needDynamicAttributes = targetDatasource.getLoadDynamicAttributes(); } View view = targetDatasource.getView(); if (view == null) { view = viewRepository.getView(entity.getClass(), View.LOCAL); } if (!entityStates.isLoadedWithView(entity, view)) { entity = targetDatasource.getDsContext().getDataSupplier().reload(entity, view, null, needDynamicAttributes); } else if (needDynamicAttributes && !dynamicAttributesAreLoaded) { dynamicAttributesGuiTools.reloadDynamicAttributes((BaseGenericIdEntity) entity); } return entity; }
/** * Adds a listener that reloads the selected record with the specified view and sets it to editDs. */ @SuppressWarnings("unchecked") protected void initBrowseItemChangeListener() { CollectionDatasource browseDs = getTable().getDatasource(); Datasource editDs = getFieldGroup().getDatasource(); browseDs.addItemChangeListener(e -> { if (e.getItem() != null) { Entity reloadedItem = getDsContext().getDataSupplier().reload( e.getDs().getItem(), editDs.getView(), null, e.getDs().getLoadDynamicAttributes()); editDs.setItem(reloadedItem); } }); }
/** * Method that is invoked by clicking Cancel button, discards changes and disables controls for editing. */ @SuppressWarnings("unchecked") public void cancel() { CollectionDatasource browseDs = getTable().getDatasource(); Datasource editDs = getFieldGroup().getDatasource(); Entity selectedItem = browseDs.getItem(); if (selectedItem != null) { Entity reloadedItem = getDsContext().getDataSupplier().reload( selectedItem, editDs.getView(), null, editDs.getLoadDynamicAttributes()); browseDs.setItem(reloadedItem); } else { editDs.setItem(null); } releaseLock(); disableEditControls(); } }
if (metadata.getTools().isPersistent(metaMetaClass) || metadata.getTools().isEmbeddable(metaMetaClass)) { View masterView = masterDs.getView(); if (masterView == null) { throw new DevelopmentException("No view for datasource " + masterDs.getId(),
if (dynamicAttributesGuiTools.screenContainsDynamicAttributes(ds.getView(), getFrame().getId())) { ds.setLoadDynamicAttributes(true); && parentDs instanceof CollectionDatasource && ((CollectionDatasource) parentDs).containsItem(item.getId()) && !entityStates.isLoadedWithView(item, ds.getView())) { item = dataservice.reload(item, ds.getView(), ds.getMetaClass(), ds.getLoadDynamicAttributes()); if (parentDs instanceof CollectionPropertyDatasourceImpl) { ((CollectionPropertyDatasourceImpl) parentDs).replaceItem(item); handlePreviouslyDeletedCompositionItems(item, parentDs); } else if (!PersistenceHelper.isNew(item)) { item = dataservice.reload(item, ds.getView(), ds.getMetaClass(), ds.getLoadDynamicAttributes());