We do not want the post processor to execute when certain mandatory dimensions are not selected. For example, We have dimensions called risk type, sensi curve, maturity, currency1 and display currency. We also have post processing measure called Rate.Move - which implements doLeafEvaluation.
In our client,
From inside a post processor, there is only one way to discover the dimensions and levels that the user initially selected (most likely in an MDX query): you introspect the location evaluated by the post processor.
Here is a small post processor example (it is designed to run in the ActivePivot Sandbox application). The post processor defines a contextual dimension, the time dimension in this example. If the user has expanded the time dimension, then the evaluated location will have a depth of at least 2 (depth 1 means only the AllMember is selected for that dimension). Then you can decide to return a different measure or calculation based on that knowledge.
/*
* (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];
}
}
}
Here is how you can declare the post processor in the cube description:
<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>