Skip to content

Commit

Permalink
Made code changes to comapre properties of data source handle and dat…
Browse files Browse the repository at this point in the history
…a source design before updating the data source handle.
  • Loading branch information
ravikirankatneni committed Jun 26, 2019
1 parent 17939e4 commit e6eb42c
Showing 1 changed file with 29 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.eclipse.datatools.connectivity.oda.design.util.DesignUtil;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.emf.ecore.util.EcoreUtil.EqualityHelper;

/*******************************************************************************
* Copyright (c) 2004 Actuate Corporation. All rights reserved. This program and
Expand Down Expand Up @@ -124,7 +125,12 @@ public OdaDataSourceHandle createDataSourceHandle(
public void updateDataSourceHandle( DataSourceDesign sourceDesign,
OdaDataSourceHandle sourceHandle ) throws SemanticException
{
if ( sourceDesign == null || sourceHandle == null )
if ( sourceDesign == null
|| sourceHandle == null
|| ( sourceHandle.getExtends( ) != null )
&& isDataSourceHandleAndDataSourceDesignEqual(
sourceHandle,
sourceDesign ) )
return;

DesignUtil.validateObject( sourceDesign );
Expand Down Expand Up @@ -184,6 +190,28 @@ public void updateDataSourceHandle( DataSourceDesign sourceDesign,

stack.commit( );
}

public boolean isDataSourceHandleAndDataSourceDesignEqual(
OdaDataSourceHandle sourceHandle, DataSourceDesign sourceDesign )
{

EqualityHelper equalityHelper = new EcoreUtil.EqualityHelper( );
// compare public properties
Properties sourceHandlePublicProperties = newOdaPublicProperties(
sourceHandle.getExtensionPropertyDefinitionList( ),
sourceHandle );
if ( !equalityHelper.equals( sourceHandlePublicProperties,
sourceDesign.getPublicProperties( ) ) )
{
return false;
}

// compare private properties
Properties sourceHandlePrivateProperties = newOdaPrivateProperties(
sourceHandle.privateDriverPropertiesIterator( ) );
return equalityHelper.equals( sourceHandlePrivateProperties,
sourceDesign.getPrivateProperties( ) );
}

public boolean isEqualDataSourceDesign( DataSourceDesign designFromHandle,
DataSourceDesign design )
Expand Down

0 comments on commit e6eb42c

Please sign in to comment.