Ниже приведён пример использования операции SetCube для настройки агрегации по уровням календарного измерения куба. В запросе передаются моникёр куба, шаблон, указывающий необходимость добавить настройки агрегации по измерению и обновленные метаданные, содержащие эти настройки. В ответе приходит обновленная информация о вариантах отображения куба.
{
"SetCube" :
{
"tCube" :
{
"id" : "S1!M!S!C1"
},
"tArg" :
{
"pattern" :
{
"obInst" : "true",
"dests" : "Change",
"dest" :
{
"dims" : "Change",
"dim" :
{
"aggregations" : "Add"
}
}
},
"meta" :
{
"dests" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"dims" :
{
"its" :
{
"it" :
[
{
"k" : "112",
"aggs" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"factKey" : "1",
"isChrono" : "true",
"chronoAggregator" :
{
"dimLevelsAggregators" :
{
"its" :
{
"it" :
[
{
"k" : "2",
"operation" : "UniformDisaggregation",
"sourceLevel" :
{
"k" : "1",
"id" : "YEARS",
"n" : "Годы",
"vis" : "true"
}
}
]
}
}
}
}
]
}
}
}
]
}
}
}
]
}
}
},
"metaGet" :
{
"obInst" : "true",
"dests" : "Get",
"dest" :
{
"all" : "true"
}
}
}
}
}
{
"SetCubeResult" :
{
"id" :
{
"id" : "S1!M!S!C1"
},
"meta" :
{
"obInst" :
{
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "34",
"@hf" : "0",
"i" : "STD_CUBE",
"n" : "Куб",
"k" : "5857",
"c" : "1281",
"p" : "5845",
"h" : "0",
"hasPrv" : "0",
"ic" : "0",
"isPermanent" : "1",
"isTemp" : "0"
}
},
"dirty" : "0",
"dests" :
{
"its" :
{
"it" :
[
{
"k" : "1",
"id" : "STD_CUBE",
"n" : "Куб",
"vis" : "1",
"isDefault" : "1",
"hideTrivialFactDimension" : "0",
"selSetOriginalOnly" : "0",
"useMultiAttrTable" : "0",
"datasets" :
{
"its" :
{
"it" :
[
{
"k" : "5878",
"id" : "OBJ5877",
"n" : "Таблица",
"vis" : "1",
"aggrType" : "Server",
"useSubqueryOptimization" : "1"
}
]
}
},
"dims" :
{
"its" :
{
"it" :
[
{
"k" : "5858",
"id" : "FACTS",
"n" : "Факты",
"vis" : "1",
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "34",
"@hf" : "0",
"i" : "FACTS",
"n" : "Факты",
"k" : "5858",
"c" : "1028",
"p" : "5857",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"aggsPresent" : "0",
"hierAggsPresent" : "0"
},
{
"k" : "112",
"id" : "CALENDAR",
"n" : "Календарь",
"vis" : "1",
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "6",
"@hf" : "0",
"i" : "CALENDAR",
"n" : "Календарь",
"k" : "112",
"c" : "1026",
"p" : "103",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"aggs" :
{
"its" :
{
"it" :
[
{
"k" : "4294967295",
"id" : "CHRONOLOGICALMATRIXAGGREGATOR",
"n" : "Хронологический агрегатор",
"vis" : "1",
"factKey" : "1",
"isChrono" : "1",
"operations" :
{
"its" :
{
"it" :
[
{
"k" : "0",
"n" : "Нет"
},
{
"k" : "1",
"n" : "Среднее хронологическое"
},
{
"k" : "2",
"n" : "Равномерная дезагрегация"
}
]
}
},
"chronoAggregator" :
{
"defaultLevelAggregation" :
{
"k" : "4294967295",
"vis" : "1",
"includeChildren" : "1",
"useDefaultLevelAggregation" : "0",
"operation" : "None",
"resultToSourceLevel" : "1",
"resultToThisLevel" : "1"
},
"dimLevelsAggregators" :
{
"its" :
{
"it" :
[
{
"k" : "2",
"id" : "HALF_YEARS",
"n" : "Полугодия",
"vis" : "1",
"includeChildren" : "0",
"useDefaultLevelAggregation" : "0",
"operation" : "UniformDisaggregation",
"sourceLevel" :
{
"k" : "1",
"id" : "YEARS",
"n" : "Годы",
"vis" : "1"
},
"resultToSourceLevel" : "1",
"resultToThisLevel" : "0"
}
]
}
},
"levelAggsPresent" : "1"
}
}
]
}
},
"aggsPresent" : "1",
"hierAggsPresent" : "0"
},
{
"k" : "116",
"id" : "DIM_1",
"n" : "Dim_1",
"vis" : "1",
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "3",
"@hf" : "0",
"i" : "DIM_1",
"n" : "Dim_1",
"k" : "116",
"c" : "1025",
"p" : "103",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"aggsPresent" : "0",
"hierAggsPresent" : "0"
},
{
"k" : "991",
"id" : "DIM_2",
"n" : "Dim_2",
"vis" : "1",
"obDesc" :
{
"@ds" : "",
"@isShortcut" : "0",
"@isLink" : "0",
"@ver" : "0",
"@hf" : "0",
"i" : "DIM_2",
"n" : "Dim_2",
"k" : "991",
"c" : "1025",
"p" : "10529",
"h" : "0",
"hasPrv" : "0",
"ic" : "0"
},
"aggsPresent" : "0",
"hierAggsPresent" : "0"
}
]
}
},
"dimBinds" :
{
"its" :
{
"it" :
[
{
"dimKey" : "5858",
"datasets" :
{
"it" :
{
"dsKey" : "5878"
}
}
},
{
"dimKey" : "112",
"datasets" :
{
"it" :
{
"dsKey" : "5878",
"indexKey" : "7",
"indexBlockKey" : "3",
"attrs" :
{
"it" :
{
"attrKey" : "2",
"fieldId" : "V_DATE",
"formula" : "OBJ5877.V_DATE"
}
}
}
}
},
{
"dimKey" : "116",
"datasets" :
{
"it" :
{
"dsKey" : "5878",
"indexKey" : "121",
"indexBlockKey" : "120",
"attrs" :
{
"it" :
{
"attrKey" : "118",
"fieldId" : "DIM1_ID",
"formula" : "OBJ5877.DIM1_ID"
}
}
}
}
},
{
"dimKey" : "991",
"datasets" :
{
"it" :
{
"dsKey" : "5878",
"indexKey" : "1001",
"indexBlockKey" : "1000",
"attrs" :
{
"it" :
{
"attrKey" : "993",
"fieldId" : "DIM2_ID",
"formula" : "OBJ5877.DIM2_ID"
}
}
}
}
}
]
}
},
"factBinds" :
{
"its" :
{
"it" :
[
{
"factKey" : "1",
"dsKey" : "5878",
"formula" : "OBJ5877.VALUE",
"aggrType" : "None"
},
{
"factKey" : "1",
"dsKey" : "5878",
"formula" : "",
"aggrType" : "None"
}
]
}
},
"calcBinds" :
{
"its" :
{
"it" :
[
{
"factKey" : "1",
"formula" : "",
"revFactKey" : "",
"revFormula" : "",
"timeLagLevel" : "None",
"timeForwardLag" : "0",
"timeBackwardLag" : "0",
"includeInSelection" : "0",
"calcMethod" : "BySelection"
},
{
"factKey" : "1",
"formula" : "",
"revFactKey" : "",
"revFormula" : "",
"timeLagLevel" : "None",
"timeForwardLag" : "0",
"timeBackwardLag" : "0",
"includeInSelection" : "0",
"calcMethod" : "ByMatrix"
}
]
}
},
"relations" :
{
"its" : ""
},
"selControl" :
{
"its" : "",
"options" : "",
"isEmpty" : "1"
}
}
]
}
},
"supportsRub" : "0"
}
}
}
public static SetCubeResult AddAggregation(CubeId moniker, DmMetadata calendarDim)
{
var somClient = new SomPortTypeClient(); //Прокси-объект для выполнения операций
//Параметры выполнения операции
var tSet = new SetCube()
{
tArg = new SetCubeArg()
{
//Шаблон, указывающий необходимость настроить агрегацию в кубе
pattern = new CubeMdPattern()
{
dests = ListOperation.Change,
dest = new CubeDestPattern()
{
dims = ListOperation.Change,
dim = new CubeDimPattern()
{
aggregations = ListOperation.Add
}
}
},
//Обновленные метаданные, содержащие параметры агрегации: равномерная дезагризация с уровня календаря
meta = new CubeMd
{
dests = new CubeDests()
{
its = new CubeDest[]
{
new CubeDest()
{
k = 1,
dims = new CubeDims()
{
its = new CubeDim[]
{
new CubeDim()
{
k = calendarDim.descr.k,
aggs = new MatrixAggregators()
{
its = new MatrixAggregator[]
{
new MatrixAggregator()
{
factKey = "1",
isChrono = true,
chronoAggregator = new ChronoMatrixAggregator()
{
dimLevelsAggregators = new ChronoDimLevelAggregators()
{
its= new ChronoDimLevelAggregator[]
{
new ChronoDimLevelAggregator()
{
k = calendarDim.levs[1].k, // Уровень-приёмник
operation = ChronologicalAggregatorOper.UniformDisaggregation,
sourceLevel = calendarDim.levs[0] //Уровень-источник
}
}
}
}
}
}
}
}
}
}
}
}
}
},
metaGet = new CubeMdPattern()
{
dests = ListOperation.Get,
dest = new CubeDestPattern()
{
all = true
}
}
},
tCube = moniker
};
//Изменение куба
var result = somClient.SetCube(tSet);
return result;
}
См. также: