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

Class DataCorrelationUtil

  • java.lang.Object
    • 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 Detail

      • ORIGINAL_REGEX_KEY

        public static final String ORIGINAL_REGEX_KEY
    • 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
      • 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)
        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<String,Object> 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.
      • 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
      • okToRemove

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

        public static Button displayLinkWithDSVOption(com.ibm.rational.common.test.editor.framework.kernel.util.LoadTestWidgetFactory 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)
      • isFixedDataSource

        public static boolean isFixedDataSource(com.ibm.rational.test.common.models.behavior.cbdata.DataSource ds)
        Returns whether the specified data source is fixed in the test, i.e. it can be consumed from anywhere in the test.
        Parameters:
        ds -
        Returns:
IBM Rational Performance Tester SDK

© Copyright IBM Corp. 2013. All rights reserved.