Package com.narirelays.ems.olap.sample.chapter10

Examples of com.narirelays.ems.olap.sample.chapter10.TopBottomTest


    StringSource prodHier = (StringSource) mdmProdHier.getSource();

    // Create a SingleSelectionTemplate to produce a Source that
    // represents the measure values specified by single members of each of
    // the dimensions of the measure other than the base dimension.
    SingleSelectionTemplate singleSelections =
                                     new SingleSelectionTemplate(units, dp);

    // Create MdmDimensionMemberInfo objects for single members of the
    // other dimensions of the measure.
    MdmDimensionMemberInfo timeMemInfo =
                new MdmDimensionMemberInfo(mdmTimeDim,
                                           "CALENDAR_YEAR_AW::YEAR_AW::4");
    MdmDimensionMemberInfo custMemInfo =
                new MdmDimensionMemberInfo(mdmCustDim,
                                           "SHIPMENTS_AW::REGION_AW::8");
    MdmDimensionMemberInfo chanMemInfo =
             new MdmDimensionMemberInfo(mdmChanDim,
                                        "CHANNEL_PRIMARY_AW::CHANNEL_AW::2");

    // Add the dimension member information objects to the
    // SingleSelectionTemplate.
    singleSelections.addDimMemberInfo(custMemInfo);
    singleSelections.addDimMemberInfo(chanMemInfo);
    singleSelections.addDimMemberInfo(timeMemInfo);

    println("Rolling Back a Transaction");

    // ***** Beginning of the Rolling Back a Transaction example *****
    // The current Transaction is a read Transaction, t1.
    // Create a TopBottomTemplate using a hierarchy of the Product dimension
    // as the base and dp as the DataProvider.
    TopBottomTemplate topNBottom = new TopBottomTemplate(prodHier, dp);

    // Changing the state of a Template requires a write Transaction, so a
    // write child Transaction, t2, is automatically started.
    topNBottom.setTopBottomType(TopBottomTemplate.TOP_BOTTOM_TYPE_TOP);
    topNBottom.setN(10);
    topNBottom.setCriterion(singleSelections.getSource());

    // Prepare and commit the Transaction t2.
    try
    {
      tp.prepareCurrentTransaction();
View Full Code Here


    // ***** Beginning of the Rolling Back a Transaction example *****
    // The current Transaction is a read Transaction, t1.
    // Create a TopBottomTemplate using a hierarchy of the Product dimension
    // as the base and dp as the DataProvider.
    TopBottomTemplate topNBottom = new TopBottomTemplate(prodHier, dp);

    // Changing the state of a Template requires a write Transaction, so a
    // write child Transaction, t2, is automatically started.
    topNBottom.setTopBottomType(TopBottomTemplate.TOP_BOTTOM_TYPE_TOP);
    topNBottom.setN(10);
    topNBottom.setCriterion(singleSelections.getSource());

    // Prepare and commit the Transaction t2.
    try
    {
      tp.prepareCurrentTransaction();
    }
    catch(NotCommittableException e)
    {
      println("Cannot commit the Transaction. " + e);
    }
    tp.commitCurrentTransaction();           //t2 disappears

    // The current Transaction is now t1.
    // Get the dynamic Source produced by the TopBottomTemplate.
    Source result = topNBottom.getSource();

    // Create a Cursor and display the results.
    println("\nThe current state of the TopBottomTemplate " +
            "\nproduces the following values:\n");
    getContext().displayTopBottomResult(result);

    // Start a child Transaction, t3. It is a read Transaction.
    tp.beginSubtransaction()// t3 is the current Transaction.

    // Change the state of topNBottom. Changing the state requires a
    // write Transaction so Transaction t4 starts automatically,
    topNBottom.setTopBottomType(TopBottomTemplate.TOP_BOTTOM_TYPE_BOTTOM);
    topNBottom.setN(15);

    // Prepare and commit the Transaction.
    // The following method of the superclass ContextExample calls the
    // prepareCurrentTransaction and commitCurrentTransaction methods of
    // the current Transaction.
    prepareAndCommit();        // t4 disappears

    // Create a Cursor and display the results; t3 is the current Transaction.
    println("\nIn the child Transaction, the state of the " +
            "\nTopBottomTemplate produces the following values:\n");
    getContext().displayTopBottomResult(result);

    // The displayTopBottomResult method closes the CursorManager for the
    // Cursor created in t3.

    // Undo t3, which discards the state of topNBottom that was set in t4.
    tp.rollbackCurrentTransaction(); // t3 disappears

    // Transaction t1 is now the current Transaction and the state of
    // topNBottom is the one defined in t2.

    // To show the current state of the TopNBottom template Source,
    // prepare and commit the Transaction, create a Cursor, and display
    // its values.
    prepareAndCommit();

    println("\nAfter rolling back the child Transaction, the state of"
            + "\nthe TopBottomTemplate produces the following values:\n");
    getContext().displayTopBottomResult(result);

    // ***** End of the Rolling Back a Transaction example *****


    println("\nUsing Child Transaction Objects");

    // ***** Beginning of the Using Child Transaction Objects example *****

    // The parent Transaction is the current Transaction at this point.
    // Save the parent read Transaction as parentT1.
    Transaction parentT1 = getCurrentTransaction();

    // Get the dynamic Source produced by the TopBottomTemplate.
    // The next line from this example is commented out because the
    // result object was created by the previous example.
    //Source result = topNBottom.getSource();

    // Create a Cursor and display the results.
    println("\nThe current state of the TopBottomTemplate" +
            "\nproduces following values:\n");
    getContext().displayTopBottomResult(result);

    // Begin a child Transaction of parentT1.
    tp.beginSubtransaction()// This is a read Transaction.

    // Save the child read Transaction as childT2.
    Transaction childT2 = tp.getCurrentTransaction();

    // Change the state of the TopBottomTemplate. This starts a
    // write Transaction, a child of the read Transaction childT2.
    topNBottom.setN(12);
    topNBottom.setTopBottomType(TopBottomTemplate.TOP_BOTTOM_TYPE_BOTTOM);

    // Save the child write Transaction as writeT3.
    Transaction writeT3 = tp.getCurrentTransaction();

    // Prepare and commit the write Transaction writeT3.
    prepareAndCommit();

    // The commit moves the changes made in writeT3 into its parent,
    // the read Transaction childT2. The writeT3 Transaction
    // disappears. The current Transaction is now childT2
    // again but the state of the TopBottomTemplate has changed.

    // Create a Cursor and display the results of the changes to the
    // TopBottomTemplate that are visible in childT2.
    try
    {
      println("\nIn the child Transaction, the state of the " +
              "\nTopBottomTemplate produces the following values:\n");
      getContext().displayTopBottomResult(result);
    }
    catch(Exception e)
    {
      println("Cannot display the results of the query. " + e);
    }

    // Begin a grandchild Transaction of the initial parent.
    tp.beginSubtransaction()// This is a read Transaction.

    // Save the grandchild read Transaction as grandchildT4.
    Transaction grandchildT4 = tp.getCurrentTransaction();

    // Change the state of the TopBottomTemplate. This starts another
    // write Transaction, a child of grandchildT4.
    topNBottom.setTopBottomType(TopBottomTemplate.TOP_BOTTOM_TYPE_TOP);

    // Save the write Transaction as writeT5.
    Transaction writeT5 = tp.getCurrentTransaction();

    // Prepare and commit writeT5.
View Full Code Here

TOP

Related Classes of com.narirelays.ems.olap.sample.chapter10.TopBottomTest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.