/** * @param setHandle * @param setDesign * @param propertyName */ void updateDataSetDesign( OdaDataSetHandle setHandle, DataSetDesign setDesign, String propertyName) { if (setHandle == null || setDesign == null || propertyName == null) return; // properties on ReportElement, like name, displayNames, etc. if (OdaDataSetHandle.NAME_PROP.equalsIgnoreCase(propertyName)) setDesign.setName(setHandle.getName()); else if (OdaDataSetHandle.DISPLAY_NAME_PROP.equalsIgnoreCase(propertyName)) setDesign.setDisplayName(setHandle.getDisplayName()); else if (OdaDataSetHandle.DISPLAY_NAME_ID_PROP.equalsIgnoreCase(propertyName)) setDesign.setDisplayNameKey(setHandle.getDisplayNameKey()); // properties such as comments, extends, etc are kept in // DataSourceHandle, not DataSourceDesign. // scripts of DataSource are kept in // DataSourceHandle, not DataSourceDesign. else if (OdaDataSourceHandle.EXTENSION_ID_PROP.equalsIgnoreCase(propertyName)) setDesign.setOdaExtensionDataSetId(setHandle.getExtensionID()); else if (OdaDataSetHandle.PRIVATE_DRIVER_PROPERTIES_PROP.equalsIgnoreCase(propertyName)) setDesign.setPrivateProperties( newOdaPrivateProperties(setHandle.privateDriverPropertiesIterator())); else if (OdaDataSetHandle.RESULT_SET_NAME_PROP.equalsIgnoreCase(propertyName)) setDesign.setPrimaryResultSetName(setHandle.getResultSetName()); else if (OdaDataSetHandle.QUERY_TEXT_PROP.equalsIgnoreCase(propertyName)) setDesign.setQueryText(setHandle.getQueryText()); // create a new data source design for this set design. else if (OdaDataSetHandle.DATA_SOURCE_PROP.equalsIgnoreCase(propertyName)) { OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle.getDataSource(); if (sourceHandle != null) setDesign.setDataSourceDesign(new DataSourceAdapter().createDataSourceDesign(sourceHandle)); } else if (OdaDataSetHandle.PARAMETERS_PROP.equalsIgnoreCase(propertyName)) { org.eclipse.datatools.connectivity.oda.design.DataSetParameters dsParams = new DataSetParameterAdapter(setHandle, setDesign) .newOdaDataSetParams( SchemaConversionUtil.convertToDesignParameters(getCachedParameters(setHandle))); if (dsParams != null) setDesign.setParameters(dsParams); else setDesign.setParameters(null); } else if (OdaDataSetHandle.RESULT_SET_PROP.equalsIgnoreCase(propertyName)) new ResultSetsAdapter(setHandle, setDesign).updateOdaResultSetDefinition(); else if (OdaDataSetHandle.COLUMN_HINTS_PROP.equalsIgnoreCase(propertyName)) new ResultSetsAdapter(setHandle, setDesign).updateOdaColumnHints(); else if (OdaDataSetHandle.FILTER_PROP.equalsIgnoreCase(propertyName)) new ResultSetCriteriaAdapter(setHandle, setDesign).updateODAResultSetCriteria(); updateODAMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle()); }
/** * @param setHandle * @param setDesign */ void updateDataSetDesign(OdaDataSetHandle setHandle, DataSetDesign setDesign) { // properties on ReportElement, like name, displayNames, etc. setDesign.setName(setHandle.getName()); String displayName = setHandle.getDisplayName(); String displayNameKey = setHandle.getDisplayNameKey(); if (displayName != null || displayNameKey != null) { setDesign.setDisplayName(displayName); setDesign.setDisplayNameKey(displayNameKey); } // properties such as comments, extends, etc are kept in // DataSourceHandle, not DataSourceDesign. // scripts of DataSource are kept in // DataSourceHandle, not DataSourceDesign. setDesign.setOdaExtensionDataSetId(setHandle.getExtensionID()); setDesign.setPublicProperties( newOdaPublicProperties(setHandle.getExtensionPropertyDefinitionList(), setHandle)); setDesign.setPrivateProperties( newOdaPrivateProperties(setHandle.privateDriverPropertiesIterator())); setDesign.setPrimaryResultSetName(setHandle.getResultSetName()); setDesign.setQueryText(setHandle.getQueryText()); // create a new data source design for this set design. OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle.getDataSource(); if (sourceHandle != null) setDesign.setDataSourceDesign(new DataSourceAdapter().createDataSourceDesign(sourceHandle)); // when converts the ODA to BIRT, some information for parameter // definitions may be lost. So, must get the cached values first. Then // try to restore to latest value. String strDesignValues = setHandle.getDesignerValues(); DesignValues designerValues = null; try { if (strDesignValues != null) designerValues = SerializerImpl.instance().read(strDesignValues); } catch (IOException e) { } // the driver defined parameters are in the designer values DataSetParameters cachedParams = null; if (designerValues != null) { cachedParams = designerValues.getDataSetParameters(); } DataSetParameterAdapter dataParamAdapter = new DataSetParameterAdapter(setHandle, setDesign); org.eclipse.datatools.connectivity.oda.design.DataSetParameters designDefinedParams = null; if (cachedParams != null) { // cached are driver-defined parameters designDefinedParams = SchemaConversionUtil.convertToDesignParameters(EcoreUtil.copy(cachedParams)); setDesign.setParameters(designDefinedParams); dataParamAdapter.updateDriverDefinedParameter( designDefinedParams, SchemaConversionUtil.getCachedDynamicList(cachedParams)); } // if there is no driver defined parameters, update parameters with set // handle defined with cached in the last request if (designDefinedParams == null) { designDefinedParams = dataParamAdapter.newOdaDataSetParams(designDefinedParams); setDesign.setParameters(designDefinedParams); } // handle those parameters defined by user dataParamAdapter.updateUserDefinedParameter(designDefinedParams); org.eclipse.datatools.connectivity.oda.design.DataSetParameters userDefinedParams = dataParamAdapter.newOdaDataSetParams(dataParamAdapter.getUserDefinedParams()); if (designDefinedParams == null) { designDefinedParams = userDefinedParams; setDesign.setParameters(designDefinedParams); } else if (userDefinedParams != null) designDefinedParams .getParameterDefinitions() .addAll(userDefinedParams.getParameterDefinitions()); new ResultSetsAdapter(setHandle, setDesign).updateOdaResultSetDefinition(); updateODAMessageFile(setDesign.getDataSourceDesign(), setHandle.getModuleHandle()); }
/** * Adapts a model oda data set handle * * @param modelDataSet model handle * @param propBindingScope Javascript scope in which to evaluate property binding expressions. If * null, property binding is not resolved * @throws BirtException */ public OdaDataSetAdapter( OdaDataSetHandle modelDataSet, Scriptable propBindingScope, ModelAdapter adapter, DataEngineContext dtContext) throws BirtException { super(modelDataSet.getQualifiedName()); // TODO: event handler // Adapt base class properties DataAdapterUtil.adaptBaseDataSet(modelDataSet, this, adapter); // Adapt extended data set elements // Set query text; if binding exists, use its result; otherwise // use static design Expression expression = modelDataSet.getPropertyBindingExpression(OdaDataSet.QUERY_TEXT_PROP); org.eclipse.birt.data.engine.api.querydefn.ScriptExpression script = adapter.adaptExpression(expression); if (propBindingScope != null && script != null && DataSessionContext.MODE_UPDATE != dtContext.getMode()) { String queryText = JavascriptEvalUtil.evaluateScript( null, propBindingScope, script.getText(), ScriptExpression.defaultID, 0) .toString(); setQueryText(queryText); } else { setQueryText(modelDataSet.getQueryText()); } // type of extended data set setExtensionID(modelDataSet.getExtensionID()); // result set name setPrimaryResultSetName(modelDataSet.getResultSetName()); if (modelDataSet.getPropertyHandle(IOdaDataSetModel.RESULT_SET_NUMBER_PROP).isSet()) setPrimaryResultSetNumber(modelDataSet.getResultSetNumber()); // static ROM properties defined by the ODA driver extension Map staticProps = DataAdapterUtil.getExtensionProperties( modelDataSet, modelDataSet.getExtensionPropertyDefinitionList()); if (staticProps != null && !staticProps.isEmpty()) { Iterator propNamesItr = staticProps.keySet().iterator(); while (propNamesItr.hasNext()) { String propName = (String) propNamesItr.next(); assert (propName != null); String propValue; String bindingExpr = modelDataSet.getPropertyBinding(propName); if (propBindingScope != null && bindingExpr != null && bindingExpr.length() > 0) { propValue = JavascriptEvalUtil.evaluateScript( null, propBindingScope, bindingExpr, ScriptExpression.defaultID, 0) .toString(); } else { propValue = (String) staticProps.get(propName); } addPublicProperty((String) propName, propValue); } } // private driver properties / private runtime data Iterator elmtIter = modelDataSet.privateDriverPropertiesIterator(); if (elmtIter != null) { while (elmtIter.hasNext()) { ExtendedPropertyHandle modelProp = (ExtendedPropertyHandle) elmtIter.next(); addPrivateProperty(modelProp.getName(), modelProp.getValue()); } } }