IBM Rational Performance Tester SDK

com.ibm.rational.test.lt.testeditor.common
Class DataCorrelationUtil

java.lang.Object
  extended by com.ibm.rational.test.lt.testeditor.common.DataCorrelationUtil
All Implemented Interfaces:
com.ibm.rational.test.lt.testeditor.main.LoadTestLoggingConstants

public class DataCorrelationUtil
extends Object
implements com.ibm.rational.test.lt.testeditor.main.LoadTestLoggingConstants

Utility class with various methods related to manipulation of Datacorrelation model elements.


Field Summary
static String ORIGINAL_REGEX_KEY
           
 
Fields inherited from interface com.ibm.rational.test.lt.testeditor.main.LoadTestLoggingConstants
prefix_RPTN, RPTNE0001_INIT_ERROR, RPTNE0002_INTERNAL_ERROR, RPTNE0003_CREATE_DATAPOOL, RPTNE0004_EXTENSION_ERROR, RPTNE0005_MARKER_NOT_FOUND, RPTNE0017_CREATE_REFERENCE, RPTNE0020_CREATE_DATAPOOL_SUBST, RPTNE0040_OPEN_FILE, RPTNE0050_DISPLAY_RULES_FAILED, RPTNI0009_COLUMNS_REFRESHED, RPTNW0006_DC_ERROR, RPTNW0007_DATAPOOL_REMOVED, RPTNW0008_COLUMNS_REMOVED, RPTNW0016_CREATE_REFERENCE
 
Constructor Summary
DataCorrelationUtil()
           
 
Method Summary
static void addDcOwnershipResolver(com.ibm.rational.test.lt.testeditor.dc.IDcOwnershipResolver resolver)
          This method should be used to store datacorrelation resolvers.
static void addFileContentsSubstitutionField(String fieldName, boolean onlyFileContents)
          Registers the field (identified by name) as supporting File Contents Substituter.
static com.ibm.rational.test.common.models.behavior.cbdata.CorrelationHarvester createCorrelationHarvester(IDCStringLocator sl, LoadTestEditor editor)
          Creates CorrelationHarvester.
static com.ibm.rational.test.common.models.behavior.cbdata.Substituter createSubstituter(IDCStringLocator strLoc, com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds, LoadTestEditor editor)
          Creates Substituter.
static Button displayLinkWithDSVOption(org.eclipse.hyades.test.ui.internal.editor.form.base.FormWidgetFactory factory, Composite parent, int cols)
           
static HashMap getAttributeDisplayNames()
           
static String getDatasourceCategory(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds)
          Return ICategoriesIDs constant for a given DataSource
static int getDcSize(CBActionElement element)
           
static String getErrorMessage()
           
static List getHarvestersFor(com.ibm.rational.test.common.models.behavior.cbdata.DataSourceHost host, String attrName, Comparator comparator)
          Returns list of harvesters for the given host.
static List getHarvestersFor(com.ibm.rational.test.common.models.behavior.cbdata.DataSourceHost host, String attrName, Comparator comparator, IProgressMonitor monitor)
           
static String getLabelForAttribute(String name)
          Returns display name for a given datacorrelation attribute.
static List getSubstitutersFor(com.ibm.rational.test.common.models.behavior.cbdata.SubstituterHost host, String attrName, Comparator comparator)
          Returns list of Substituter objects.
static List getSubstitutersFor(com.ibm.rational.test.common.models.behavior.cbdata.SubstituterHost host, String attrName, Comparator comparator, IProgressMonitor monitor)
           
static boolean isReadOnly(com.ibm.rational.test.common.models.behavior.cbdata.CoreHarvester ch, String feature)
           
static boolean isShowMoreSubstitutionOptions()
           
static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Arbitrary a, LoadTestEditor editor)
           
static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds, LoadTestEditor editor)
           
static boolean okToRemove(com.ibm.rational.test.lt.testeditor.common.LTTextStructuredSelection s, LoadTestEditor editor)
           
