Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

(tick) Kyvos Azure Marketplace   (tick) Kyvos GCP Marketplace (tick) Kyvos Single Node Installation (Kyvos SNI)

...

Overview

  1. Specify required imports

  2. Prepare the request

  3. Call the method executeOlapQuery

  4. Use the response

Example

  1. Specify required imports.

    Code Block
    import org.olap4j.Cell;
    import org.olap4j.CellSet;
    import org.olap4j.OlapConnection;
    import org.olap4j.OlapStatement;
    import org.olap4j.Position;
  2. Prepare the request.

    Code Block
    Class.forName("org.olap4j.driver.xmla.XmlaOlap4jDriver");
    /* Append “xmlaKyvos” to your Kyvos URL in below statement.
    Catalog is the folder name where the cube is saved to run MDX query else give [Root] here.
    Specify “KYVOS” under DataSource.*/
          Connection connection =
    DriverManager.getConnection(“jdbc:xmla:Server=http://localhost:8080/kyvos/xmlaKyvos;User=Admin;Password=Admin;Catalog=FlightShopDetails;DataSource=KYVOS");
    OlapConnection olapConnection = connection.unwrap(OlapConnection.class);
    OlapStatement statement = olapConnection.createStatement();
    String mdx = "SELECT [Measures].[Miles Traveled] DIMENSION PROPERTIES [MEMBER_UNIQUE_NAME],[MEMBER_CAPTION] ON COLUMNS,NON EMPTY CROSSJOIN( [Travel Agent].[Hierarchy].[Travel Agent].AllMembers, [Departure Airport].[Hierarchy].[Departure Country].AllMembers) DIMENSION PROPERTIES [MEMBER_UNIQUE_NAME],[MEMBER_CAPTION] ON ROWS FROM [Flight Shop Analysis]";
  3. Call the method executeOlapQuery.

    Code Block
    CellSet cellSet = statement.executeOlapQuery(String mdx, boolean getMemberDetails);
    /*Pass getMemberDetails as false to avoid sending further request for each member to fetch extra information like member’s parent, child count, etc. This would ensure a faster response.*/
  4. Use the response.

    Code Block
    private static void getResponse(CellSet cellSet){
                 List<CellSetAxis> cellSetAxes = cellSet.getAxes();
                 for (Position row : cellSetAxes.get(0))
                 {
                       if(cellSetAxes.size() > 1)
                       {
                             for (Position column : cellSetAxes.get(1))
                             {
                                   for (Member member : row.getMembers())
                                   {
                                       System.out.print(member.getName() + ":" + " ");
                                   }
                                   for (Member member : column.getMembers())
                                   {
                                       System.out.println(member.getName() + "=" + " ");
                                   }
                                   final Cell cell = cellSet.getCell(row, column);
                                   System.out.println(cell.getValue());
                             }
                       }
                       else
                       {
                             for (Member member : row.getMembers())
                             {
                                   System.out.println(member.getName());
                             }
                             final Cell cell = cellSet.getCell(row);
                             System.out.println(cell.getValue());
                             System.out.println();
                       }
                             }

Token based SSO

In the above example, basic authentication is used with a connection URL. But sometimes, users do not want to use their credentials in some scenarios. To deal with such scenarios, Kyvos provides another authentication mechanism which is token-based SSO. Users can invoke Kyvos Login REST API to get a token and then use that token with a connection URL. Users will have to perform the following steps to use token-based SSO.

...

You can use this connection URL in the code provided in the examples while using the token, do not provide any username and password.

Examples

Code to get the token from REST API.

...