Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private sanitizeFilter(filter: AFM.CompatibilityFilter): ExecuteAFM.CompatibilityFilter | null {
if (AFM.isAttributeFilter(filter)) {
return convertAttributeFilter(filter);
} else if (AFM.isAbsoluteDateFilter(filter)) {
return convertAbsoluteDateFilter(filter);
} else if (AFM.isRelativeDateFilter(filter)) {
return convertRelativeDateFilter(filter);
}
return filter;
}
}
function isDateFilterAllTime(dateFilter: AFM.DateFilterItem): boolean {
if (AFM.isRelativeDateFilter(dateFilter)) {
return dateFilter.relativeDateFilter.granularity === ALL_TIME_GRANULARITY;
}
return false;
}
export function getDateFilterDateDataSet(filter: AFM.DateFilterItem): AFM.ObjQualifier {
if (AFM.isRelativeDateFilter(filter)) {
return filter.relativeDateFilter.dataSet;
}
if (AFM.isAbsoluteDateFilter(filter)) {
return filter.absoluteDateFilter.dataSet;
}
throw new Error("Unsupported type of date filter");
}
export function getDateFilterDateDataSet(filter: AFM.DateFilterItem): AFM.ObjQualifier {
if (AFM.isRelativeDateFilter(filter)) {
return filter.relativeDateFilter.dataSet;
}
if (AFM.isAbsoluteDateFilter(filter)) {
return filter.absoluteDateFilter.dataSet;
}
throw new Error("Unsupported type of date filter");
}
private sanitizeFilter(filter: AFM.CompatibilityFilter): ExecuteAFM.CompatibilityFilter | null {
if (AFM.isAttributeFilter(filter)) {
return convertAttributeFilter(filter);
} else if (AFM.isAbsoluteDateFilter(filter)) {
return convertAbsoluteDateFilter(filter);
} else if (AFM.isRelativeDateFilter(filter)) {
return convertRelativeDateFilter(filter);
}
return filter;
}
}
function getFormat(measure: IMeasure): string | undefined {
const {
measure: { definition },
} = measure;
const measureFormat = get(measure.measure, "format");
if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
if (definition.arithmeticMeasure.operator === "change") {
return "#,##0.00%";
}
}
const predefinedFormat = VisualizationObject.isMeasureDefinition(definition)
? getPredefinedFormat(definition)
: undefined;
return predefinedFormat || measureFormat;
}
function convertMeasureDefinition(definition: IMeasureDefinitionType): AFM.MeasureDefinition {
if (VisualizationObject.isMeasureDefinition(definition)) {
return convertSimpleMeasureDefinition(definition);
} else if (VisualizationObject.isPopMeasureDefinition(definition)) {
return convertPopMeasureDefinition(definition);
} else if (VisualizationObject.isPreviousPeriodMeasureDefinition(definition)) {
return convertPreviousPeriodMeasureDefinition(definition);
} else if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
return convertArithmeticMeasureDefinition(definition);
} else {
throw Error("The measure definition is not supported: " + JSON.stringify(definition));
}
}
function convertMeasureDefinition(definition: IMeasureDefinitionType): AFM.MeasureDefinition {
if (VisualizationObject.isMeasureDefinition(definition)) {
return convertSimpleMeasureDefinition(definition);
} else if (VisualizationObject.isPopMeasureDefinition(definition)) {
return convertPopMeasureDefinition(definition);
} else if (VisualizationObject.isPreviousPeriodMeasureDefinition(definition)) {
return convertPreviousPeriodMeasureDefinition(definition);
} else if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
return convertArithmeticMeasureDefinition(definition);
} else {
throw Error("The measure definition is not supported: " + JSON.stringify(definition));
}
}
function getFormat(measure: IMeasure): string | undefined {
const {
measure: { definition },
} = measure;
const measureFormat = get(measure.measure, "format");
if (VisualizationObject.isArithmeticMeasureDefinition(definition)) {
if (definition.arithmeticMeasure.operator === "change") {
return "#,##0.00%";
}
}
const predefinedFormat = VisualizationObject.isMeasureDefinition(definition)
? getPredefinedFormat(definition)
: undefined;
return predefinedFormat || measureFormat;
}
afmFilters = afmFilters.filter(filter => {
if (AFM.isDateFilter(filter)) {
return !dateFiltersDataSetsMatch(filter, dateFilter);
}
return true;
});
}