@Override public DsContext getDsContext() { return masterDs.getDsContext(); }
@Override public DsContext getDsContext() { return masterDs.getDsContext(); }
protected void addCommitListeners() { String xml = reportService.convertToString(getItem()); getItem().setXml(xml); reportDs.getDsContext().addBeforeCommitListener(context -> { context.getCommitInstances() .removeIf(entity -> !(entity instanceof Report || entity instanceof ReportTemplate) ); }); }
protected void addParentsToNested() { if (parentDs == null || getDsContext() == parentDs.getDsContext()) { return; } // Iterate through all datasources in the same DsContext for (Datasource sibling : getDsContext().getAll()) { // If the datasource is a property datasource of the Child if (sibling instanceof NestedDatasource && ((NestedDatasource) sibling).getMaster().equals(this) && !metadata.getTools().isEmbeddable(sibling.getMetaClass())) { // Look for corresponding property datasource in the Parent's DsContext for (Datasource siblingOfParent : parentDs.getDsContext().getAll()) { if (siblingOfParent instanceof NestedDatasource && ((NestedDatasource) siblingOfParent).getProperty().equals(((NestedDatasource) sibling).getProperty()) && ((NestedDatasource) siblingOfParent).getMaster() == parentDs) { // If such corresponding datasource found, set it as a parent for our property datasource ((DatasourceImplementation) sibling).setParent(siblingOfParent); } } } } }
protected Datasource getPropertyDatasource() { if (pickerField.getDatasource() == null || pickerField.getMetaPropertyPath() == null || pickerField.getMetaPropertyPath().getMetaProperty().getType() != MetaProperty.Type.COMPOSITION || pickerField.getDatasource().getDsContext() == null) return null; for (Datasource datasource : pickerField.getDatasource().getDsContext().getAll()) { if (datasource instanceof NestedDatasource && ((NestedDatasource) datasource).getMaster() == pickerField.getDatasource() && ((NestedDatasource) datasource).getProperty() == pickerField.getMetaPropertyPath().getMetaProperty()) return datasource; } return null; }
/** * 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; }
@Override protected boolean preCommit() { //remove ds contexts from widget frames dashboardDs.getDsContext().getChildren().removeIf(dsContext -> !((dsContext.get("parametersDs") != null && dsContext.get("parametersDs").getMetaClass() != null && "dashboard$Parameter".equals(dsContext.get("parametersDs").getMetaClass().getName())) || (dsContext.get("widgetTemplatesDs") != null && dsContext.get("widgetTemplatesDs").getMetaClass() != null) && "dashboard$WidgetTemplate".equals(dsContext.get("widgetTemplatesDs").getMetaClass().getName()))); FieldGroup.FieldConfig assistantBeanName = fieldGroup2.getField("assistantBeanName"); LookupField lookupField = (LookupField) assistantBeanName.getComponent(); String val = lookupField.getValue(); dashboardDs.getItem().setAssistantBeanName(val); PersistentDashboard persDash = getItem(); Dashboard dashboard = getDashboard(); String jsonModel = converter.dashboardToJson(dashboard); persDash.setDashboardModel(jsonModel); persDash.setName(dashboard.getTitle()); persDash.setCode(dashboard.getCode()); persDash.setIsAvailableForAllUsers(dashboard.getIsAvailableForAllUsers()); return true; }
Datasource propertyDatasource = getPropertyDatasource(); if (propertyDatasource != null) { for (Datasource datasource : propertyDatasource.getDsContext().getAll()) { if (datasource instanceof NestedDatasource && ((NestedDatasource) datasource).getMaster() == propertyDatasource
for (Datasource datasource : ds.getDsContext().getAll()) { if (datasource instanceof NestedDatasource && ((NestedDatasource) datasource).getMaster() == ds) { if (datasource.getItem() != null && PersistenceHelper.isNew(datasource.getItem()))