static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Substituter su, LoadTestEditor editor)
           
protected static IDCStringLocator promptForHarvesterType(List list, IDCStringLocator sl)
           
static boolean promptToRemove(Datapool datapool, LoadTestEditor editor)
           
static boolean promptToRemove(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds, LoadTestEditor editor)
           
static boolean promptToRemove(List dataSourcesLIst, LoadTestEditor editor)
           
static boolean promptToRemove(com.ibm.rational.test.lt.testeditor.common.LTTextStructuredSelection sel, LoadTestEditor editor)
           
static boolean promptToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Substituter su, LoadTestEditor editor)
           
static com.ibm.rational.test.common.models.behavior.cbdata.Substituter replaceDataSource(com.ibm.rational.test.common.models.behavior.cbdata.Substituter subst, com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds)
          Deprecated. Use DataCorrelationUtil.replaceDataSource(Substituter, DataSource, DataSource)
static com.ibm.rational.test.common.models.behavior.cbdata.Substituter replaceDataSource(com.ibm.rational.test.common.models.behavior.cbdata.Substituter subst, com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds, com.ibm.rational.test.common.models.behavior.cbdata.DataSource _oldDs)
          Replaces DataSource in the given Substituter.
static void replaceSubstitutersInMatches(com.ibm.rational.test.common.models.behavior.cbdata.Substituter oldSub, com.ibm.rational.test.common.models.behavior.cbdata.Substituter newSub)
           
static CBActionElement resolveDcOwnership(com.ibm.rational.test.common.models.behavior.cbdata.CoreHarvester ch)
          Finds IDcWonershipResolver based on the argument DataSource.
static CBActionElement resolveDcOwnership(String attribute, CBActionElement action)
           
static CBActionElement resolveDcOwnership(com.ibm.rational.test.common.models.behavior.cbdata.Substituter substituter)
          Finds IDcWonershipResolver based on the argument DataSource.
static void setErrorMessage(String errorMessage)
           
static void setLabelForAttribute(String name, com.ibm.rational.test.lt.testeditor.dc.DataCorrelationLabelProvider.LabelFormatter formatter)
          Stores a human-readable LabelFormatter for a given attribute name.
static void setLabelForAttribute(String name, String displayName)
          Stores a human-readable display name for a given attribute name.
static void setShowMoreSubstitutionOptions(boolean b)
           
static void showLinkWithDSVMessage(Shell shell, LoadTestEditor editor, com.ibm.rational.test.lt.testeditor.views.ISubstitutionTargetProvider targetProvider)
          Enables link with Data Sources View.
static Boolean supportsFileContentsSubstitution(String fieldName)
          Checks if the field identified by supplied fieldName supports FileContents Substituters.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ORIGINAL_REGEX_KEY

public static final String ORIGINAL_REGEX_KEY
See Also:
Constant Field Values
Constructor Detail

DataCorrelationUtil

public DataCorrelationUtil()
Method Detail

createCorrelationHarvester

public static com.ibm.rational.test.common.models.behavior.cbdata.CorrelationHarvester createCorrelationHarvester(IDCStringLocator sl,
                                                                                                                  LoadTestEditor editor)
                                                                                                           throws com.ibm.rational.test.lt.datacorrelation.testgen.DCException
Creates CorrelationHarvester.

This method is called from ExtendedStyledText in response of user's selecting of various menu options. This method collects available datacorrelation provider that are capable of creating Harvester for selected text. If more than one handler is found, the method presents a dialog box with selection.

Parameters:
sl - IDCStringLocator description of the selected text.
editor - LoadTestEditor
Returns:
CorrelationHarvester if one was created successfully, or null.
Throws:
com.ibm.rational.test.lt.datacorrelation.testgen.DCException
See Also:
DataCorrelator

promptForHarvesterType

protected static IDCStringLocator promptForHarvesterType(List list,
                                                         IDCStringLocator sl)
Parameters:
list -
Returns:
IDCStringLocator

getErrorMessage

