[28769] Refined fix for QuerySpecification#getParameterValue not finding matching parameter
diff --git a/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/spec/QuerySpecification.java b/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/spec/QuerySpecification.java
index e36b5bf..1db7fe8 100644
--- a/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/spec/QuerySpecification.java
+++ b/plugins/org.eclipse.datatools.connectivity.oda/src/org/eclipse/datatools/connectivity/oda/spec/QuerySpecification.java
@@ -221,11 +221,16 @@
{
if( m_parameterValues == null )
return null;
-
+
+ Object paramValue = m_parameterValues.get( paramIdentifier );
+ if( paramValue != null )
+ return paramValue;
+
+ // try match by name or id
for( Entry<ParameterIdentifier, Object> entry : m_parameterValues.entrySet() )
{
ParameterIdentifier paramIdKey = entry.getKey();
- if( paramIdKey.equals( paramIdentifier ) )
+ if( paramIdKey.matchesByNameOrId( paramIdentifier ) )
return entry.getValue();
}
return null;
@@ -388,6 +393,32 @@
return ( m_paramId != null && m_paramId.intValue() > 0 );
}
+ private boolean matchesByNameOrId( Object obj )
+ {
+ if( ! (obj instanceof ParameterIdentifier) )
+ return false;
+
+ ParameterIdentifier thatObj = (ParameterIdentifier) obj;
+ if( this == thatObj )
+ return true;
+
+ // compares by name first, if exists
+ boolean matchesName = false;
+ if( this.hasName() && thatObj.hasName() )
+ {
+ if( this.m_paramName.equals( thatObj.m_paramName ) )
+ matchesName = true;
+ else
+ return false;
+ }
+
+ // compares by id, if exists
+ if( this.hasId() && thatObj.hasId() )
+ return( this.m_paramId.equals( thatObj.m_paramId ));
+
+ return matchesName;
+ }
+
/* (non-Javadoc)
* @see java.lang.Object#equals(java.lang.Object)
*/
@@ -403,7 +434,7 @@
// compares by name first, if exists
boolean isNameEqual = false;
- if( this.hasName() && thatObj.hasName() )
+ if( this.hasName() )
{
if( this.m_paramName.equals( thatObj.m_paramName ) )
isNameEqual = true;
@@ -412,7 +443,7 @@
}
// compares by id, if exists
- if( this.hasId() && thatObj.hasId() )
+ if( this.hasId() )
return( this.m_paramId.equals( thatObj.m_paramId ));
return isNameEqual;
diff --git a/releng/org.eclipse.datatools.connectivity.releng/maps/connectivity-plugins.map b/releng/org.eclipse.datatools.connectivity.releng/maps/connectivity-plugins.map
index ea1415f..9c3ba85 100644
--- a/releng/org.eclipse.datatools.connectivity.releng/maps/connectivity-plugins.map
+++ b/releng/org.eclipse.datatools.connectivity.releng/maps/connectivity-plugins.map
@@ -5,7 +5,7 @@
plugin@org.eclipse.datatools.connectivity.sqm.core=v200906020553,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.sqm.core
plugin@org.eclipse.datatools.connectivity.sqm.core.ui=v200906020553,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.sqm.core.ui
plugin@org.eclipse.datatools.connectivity.sqm.server.ui=v200906020553,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.sqm.server.ui
-plugin@org.eclipse.datatools.connectivity.oda=v200908271248,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.oda
+plugin@org.eclipse.datatools.connectivity.oda=v200909031448,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.oda
plugin@org.eclipse.datatools.connectivity.oda.template.ui=v200906020553,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.oda.template.ui
plugin@org.eclipse.datatools.connectivity.oda.profile=v200906020553,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.oda.profile
plugin@org.eclipse.datatools.connectivity.oda.flatfile=v200907061455,:pserver:anonymous@dev.eclipse.org:/cvsroot/datatools,,org.eclipse.datatools.connectivity/plugins/org.eclipse.datatools.connectivity.oda.flatfile
diff --git a/tests/org.eclipse.datatools.connectivity.oda.tests/src/org/eclipse/datatools/connectivity/oda/spec/tests/QuerySpecTest.java b/tests/org.eclipse.datatools.connectivity.oda.tests/src/org/eclipse/datatools/connectivity/oda/spec/tests/QuerySpecTest.java
index 80fec0b..16506c0 100644
--- a/tests/org.eclipse.datatools.connectivity.oda.tests/src/org/eclipse/datatools/connectivity/oda/spec/tests/QuerySpecTest.java
+++ b/tests/org.eclipse.datatools.connectivity.oda.tests/src/org/eclipse/datatools/connectivity/oda/spec/tests/QuerySpecTest.java
@@ -53,6 +53,7 @@
querySpec.setParameterValue( paramName, paramValue );
assertEquals( 1, querySpec.getParameterValues().size() );
assertEquals( paramValue, querySpec.getParameterValue( paramName ) );
+ assertEquals( paramValue, querySpec.getParameterValue( querySpec.new ParameterIdentifier( paramName, 100 )) );
assertEquals( paramValue, querySpec.getParameterValues().get( querySpec.new ParameterIdentifier( paramName )) );
// test case sensitive parameter name comparison
@@ -64,6 +65,7 @@
querySpec.setParameterValue( querySpec.new ParameterIdentifier( paramId ), "overrideParamValue" );
assertEquals( 2, querySpec.getParameterValues().size() );
assertEquals( "overrideParamValue", querySpec.getParameterValue( paramId ) );
+ assertEquals( "overrideParamValue", querySpec.getParameterValue( querySpec.new ParameterIdentifier( "dummyName", paramId ) ) );
assertEquals( "overrideParamValue", querySpec.getParameterValues().get( querySpec.new ParameterIdentifier( paramId ) ) );
// test setting parameter value by name and position
@@ -75,6 +77,7 @@
assertEquals( paramValue, querySpec.getParameterValue( paramName ) );
assertEquals( paramValue, querySpec.getParameterValue( paramId ) );
assertEquals( paramValue, querySpec.getParameterValue( paramIdentifier ) );
+ assertEquals( paramValue, querySpec.getParameterValue( querySpec.new ParameterIdentifier( paramName, paramId ) ) );
Object actualValue = querySpec.getParameterValue( "param1" );
assertNotNull( actualValue );