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; } } }
@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); }
@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; }
@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); }
protected Datasource loadDatasource(Element element) { String datasource = element.attributeValue("datasource"); if (!StringUtils.isBlank(datasource)) { Datasource ds = context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getFullFrameId()); } return ds; } return null; }
@Override protected void loadDatasource(DatasourceComponent component, Element element) { super.loadDatasource(component, element); String datasource = element.attributeValue("optionsDatasource"); if (!StringUtils.isEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); ((LookupField) component).setOptionsDatasource((CollectionDatasource) ds); } }
@Override public Datasource get(String id) { checkNotNullArgument(id, "Null datasource ID"); id = aliasesMap.getOrDefault(id, id); Datasource ds = null; if (!id.contains(".")) { ds = datasourceMap.get(id); if (ds == null && parent != null) { ds = parent.get(id); } } else { if (windowContext != null) { String nestedFramePath = id.substring(0, id.indexOf(".")); Component nestedFrame = getFrameContext().getFrame().getComponent(nestedFramePath); if (nestedFrame instanceof Frame) { String nestedDsId = id.substring(id.indexOf(".") + 1); FrameOwner frameOwner = ((Frame) nestedFrame).getFrameOwner(); if (frameOwner instanceof LegacyFrame) { ds = ((LegacyFrame) frameOwner).getDsContext().get(nestedDsId); } } } } return ds; }
@Nullable protected CollectionDatasource findOptionsDatasource(Table.Column columnConf, String propertyId) { String optDsName = columnConf.getXmlDescriptor() != null ? columnConf.getXmlDescriptor().attributeValue("optionsDatasource") : ""; if (Strings.isNullOrEmpty(optDsName)) { return null; } else { if (webTable.getDatasource() == null) { throw new IllegalStateException("Table datasource is null"); } DsContext dsContext = webTable.getDatasource().getDsContext(); CollectionDatasource ds = (CollectionDatasource) dsContext.get(optDsName); if (ds == null) { throw new IllegalStateException( String.format("Options datasource for table column '%s' not found: %s", propertyId, optDsName)); } return ds; } } }
protected void initDatasources(Map<String, Object> params) { String dsId = (String) params.get("runtimeDs"); if (dsId == null) { throw new DevelopmentException("runtimeProperties initialization error: runtimeDs is not provided"); } rds = (RuntimePropsDatasource) getDsContext().get(dsId); if (rds == null) { throw new DevelopmentException( String.format("runtimeProperties initialization error: runtimeDs '%s' does not exist", dsId)); } String categoriesDsId = (String) params.get("categoriesDs"); if (categoriesDsId == null) { throw new DevelopmentException("runtimeProperties initialization error: categoriesDs is not provided"); } categoriesDs = (CollectionDatasource) getDsContext().get(categoriesDsId); if (categoriesDs == null) { throw new DevelopmentException( String.format("runtimeProperties initialization error: categoriesDs '%s' does not exist", categoriesDsId) ); } }
protected void loadDatasource(Calendar component, Element element) { final String datasource = element.attributeValue("datasource"); CollectionDatasource ds = (CollectionDatasource) context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), getContext().getFullFrameId(), "Component ID", component.getId()); } component.setDatasource(ds); }
protected void loadDatasource(Image component, Element element) { final String datasource = element.attributeValue("datasource"); if (!StringUtils.isEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), getContext().getFullFrameId(), "Component ID", component.getId()); } String property = element.attributeValue("property"); if (StringUtils.isEmpty(property)) { throw new GuiDevelopmentException( String.format("Can't set datasource '%s' for component '%s' because 'property' " + "attribute is not defined", datasource, component.getId()), context.getFullFrameId()); } component.setDatasource(ds, property); } } }
protected void loadDatasource(Chart chart, Element element) { String datasource = element.attributeValue("datasource"); if (StringUtils.isNotEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getCurrentFrameId()); } if (!(ds instanceof CollectionDatasource)) { throw new GuiDevelopmentException("Not a CollectionDatasource: " + datasource, context.getCurrentFrameId()); } chart.setDatasource((CollectionDatasource) ds); } }
@SuppressWarnings("unchecked") protected void loadDatasource(TokenList tokenList, Element element) { final String datasourceId = element.attributeValue("datasource"); if (StringUtils.isNotEmpty(datasourceId)) { Datasource datasource = context.getDsContext().get(datasourceId); if (datasource == null) { throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasourceId), context.getFullFrameId()); } if (!(datasource instanceof CollectionDatasource)) { throw new GuiDevelopmentException( String.format("Can't set datasource '%s' for TokenList because it supports only CollectionDatasources", datasourceId), context.getFullFrameId()); } tokenList.setValueSource(new LegacyCollectionDsValueSource((CollectionDatasource) datasource)); } }
protected void loadDatasource(DatasourceComponent component, Element element) { final String datasource = element.attributeValue("datasource"); if (!StringUtils.isEmpty(datasource)) { if (context.getDsContext() == null) { throw new IllegalStateException("'datasource' attribute can be used only in screens with 'dsContext' element. " + "In a screen with 'data' element use 'dataContainer' attribute."); } Datasource ds = context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException(String.format("Datasource '%s' is not defined", datasource), getContext().getFullFrameId(), "Component ID", component.getId()); } String property = element.attributeValue("property"); if (StringUtils.isEmpty(property)) { throw new GuiDevelopmentException( String.format("Can't set datasource '%s' for component '%s' because 'property' " + "attribute is not defined", datasource, component.getId()), context.getFullFrameId()); } component.setDatasource(ds, property); } } }
protected void loadDatasource(PivotTable pivotTable, Element element) { String datasource = element.attributeValue("datasource"); if (StringUtils.isNotEmpty(datasource)) { Datasource ds = context.getDsContext().get(datasource); if (ds == null) { throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context.getCurrentFrameId()); } if (!(ds instanceof CollectionDatasource)) { throw new GuiDevelopmentException("Not a CollectionDatasource: " + datasource, context.getCurrentFrameId()); } pivotTable.setDatasource((CollectionDatasource) ds); } }
protected Datasource getDatasourceInternal() { Datasource ds = null; Element element = ((Component.HasXmlDescriptor) getFrame()).getXmlDescriptor(); String datasourceName = element.attributeValue("datasource"); if (!StringUtils.isEmpty(datasourceName)) { DsContext context = getDsContext(); if (context != null) { ds = context.get(datasourceName); } } if (ds == null) { throw new GuiDevelopmentException("Can't find main datasource", getFrame().getId()); } return ds; }
String datasource = itemsElem.attributeValue("datasource"); if (!StringUtils.isBlank(datasource)) { HierarchicalDatasource ds = (HierarchicalDatasource) context.getDsContext().get(datasource); resultComponent.setDatasource(ds);
@Override public void init(Map<String, Object> params) { datasource = getDsContext().get("attribute"); FieldGroup fields = (FieldGroup) getComponent("fields"); FieldGroup.FieldConfig field = fields.getField("datatype"); fields.addCustomField(field, new FieldGroup.CustomFieldGenerator() { @Override public Component generateField(Datasource datasource, String propertyId) { LookupField lookup = AppConfig.getFactory().createComponent(LookupField.class); lookup.setDatasource(datasource, propertyId); lookup.setRequiredMessage(getMessage("datatypeMsg")); lookup.setRequired(true); lookup.setPageLength(15); Map<String, Object> options = new TreeMap<>(); String mainMessagePack = AppConfig.getMessagesPack(); for (String datatypeId : Datatypes.getIds()) { options.put(messages.getMessage(mainMessagePack, "Datatype." + datatypeId), datatypeId); } lookup.setOptionsMap(options); return lookup; } } ); }
@Override protected void loadData(Map<String, Object> params) { data.clear(); Datasource mbeanDs = getDsContext().get("mbeanDs"); ManagedBeanInfo mbean = (ManagedBeanInfo) mbeanDs.getItem(); if (mbean != null) { try { jmxControlAPI.loadAttributes(mbean); } catch (JmxControlException e) { log.error("Error loading attributes", e); } if (mbean.getAttributes() != null) { for (ManagedBeanAttribute attr : mbean.getAttributes()) { data.put(attr.getId(), attr); } } } } }
@SuppressWarnings("unchecked") protected void setMainDs(String name) { mainDs = dsContext.get(name); if (mainDs == null) { throw new DevelopmentException(