public static String getErrorMessage()
Returns:
Returns the errorMessage.

setErrorMessage

public static void setErrorMessage(String errorMessage)
Parameters:
errorMessage - The errorMessage to set.

replaceDataSource

public static com.ibm.rational.test.common.models.behavior.cbdata.Substituter replaceDataSource(com.ibm.rational.test.common.models.behavior.cbdata.Substituter subst,
                                                                                                com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds,
                                                                                                com.ibm.rational.test.common.models.behavior.cbdata.DataSource _oldDs)
Replaces DataSource in the given Substituter. There are cases when the entire Substituter must be recreated, as in for BuiltInDataSource.

Parameters:
subst - Substituter. Substituter in which the DataSource needs to be replaced, or set.
ds - DataSource to correlate with.
_oldDs - previous data source, if any
Returns:
Substituter. Can be same as the input, or a new, different, one. Callers are responsible to update the UI.

replaceDataSource

public static com.ibm.rational.test.common.models.behavior.cbdata.Substituter replaceDataSource(com.ibm.rational.test.common.models.behavior.cbdata.Substituter subst,
                                                                                                com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds)
Deprecated. Use DataCorrelationUtil.replaceDataSource(Substituter, DataSource, DataSource)

Replaces DataSource in the given Substituter. There are cases when the entire Substituter must be recreated, as in for BuiltInDataSource.

Parameters:
subst - Substituter. Substituter in which the DataSource needs to be replaced, or set.
ds - DataSource to correlate with.
Returns:
Substituter. Can be same as the input, or a new, different, one. Callers are responsible to update the UI.

createSubstituter

public static com.ibm.rational.test.common.models.behavior.cbdata.Substituter createSubstituter(IDCStringLocator strLoc,
                                                                                                com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds,
                                                                                                LoadTestEditor editor)
                                                                                         throws com.ibm.rational.test.lt.datacorrelation.testgen.DCException
Creates Substituter.

This method is called from ExtendedStyledText in response of user's selecting of various menu options. This method collects available datacorrelation providers that are capable of creating Substituters for selected text. If more than one handler is found, the method presents a dialog box with selection.

Parameters:
strLoc - IDCStringLocator description of the selected text.
ds - DataSource to use for substitution.
editor - LoadTestEditor
Returns:
Substituter if one was created successfully, or null.
Throws:
com.ibm.rational.test.lt.datacorrelation.testgen.DCException
See Also:
DataCorrelator

okToRemove

public static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds,
                                 LoadTestEditor editor)
Parameters:
ds -
editor -
Returns:
boolean

promptToRemove

public static boolean promptToRemove(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds,
                                     LoadTestEditor editor)
Parameters:
ds -
editor -
Returns:
boolean

promptToRemove

public static boolean promptToRemove(com.ibm.rational.test.lt.testeditor.common.LTTextStructuredSelection sel,
                                     LoadTestEditor editor)
Parameters:
ds -
editor -
Returns:
boolean

promptToRemove

public static boolean promptToRemove(List dataSourcesLIst,
                                     LoadTestEditor editor)
Parameters:
ds -
editor -
Returns:
boolean

okToRemove

public static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Arbitrary a,
                                 LoadTestEditor editor)
Parameters:
a - Arbitrary
editor - LoadTestEditor
Returns:
boolean

okToRemove

public static boolean okToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Substituter su,
                                 LoadTestEditor editor)
Parameters:
su -
editor -
Returns:
boolean

promptToRemove

public static boolean promptToRemove(com.ibm.rational.test.common.models.behavior.cbdata.Substituter su,
                                     LoadTestEditor editor)
Parameters:
su -
editor -
Returns:
boolean

getLabelForAttribute

public static String getLabelForAttribute(String name)
Returns display name for a given datacorrelation attribute. Name must be registered by calling DataCorrelationLabelProvider#setLabelForAttribute(String, LabelFormatter) or DataCorrelationLabelProvider#setLabelForAttribute(String, String).

Parameters:
name - String attribute name
Returns:
String display name

