3

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

在我们的客户中,

  1. 如果未选择敏感曲线,我们不想在风险类型为 RateRisk 时显示 Rate.Move
  2. 如果没有选择货币 1,我们不想在风险类型为 BasisSwapRisk 时显示 Rate.Move
4

1 回答 1

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>
于 2012-11-14T09:18:08.440 回答