Class WebTools


  • public class WebTools
    extends java.lang.Object
    This class provides static utility methods that can be used in various tasks.
    Since:
    MicroStrategy Web 7.3.1 or earlier
    • Constructor Detail

      • WebTools

        public WebTools()
    • Method Detail

      • getObjectNodeName

        public static java.lang.String getObjectNodeName​(int objectType)
        This function maps the object type with the XML short name.
        Parameters:
        objectType - The type of object we want to look for.
        Returns:
        The XML short name of the specified object type.
      • getObjectNodeName

        public static java.lang.String getObjectNodeName​(java.lang.Integer objectType)
      • removeParameterFromURL

        public static java.lang.String removeParameterFromURL​(java.lang.String URL,
                                                              java.lang.String parameter)
        Removes the requested parameter from the URL, together with its value assigned.
        Parameters:
        URL - the query string from where the parameter should be removed
        parameter - the name of the parameter to search and remove
        Returns:
        The resulting string after removing the parameter. - If not found, returns the same string, - If it's the only parameter on the URL, returns an empty string - In any other case, returns the string without the parameter and its value
      • compareStrings

        public static int compareStrings​(java.lang.String str1,
                                         java.lang.String str2,
                                         java.util.Locale loc)
        Since:
        MicroStrategy Web 9.0.0
      • getObjectComparator

        public static java.util.Comparator getObjectComparator​(int sortField,
                                                               boolean isAscending)
        This method can be used to get a Comparator for sorting objects within a WebFolder Using a sort field argument specified from the interface EnumWebObjectSort, one can obtain a corresponding Comparator. The Comparator can be used on the WebDisplayUnits object returned by WebDisplayUnit.getChildUnits() method of a WebFolder to sort the WebObjectInfo objects of the WebFolder.
        Parameters:
        sortField - the sort field. Must be a value from EnumWebObjectSort. The sort fields cannot be combined.
        isAscending - Specify whether Comparator will be used for ascending sorting or descending sorting.
        Returns:
        the corresponding Comparator
      • getObjectComparator

        public static java.util.Comparator getObjectComparator​(int sortField,
                                                               java.util.Locale numberDateLocale,
                                                               boolean isAscending)
        This method can be used to get a Comparator for sorting objects within a WebFolder Using a sort field argument specified from the interface EnumWebObjectSort, one can obtain a corresponding Comparator. The Comparator can be used on the WebDisplayUnits object returned by WebDisplayUnit.getChildUnits() method of a WebFolder to sort the WebObjectInfo objects of the WebFolder.
        Parameters:
        sortField - the sort field. Must be a value from EnumWebObjectSort. The sort fields cannot be combined.
        numberDateLocale - The associated locale. This will be used in number/date comparisons. If the locale parameter is passed in as null, then the default locale is used.
        isAscending - Specify whether Comparator will be used for ascending sorting or descending sorting.
        Returns:
        the corresponding Comparator
        Since:
        MicroStrategy Web 8.0.0
      • getObjectComparator

        public static java.util.Comparator<WebDisplayUnitEntry> getObjectComparator​(int sortField,
                                                                                    RegionalOptions locales,
                                                                                    boolean isAscending)
        This method can be used to get a Comparator for sorting objects within a WebFolder Using a sort field argument specified from the interface EnumWebObjectSort, one can obtain a corresponding Comparator. The Comparator can be used on the WebDisplayUnits object returned by WebDisplayUnit.getChildUnits() method of a WebFolder to sort the WebObjectInfo objects of the WebFolder.
        Parameters:
        sortField - the sort field. Must be a value from EnumWebObjectSort. The sort fields cannot be combined.
        locales - The associated locales.
        isAscending - Specify whether Comparator will be used for ascending sorting or descending sorting.
        Returns:
        the corresponding Comparator
        Since:
        MicroStrategy Web 9.0.0
      • isConnected

        public static boolean isConnected​(java.lang.String serverName,
                                          int serverPort)
        Makes a checkConnection(String, int) call, returning true/false depending on whether it was successful. No exception is thrown by this method.
        Parameters:
        serverName - name of the Intelligence Server.
        serverPort - port of the Intelligence Server.
        Returns:
        whether we're connected
        Since:
        MicroStrategy Web 9.0.0
        See Also:
        checkConnection(String, int)
      • checkConnection

        public static boolean checkConnection​(java.lang.String serverName,
                                              int serverPort)
                                       throws MSTRWebAPIException
        Checks to see if MicroStrategy Web is connected to the given Intelligence Server. We will attempt connecting if (IDSSXMLAdmin.getAutoConnect()) is true. checkConnection (1) finds out if the cluster exists, (2) automatically reconnects to the IServer if the auto-connect feature is on.
        Parameters:
        serverName - name of the Intelligence Server.
        serverPort - port of the Intelligence Server.
        Returns:
        whether we're connected
        Throws:
        MSTRWebAPIException - thrown if there was a problem establishing a connection.
        Since:
        MicroStrategy Web 9.0.1
      • addToElementsCollection

        public static WebElement addToElementsCollection​(WebElements collection,
                                                         java.lang.String originalID,
                                                         java.lang.String displayFormIndices)
        Utility method to add an element to the element collection
        Parameters:
        collection - - WebElements the collection to add the element to.
        originalID - - The element id.
        displayFormIndices - - comma separated list of attribute form indices that are part of the display name
        Returns:
        WebElement that was added.
        Since:
        MicroStrategy Web 8.1.2
      • addToElementsCollection

        public static WebElement addToElementsCollection​(WebElements collection,
                                                         java.lang.String originalID)
        Utility method to add an element to the element collection
        Parameters:
        collection - - WebElements the collection to add the element to.
        originalID - - The element id.
        Returns:
        WebElement that was added.
        Since:
        MicroStrategy Web 8.1.2
      • getMRPFunction

        public static int getMRPFunction​(int dssFunc,
                                         int funcType,
                                         boolean asc)
        This method returns the MRP function for a DSS function, function type, and ascending/descending flag. This is used to map the preference for default operator to the EnumWebMRPFunction, which is required for rank/ percent to build those expressions.
        Parameters:
        dssFunc - The function, from EnumDSSXMLFunction.
        funcType - The function type, from EnumWebFunctionType.
        asc - Whether the order should be ascending or descending
        Returns:
        The correct function - if rank/percent, from EnumWebMRPFunction, otherwise the original function.
        Since:
        MicroStrategy Web 9.0.0
      • canSelectElements

        public static boolean canSelectElements​(WebAttribute webAttribute,
                                                WebElementSource elementSource)
        Check whether we do project browsing or not
        Parameters:
        webAttribute -
        elementSource -
        Since:
        MicroStrategy Web 9.0.1
      • showHyperCard

        public static boolean showHyperCard()