123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323 |
- 'use strict';
- /*
- *+------------------------------------------------------------------------+
- *| Licensed Materials - Property of IBM
- *| IBM Cognos Products: BI Dashboard
- *| (C) Copyright IBM Corp. 2016, 2017
- *|
- *| US Government Users Restricted Rights - Use, duplication or disclosure
- *| restricted by GSA ADP Schedule Contract with IBM Corp.
- *+------------------------------------------------------------------------+
- */
- define(['../../../lib/@waca/core-client/js/core-client/ui/core/Class', '../../../lib/@waca/upgrades/UpgradeBase', './RAVE1ArcheTypes', 'underscore'], function (Class, UpgradeBase, ArcheTypes, _) {
- /*upgrade handlers that have special logic to do properties/slots upgrade instead of just IDs conversions*/
- var UPGRADE_HANDLDERS = {
- pieAsDonutUpgradeHandler: function pieAsDonutUpgradeHandler(value) {
- if (value + '' !== 'true') {
- return 1;
- }
- return 0.4;
- },
- hideRadialValueHandler: function hideRadialValueHandler(value) {
- if (value + '' === 'true') {
- return 'none';
- }
- return 'center';
- }
- };
- /*Common slots and properties upgrade mappings across all widgets*/
- var COMMON_UPGRADE_MAPPINGS = {
- SLOTS: {
- //No common slots upgrade currently
- },
- PROPERTIES: {
- 'legendPosition': {
- 'id': 'legend.position'
- }
- }
- };
- /*Individual chart slots and properties upgrade mappings*/
- var UPGRADE_MAPPINGS = {
- 'area': {
- 'ID': 'RAVE2_smoothArea',
- 'SLOTS': {
- 'categories': 'x',
- 'color': 'color',
- 'values': 'y'
- }
- },
- 'pie': {
- 'ID': 'RAVE2_pie',
- 'SLOTS': {
- 'categories': 'color',
- 'values': 'value'
- },
- 'PROPERTIES': {
- 'pieAsDonut': {
- 'id': 'donutRadius',
- 'propertyValueHandler': UPGRADE_HANDLDERS.pieAsDonutUpgradeHandler
- },
- 'hideRadialValue': {
- 'id': 'labelLocation',
- 'propertyValueHandler': UPGRADE_HANDLDERS.hideRadialValueHandler
- }
- }
- },
- 'clusterLine': {
- 'ID': 'RAVE2_smoothline',
- 'SLOTS': {
- 'categories': 'x',
- 'values': 'y',
- 'color': 'color',
- 'valuesRepeating': 'y0'
- },
- 'PROPERTIES': {
- 'symbolShape': {
- 'id': 'lineWithPoints.symbol' //RAVE2 default to circle
- }
- }
- },
- 'bubble': {
- 'ID': 'RAVE2_bubble',
- 'SLOTS': {
- 'xAxis': 'x',
- 'yAxis': 'y',
- 'size': 'size',
- 'color': 'color'
- }
- },
- 'packedBubble': {
- 'ID': 'RAVE2_packedBubble',
- 'SLOTS': {
- 'categories': 'label',
- 'color': 'color',
- 'size': 'size'
- }
- },
- 'radial': {
- 'ID': 'RAVE2_multipleDialCategoryLabel',
- 'SLOTS': {
- 'categories': 'category',
- 'values': 'value',
- 'maxSize': 'maxValue'
- }
- },
- 'radialBar': {
- 'ID': 'RAVE2_dial',
- 'SLOTS': {
- 'categories': 'label',
- 'values': 'value'
- }
- },
- 'point': {
- 'ID': 'RAVE2_point',
- 'SLOTS': {
- 'categories': 'x',
- 'values': 'y',
- 'color': 'color'
- }
- },
- 'clusterColumn': {
- 'ID': 'RAVE2_clusteredcolumn',
- 'SLOTS': {
- 'categories': 'x',
- 'color': 'color',
- 'values': 'y',
- 'valuesRepeating': 'y0'
- }
- },
- 'stackedColumn': {
- 'ID': 'RAVE2_stackedcolumn',
- 'SLOTS': {
- 'categories': 'x',
- 'color': 'color',
- 'values': 'y',
- 'valuesRepeating': 'y0'
- }
- },
- 'clusterBar': {
- 'ID': 'RAVE2_clusteredbar',
- 'SLOTS': {
- 'categories': 'x',
- 'color': 'color',
- 'values': 'y',
- 'valuesRepeating': 'y0'
- }
- },
- 'stackedBar': {
- 'ID': 'RAVE2_stackedbar',
- 'SLOTS': {
- 'categories': 'x',
- 'color': 'color',
- 'values': 'y',
- 'valuesRepeating': 'y0'
- }
- },
- 'wordCloud': {
- 'ID': 'RAVE2_wordcloud',
- 'SLOTS': {
- 'word': 'label',
- 'color': 'color',
- 'scale': 'size'
- }
- },
- 'scatterPlot': {
- 'ID': 'RAVE2_scatter',
- 'SLOTS': {
- 'xAxis': 'x',
- 'yAxis': 'y',
- 'categories': 'label',
- 'color': 'color'
- }
- },
- 'lineColumnCombo': {
- 'ID': 'RAVE2_compositeSmoothOneDataSet',
- 'SLOTS': {
- 'lineValue': 'yLine',
- 'columnValue': 'y',
- 'category': 'x'
- },
- 'PROPERTIES': {
- 'symbolShape': {
- 'id': 'lineWithPoints.symbol'
- }
- }
- },
- 'heat': {
- 'ID': 'RAVE2_heatmap',
- 'SLOTS': {
- 'xAxis': 'x',
- 'yAxis': 'y',
- 'values': 'color'
- }
- }
- };
- var Upgrade = Class.extend([UpgradeBase], {
- init: function init() {
- this.VERSION = 7;
- },
- /**
- * Perform upgrade
- *
- * @param {object} spec - spec to perform upgrade on
- *
- * @return {Promise} Promise to be resolved when upgrade performed
- */
- up: function up(spec) {
- if (!spec) {
- return Promise.resolve(spec);
- }
- _.each(spec.widgets, this._widgetSpecUpgrade.bind(this));
- return Promise.resolve(spec);
- },
- _widgetSpecUpgrade: function _widgetSpecUpgrade(oWidgetSpec) {
- var sArchetype = oWidgetSpec.archetype || ArcheTypes.getArcheTypeFromVizId(oWidgetSpec.visId);
- if (sArchetype) {
- var oUpgradedArcheType = UPGRADE_MAPPINGS[sArchetype];
- if (oUpgradedArcheType) {
- if (oWidgetSpec.archetype) {
- oWidgetSpec.archetype = oUpgradedArcheType.ID;
- }
- oWidgetSpec.visId = oUpgradedArcheType.ID;
- this._slotsUpgrade(oWidgetSpec.id, oWidgetSpec.mapping, sArchetype);
- this._propertyUpgrade(oWidgetSpec.properties, sArchetype);
- }
- }
- },
- _propertyUpgrade: function _propertyUpgrade(properties, archetype) {
- _.each(properties, function (property) {
- this._upgradeSingleProperty(property, COMMON_UPGRADE_MAPPINGS.PROPERTIES);
- if (UPGRADE_MAPPINGS[archetype] && UPGRADE_MAPPINGS[archetype].PROPERTIES) {
- this._upgradeSingleProperty(property, UPGRADE_MAPPINGS[archetype].PROPERTIES);
- }
- }.bind(this));
- },
- _upgradeSingleProperty: function _upgradeSingleProperty(property, propertiesMap) {
- var oMatched = propertiesMap[property.id];
- if (oMatched) {
- var sValue = property.value;
- if (oMatched.propertyValueHandler) {
- sValue = oMatched.propertyValueHandler(property.value);
- }
- property.id = oMatched.id;
- property.value = sValue;
- }
- },
- _slotsUpgrade: function _slotsUpgrade(widgetID, oOldSlots, sArchetype) {
- var oMappedRave2Slots = UPGRADE_MAPPINGS[sArchetype].SLOTS;
- _.each(oOldSlots, function (slot) {
- var sId = oMappedRave2Slots[slot.slotId];
- if (!sId) {
- var logger = this.data && this.data.logger && this.data.logger;
- if (logger) {
- this.data.logger.warn('No id for ' + widgetID + ' archetype ' + sArchetype + ' slotId ' + slot.slotId);
- }
- } else {
- slot.id = sId;
- slot.slotId = sId;
- }
- }.bind(this));
- },
- down: function down(spec) {
- // no downgrade at this time; return as is
- return Promise.resolve(spec);
- }
- });
- return new Upgrade();
- });
- //# sourceMappingURL=7.js.map
|