@sapui5/sap.ushell_abap 1.94.0 → 1.96.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (115) hide show
  1. package/package.json +1 -1
  2. package/src/main/js/sap/ui2/srvc/ODataWrapper.js +1 -1
  3. package/src/main/js/sap/ushell_abap/.library +4 -9
  4. package/src/main/js/sap/ushell_abap/adapters/abap/AdapterContainer.js +12 -5
  5. package/src/main/js/sap/ushell_abap/adapters/abap/AppStateAdapter.js +11 -7
  6. package/src/main/js/sap/ushell_abap/adapters/abap/ClientSideTargetResolutionAdapter.js +47 -32
  7. package/src/main/js/sap/ushell_abap/adapters/abap/ConfigurationDefaultsAdapter.js +1 -1
  8. package/src/main/js/sap/ushell_abap/adapters/abap/ContainerAdapter.js +46 -38
  9. package/src/main/js/sap/ushell_abap/adapters/abap/LaunchPageAdapter.js +438 -398
  10. package/src/main/js/sap/ushell_abap/adapters/abap/NavTargetResolutionAdapter.js +1 -1
  11. package/src/main/js/sap/ushell_abap/adapters/abap/PageBuildingAdapter.js +25 -15
  12. package/src/main/js/sap/ushell_abap/adapters/abap/PagePersistenceAdapter.js +3 -2
  13. package/src/main/js/sap/ushell_abap/adapters/abap/PersonalizationAdapter.js +16 -7
  14. package/src/main/js/sap/ushell_abap/adapters/abap/SearchAdapter.js +1 -1
  15. package/src/main/js/sap/ushell_abap/adapters/abap/SupportTicketAdapter.js +8 -8
  16. package/src/main/js/sap/ushell_abap/adapters/abap/Ui5ComponentLoaderAdapter.js +1 -1
  17. package/src/main/js/sap/ushell_abap/adapters/abap/UserInfoAdapter.js +11 -4
  18. package/src/main/js/sap/ushell_abap/adapters/hana/ContainerAdapter.js +9 -3
  19. package/src/main/js/sap/ushell_abap/bootstrap/evo/XhrLogonEventHandler.js +13 -11
  20. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def-dev.js +1 -1
  21. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap-def.js +1 -1
  22. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.bootstrap.utils.js +8 -4
  23. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.configure.ushell.js +1 -1
  24. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.constants.js +9 -0
  25. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.get.server.config.Urls.js +12 -5
  26. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.load.launchpad.js +21 -22
  27. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.pageset.js +8 -2
  28. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.server.config.js +6 -3
  29. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.request.startup.js +10 -5
  30. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.ui5.boot.handler.js +7 -4
  31. package/src/main/js/sap/ushell_abap/bootstrap/evo/abap.xhr.handler.js +10 -3
  32. package/src/main/js/sap/ushell_abap/bootstrap/evo/boottask.js +21 -16
  33. package/src/main/js/sap/ushell_abap/library.js +2 -2
  34. package/src/main/js/sap/ushell_abap/pbServices/ui2/AllCatalogs.js +186 -0
  35. package/src/main/js/sap/ushell_abap/pbServices/ui2/Bag.js +704 -0
  36. package/src/main/js/sap/ushell_abap/pbServices/ui2/Catalog.js +930 -0
  37. package/src/main/js/sap/ushell_abap/pbServices/ui2/Chip.js +1027 -0
  38. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipDefinition.js +216 -0
  39. package/src/main/js/sap/ushell_abap/pbServices/ui2/ChipInstance.js +933 -0
  40. package/src/main/js/sap/ushell_abap/pbServices/ui2/Error.js +45 -0
  41. package/src/main/js/sap/ushell_abap/pbServices/ui2/Factory.js +647 -0
  42. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataService.js +251 -0
  43. package/src/main/js/sap/ushell_abap/pbServices/ui2/ODataWrapper.js +1262 -0
  44. package/src/main/js/sap/ushell_abap/pbServices/ui2/Page.js +920 -0
  45. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageBuildingService.js +1498 -0
  46. package/src/main/js/sap/ushell_abap/pbServices/ui2/PageSet.js +466 -0
  47. package/src/main/js/sap/ushell_abap/pbServices/ui2/RemoteCatalogService.js +52 -0
  48. package/src/main/js/sap/ushell_abap/pbServices/ui2/Utils.js +767 -0
  49. package/src/main/js/sap/ushell_abap/pbServices/ui2/chipdefinition.xsd +139 -0
  50. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/actions.js +244 -0
  51. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/bag.js +150 -0
  52. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configuration.js +165 -0
  53. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/configurationUi.js +330 -0
  54. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/fullscreen.js +70 -0
  55. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/navigation.js +50 -0
  56. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/preview.js +289 -0
  57. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/refresh.js +43 -0
  58. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/search.js +115 -0
  59. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/types.js +9 -0
  60. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/url.js +105 -0
  61. package/src/main/js/sap/ushell_abap/pbServices/ui2/contracts/visible.js +128 -0
  62. package/ui5.yaml +30 -0
  63. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/Component.js +0 -426
  64. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/css/style.css +0 -1
  65. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n.properties +0 -56
  66. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ar.properties +0 -36
  67. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_bg.properties +0 -36
  68. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ca.properties +0 -36
  69. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_cs.properties +0 -36
  70. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_cy.properties +0 -36
  71. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_da.properties +0 -36
  72. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_de.properties +0 -36
  73. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_el.properties +0 -36
  74. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_en.properties +0 -36
  75. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_en_GB.properties +0 -36
  76. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_en_US_sappsd.properties +0 -36
  77. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_en_US_saprigi.properties +0 -36
  78. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_en_US_saptrc.properties +0 -36
  79. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_es.properties +0 -36
  80. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_es_MX.properties +0 -36
  81. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_et.properties +0 -36
  82. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_fi.properties +0 -36
  83. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_fr.properties +0 -36
  84. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_fr_CA.properties +0 -36
  85. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_hi.properties +0 -36
  86. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_hr.properties +0 -36
  87. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_hu.properties +0 -36
  88. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_id.properties +0 -36
  89. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_it.properties +0 -36
  90. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_iw.properties +0 -36
  91. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ja.properties +0 -36
  92. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_kk.properties +0 -36
  93. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ko.properties +0 -36
  94. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_lt.properties +0 -36
  95. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_lv.properties +0 -36
  96. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ms.properties +0 -36
  97. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_nl.properties +0 -36
  98. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_no.properties +0 -36
  99. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_pl.properties +0 -36
  100. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_pt.properties +0 -36
  101. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_pt_PT.properties +0 -36
  102. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ro.properties +0 -36
  103. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_ru.properties +0 -36
  104. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_sh.properties +0 -36
  105. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_sk.properties +0 -36
  106. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_sl.properties +0 -36
  107. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_sv.properties +0 -36
  108. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_th.properties +0 -36
  109. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_tr.properties +0 -36
  110. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_uk.properties +0 -36
  111. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_vi.properties +0 -36
  112. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_zh_CN.properties +0 -36
  113. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/i18n/i18n_zh_TW.properties +0 -36
  114. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/manifest.json +0 -153
  115. package/src/main/js/sap/ushell_abap/plugins/fcc-transport-ui/model/models.js +0 -14