setLabelForAttribute

public static void setLabelForAttribute(String name,
                                        String displayName)
Stores a human-readable display name for a given attribute name. Protocol extension plugin must register its attribute names/display names if it supports datacorrelation/datapooling.

Parameters:
name - String Attribute name.
displayName - Display Name
See Also:
ExtendedStyledText

setLabelForAttribute

public static void setLabelForAttribute(String name,
                                        com.ibm.rational.test.lt.testeditor.dc.DataCorrelationLabelProvider.LabelFormatter formatter)
Stores a human-readable LabelFormatter for a given attribute name. Protocol extension plugin must register its attribute names/display names if it supports datacorrelation/datapooling. LabelFormatter is responsible for formatting and returning correct display name for a given attribute name

Parameters:
name - String Datacorrelation Attribute Name.
formatter - Class implementing DataCorrelationLabelProvider.LabelFormatter
See Also:
ExtendedStyledText, DataCorrelationLabelProvider.LabelFormatter

getAttributeDisplayNames

public static HashMap getAttributeDisplayNames()
Returns:
map of datacorrelation attributes and displaynames/labelformatters.

addDcOwnershipResolver

public static void addDcOwnershipResolver(com.ibm.rational.test.lt.testeditor.dc.IDcOwnershipResolver resolver)
This method should be used to store datacorrelation resolvers. IDcOwnershipResolver returns real parent of DataSource or Substituter based on the attribute name.

Parameters:
resolver - IDcOwnershipResolver, must not be null.

resolveDcOwnership

public static CBActionElement resolveDcOwnership(com.ibm.rational.test.common.models.behavior.cbdata.CoreHarvester ch)
Finds IDcWonershipResolver based on the argument DataSource.

Parameters:
ch - CorrelationHarvester
Returns:
CBActionElement the real parent.

resolveDcOwnership

public static CBActionElement resolveDcOwnership(com.ibm.rational.test.common.models.behavior.cbdata.Substituter substituter)
Finds IDcWonershipResolver based on the argument DataSource.

Parameters:
substituter - Substituter
Returns:
CBActionElement the real parent.

resolveDcOwnership

public static CBActionElement resolveDcOwnership(String attribute,
                                                 CBActionElement action)

getSubstitutersFor

public static List getSubstitutersFor(com.ibm.rational.test.common.models.behavior.cbdata.SubstituterHost host,
                                      String attrName,
                                      Comparator comparator,
                                      IProgressMonitor monitor)

getSubstitutersFor

public static List getSubstitutersFor(com.ibm.rational.test.common.models.behavior.cbdata.SubstituterHost host,
                                      String attrName,
                                      Comparator comparator)
Returns list of Substituter objects. The list contains only substituters that with a given attributeName. In addition, the comparator is used to further filter the list.

Parameters:
host - SubstituterHost host.
attrName - String. Attribute name
comparator - Comparator. This can be either a class that implements Comparator directly or an instance of DefaultAttributeMatcher.
Returns:
List of substituters
Since:
7.0.1

getHarvestersFor

public static List getHarvestersFor(com.ibm.rational.test.common.models.behavior.cbdata.DataSourceHost host,
                                    String attrName,
                                    Comparator comparator,
                                    IProgressMonitor monitor)

getHarvestersFor

public static List getHarvestersFor(com.ibm.rational.test.common.models.behavior.cbdata.DataSourceHost host,
                                    String attrName,
                                    Comparator comparator)
Returns list of harvesters for the given host. The list contains only harvesters with a given attributeName. In addition, the comparator is used to further filter the list.

Parameters:
host - DataSourceHost host.
attrName - String. Attribute name
comparator - Comparator. This can be either a class that implements Comparator directly or an instance of DefaultAttributeMatcher.
Returns:
List of harvesters

promptToRemove

public static boolean promptToRemove(Datapool datapool,
                                     LoadTestEditor editor)

okToRemove

public static boolean okToRemove(com.ibm.rational.test.lt.testeditor.common.LTTextStructuredSelection s,
                                 LoadTestEditor editor)

