@Override protected void loadDatasource(DatasourceComponent component, Element element) { String datasource = element.attributeValue("optionsDatasource"); if (!StringUtils.isEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); ((TwinColumn) component).setOptionsDatasource((CollectionDatasource) ds); } super.loadDatasource(component, element); }
private DataSupplier getDataService() { DsContext context = getDsContext(); if (context == null) { throw new UnsupportedOperationException(); } else { return context.getDataSupplier(); } }
protected void initParentDsContextCommitListener() { getDsContext().addBeforeCommitListener(context -> { List<FileDescriptor> fileDescriptorsToCommit = new ArrayList<>(); Collection<Entity> commitInstances = context.getCommitInstances(); for (Entity commitInstance : commitInstances) { if (commitInstance instanceof ProcAttachment && PersistenceHelper.isNew(commitInstance)) { ProcAttachment procAttachment = (ProcAttachment) commitInstance; fileDescriptorsToCommit.add(procAttachment.getFile()); } } if (!fileDescriptorsToCommit.isEmpty()) { commitInstances.addAll(fileDescriptorsToCommit); context.setCommitInstances(commitInstances); } }); }
protected CollectionDatasource findDatasourceRecursively(DsContext dsContext, String dsName) { if (dsContext == null) { return null; } Datasource datasource = dsContext.get(dsName); if (datasource != null && datasource instanceof CollectionDatasource) { return (CollectionDatasource) datasource; } else { if (dsContext.getParent() != null) { return findDatasourceRecursively(dsContext.getParent(), dsName); } else { return null; } } }
protected void addDsContextToResume(DsContext dsContext, List<CollectionDatasource.Suspendable> list) { for (Datasource datasource : dsContext.getAll()) { if (datasource instanceof CollectionDatasource.Suspendable) { addDatasourceToResume(list, datasource); } } for (DsContext childContext : dsContext.getChildren()) { addDsContextToResume(childContext, list); } }
final Datasource ds = dsContext.get(source); if (ds != null) { dsContext.registerDependency(this, ds, property); } else { ((DsContextImplementation) dsContext).addLazyTask(context -> { String source1 = strings1[0]; final Datasource ds1 = dsContext.get(source1); if (ds1 != null) { dsContext.registerDependency(AbstractCollectionDatasource.this, ds1, property);
return frameOwner.getDsContext().get(name); return frameOwner.getDsContext().getDataSupplier();
protected void loadDsContext(@Nullable Element dsContextElement) { DsContext dsContext = null; if (resultComponent.getFrameOwner() instanceof LegacyFrame) { DsContextLoader dsContextLoader; DsContext parentDsContext = context.getParent().getDsContext(); if (parentDsContext != null){ dsContextLoader = new DsContextLoader(parentDsContext.getDataSupplier()); } else { dsContextLoader = new DsContextLoader(new GenericDataSupplier()); } dsContext = dsContextLoader.loadDatasources(dsContextElement, parentDsContext, getContext().getAliasesMap()); ((ComponentLoaderContext) context).setDsContext(dsContext); } if (dsContext != null) { FrameOwner frameOwner = getContext().getFrame().getFrameOwner(); if (frameOwner instanceof LegacyFrame) { LegacyFrame frame = (LegacyFrame) frameOwner; frame.setDsContext(dsContext); for (Datasource ds : dsContext.getAll()) { if (ds instanceof DatasourceImplementation) { ((DatasourceImplementation) ds).initialized(); } } dsContext.setFrameContext(resultComponent.getContext()); } } }
@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; }
@Override public boolean isModified() { for (Datasource datasource : datasourceMap.values()) { if (datasource.isModified()) { return true; } } for (DsContext childDsContext : children) { for (Datasource datasource : childDsContext.getAll()) { if (datasource.isModified()) { return true; } } } return false; }
case DATASOURCE: { String dsName = elements[0]; final Datasource datasource = dsContext.get(dsName); if (datasource == null) { throw new DevelopmentException("Datasource '" + dsName + "' not found in dsContext", if (dsContext.getFrameContext() == null) { value = null; } else { Map<String, Object> windowParams = dsContext.getFrameContext().getParams(); value = windowParams.get(path); if (value == null && elements.length > 1) { if (dsContext.getFrameContext() != null) { value = dsContext.getFrameContext().getValue(path); if (value instanceof String && info.isCaseInsensitive()) { value = makeCaseInsensitive((String) value); componentValueListener = new ComponentValueListener(); try { dsContext.getFrameContext().addValueChangeListener(path, componentValueListener); } catch (Exception e) { Logger log = LoggerFactory.getLogger(AbstractCollectionDatasource.class);
public void commitAndClose() { if (getDsContext().commit()) { saveFiles(); close(COMMIT_ACTION_ID); } }
@Override public void setParent(DsContext parent) { this.parent = parent; if (!parent.getChildren().contains(this)) { parent.getChildren().add(this); } }
protected <T extends Screen> void loadWindowFromXml(Element element, WindowInfo windowInfo, Window window, T controller, ComponentLoaderContext componentLoaderContext) { LayoutLoader layoutLoader = beanLocator.getPrototype(LayoutLoader.NAME, componentLoaderContext); layoutLoader.setLocale(getLocale()); layoutLoader.setMessagesPack(getMessagePack(windowInfo.getTemplate())); ComponentLoader<Window> windowLoader = layoutLoader.createWindowContent(window, element, windowInfo.getId()); if (controller instanceof LegacyFrame) { screenViewsLoader.deployViews(element); initDsContext(window, element, componentLoaderContext); DsContext dsContext = ((LegacyFrame) controller).getDsContext(); if (dsContext != null) { dsContext.setFrameContext(window.getContext()); } } windowLoader.loadComponent(); }
return ((LegacyFrame) frame.getFrameOwner()).getDsContext().get(name); if (frame.getFrameOwner() instanceof LegacyFrame) { return ((LegacyFrame) frame.getFrameOwner()).getDsContext().getDataSupplier(); } else { throw new DevelopmentException("DataSupplier can be injected only into LegacyFrame inheritors");
protected Map<DataSupplier, Collection<Datasource<Entity>>> collectCommitData() { Collection<Datasource> datasources = new ArrayList<>(); for (DsContext childDsContext : children) { datasources.addAll(childDsContext.getAll()); } datasources.addAll(datasourceMap.values()); Map<DataSupplier, Collection<Datasource<Entity>>> commitDatasources = new HashMap<>(); for (Datasource datasource : datasources) { if (Datasource.CommitMode.DATASTORE == datasource.getCommitMode() && datasource.isAllowCommit() && (datasource.isModified() || !((DatasourceImplementation) datasource).getItemsToCreate().isEmpty())) { DataSupplier dataservice = datasource.getDataSupplier(); Collection<Datasource<Entity>> collection = commitDatasources.get(dataservice); if (collection == null) { collection = new ArrayList<>(); commitDatasources.put(dataservice, collection); } collection.add(datasource); } } return commitDatasources; }
public void onWindowCommit() { if (!validateAll()) { return; } getDsContext().commit(); procAttachmentsFrame.putFilesIntoStorage(); close(COMMIT_ACTION_ID); }
@SuppressWarnings("unchecked") @Override protected void loadDatasource(DatasourceComponent component, Element element) { String datasource = element.attributeValue("optionsDatasource"); if (!StringUtils.isEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); ((T) component).setOptionsDatasource((CollectionDatasource) ds); } super.loadDatasource(component, element); }
/** * INTERNAL */ public DsBuilder(DsContext dsContext) { this.dsContext = dsContext; this.id = "ds"; if (dsContext != null) this.dataSupplier = dsContext.getDataSupplier(); else this.dataSupplier = new GenericDataSupplier(); }
protected void notifyAllDsCommited(DataSupplier dataservice, Set<Entity> committedEntities) { // Notify all datasources in context List<Datasource> datasources = new ArrayList<>(); for (DsContext childDsContext : children) { for (Datasource ds : childDsContext.getAll()) { if (Objects.equals(ds.getDataSupplier(), dataservice) && ds.getCommitMode() == Datasource.CommitMode.DATASTORE) { datasources.add(ds); } } } for (Datasource ds : datasourceMap.values()) { if (Objects.equals(ds.getDataSupplier(), dataservice) && ds.getCommitMode() == Datasource.CommitMode.DATASTORE) { datasources.add(ds); } } List<Datasource> sortedList = new DsTree(datasources).toDsList(); for (Datasource datasource : sortedList) { ((DatasourceImplementation) datasource).committed(committedEntities); } }