当未选择强制尺寸时,我们如何使后处理器测量不显示数据?

时间:2012-11-13 17:38:25

标签: olap aggregation activepivot

我们不希望在未选择某些强制尺寸时执行后处理器。 例如, 我们有称为风险类型,敏感曲线,成熟度,货币1和显示货币的维度。 我们还有一个名为Rate.Move的后处理度量 - 它实现了doLeafEvaluation。

在我们的客户中,

  1. 如果未选择sensi曲线,我们不希望在风险类型为RateRisk时显示Rate.Move
  2. 如果未选择currency1,我们不希望显示Rate.Move,当风险类型为BasisSwapRisk时

1 个答案:

答案 0 :(得分:2)

从后处理器内部,只有一种方法可以发现用户最初选择的维度和级别(最有可能是在MDX查询中):您自省后期处理器评估的位置

这是一个小型后处理器示例(它设计为在ActivePivot Sandbox应用程序中运行)。后处理器定义上下文维度,此示例中为时间维度。如果用户已扩展时间维度,则评估的位置将具有至少2的深度(深度1表示仅为该维度选择AllMember)。然后,您可以决定根据该知识返回不同的度量或计算。

/*
 * (C) Quartet FS 2010
 * ALL RIGHTS RESERVED. This material is the CONFIDENTIAL and PROPRIETARY
 * property of Quartet Financial Systems Limited. Any unauthorized use,
 * reproduction or transfer of this material is strictly prohibited
 */
package com.quartetfs.pivot.sandbox.postprocessor.impl;

import java.util.Properties;

import com.quartetfs.biz.pivot.IActivePivot;
import com.quartetfs.biz.pivot.ILocation;
import com.quartetfs.biz.pivot.impl.Util;
import com.quartetfs.biz.pivot.postprocessing.impl.ABasicPostProcessor;
import com.quartetfs.fwk.QuartetException;
import com.quartetfs.fwk.QuartetExtendedPluginValue;

/**
 * 
 * @author Quartet FS
 *
 */
@QuartetExtendedPluginValue(
    interfaceName = "com.quartetfs.biz.pivot.postprocessing.IPostProcessor",
    key = ContextualPostProcessor.PLUGIN_TYPE
)
public class ContextualPostProcessor extends ABasicPostProcessor<Double> {

    /** serialVersionUID */
    private static final long serialVersionUID = 4484708084267009957L;

    /** Plugin key */
    static final String PLUGIN_TYPE = "CTX";

    /** Ordinal of the time dimension */
    protected int timeDimensionOrdinal = -1;

    /** Constructor */
    public ContextualPostProcessor(String name, IActivePivot pivot) {
        super(name, pivot);
    }

    @Override
    public String getType() { return PLUGIN_TYPE; }

    @Override
    public void init(Properties properties) throws QuartetException {
        super.init(properties);

        // Store the ordinal of the time dimension
        timeDimensionOrdinal = Util.findDimension(pivot.getDimensions(), "TimeBucket");
    }

    @Override
    protected Double doEvaluation(ILocation location, Object[] underlyingMeasures) throws QuartetException {
        if(location.getLevelDepth(timeDimensionOrdinal - 1) > 1) {
            return (Double) underlyingMeasures[0];
        } else {
            return (Double) underlyingMeasures[1];
        }
    }

}

以下是如何在多维数据集描述中声明后处理器:

    <measure name="ctx" isIntrospectionMeasure="false">

        <!-- This post processor dynamically buckets an underlying measure -->
        <!-- It works together with a dynamic bucket dimension.            -->
        <postProcessor pluginKey="CTX">
            <properties>
                <entry key="id" value="SUM" />
                <entry key="underlyingMeasures" value="pv.SUM,pnl.SUM" />
            </properties>
        </postProcessor>
    </measure>
相关问题