@@ -0,0 +1,1027 @@
1
+ // Copyright (c) 2009-2021 SAP SE. All rights reserved.
2
+
3
+ /**
4
+ * @fileOverview The <code>sap.ushell_abap.pbServices.ui2.Chip</code> object with related functions.
5
+ */
6
+
7
+ sap.ui.define([
8
+ "sap/ushell_abap/pbServices/ui2/Bag",
9
+ "sap/ushell_abap/pbServices/ui2/Utils",
10
+ "sap/ushell_abap/pbServices/ui2/Error",
11
+ "sap/ushell_abap/pbServices/ui2/ChipDefinition",
12
+ "sap/base/Log",
13
+ "sap/ui/thirdparty/jquery"
14
+ ], function (
15
+ Bag,
16
+ Utils,
17
+ SrvcError,
18
+ ChipDefinition,
19
+ Log,
20
+ jQuery
21
+ ) {
22
+ "use strict";
23
+
24
+ /*
25
+ * A map of all registered contracts by name.
26
+ * @see sap.ushell_abap.pbServices.ui2.Chip.addContract
27
+ */
28
+ var mContractsByName = {};
29
+
30
+ // "private" methods (static) without need to access properties -------------
31
+
32
+ /**
33
+ * Returns the initializer function for the given contract name or <code>null</code> if not found.
34
+ *
35
+ * @param {string} sName
36
+ * name of the contract to be return
37
+ * @returns {function}
38
+ * function to be called to initialize the contract or null if none was found
39
+ */
40
+ function getContractInitializer (sName) {
41
+ return Object.prototype.hasOwnProperty.call(mContractsByName, sName) ?
42
+ mContractsByName[sName] : null;
43
+ }
44
+
45
+ // "public class" -----------------------------------------------------------
46
+
47
+ /**
48
+ * Constructs a new representation (wrapper) of the CHIP with the given CHIP data as loaded from
49
+ * the page building service.
50
+ * <p>
51
+ * Initially a stub is created which can load its CHIP definition XML later on in an asynchronous
52
+ * fashion.
53
+ * <p>
54
+ * CHIPs are currently read-only and cannot be updated through the page building service.
55
+ * (see {@link sap.ushell_abap.pbServices.ui2.PageBuildingService})
56
+ *
57
+ * @param {object} oAlterEgo
58
+ * the CHIP data as loaded via page building service
59
+ * @param {sap.ushell_abap.pbServices.ui2.Factory} oFactory
60
+ * the factory
61
+ *
62
+ * @class
63
+ * @since 1.2.0
64
+ */
65
+ var Chip = function (oAlterEgo, oFactory) {
66
+ var that = this,
67
+ oBags,
68
+ /*
69
+ * {string}
70
+ * The URL of the CHIP definition XML (as base for the referenced files)
71
+ */
72
+ sChipUrl,
73
+ /*
74
+ * {map<string,string>}
75
+ * The configuration as read from the CHIP spec in the page building service.
76
+ * The values are already validated and typed correctly. (Must be initialized
77
+ * after the CHIP definition XML has been parsed.)
78
+ */
79
+ oConfiguration,
80
+ /*
81
+ * {sap.ushell_abap.pbServices.ui2.ChipDefinition}
82
+ * The data from the CHIP definition XML. If undefined, the CHIP is still a stub.
83
+ */
84
+ oDefinition,
85
+ /*
86
+ * {string}
87
+ * Cached error message in case loading fails.
88
+ */
89
+ sErrorMessage,
90
+ /*
91
+ * {object}
92
+ * Cached error information in case loading fails.
93
+ */
94
+ oErrorInformation,
95
+ /*
96
+ * List of all success and failure handlers passed to a <code>load()</code> call while this
97
+ * CHIP is already loading its XML; these will all be called after initialization has
98
+ * finished. This list is non-<code>null</code> iff. this CHIP is currently loading its XML.
99
+ *
100
+ * @see #load()
101
+ */
102
+ aLoadHandlers,
103
+ /*
104
+ * The remote catalog if there is one.
105
+ */
106
+ oRemoteCatalog,
107
+ /*
108
+ * whether the chip expects to be updated from a (remote) catalog
109
+ */
110
+ bWaitingForUpdateViaCatalog;
111
+
112
+ // BEWARE: constructor code below!
113
+
114
+ // "private" or hidden methods --------------------------------------------
115
+
116
+ /**
117
+ * Makes sure this CHIP is not just a stub.
118
+ *
119
+ * @private
120
+ */
121
+ function checkStub () {
122
+ if (!oDefinition) {
123
+ throw new SrvcError(that + ": CHIP is just a stub", "sap.ushell_abap.pbServices.ui2.Chip");
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Initialize the bags from raw CHIP bags array.
129
+ *
130
+ * @param {object[]} aRawChipBags
131
+ * Array of raw CHIP bags
132
+ *
133
+ * @private
134
+ */
135
+ function initBags (aRawChipBags) {
136
+ var i;
137
+
138
+ oBags = new Utils.Map();
139
+ if (!aRawChipBags) {
140
+ return;
141
+ }
142
+ for (i = 0; i < aRawChipBags.length; i += 1) {
143
+ // for each bag instance: create wrapper
144
+ oBags.put(aRawChipBags[i].id,
145
+ new Bag(oFactory, aRawChipBags[i]));
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Initialize some details (which need only be computed once) in the given SAPUI5
151
+ * implementation by decorating it with additional properties starting with "$".
152
+ *
153
+ * @param {object} oImplementation
154
+ * UI5 inplementation
155
+ * @private
156
+ */
157
+ function initSAPUI5 (oImplementation) {
158
+ /*jslint regexp: true */
159
+ var sBasePath = oImplementation.basePath,
160
+ iLastSlash,
161
+ aMatches,
162
+ sNamespace,
163
+ sViewName = oImplementation.viewName;
164
+
165
+ if (oImplementation.componentName) {
166
+ oImplementation.$Namespace = oImplementation.componentName;
167
+ } else {
168
+ // (namespace)/(viewName).view.(viewType)
169
+
170
+ // eslint-disable-next-line no-useless-escape
171
+ aMatches = /^(?:([^\/]+)\/)?(.*)\.view\.(.*)$/.exec(sViewName);
172
+ if (!aMatches) {
173
+ throw new SrvcError(that + ": Illegal view name: " + sViewName,
174
+ "Chip");
175
+ }
176
+
177
+ // determine namespace, view name, and view type
178
+ sNamespace = aMatches[1];
179
+ sViewName = aMatches[2];
180
+ oImplementation.$ViewType = aMatches[3].toUpperCase(); // @see sap.ui.core.mvc.ViewType
181
+ if (sNamespace) {
182
+ // prefix view name with namespace
183
+ sViewName = sNamespace + "." + sViewName;
184
+ } else {
185
+ // derive namespace from view name's "package"
186
+ iLastSlash = sViewName.lastIndexOf(".");
187
+ if (iLastSlash < 1) {
188
+ throw new SrvcError(that + ": Missing namespace: " + sViewName,
189
+ "Chip");
190
+ }
191
+ sNamespace = sViewName.substring(0, iLastSlash);
192
+ }
193
+ oImplementation.$Namespace = sNamespace;
194
+ oImplementation.$ViewName = sViewName;
195
+ }
196
+
197
+ // if virtualNameSpace is set, carry with oImplementation
198
+ var bVirtualNamespace = oImplementation.virtualNamespace;
199
+ if (bVirtualNamespace) {
200
+ oImplementation.$VirtualNamespace = bVirtualNamespace;
201
+ }
202
+
203
+ // URL prefix to load module for given namespace relative to CHIP definition XML
204
+ oImplementation.$UrlPrefix = oImplementation.$Namespace.replace(/\./g, "/");
205
+ if (sBasePath !== ".") {
206
+ sBasePath = sBasePath.replace(/\/?$/, "/"); // ensure it ends with a slash
207
+ oImplementation.$UrlPrefix = sBasePath + oImplementation.$UrlPrefix;
208
+ }
209
+ oImplementation.$UrlPrefix = that.toAbsoluteUrl(oImplementation.$UrlPrefix);
210
+ }
211
+
212
+ /**
213
+ * Initializes the configuration, considers defaults set in the CHIP definition XML.
214
+ *
215
+ * @private
216
+ */
217
+ function initConfiguration () {
218
+ oConfiguration = {};
219
+ if (oDefinition.contracts.configuration && oDefinition.contracts.configuration.parameters) {
220
+ // clone the parameters so that we can merge in oAlterEgo.configuration
221
+ oConfiguration = JSON.parse(JSON.stringify(oDefinition.contracts.configuration.parameters));
222
+ }
223
+ that.updateConfiguration(oConfiguration, oAlterEgo.configuration);
224
+ }
225
+
226
+ /**
227
+ * Initialize this CHIP using the given CHIP definition.
228
+ *
229
+ * @param {sap.ushell_abap.pbServices.ui2.ChipDefinition} oNewDefinition
230
+ * the CHIP definition
231
+ *
232
+ * @private
233
+ */
234
+ function initialize (oNewDefinition) {
235
+ var i1, n1;
236
+
237
+ if (oDefinition) {
238
+ throw new SrvcError(that + ": cannot initialize twice", null, "Chip");
239
+ }
240
+ oDefinition = oNewDefinition;
241
+ oDefinition.contracts = oDefinition.contracts || {};
242
+
243
+ if (!oDefinition.implementation || !oDefinition.implementation.sapui5) {
244
+ throw new SrvcError(that + ": Missing SAPUI5 implementation",
245
+ "Chip");
246
+ }
247
+ initSAPUI5(oDefinition.implementation.sapui5);
248
+
249
+ initConfiguration();
250
+
251
+ Log.debug("Initialized: " + that, null, "Chip");
252
+ if (aLoadHandlers) {
253
+ // initialization has finished, call all waiting success handlers
254
+ for (i1 = 0, n1 = aLoadHandlers.length; i1 < n1; i1 += 2) {
255
+ aLoadHandlers[i1]();
256
+ }
257
+ aLoadHandlers = null;
258
+ }
259
+ }
260
+
261
+ /**
262
+ * Updates property bags with given raw data.
263
+ *
264
+ * @param {object[]} aRawChipBags
265
+ * Array of raw CHIP bags
266
+ *
267
+ * @private
268
+ */
269
+ this.updateBags = function (aRawChipBags) {
270
+ var i, sKey, aExistingKeys = oBags.keys();
271
+ for (i = 0; i < aRawChipBags.length; i += 1) {
272
+ sKey = aRawChipBags[i].id;
273
+ if (oBags.containsKey(sKey)) {
274
+ oBags.get(sKey).update(aRawChipBags[i]);
275
+ aExistingKeys.splice(aExistingKeys.indexOf(sKey), 1);
276
+ } else {
277
+ oBags.put(sKey, new Bag(oFactory, aRawChipBags[i]));
278
+ }
279
+ }
280
+ for (i = 0; i < aExistingKeys.length; i += 1) {
281
+ oBags.remove(aExistingKeys[i]);
282
+ }
283
+ };
284
+
285
+ // "public" methods -------------------------------------------------------
286
+
287
+ /**
288
+ * Creates the API object for a CHIP instance. Can only be called if the CHIP is not a stub
289
+ * anymore.
290
+ *
291
+ * @param {sap.ushell_abap.pbServices.ui2.ChipInstance} oChipInstance
292
+ * the CHIP instance
293
+ * @param {Utils.Map} [oContractsByName]
294
+ * CHIP instance's map from contract name to contract interface for page builder
295
+ * (since 1.11.0)
296
+ * @return {object}
297
+ * the API object
298
+ * @since 1.2.0
299
+ *
300
+ * @see #isStub()
301
+ * @see sap.ushell_abap.pbServices.ui2.ChipInstance#getContract()
302
+ */
303
+ this.createApi = function (oChipInstance, oContractsByName) {
304
+ var oApi = {},
305
+ oContract,
306
+ fnInitializer,
307
+ sName,
308
+ mRequestedContracts;
309
+
310
+ checkStub();
311
+ mRequestedContracts = oDefinition.contracts;
312
+ if (mRequestedContracts) {
313
+ for (sName in mRequestedContracts) {
314
+ if (Object.prototype.hasOwnProperty.call(mRequestedContracts, sName)) {
315
+ fnInitializer = getContractInitializer(sName);
316
+ if (!fnInitializer) {
317
+ throw new SrvcError(this + ": Contract '" + sName + "' is not supported",
318
+ "Chip");
319
+ }
320
+ oApi[sName] = {};
321
+ oContract = fnInitializer.call(oApi[sName], oChipInstance);
322
+ if (oContractsByName) {
323
+ oContractsByName.put(sName, oContract);
324
+ }
325
+ }
326
+ }
327
+ }
328
+ return oApi;
329
+ };
330
+
331
+ /**
332
+ * Returns the list of available types of visualization. The types are always lower case.
333
+ *
334
+ * @returns {string[]}
335
+ * the available tile types in lower case, e.g. <code>["tile", "link"]</code>
336
+ * @private
337
+ * @see chip.types.getAvailableTypes
338
+ */
339
+ this.getAvailableTypes = function () {
340
+ var sTypes;
341
+ checkStub();
342
+ if (oDefinition.contracts.types &&
343
+ oDefinition.contracts.types.parameters &&
344
+ typeof oDefinition.contracts.types.parameters.supportedTypes === "string" &&
345
+ oDefinition.contracts.types.parameters.supportedTypes !== "") {
346
+ // convert all supported types to lower case to make comparison easier
347
+ sTypes = oDefinition.contracts.types.parameters.supportedTypes.toLowerCase();
348
+ // types are comma separated
349
+ return sTypes.split(",");
350
+ }
351
+ return [];
352
+ };
353
+
354
+ /**
355
+ * Returns the default type. The type is always lower case.
356
+ * If no default type is specified "tile" is used if it is supported.
357
+ * If no default type is specified and "tile" is not supported. The first supported one will be used
358
+ *
359
+ * @returns {string}
360
+ * the default tile type in lower case, e.g. <code>"tile"</code>
361
+ * @private
362
+ *
363
+ * @since 1.86.0
364
+ */
365
+ this.getDefaultType = function () {
366
+ //If you refactor this out make sure to call 'checkStub' as it is now called in 'getAvailableTypes'
367
+ var aSupportedTypes = this.getAvailableTypes();
368
+
369
+ if (oDefinition.contracts.types &&
370
+ oDefinition.contracts.types.parameters &&
371
+ typeof oDefinition.contracts.types.parameters.defaultType === "string" &&
372
+ oDefinition.contracts.types.parameters.defaultType !== "") {
373
+ var sDefaultType = oDefinition.contracts.types.parameters.defaultType;
374
+
375
+ // the supported types are returned in lower case
376
+ sDefaultType = sDefaultType.toLowerCase();
377
+ if (aSupportedTypes.indexOf(sDefaultType) > -1) {
378
+ return sDefaultType;
379
+ }
380
+ throw new SrvcError("The chip has the default type: " + sDefaultType + " which is not supported");
381
+ }
382
+ if (aSupportedTypes.indexOf("tile") > -1) {
383
+ return "tile";
384
+ }
385
+ if (aSupportedTypes.length > 0) {
386
+ return aSupportedTypes[0];
387
+ }
388
+ return "";
389
+ };
390
+
391
+ /**
392
+ * Returns the property bag with given ID attached to this CHIP.
393
+ * <p>
394
+ * If there is no bag with that ID <code>undefined</code> is returned.
395
+ *
396
+ * @param {string} sBagId
397
+ * the bag ID
398
+ *
399
+ * @returns {sap.ushell_abap.pbServices.ui2.Bag}
400
+ * the CHIP's bag for given ID
401
+ * @private
402
+ */
403
+ this.getBag = function (sBagId) {
404
+ if (!sBagId) {
405
+ throw new SrvcError("Missing bag ID", "Chip");
406
+ }
407
+
408
+ return oBags.get(sBagId);
409
+ };
410
+
411
+ /**
412
+ * Returns an array of bag IDs attached to this CHIP.
413
+ *
414
+ * @returns {string[]}
415
+ * array of bag IDs
416
+ * @private
417
+ */
418
+ this.getBagIds = function () {
419
+ return oBags.keys();
420
+ };
421
+
422
+ /**
423
+ * Returns the id of this CHIP's base CHIP as defined by the page building service. Returns
424
+ * the empty String if the CHIP does not have a base CHIP.
425
+ *
426
+ * @returns {string}
427
+ * the id of this CHIP's base CHIP. Empty string in case the CHIP has no base CHIP.
428
+ * @see #isBasedOn()
429
+ * @since 1.11.0
430
+ */
431
+ this.getBaseChipId = function () {
432
+ return oAlterEgo.baseChipId;
433
+ };
434
+
435
+ /**
436
+ * Returns the catalog by which this CHIP was loaded. The result may be
437
+ * <code>undefined</code> if the CHIP is only a proxy and the actual
438
+ * instance has been deleted in the backend server. This may happen for
439
+ * CHIPs referenced by a chip instance.
440
+ *
441
+ * @returns {sap.ushell_abap.pbServices.ui2.Catalog}
442
+ * this CHIP's catalog or <code>undefined</code>
443
+ * @since 1.19.0
444
+ */
445
+ this.getCatalog = function () {
446
+ // CHIP from remote catalog
447
+ if (oRemoteCatalog) {
448
+ return oRemoteCatalog;
449
+ }
450
+
451
+ return oAlterEgo.$proxy ? undefined : oFactory.createCatalog(oAlterEgo.catalogId);
452
+ };
453
+
454
+ /**
455
+ * Gets the value of a configuration parameter. Can only be called if the CHIP is not a stub
456
+ * anymore.
457
+ *
458
+ * @param {string} sKey
459
+ * the name of the parameter
460
+ * @returns {string}
461
+ * the value of the parameter or <code>undefined</code> if it does not exist
462
+ * @since 1.2.0
463
+ *
464
+ * @see #isStub()
465
+ */
466
+ this.getConfigurationParameter = function (sKey) {
467
+ checkStub();
468
+ return oConfiguration[sKey];
469
+ };
470
+
471
+ /**
472
+ * Returns the raw configuration of the OData CHIP entity ignoring defaults from
473
+ * CHIP Definition XML.
474
+ *
475
+ * @returns {string}
476
+ * raw configuration of the OData CHIP entity; may be undefined
477
+ * @private
478
+ */
479
+ this._getChipRawConfigurationString = function () {
480
+ return oAlterEgo.configuration;
481
+ };
482
+
483
+ /**
484
+ * Returns this CHIP's description as defined by the page building service.
485
+ *
486
+ * @returns {string}
487
+ * this CHIP's description
488
+ * @since 1.2.0
489
+ */
490
+ this.getDescription = function () {
491
+ return oAlterEgo.description;
492
+ };
493
+
494
+ /**
495
+ * Returns this CHIP's ID.
496
+ *
497
+ * @returns {string}
498
+ * this CHIP's ID
499
+ * @since 1.2.0
500
+ */
501
+ this.getId = function () {
502
+ return oAlterEgo.id;
503
+ };
504
+
505
+ /**
506
+ * Returns this CHIP instance's implementation of type SAPUI5 as a control. This control
507
+ * represents the root of this CHIP instance's UI from a page builder point of view. Can only
508
+ * be called if the CHIP is not a stub anymore.
509
+ *
510
+ * @param {object} oApi
511
+ * the CHIP instance specific API
512
+ * @returns {sap.ui.core.Control}
513
+ * this CHIP instance's SAPUI5 implementation as a control
514
+ * @since 1.2.0
515
+ *
516
+ * @see #isStub()
517
+ */
518
+ this.getImplementationAsSapui5 = function (oApi) {
519
+ var oData, oImplementation, sBaseChipId;
520
+
521
+ checkStub();
522
+ oData = {
523
+ /*
524
+ * @namespace The namespace for the instance specific CHIP API, which allows you to
525
+ * access the various contracts consumed by your CHIP instance.
526
+ * @name chip
527
+ */
528
+ chip: oApi
529
+ };
530
+ oImplementation = oDefinition.implementation.sapui5;
531
+
532
+ // In case the chip is used in FLP wave 2 or later context we load it from the standard path
533
+ sBaseChipId = this.getBaseChipId();
534
+ if ((sBaseChipId !== "X-SAP-UI2-CHIP:/UI2/STATIC_APPLAUNCHER") && (sBaseChipId !== "X-SAP-UI2-CHIP:/UI2/DYNAMIC_APPLAUNCHER")) {
535
+ if (oImplementation.$VirtualNamespace) {
536
+ oImplementation.$absolutePath = this.toAbsoluteUrl(oImplementation.basePath);
537
+ jQuery.sap.registerModulePath(oImplementation.$Namespace, oImplementation.$absolutePath);
538
+ } else {
539
+ jQuery.sap.registerModulePath(oImplementation.$Namespace, oImplementation.$UrlPrefix);
540
+ }
541
+ }
542
+
543
+ if (oImplementation.componentName) {
544
+ // SAPUI5 component
545
+ return new sap.ui.core.ComponentContainer({
546
+ component: sap.ui.getCore().createComponent({
547
+ componentData: oData,
548
+ name: oImplementation.componentName
549
+ })
550
+ });
551
+ }
552
+
553
+ // SAPUI5 MVC
554
+ return sap.ui.view({
555
+ type: oImplementation.$ViewType,
556
+ viewName: oImplementation.$ViewName,
557
+ viewData: oData
558
+ });
559
+ };
560
+
561
+ /**
562
+ * Returns the catalog by which this remote CHIP was loaded. This catalog is
563
+ * <code>undefined</code> if the CHIP is from the same system as the catalog.
564
+ *
565
+ * @returns {sap.ushell_abap.pbServices.ui2.Catalog}
566
+ * this CHIP's remote catalog or <code>undefined</code>
567
+ * @since 1.9.0
568
+ */
569
+ this.getRemoteCatalog = function () {
570
+ return oRemoteCatalog;
571
+ };
572
+
573
+ /**
574
+ * Returns this CHIP's title as defined by the page building service or the CHIP definition XML
575
+ * (if available).
576
+ *
577
+ * @returns {string}
578
+ * this CHIP's title
579
+ * @since 1.2.0
580
+ */
581
+ this.getTitle = function () {
582
+ return oAlterEgo.title
583
+ || (oDefinition && oDefinition.appearance && oDefinition.appearance.title);
584
+ };
585
+
586
+ /**
587
+ * Checks whether this CHIP is based on the given CHIP instance. This can happen because there
588
+ * is a catalog type which is built on a catalog page. In such a case the ABAP backend maps
589
+ * each CHIP instance on that page to a CHIP in the resulting catalog.
590
+ * <p>
591
+ * Note: This CHIP's <code>baseChipId</code> is exactly non-empty if the CHIP is catalog-page
592
+ * based. Then it is the ID of the CHIP used to build the CHIP instance. (This is recursive.
593
+ * So if that CHIP is again catalog-page based...)
594
+ *
595
+ * @param {sap.ushell_abap.pbServices.ui2.ChipInstance} oChipInstance
596
+ * the CHIP instance to compare with
597
+ * @returns {boolean}
598
+ * <code>true</code> iff the CHIP is based on the given CHIP instance
599
+ * @since 1.19.1
600
+ * @see #refresh()
601
+ */
602
+ this.isBasedOn = function (oChipInstance) {
603
+ var sExpectedId
604
+ = "X-SAP-UI2-PAGE:" + oChipInstance.getPage().getId()
605
+ + ":" + oChipInstance.getId();
606
+
607
+ /*
608
+ * @param {string} sActualId
609
+ * @returns {boolean}
610
+ * @private
611
+ */
612
+ function matchesExpectation (sActualId) {
613
+ // TODO use oAlterEgo.catalogPageChipInstanceId
614
+ return sActualId === sExpectedId
615
+ || sActualId.indexOf(sExpectedId + ":") === 0; // old IDs still contain the scope
616
+ }
617
+
618
+ return (oAlterEgo.referenceChipId && matchesExpectation(oAlterEgo.referenceChipId))
619
+ || matchesExpectation(oAlterEgo.id);
620
+ };
621
+
622
+ /**
623
+ * Tells whether this CHIP is a reference, pointing to its original CHIP.
624
+ * Note: A refresh on the CHIP may be needed before calling this method, but only if the CHIP
625
+ * is based on a catalog page and that corresponding catalog page may be updated in your use
626
+ * case after the CHIP has been loaded.
627
+ *
628
+ * @returns {boolean}
629
+ * whether this CHIP is a reference
630
+ * @since 1.19.1
631
+ * @see #refresh()
632
+ *
633
+ */
634
+ this.isReference = function () {
635
+ return !!oAlterEgo.referenceChipId;
636
+ };
637
+
638
+ /**
639
+ * Tells whether this CHIP is a broken reference,
640
+ * as indicated by referenceChipId being set to "O" (Orphaned)
641
+ *
642
+ * @returns {boolean}
643
+ * whether this CHIP is a broken reference
644
+ * @since 1.23.1
645
+ *
646
+ */
647
+ this.isBrokenReference = function () {
648
+ // If an underlying chip of a reference is deleted, the property referenceChipId is set
649
+ // to "O" (Orphaned)
650
+ return oAlterEgo.referenceChipId === "O";
651
+ };
652
+
653
+ /**
654
+ * Tells whether this CHIP is still only a stub and does not yet know its CHIP definition XML.
655
+ *
656
+ * @returns {boolean}
657
+ * whether this CHIP is still only a stub
658
+ * @since 1.2.0
659
+ *
660
+ * @see #load()
661
+ */
662
+ this.isStub = function () {
663
+ return !oDefinition;
664
+ };
665
+
666
+ /**
667
+ * Loads the CHIP definition XML in case this has not yet been done. If this CHIP is not a stub
668
+ * anymore this method fails!
669
+ *
670
+ * @param {function ()} fnSuccess
671
+ * no-args success handler
672
+ * @param {function (string, [object])} [fnFailure]
673
+ * error handler taking an error message and, since version 1.28.6, an
674
+ * optional object containing the complete error information as delivered
675
+ * by the ODataService. See fnFailure parameter of {@link sap.ushell_abap.pbServices.ui2.ODataWrapper#onError}
676
+ * for more details.
677
+ * If not given
678
+ * <code>{@link sap.ushell_abap.pbServices.ui2.ODataService#getDefaultErrorHandler}</code> is used.
679
+ * @since 1.2.0
680
+ *
681
+ * @see #isStub()
682
+ */
683
+ this.load = function (fnSuccess, fnFailure) {
684
+ function onError (sErrMessage, oErrDetails) {
685
+ // loading has failed, call all waiting error handlers
686
+ sErrorMessage = sErrMessage;
687
+ oErrorInformation = oErrDetails;
688
+ var i, n;
689
+ if (aLoadHandlers) {
690
+ for (i = 1, n = aLoadHandlers.length; i < n; i += 2) {
691
+ aLoadHandlers[i](sErrMessage, oErrDetails);
692
+ }
693
+ aLoadHandlers = null;
694
+ }
695
+ }
696
+
697
+ // Note: might fail synchronously!
698
+ function createChipDefinition () {
699
+ if (oFactory) { // Note: factory is optional!
700
+ oFactory.createChipDefinition(oAlterEgo.url, initialize, onError);
701
+ return;
702
+ }
703
+ Utils.get(oAlterEgo.url, /*XML=*/true,
704
+ function (oXml) {
705
+ Log.debug("Loaded: " + that, null, "Chip");
706
+ initialize(new ChipDefinition(oXml));
707
+ }, onError);
708
+ }
709
+
710
+ function onChipUpdated () {
711
+ if (!oAlterEgo.url) {
712
+ if (bWaitingForUpdateViaCatalog) {
713
+ throw new SrvcError("Remote catalog did not deliver CHIP '" + oAlterEgo.id
714
+ + "'", "Chip");
715
+ }
716
+ throw new SrvcError("Missing module URL", "Chip");
717
+ }
718
+ bWaitingForUpdateViaCatalog = false;
719
+ sChipUrl = Utils.absoluteUrl(oAlterEgo.url);
720
+ createChipDefinition();
721
+ }
722
+
723
+ if (!this.isStub()) {
724
+ throw new SrvcError("Chip is not a stub anymore", "Chip");
725
+ }
726
+ if (typeof fnSuccess !== "function") {
727
+ throw new SrvcError("Missing success handler", "Chip");
728
+ }
729
+ fnFailure = fnFailure || oFactory.getPageBuildingService().getDefaultErrorHandler();
730
+
731
+ if (sErrorMessage) { // NOTE: check sErrorMessage only
732
+ Utils.callHandler(fnFailure.bind(null, sErrorMessage, oErrorInformation), null, true);
733
+ return;
734
+ }
735
+
736
+ if (aLoadHandlers) {
737
+ // wait until loading has finished (one way or the other)
738
+ aLoadHandlers.push(fnSuccess, fnFailure);
739
+ return;
740
+ }
741
+
742
+ // start loading
743
+ if (oAlterEgo.url) {
744
+ createChipDefinition();
745
+ } else if (oAlterEgo.remoteCatalogId) {
746
+ // a remote chip, request the catalog to update all registered CHIPs (incl. this one)
747
+ this.getRemoteCatalog().readRegisteredChips(onChipUpdated, onError);
748
+ bWaitingForUpdateViaCatalog = true;
749
+ } else {
750
+ // this looks like a null object, try to read our raw data and expect a failure
751
+ // Note: might fail synchronously!
752
+ oFactory.getPageBuildingService().readChip(
753
+ oAlterEgo.id,
754
+ function (oRawChip) {
755
+ oAlterEgo = oRawChip;
756
+ onChipUpdated();
757
+ },
758
+ onError
759
+ );
760
+ }
761
+ aLoadHandlers = [fnSuccess, fnFailure];
762
+ };
763
+
764
+ /**
765
+ * Refreshes the CHIP from the OData service. Use this only for CHIPs that you received via a
766
+ * catalog. When called on a CHIP received via a page, the function may fail.
767
+ * <p>
768
+ * This method is intended to refresh a CHIP in a catalog based on a catalog page. Such a CHIP
769
+ * is based on a CHIP instance of this catalog page. If such a CHIP instance is changed this
770
+ * method can be used to refresh the corresponding CHIP.
771
+ * <p>
772
+ * Note: This method does not replace the {@link #load} method, as the CHIP definition is not
773
+ * loaded. Thus, if the CHIP was a stub before the refresh, it is still a stub afterwards.
774
+ *
775
+ * @param {function ()} fnSuccess
776
+ * no-args success handler
777
+ * @param {function (string, [object])} [fnFailure]
778
+ * error handler taking an error message and, since version 1.28.6, an
779
+ * optional object containing the complete error information as delivered
780
+ * by the ODataService. See fnFailure parameter of {@link sap.ushell_abap.pbServices.ui2.ODataWrapper#onError}
781
+ * for more details.
782
+ * If not given
783
+ * <code>{@link sap.ushell_abap.pbServices.ui2.ODataService#getDefaultErrorHandler}</code> is used
784
+ * @since 1.16.5
785
+ *
786
+ * @see #load()
787
+ * @see #isStub()
788
+ * @see #isBasedOn()
789
+ */
790
+ this.refresh = function (fnSuccess, fnFailure) {
791
+ function updateChip (oNewAlterEgo) {
792
+ oAlterEgo.title = oNewAlterEgo.title;
793
+ oAlterEgo.configuration = oNewAlterEgo.configuration;
794
+ oAlterEgo.referenceChipId = oNewAlterEgo.referenceChipId;
795
+ initBags(oNewAlterEgo.ChipBags && oNewAlterEgo.ChipBags.results);
796
+ // All other fields cannot be changed via the corresponding CHIP instance.
797
+ // TODO throw exception if URL changes?
798
+ if (!that.isStub()) {
799
+ that.updateConfiguration(oConfiguration, oAlterEgo.configuration);
800
+ }
801
+ fnSuccess();
802
+ }
803
+
804
+ function updateRemoteChip (oResult) {
805
+ if (oResult.results[0]) {
806
+ updateChip(oResult.results[0]);
807
+ } else {
808
+ fnFailure = fnFailure || oFactory.getPageBuildingService().getDefaultErrorHandler();
809
+ fnFailure("Could not refresh CHIP. No update received from catalog "
810
+ + oAlterEgo.remoteCatalogId);
811
+ }
812
+ }
813
+
814
+ if (typeof fnSuccess !== "function") {
815
+ throw new SrvcError("Missing success handler", "Chip");
816
+ }
817
+ if (!oAlterEgo.url) {
818
+ throw new SrvcError(that + ": CHIP is just a stub", "Chip");
819
+ }
820
+ if (oAlterEgo.remoteCatalogId) {
821
+ this.getRemoteCatalog().readChips([oAlterEgo.id], updateRemoteChip, fnFailure);
822
+ } else {
823
+ oFactory.getPageBuildingService().readChip(oAlterEgo.id, updateChip, fnFailure);
824
+ }
825
+ };
826
+
827
+ /**
828
+ * Updates the CHIP. This is an internal function, used when a "preliminary" object has been
829
+ * created and the data from the page building service are delivered together with another
830
+ * object (e.g. the catalog).
831
+ *
832
+ * @param {object} oNewAlterEgo
833
+ * the CHIP data as loaded via page building service
834
+ * @private
835
+ * @throws Error when the update data do not match or when the CHIP already is complete
836
+ */
837
+ this.update = function (oNewAlterEgo) {
838
+ // was erroneously publicly documented in 1.18 and made @private in 1.19.0
839
+ if (typeof oNewAlterEgo !== "object" || oNewAlterEgo.id !== this.getId()) {
840
+ throw new SrvcError("Invalid update data: " + this, "Chip");
841
+ }
842
+ // update bags if available
843
+ if (oNewAlterEgo.ChipBags && oNewAlterEgo.ChipBags.results) {
844
+ this.updateBags(oNewAlterEgo.ChipBags && oNewAlterEgo.ChipBags.results);
845
+ }
846
+
847
+ if (oAlterEgo.url) {
848
+ return; // No more update, please!
849
+ }
850
+ if (!oNewAlterEgo.url) {
851
+ return; // This is not really an update!
852
+ }
853
+ oAlterEgo = oNewAlterEgo;
854
+ sChipUrl = Utils.absoluteUrl(oAlterEgo.url);
855
+ Log.debug("Updated: " + this, null, "Chip");
856
+ };
857
+
858
+ /**
859
+ * Updates the given parameter map from the given JSON string. All parameters that actually were
860
+ * defined in the CHIP definition XML are accepted. All others will raise a warning to the log.
861
+ *
862
+ * @param {map<String,String>} mParameters
863
+ * the parameter map to fill
864
+ * @param {map<String,String>|string} vConfigurationUpdates
865
+ * the configuration updates as parameter map or as JSON string
866
+ * <p>If one parameter value is <code>undefined</code> (which can only happen by supplying a
867
+ * map) then this property is removed from <code>mParameters</code>.
868
+ *
869
+ * @since 1.2.0
870
+ */
871
+ this.updateConfiguration = function (mParameters, vConfigurationUpdates) {
872
+ var mConfigurationUpdates,
873
+ sKey,
874
+ sValue;
875
+ if (!vConfigurationUpdates) {
876
+ return;
877
+ }
878
+ if (typeof vConfigurationUpdates === "string") {
879
+ try {
880
+ mConfigurationUpdates = JSON.parse(vConfigurationUpdates);
881
+ } catch (e) {
882
+ // configuration as a whole is incorrect and will be ignored
883
+ // Note: toString(true) will also output configuration, thus it is no secret
884
+ Log.warning(this + ': ignoring invalid configuration "'
885
+ + vConfigurationUpdates + '"', null, "Chip");
886
+ return;
887
+ }
888
+ } else {
889
+ mConfigurationUpdates = vConfigurationUpdates;
890
+ }
891
+ for (sKey in mConfigurationUpdates) {
892
+ if (Object.prototype.hasOwnProperty.call(mConfigurationUpdates, sKey)) {
893
+ if (Object.prototype.hasOwnProperty.call(oConfiguration, sKey)) {
894
+ sValue = mConfigurationUpdates[sKey];
895
+ if (sValue === undefined) {
896
+ delete mParameters[sKey];
897
+ } else if (typeof sValue !== "string") {
898
+ throw new SrvcError("Value for '" + sKey + "' must be a string",
899
+ "Chip");
900
+ } else {
901
+ mParameters[sKey] = sValue;
902
+ }
903
+ } else {
904
+ Log.warning(this + ": ignoring unknown configuration parameter " + sKey,
905
+ null, "Chip");
906
+ }
907
+ }
908
+ }
909
+ };
910
+
911
+ /**
912
+ * Makes the given relative URL absolute. URLs containing host and/or protocol
913
+ * and URLs with an absolute path remain unchanged. The URL is in no way
914
+ * normalized; the function takes the URL of the CHIP definition XML as base.
915
+ *
916
+ * @param {string} sUrl
917
+ * the (possibly server-relative) URL
918
+ * @returns {string}
919
+ * the absolute URL
920
+ * @since 1.2.0
921
+ */
922
+ this.toAbsoluteUrl = function (sUrl) {
923
+ return Utils.absoluteUrl(sUrl, sChipUrl);
924
+ };
925
+
926
+ /**
927
+ * Returns this CHIP's string representation.
928
+ *
929
+ * @param {boolean} [bVerbose=false]
930
+ * flag whether to show all properties
931
+ * @returns {string}
932
+ * this CHIP's string representation
933
+ * @since 1.2.0
934
+ */
935
+ this.toString = function (bVerbose) {
936
+ var aResult = [
937
+ 'Chip({sChipUrl:"', sChipUrl, '"'
938
+ ];
939
+ if (bVerbose) {
940
+ aResult.push(",oAlterEgo:", JSON.stringify(oAlterEgo),
941
+ ",oBags:", oBags.toString(),
942
+ ",oDefinition:", JSON.stringify(oDefinition)
943
+ );
944
+ }
945
+ aResult.push("})");
946
+ return aResult.join("");
947
+ };
948
+
949
+ /**
950
+ * This method can be used to figure out if the CHIP initially existed.
951
+ * This is only relevant when the CHIP navigation property was expanded
952
+ * (OData $expand).
953
+ *
954
+ * @returns {boolean}
955
+ * Whether the CHIP initially existed.
956
+ *
957
+ * @private
958
+ */
959
+ this.isInitiallyDefined = function (bDefined) {
960
+ return bDefined;
961
+ }.bind(
962
+ null,
963
+ oAlterEgo && !oAlterEgo.hasOwnProperty("$proxy") // $proxy (set from factory) when null
964
+ );
965
+
966
+ // constructor code -------------------------------------------------------
967
+ if (!oAlterEgo) {
968
+ throw new SrvcError("Missing CHIP description", "Chip");
969
+ }
970
+
971
+ sChipUrl = Utils.absoluteUrl(oAlterEgo.url);
972
+ if (oAlterEgo.remoteCatalogId) {
973
+ oRemoteCatalog = oFactory.createCatalog(oAlterEgo.remoteCatalogId);
974
+ if (!oAlterEgo.url) {
975
+ oRemoteCatalog.registerChip(this);
976
+ }
977
+ }
978
+ initBags(oAlterEgo.ChipBags && oAlterEgo.ChipBags.results);
979
+ Log.debug("Created: " + this, null, "Chip");
980
+ };
981
+
982
+ // "public" methods (static) ------------------------------------------------
983
+
984
+ /**
985
+ * Adds a contract to the list of known contracts which can be consumed by CHIPs.
986
+ *
987
+ * @param {string} sName
988
+ * The name of the contract.
989
+ * @param {function (sap.ushell_abap.pbServices.ui2.ChipInstance)} fnInitializer
990
+ * This function will initialize the contract for a CHIP instance. When the API object for a
991
+ * CHIP instance requesting this contract is initialized, a sub-object with the contract's name
992
+ * is added to the API. The initializer is then called with this sub-object as <code>this</code>
993
+ * and the CHIP instance as parameter.
994
+ * @since 1.2.0
995
+ */
996
+ Chip.addContract = function (sName, fnInitializer) {
997
+ if (getContractInitializer(sName)) {
998
+ throw new SrvcError("Cannot register contract '" + sName + "' twice",
999
+ "Chip");
1000
+ }
1001
+ mContractsByName[sName] = fnInitializer;
1002
+ };
1003
+
1004
+
1005
+ /**
1006
+ * Removes a contract from the list of known contracts which can be consumed by CHIPs. Does not
1007
+ * fail even if the contract was not known before!
1008
+ * Note: Only used in test code
1009
+ *
1010
+ * @param {string} sName
1011
+ * The name of the contract.
1012
+ * @since 1.11.0
1013
+ * @private
1014
+ */
1015
+ Chip.removeContract = function (sName) {
1016
+ delete mContractsByName[sName];
1017
+ };
1018
+
1019
+ // TODO remove when FLPD is adapted (uses this function in global namespace)
1020
+ if (jQuery && jQuery.sap) { // true only in FLPD case
1021
+ jQuery.sap.declare("sap.ui2.srvc.chip");
1022
+ jQuery.sap.declare("sap.ui2.srvc.Chip");
1023
+ sap.ui2.srvc.Chip = sap.ui2.srvc.chip = Chip;
1024
+ }
1025
+
1026
+ return Chip;
1027
+ }, true);