displayLinkWithDSVOption

public static Button displayLinkWithDSVOption(org.eclipse.hyades.test.ui.internal.editor.form.base.FormWidgetFactory factory,
                                              Composite parent,
                                              int cols)

showLinkWithDSVMessage

public static void showLinkWithDSVMessage(Shell shell,
                                          LoadTestEditor editor,
                                          com.ibm.rational.test.lt.testeditor.views.ISubstitutionTargetProvider targetProvider)
Enables link with Data Sources View. Any UI that allows users to manipulate this option, needs to call this method to ensure common behavior in the UI. This method displays a popup dialog with toggle that can be turned off by user. The linkgae between editors and Dayta Sources View is controlled by LoadTestEditorPlugin.isAutoLinkWithDsv(). When this value is true, the UI is expected to update the Test Data Sources View with substitutable locations where appropriate (by using ISubstitutionTargetProvider.

Parameters:
shell - Shell for any popup dialogs that may be displayed by this method.
editor - LoadTestEditor the editor. If not null the Data Source View will be displayed.
targetProvider - ISubstitutionTargetProvider. If not null, the Data Sources View will display this target
See Also:
ISubstitutionTargetProvider, LoadTestEditorPlugin.isAutoLinkWithDsv(), LoadTestEditorPlugin.setAutoLinkWithDsv(boolean), ShowDataSourceViewAction

supportsFileContentsSubstitution

public static Boolean supportsFileContentsSubstitution(String fieldName)
Checks if the field identified by supplied fieldName supports FileContents Substituters. This method is called by Editor's core (such as Data Sources View) to facilitate "standard" behavior.

Parameters:
fieldName - String
Returns:
Boolean. null if not supported. Otherwise, the value of the returned Boolean is true if this field supports file contents substitution only, or false if both types.
See Also:
ToggleFileSubstitutionAction, DataCorrelationUtil.addFileContentsSubstitutionField(String, boolean)

addFileContentsSubstitutionField

public static void addFileContentsSubstitutionField(String fieldName,
                                                    boolean onlyFileContents)
Registers the field (identified by name) as supporting File Contents Substituter. Extensions need to call this method once to register any such field. The name is the same string returned from DataCorrelatingTextAttrField.getAttributeName().

NOTE: The use case where the same field can have both file contents and regular substitution, based on some external criteria is not supported. For example, HTTP POST data chunks, if binary, can have only file contents substitution, and, if text, both types.

Parameters:
fieldName - String field Name.
onlyFileContents - boolean. If true then the field supports file contents substitution only, if false both regular and file contents substitution types are supported in this field.
See Also:
ToggleFileSubstitutionAction, DataCorrelationUtil.addFileContentsSubstitutionField(String, boolean)

getDcSize

public static int getDcSize(CBActionElement element)
Parameters:
element - CBActionElement. Expected to be instance of DataSourceHost and/or SubstituterHost
Returns:
combined number of DataSource (if the element is DataSourceHost) and/or Substituter (if the element is SubstituterHost)

getDatasourceCategory

public static String getDatasourceCategory(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds)
Return ICategoriesIDs constant for a given DataSource

Parameters:
ds - DataSource
Returns:
String ID or null if ds is unknown type.

isReadOnly

public static boolean isReadOnly(com.ibm.rational.test.common.models.behavior.cbdata.CoreHarvester ch,
                                 String feature)

isShowMoreSubstitutionOptions

public static boolean isShowMoreSubstitutionOptions()

setShowMoreSubstitutionOptions

public static void setShowMoreSubstitutionOptions(boolean b)

replaceSubstitutersInMatches

public static void replaceSubstitutersInMatches(com.ibm.rational.test.common.models.behavior.cbdata.Substituter oldSub,
                                                com.ibm.rational.test.common.models.behavior.cbdata.Substituter newSub)

IBM Rational Performance Tester SDK

© Copyright IBM Corp. 2012. All rights reserved.