if ( setDesign == null || setHandle == null ) return;  DesignUtil.validateObject( setDesign );  CommandStack stack = setHandle.getModuleHandle( ).getCommandStack( );  stack.startTrans( null ); try {   setHandle.getElement( ).setProperty( OdaDataSourceHandle.EXTENSION_ID_PROP, setDesign.getOdaExtensionDataSetId( ) );  setHandle.setName( setDesign.getName( ) ); setHandle.setDisplayName( setDesign.getDisplayName( ) );    Properties props = setDesign.getPublicProperties( ); if ( props != null ) { EList propList = props.getProperties( ); for ( int i = 0; i < propList.size( ); i++ ) { Property prop = (Property) propList.get( i ); setHandle.setProperty( prop.getName( ), prop.getValue( ) ); } }    props = setDesign.getPrivateProperties( ); if ( props != null ) { EList propList = props.getProperties( ); for ( int i = 0; i < propList.size( ); i++ ) { Property prop = (Property) propList.get( i ); setHandle.setPrivateDriverProperty( prop.getName( ), prop .getValue( ) ); } }  DesignValues designerValues = null;  try { designerValues = SerializerImpl.instance( ).read( setHandle.getDesignerValues( ) ); } catch ( IOException e ) { }  updateROMDataSetParamList( setHandle, new DataSetParameterAdapter( ) .newROMSetParams( setDesign, setHandle, designerValues == null ? null : designerValues .getDataSetParameters( ) ) );  ResultSets cachedResultSets = designerValues == null ? null : designerValues.getResultSets( );  ResultSetDefinition cachedResultDefn = null;  if ( cachedResultSets != null && !cachedResultSets.getResultSetDefinitions( ).isEmpty( ) ) cachedResultDefn = (ResultSetDefinition) cachedResultSets .getResultSetDefinitions( ).get( 0 );  updateROMResultSets( setHandle, new ResultSetsAdapter( ) .newROMResultSets( setDesign, setHandle, cachedResultDefn ) );  setHandle.setResultSetName( setDesign.getPrimaryResultSetName( ) );  setHandle.setQueryText( setDesign.getQueryText( ) );     String odaValues = serializeOdaValues( setDesign ); setHandle.setDesignerValues( odaValues );  DataSourceDesign sourceDesign = setDesign.getDataSourceDesign( ); if ( sourceDesign != null ) { OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle .getDataSource( );    if ( isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle( ).isReadOnly( ) ) { setHandle.setDataSource( sourceDesign.getName( ) ); updateDataSourceHandle( sourceDesign, sourceHandle ); }     if ( !isSourceChanged && sourceHandle != null && !sourceHandle.getModuleHandle( ).isReadOnly( ) && !( new EcoreUtil.EqualityHelper( ).equals( createDataSourceDesign( sourceHandle ), sourceDesign ) ) ) { updateDataSourceHandle( sourceDesign, sourceHandle ); } } else setHandle.setDataSource( null ); } catch ( SemanticException e ) { stack.rollback( ); throw e; }  stack.commit( );
updateDataSetHandle( setDesign, setHandle, isSourceChanged, false );
	public void updateDataSetHandle( DataSetDesign setDesign,			OdaDataSetHandle setHandle, boolean isSourceChanged )			throws SemanticException	{		if ( setDesign == null || setHandle == null )			return;		DesignUtil.validateObject( setDesign );		CommandStack stack = setHandle.getModuleHandle( ).getCommandStack( );		stack.startTrans( null );		try		{			// extension id is set without undo/redo support.			setHandle.getElement( ).setProperty(					OdaDataSourceHandle.EXTENSION_ID_PROP,					setDesign.getOdaExtensionDataSetId( ) );			setHandle.setName( setDesign.getName( ) );			setHandle.setDisplayName( setDesign.getDisplayName( ) );			// set public properties.			Properties props = setDesign.getPublicProperties( );			if ( props != null )			{				EList propList = props.getProperties( );				for ( int i = 0; i < propList.size( ); i++ )				{					Property prop = (Property) propList.get( i );					setHandle.setProperty( prop.getName( ), prop.getValue( ) );				}			}			// set private properties.			props = setDesign.getPrivateProperties( );			if ( props != null )			{				EList propList = props.getProperties( );				for ( int i = 0; i < propList.size( ); i++ )				{					Property prop = (Property) propList.get( i );					setHandle.setPrivateDriverProperty( prop.getName( ), prop							.getValue( ) );				}			}			DesignValues designerValues = null;			try			{				designerValues = SerializerImpl.instance( ).read(						setHandle.getDesignerValues( ) );			}			catch ( IOException e )			{			}			updateROMDataSetParamList( setHandle, new DataSetParameterAdapter( )					.newROMSetParams( setDesign, setHandle,							designerValues == null ? null : designerValues									.getDataSetParameters( ) ) );			ResultSets cachedResultSets = designerValues == null					? null					: designerValues.getResultSets( );			ResultSetDefinition cachedResultDefn = null;			if ( cachedResultSets != null					&& !cachedResultSets.getResultSetDefinitions( ).isEmpty( ) )				cachedResultDefn = (ResultSetDefinition) cachedResultSets						.getResultSetDefinitions( ).get( 0 );			updateROMResultSets( setHandle, new ResultSetsAdapter( )					.newROMResultSets( setDesign, setHandle, cachedResultDefn ) );			setHandle.setResultSetName( setDesign.getPrimaryResultSetName( ) );			setHandle.setQueryText( setDesign.getQueryText( ) );			// designer values must be saved after convert data set parameters			// and result set columns.			String odaValues = serializeOdaValues( setDesign );			setHandle.setDesignerValues( odaValues );			DataSourceDesign sourceDesign = setDesign.getDataSourceDesign( );			if ( sourceDesign != null )			{				OdaDataSourceHandle sourceHandle = (OdaDataSourceHandle) setHandle						.getDataSource( );				// only the local data source can be used.				if ( isSourceChanged && sourceHandle != null						&& !sourceHandle.getModuleHandle( ).isReadOnly( ) )				{					setHandle.setDataSource( sourceDesign.getName( ) );					updateDataSourceHandle( sourceDesign, sourceHandle );				}				// if the source is not changed, and it is not in the included				// library, then we can update it.				if ( !isSourceChanged						&& sourceHandle != null						&& !sourceHandle.getModuleHandle( ).isReadOnly( )						&& !( new EcoreUtil.EqualityHelper( ).equals(								createDataSourceDesign( sourceHandle ),								sourceDesign ) ) )				{					updateDataSourceHandle( sourceDesign, sourceHandle );				}			}			else				setHandle.setDataSource( null );		}		catch ( SemanticException e )		{			stack.rollback( );			throw e;		}		stack.commit( );	}