123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- /****************************************************************
- ** Licensed Materials - Property of IBM
- **
- ** BI and PM: qs
- **
- ** (C) Copyright IBM Corp. 2001, 2015
- **
- ** US Government Users Restricted Rights - Use, duplication or
- ** disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
- *****************************************************************/
- // Copyright (C) 2008 Cognos ULC, an IBM Company. All Rights Reserved.
- // Cognos and the Cognos logo are trademarks of Cognos ULC (formerly Cognos Incorporated) in the United States and/or other countries. IBM and the IBM logo are trademarks of International Business Machines Corporation in the United States, or other countries, or both. Other company, product, or service names may be trademarks or service marks of others.
- function CFormat()
- {
- };
- CFormat.prototype = new AFeatureObject();
- CFormat.prototype.setup = function (aFeatureParams)
- {
- if (typeof aFeatureParams != "undefined" && aFeatureParams instanceof Array && aFeatureParams.length > 0)
- {
- if (aFeatureParams[0] == "default")
- {
- validateFormat();
- }
- }
- };
- function submitFormat(oFormatValues)
- {
- var aFormatParams = new Array();
- for (var idxFormatVals = 0; idxFormatVals < oFormatValues.length; idxFormatVals++)
- {
- aFormatParams[aFormatParams.length] = oFormatValues[idxFormatVals];
- }
- var sCommand = createCommand("O", "F", aFormatParams);
- sendCmd(sCommand, "", false);
- };
- function validateFormat()
- {
- var oMQMgr = goApplicationManager.getMiniQueryManager();
- var numSel = cfgSize("SelColumns");
- if (numSel == 0)
- {
- dlgReset();
- cfgSet("LAST_DIALOG", "format");
- dlgShowMessage("FORMAT_TITLE", "", "FORMAT_NO_SELECTION");
- return;
- }
- else
- {
- if (!checkForValidSelection(true))
- return;
- var selTypes = getSelectionsDataType();
- if (selTypes === -1)
- {
- dlgShowMessage("FORMAT_TITLE", "", "FORMAT_SELECTION_TYPES_INVALID");
- return;
- }
- dlgReset();
- dlgGlobalReset();
- cfgSet("LAST_DIALOG", "format");
- var colFormatType = "";
- var errorMsg = "";
- cfgSet("formatDlgAdvanced","false");
- cfgRemove("formatCurrentNumDecs");
- cfgRemove("formatCurrentScale");
- cfgRemove("formatCurrentThousandSep");
- cfgRemove("formatCurrentPercentSymbol");
- cfgRemove("formatCurrentNegAtts");
- cfgRemove("formatCurrentSymbol");
- cfgRemove("formatCurrentDisp");
- for (var i = 0; i < numSel; i++)
- {
- if (oMQMgr.getDisplayType(cfgGetAt("SelColumns", i)) === 1)
- {
- dlgShowMessage("FORMAT_TITLE", "", "FORMAT_SELECTION_TYPES_INVALID");
- return;
- }
- }
-
-
- if (selTypes == 5 && oMQMgr.hasNumericDetailAggregate(cf.cfgGetAt("SelColumns", 0)))
- {
- selTypes = 0;
- }
-
- var currentFormat = getCurrentFormat();
- switch (selTypes)
- {
- case 0:
- colFormatType = currentFormat;
- var advType = oMQMgr.getFormatTypeForAdvanced(cfgGetAt("SelColumns", 0));
- if (advType === MINI_QUERY_ATTRIBUTE_NOT_FOUND)
- {
- advType = "";
- }
- if (advType == "true")
- {
- for (var i = 1; i < numSel; i++)
- {
- var sNextFormatType = oMQMgr.getFormatTypeForAdvanced(cfgGetAt("SelColumns", i));
- if (sNextFormatType === MINI_QUERY_ATTRIBUTE_NOT_FOUND)
- {
- sNextFormatType = "";
- }
- if (advType != sNextFormatType)
- {
- advType = "false";
- break;
- }
- }
- }
- cfgSet("formatDlgAdvanced",advType);
- cfgSet("formatDlgVars", colFormatType);
- if (colFormatType != "" && colFormatType != "mixed")
- {
- setFormatDlgVars("scale", "xxScale");
- setFormatDlgVars("percentSymbol", "xxPercentSymbol");
- if (advType == "true")
- {
- cfgSet("formatDlgVars", colFormatType +"A");
- setFormatDlgVars("pattern", "xxPattern");
- setFormatDlgVars("whenNegative", "xxNegative");
- setFormatDlgVars("whenZero", "xxZero");
- setFormatDlgVars("whenMissing", "xxMissing");
- }
- else
- {
- setFormatDlgVars("decimalSize", "xxDecimalSize");
- setFormatDlgVars("useGrouping", "xxGrouped");
- setFormatDlgVars("sign", "xxSign");
- setFormatDlgVars("useTrailingSign", "xxTrailingSign");
- setFormatDlgVars("currencyCode", "xxCurrencyCode");
- setFormatDlgVars("useIntlSymbol", "xxIntlSymbol");
- }
- }
- else if (colFormatType == "")
- colFormatType = "default";
- break;
- case 1:
- colFormatType = "date";
- case 2:
- if (colFormatType == "")
- colFormatType = "time";
- case 3:
- if (colFormatType == "")
- colFormatType = "datetime";
- case 4:
- if (colFormatType == "")
- colFormatType = "interval";
- if (currentFormat == "")
- currentFormat ="default";
- dlgGlobalSetParm("xxDateTime", currentFormat);
- if (currentFormat != "default" && currentFormat != "mixed")
- {
- if(!isFormatCommon())
- currentFormat = "mixed";
- }
- dlgGlobalSetParm("xxSelectedFormat", currentFormat);
- break;
- case 5:
- colFormatType = "text";
- setFormatDlgVars("textLength", "xxTextLength");
- break;
- case 6:
- case 7:
- dlgShowMessage("FORMAT_TITLE", "", "FORMAT_SELECTION_TYPES_INVALID");
- return;
- default:
- dlgShowMessage("FORMAT_TITLE", "", "FORMAT_SELECTION_TYPES_DIFFER");
- return;
- }
- for (var j=0; j < numSel; j++)
- dlgGlobalSetParmAt("xxformatSelCols", dlgGlobalSize('xxformatSelCols'), oMQMgr.getColumnId(cfgGetAt("SelColumns", j)));
- cfgSet("formatDlgType", colFormatType);
- }
- format();
- };
- function getCurrentFormat()
- {
- var oMQMgr = goApplicationManager.getMiniQueryManager();
- var numSel = cfgSize("SelColumns");
- var colFormatType = oMQMgr.getFormatType(cfgGetAt("SelColumns", 0));
- if (colFormatType === MINI_QUERY_ATTRIBUTE_NOT_FOUND)
- {
- colFormatType = "";
- }
- for (var i = 1; i < numSel; i++)
- {
- var sNextFormatType = oMQMgr.getFormatType(cfgGetAt("SelColumns", i));
- if (sNextFormatType === MINI_QUERY_ATTRIBUTE_NOT_FOUND)
- {
- sNextFormatType = "";
- }
- if (colFormatType != sNextFormatType)
- {
- colFormatType = "mixed";
- break;
- }
- }
- return colFormatType;
- };
- function findFormatInSampleList(SampleListName)
- {
- var numSel = cfgSize("SelColumns");
- var formatArray = cfgGetAt("ColFormat", cfgGetAt("SelColumns", 0));
- var formatSize = formatArray.length;
- var sampleListSize = cfgSize(SampleListName);
- if (formatSize > 0 && sampleListSize > 0)
- {
- for (var sampleIter = 0; sampleIter < sampleListSize; sampleIter++)
- {
- var sampleFormat = cfgGetAt(SampleListName, sampleIter);
- var sampleSize = sampleFormat.length;
- if (formatSize == sampleSize || formatArray[0] == sampleFormat[0])
- {
- var attIter = 1;
- while (attIter + 1 < formatSize)
- {
- if (!isFormatAttributeEqual(formatArray[attIter], formatArray[attIter + 1],SampleListName, sampleIter))
- break;
- attIter = attIter + 2;
- }
- if (attIter >= formatSize)
- return sampleIter;
- }
- }
- }
- return -1;
- };
- function isFormatCommon()
- {
- var numSel = cfgSize("SelColumns");
- var formatArray = cfgGetAt("ColFormat", cfgGetAt("SelColumns", 0));
- var formatSize = formatArray.length;
- if (formatSize < 1)
- return false;
- var colIter = 1;
- var format = formatArray[0];
- for (colIter = 1; colIter < numSel; colIter++)
- {
- var nextformatArray = cfgGetAt("ColFormat", cfgGetAt("SelColumns", colIter));
- var nextFormatSize = nextformatArray.length;
- if (formatSize != nextFormatSize || format != nextformatArray[0])
- return false;
- }
- var attIter = 1;
- while (attIter + 1 < formatSize)
- {
- var attValue = formatArray[attIter + 1];
- for (colIter = 1; colIter < numSel; colIter++)
- {
- if (!isFormatAttributeEqual(formatArray[attIter], attValue, "ColFormat", cfgGetAt("SelColumns", colIter)))
- return false;
- }
- attIter = attIter + 2;
- }
- return ((attIter >= formatSize) ? true : false);
- };
- function isFormatAttributeEqual(attName, attValue, arrayName, arrayIndex)
- {
- return (attValue == getAttValFromFormatArray(attName, arrayName, arrayIndex));
- };
- function getAttValFromFormatArray(attName, arrayName, arrayIndex)
- {
- var formatArray = cfgGetAt(arrayName, arrayIndex);
- var size = formatArray.length;
- var i = 1;
- while (i < size)
- {
- if (formatArray[i] == attName)
- return formatArray[i + 1];
- else
- i = i + 2;
- }
- return "";
- };
- function setFormatDlgVars(attribute, dlgVarName)
- {
- var numSel = cfgSize("SelColumns");
- var value = getAttValFromFormatArray(attribute,"ColFormat",cfgGetAt("SelColumns", 0));
- for (var i = 1; i < numSel; i++)
- {
- if (value != getAttValFromFormatArray(attribute, "ColFormat", cfgGetAt("SelColumns", i)))
- {
- dlgGlobalSetParm(dlgVarName, "mixed");
- return;
- }
- }
- dlgGlobalSetParm(dlgVarName, value);
- };
- function format()
- {
- cfgSet("LAST_DIALOG", "format");
- var formatDlgType = cfgGet("formatDlgType");
- dlgGlobalSetParm("xxformatDlgType", formatDlgType);
- if (cfgGet("formatDlgAdvanced") == "true")
- dlgSetParm("m", "/" + qs_dir + "/formatNumericAdvanced.xts");
- else if (formatDlgType == "text")
- dlgSetParm("m", "/" + qs_dir + "/formatText.xts");
- else if (formatDlgType == "interval" || formatDlgType == "datetime" || formatDlgType == "date" || formatDlgType == "time")
- {
- dlgSetParm("m", "/" + qs_dir + "/formatSamples.xts");
- dlgSetParm("samplesLoaded", (cfgGet("formatSamplesLoaded")? true:false));
- }
- else
- {
- dlgSetParm("m", "/" + qs_dir + "/formatNumeric.xts");
- dlgSetParm("listsLoaded", (cfgGet("formatListsLoaded")? true:false));
- }
- dlgSubmit();
- };
|