@talxis/base-controls 1.2406.2 → 1.2406.4

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 (214) hide show
  1. package/package.json +1 -1
  2. package/.env +0 -1
  3. package/.eslintrc +0 -117
  4. package/.npmgitignore +0 -9
  5. package/.vscode/settings.json +0 -3
  6. package/.yalcignore +0 -2
  7. package/azure-pipelines.yml +0 -44
  8. package/examples/Currency/Currency/ControlManifest.Input.xml +0 -53
  9. package/examples/Currency/Currency/index.ts +0 -66
  10. package/examples/Currency/Currency.pcfproj +0 -46
  11. package/examples/Currency/package-lock.json +0 -15900
  12. package/examples/Currency/package.json +0 -29
  13. package/examples/Currency/pcfconfig.json +0 -3
  14. package/examples/Currency/tsconfig.json +0 -7
  15. package/examples/DateTime/DateTime/ControlManifest.Input.xml +0 -58
  16. package/examples/DateTime/DateTime/index.ts +0 -69
  17. package/examples/DateTime/DateTime.pcfproj +0 -46
  18. package/examples/DateTime/package-lock.json +0 -15900
  19. package/examples/DateTime/package.json +0 -29
  20. package/examples/DateTime/pcfconfig.json +0 -3
  21. package/examples/DateTime/tsconfig.json +0 -7
  22. package/examples/Decimal/Decimal/ControlManifest.Input.xml +0 -66
  23. package/examples/Decimal/Decimal/index.ts +0 -66
  24. package/examples/Decimal/Decimal.pcfproj +0 -46
  25. package/examples/Decimal/package-lock.json +0 -15900
  26. package/examples/Decimal/package.json +0 -28
  27. package/examples/Decimal/pcfconfig.json +0 -3
  28. package/examples/Decimal/tsconfig.json +0 -7
  29. package/examples/Duration/Duration/ControlManifest.Input.xml +0 -53
  30. package/examples/Duration/Duration/index.ts +0 -66
  31. package/examples/Duration/Duration.pcfproj +0 -46
  32. package/examples/Duration/package-lock.json +0 -15900
  33. package/examples/Duration/package.json +0 -29
  34. package/examples/Duration/pcfconfig.json +0 -3
  35. package/examples/Duration/tsconfig.json +0 -7
  36. package/examples/Grid/Grid/ControlManifest.Input.xml +0 -28
  37. package/examples/Grid/Grid/index.ts +0 -100
  38. package/examples/Grid/Grid.pcfproj +0 -46
  39. package/examples/Grid/package-lock.json +0 -15901
  40. package/examples/Grid/package.json +0 -30
  41. package/examples/Grid/pcfconfig.json +0 -3
  42. package/examples/Grid/tsconfig.json +0 -7
  43. package/examples/Lookup/Lookup/ControlManifest.Input.xml +0 -51
  44. package/examples/Lookup/Lookup/index.ts +0 -90
  45. package/examples/Lookup/Lookup.pcfproj +0 -46
  46. package/examples/Lookup/package-lock.json +0 -15900
  47. package/examples/Lookup/package.json +0 -29
  48. package/examples/Lookup/pcfconfig.json +0 -3
  49. package/examples/Lookup/tsconfig.json +0 -8
  50. package/examples/MultiSelectOptionSet/MultiSelectOptionSet/ControlManifest.Input.xml +0 -53
  51. package/examples/MultiSelectOptionSet/MultiSelectOptionSet/index.ts +0 -86
  52. package/examples/MultiSelectOptionSet/MultiSelectOptionSet.pcfproj +0 -46
  53. package/examples/MultiSelectOptionSet/package-lock.json +0 -15900
  54. package/examples/MultiSelectOptionSet/package.json +0 -31
  55. package/examples/MultiSelectOptionSet/pcfconfig.json +0 -3
  56. package/examples/MultiSelectOptionSet/tsconfig.json +0 -7
  57. package/examples/OptionSet/OptionSet/ControlManifest.Input.xml +0 -53
  58. package/examples/OptionSet/OptionSet/index.ts +0 -70
  59. package/examples/OptionSet/OptionSet.pcfproj +0 -46
  60. package/examples/OptionSet/package-lock.json +0 -15900
  61. package/examples/OptionSet/package.json +0 -29
  62. package/examples/OptionSet/pcfconfig.json +0 -3
  63. package/examples/OptionSet/tsconfig.json +0 -7
  64. package/examples/TwoOptions/TwoOptions/ControlManifest.Input.xml +0 -53
  65. package/examples/TwoOptions/TwoOptions/index.ts +0 -69
  66. package/examples/TwoOptions/TwoOptions.pcfproj +0 -46
  67. package/examples/TwoOptions/package-lock.json +0 -15900
  68. package/examples/TwoOptions/package.json +0 -29
  69. package/examples/TwoOptions/pcfconfig.json +0 -3
  70. package/examples/TwoOptions/tsconfig.json +0 -7
  71. package/public/index.html +0 -43
  72. package/public/manifest.json +0 -25
  73. package/rollup.config.js +0 -44
  74. package/src/components/DateTime/DateTime.tsx +0 -97
  75. package/src/components/DateTime/components/Calendar.tsx +0 -80
  76. package/src/components/DateTime/hooks/useDateTime.ts +0 -144
  77. package/src/components/DateTime/index.ts +0 -2
  78. package/src/components/DateTime/interfaces.ts +0 -22
  79. package/src/components/DateTime/styles.ts +0 -37
  80. package/src/components/DateTime/translations.ts +0 -18
  81. package/src/components/Decimal/Decimal.tsx +0 -120
  82. package/src/components/Decimal/index.ts +0 -2
  83. package/src/components/Decimal/interfaces.ts +0 -20
  84. package/src/components/Duration/Duration.tsx +0 -143
  85. package/src/components/Duration/index.ts +0 -2
  86. package/src/components/Duration/interfaces.ts +0 -22
  87. package/src/components/Duration/translations.ts +0 -30
  88. package/src/components/Grid/Grid.tsx +0 -24
  89. package/src/components/Grid/core/components/AgGrid/AgGrid.tsx +0 -206
  90. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/EmptyRecords.tsx +0 -16
  91. package/src/components/Grid/core/components/AgGrid/components/EmptyRecordsOverlay/styles.ts +0 -20
  92. package/src/components/Grid/core/components/AgGrid/components/LoadingOverlay/LoadingOverlay.tsx +0 -7
  93. package/src/components/Grid/core/components/AgGrid/controllers/useAgGridController.ts +0 -68
  94. package/src/components/Grid/core/components/AgGrid/model/AgGrid.ts +0 -100
  95. package/src/components/Grid/core/components/AgGrid/styles.ts +0 -72
  96. package/src/components/Grid/core/components/Cell/Commands/Commands.tsx +0 -32
  97. package/src/components/Grid/core/components/Cell/Commands/Icon.tsx +0 -17
  98. package/src/components/Grid/core/components/Cell/Commands/styles.ts +0 -21
  99. package/src/components/Grid/core/components/Cell/Commands/useCommands.tsx +0 -53
  100. package/src/components/Grid/core/components/Cell/EditableCell/EditableCell.tsx +0 -140
  101. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyCell.tsx +0 -176
  102. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/ReadOnlyOptionSet.tsx +0 -67
  103. package/src/components/Grid/core/components/Cell/ReadOnlyCell/ReadOnlyOptionSet/styles.ts +0 -24
  104. package/src/components/Grid/core/components/Cell/ReadOnlyCell/styles.ts +0 -56
  105. package/src/components/Grid/core/components/ColumnHeader/ColumnHeader.tsx +0 -71
  106. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/GlobalCheckbox.tsx +0 -31
  107. package/src/components/Grid/core/components/ColumnHeader/components/GlobalCheckbox/styles.ts +0 -16
  108. package/src/components/Grid/core/components/ColumnHeader/styles.ts +0 -40
  109. package/src/components/Grid/core/components/Component/Component.tsx +0 -59
  110. package/src/components/Grid/core/components/Component/controller/useComponentController.ts +0 -39
  111. package/src/components/Grid/core/components/Component/model/Component.ts +0 -251
  112. package/src/components/Grid/core/components/Dialog/Constants.tsx +0 -8
  113. package/src/components/Grid/core/components/Dialog/Styles.tsx +0 -61
  114. package/src/components/Grid/core/components/Dialog/index.tsx +0 -22
  115. package/src/components/Grid/core/components/Dialog/interfaces/index.d.ts +0 -7
  116. package/src/components/Grid/core/components/Save/Save.tsx +0 -74
  117. package/src/components/Grid/core/components/Save/components/ChangeEditor/ChangeEditor.tsx +0 -63
  118. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/RecordGrids.tsx +0 -153
  119. package/src/components/Grid/core/components/Save/components/ChangeEditor/components/RecordGrids/styles.ts +0 -52
  120. package/src/components/Grid/core/components/Save/components/ChangeEditor/styles.ts +0 -34
  121. package/src/components/Grid/core/components/Save/hooks/useSave.ts +0 -59
  122. package/src/components/Grid/core/components/Save/styles.ts +0 -41
  123. package/src/components/Grid/core/controllers/useGridController.ts +0 -46
  124. package/src/components/Grid/core/enums/ConditionOperator.ts +0 -46
  125. package/src/components/Grid/core/enums/DataType.ts +0 -25
  126. package/src/components/Grid/core/hooks/useGridInstance.ts +0 -7
  127. package/src/components/Grid/core/hooks/useRefreshCallback.ts +0 -20
  128. package/src/components/Grid/core/hooks/useRerender.ts +0 -15
  129. package/src/components/Grid/core/interfaces/IGridColumn.ts +0 -19
  130. package/src/components/Grid/core/interfaces/IGridContext.ts +0 -7
  131. package/src/components/Grid/core/model/Grid.ts +0 -250
  132. package/src/components/Grid/core/model/GridDependency.ts +0 -34
  133. package/src/components/Grid/core/model/Metadata.ts +0 -20
  134. package/src/components/Grid/core/services/RecordUpdateService/controllers/useRecordUpdateServiceController.ts +0 -36
  135. package/src/components/Grid/core/services/RecordUpdateService/model/RecordUpdateService.ts +0 -222
  136. package/src/components/Grid/filtering/components/FilterCallout/FilterCallout.tsx +0 -83
  137. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionOperator/ConditionOperator.tsx +0 -66
  138. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/ConditionValue.tsx +0 -48
  139. package/src/components/Grid/filtering/components/FilterCallout/components/ConditionValue/model/ConditionComponentValue.ts +0 -120
  140. package/src/components/Grid/filtering/components/FilterCallout/styles.ts +0 -37
  141. package/src/components/Grid/filtering/constants.ts +0 -48
  142. package/src/components/Grid/filtering/controller/useColumnFilterConditionController.ts +0 -63
  143. package/src/components/Grid/filtering/model/Condition.ts +0 -309
  144. package/src/components/Grid/filtering/model/Filtering.ts +0 -78
  145. package/src/components/Grid/filtering/utils/FilteringUtilts.ts +0 -190
  146. package/src/components/Grid/interfaces.ts +0 -109
  147. package/src/components/Grid/paging/components/Paging/Paging.tsx +0 -76
  148. package/src/components/Grid/paging/components/Paging/styles.ts +0 -38
  149. package/src/components/Grid/paging/controllers/usePagingController.ts +0 -34
  150. package/src/components/Grid/paging/model/Paging.ts +0 -49
  151. package/src/components/Grid/selection/controllers/useSelectionController.ts +0 -25
  152. package/src/components/Grid/selection/model/Selection.ts +0 -60
  153. package/src/components/Grid/sorting/Sorting.ts +0 -30
  154. package/src/components/Grid/sorting/components/SortingContextualMenu/SortingContextualMenu.tsx +0 -126
  155. package/src/components/Grid/sorting/components/SortingContextualMenu/styles.ts +0 -12
  156. package/src/components/Grid/sorting/controllers/useColumnSortingController.ts +0 -26
  157. package/src/components/Grid/translations.ts +0 -80
  158. package/src/components/Grid/validation/controllers/useRecordValidationController.ts +0 -31
  159. package/src/components/Grid/validation/model/ColumnValidation.ts +0 -81
  160. package/src/components/Lookup/Lookup.tsx +0 -199
  161. package/src/components/Lookup/components/RecordCreator.tsx +0 -53
  162. package/src/components/Lookup/components/TargetSelector.tsx +0 -43
  163. package/src/components/Lookup/hooks/useFetchXml.ts +0 -31
  164. package/src/components/Lookup/hooks/useLoadedEntities.ts +0 -23
  165. package/src/components/Lookup/hooks/useLookup.ts +0 -126
  166. package/src/components/Lookup/index.ts +0 -2
  167. package/src/components/Lookup/interfaces.ts +0 -45
  168. package/src/components/Lookup/lib.ts +0 -3110
  169. package/src/components/Lookup/styles.ts +0 -106
  170. package/src/components/Lookup/translations.ts +0 -28
  171. package/src/components/MultiSelectOptionSet/MultiSelectOptionSet.tsx +0 -83
  172. package/src/components/MultiSelectOptionSet/index.ts +0 -2
  173. package/src/components/MultiSelectOptionSet/interfaces.ts +0 -14
  174. package/src/components/OptionSet/OptionSet.tsx +0 -67
  175. package/src/components/OptionSet/index.ts +0 -2
  176. package/src/components/OptionSet/interfaces.ts +0 -17
  177. package/src/components/TextField/TextField.tsx +0 -58
  178. package/src/components/TextField/hooks/useTextField.ts +0 -42
  179. package/src/components/TextField/index.ts +0 -2
  180. package/src/components/TextField/interfaces.ts +0 -20
  181. package/src/components/TwoOptions/TwoOptions.tsx +0 -43
  182. package/src/components/TwoOptions/index.ts +0 -2
  183. package/src/components/TwoOptions/interfaces.ts +0 -17
  184. package/src/hooks/index.ts +0 -1
  185. package/src/hooks/useComponent.ts +0 -83
  186. package/src/hooks/useFocusIn.ts +0 -23
  187. package/src/hooks/useInputBasedComponent.ts +0 -71
  188. package/src/hooks/useMouseOver.ts +0 -23
  189. package/src/index.tsx +0 -12
  190. package/src/interfaces/context.ts +0 -21
  191. package/src/interfaces/index.ts +0 -12
  192. package/src/interfaces/parameters.ts +0 -26
  193. package/src/interfaces/property.ts +0 -111
  194. package/src/sandbox/index.tsx +0 -137
  195. package/src/sandbox/mock/Context.ts +0 -18
  196. package/src/sandbox/mock/Formatting.ts +0 -186
  197. package/src/sandbox/mock/Mode.ts +0 -25
  198. package/src/sandbox/mock/UserSettings.ts +0 -31
  199. package/src/sandbox/mock/Utility.ts +0 -14
  200. package/src/sandbox/shared/durationList.tsx +0 -24
  201. package/src/sandbox/shared/multiSelectOptionList.tsx +0 -5
  202. package/src/sandbox/shared/optionList.tsx +0 -5
  203. package/src/stories/Introduction.stories.mdx +0 -122
  204. package/src/stories/assets/code-brackets.svg +0 -1
  205. package/src/stories/assets/colors.svg +0 -1
  206. package/src/stories/assets/comments.svg +0 -1
  207. package/src/stories/assets/direction.svg +0 -1
  208. package/src/stories/assets/flow.svg +0 -1
  209. package/src/stories/assets/plugin.svg +0 -1
  210. package/src/stories/assets/repo.svg +0 -1
  211. package/src/stories/assets/stackalt.svg +0 -1
  212. package/src/types/index.ts +0 -3
  213. package/src/utils/NumeralPCF.ts +0 -62
  214. package/tsconfig.json +0 -28
@@ -1,3110 +0,0 @@
1
- //@ts-nocheck
2
- /*
3
- The MIT License (MIT)
4
-
5
- Copyright (c) 2016 Jim Daly
6
-
7
- Permission is hereby granted, free of charge, to any person obtaining a copy
8
- of this software and associated documentation files (the "Software"), to deal
9
- in the Software without restriction, including without limitation the rights
10
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom the Software is
12
- furnished to do so, subject to the following conditions:
13
-
14
- The above copyright notice and this permission notice shall be included in all
15
- copies or substantial portions of the Software.
16
-
17
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
- SOFTWARE.
24
- */
25
-
26
- export namespace Sdk.FetchXml {
27
- @sealed
28
- export class attribute {
29
- /**
30
- * Contains the data for a fetchXml attribute element.
31
- * @param name The logical name of the attribute
32
- */
33
- constructor(name: string) {
34
- //new keyword not required
35
- if (!(this instanceof attribute))
36
- { return new attribute(name); }
37
-
38
- this.name = name;
39
- }
40
-
41
- private _name: string;
42
- private _build: Build = null;
43
- private _addedBy: string = null;
44
- private _alias: string = null;
45
- private _aggregate: Aggregate = null;
46
- private _groupBy: boolean = null;
47
- private _dateGrouping: DateGrouping = null;
48
- private _userTimeZone: boolean = null;
49
-
50
- /**
51
- *Gets or sets logical name of the attribute
52
- */
53
- public get name(): string {
54
- return this._name;
55
- }
56
- public set name(value: string) {
57
- if (!Util.isString(value)) {
58
- throw new Error("Sdk.FetchXml.attribute name property must be an string.");
59
- }
60
- this._name = value;
61
- }
62
- /**
63
- *Gets or sets the build of the attribute
64
- */
65
- public get build(): Build {
66
- return this._build;
67
- }
68
- public set build(value: Build) {
69
- if (!Util.isEnumMemberOrNull(Build, value)) {
70
- throw new Error("Sdk.FetchXml.attribute build property must be an Sdk.FetchXml.Build value or null.");
71
- }
72
- this._build = value;
73
- }
74
- /**
75
- *Gets or sets the addedBy property of the attribute
76
- */
77
- public get addedBy(): string {
78
- return this._addedBy;
79
- }
80
- public set addedBy(value: string) {
81
- if (!Util.isStringOrNull(value)) {
82
- throw new Error("Sdk.FetchXml.attribute addedBy property must be an string value or null.");
83
- }
84
- this._addedBy = value;
85
- }
86
- /**
87
- *Gets or sets the alias property of the attribute
88
- */
89
- public get alias(): string {
90
- return this._alias;
91
- }
92
- public set alias(value: string) {
93
- if (!Util.isStringOrNull(value)) {
94
- throw new Error("Sdk.FetchXml.attribute alias property must be an string value or null.");
95
- }
96
- this._alias = value;
97
- }
98
- /**
99
- *Gets or sets the aggregate property of the attribute
100
- */
101
- public get aggregate(): Aggregate {
102
- return this._aggregate;
103
- }
104
- public set aggregate(value: Aggregate) {
105
- if (!Util.isEnumMemberOrNull(Aggregate, value)) {
106
- throw new Error("Sdk.FetchXml.attribute aggregate property must be an Sdk.FetchXml.Aggregate value or null.");
107
- }
108
- this._aggregate = value;
109
- }
110
- /**
111
- *Gets or sets the groupBy property of the attribute
112
- */
113
- public get groupBy(): boolean {
114
- return this._groupBy;
115
- }
116
- public set groupBy(value: boolean) {
117
- if (!Util.isBooleanOrNull(value)) {
118
- throw new Error("Sdk.FetchXml.attribute groupBy property must be an boolean value or null.");
119
- }
120
- this._groupBy = value;
121
- }
122
- /**
123
- * Gets or sets the dateGrouping property of the attribute
124
- */
125
- public get dateGrouping(): DateGrouping {
126
- return this._dateGrouping;
127
- }
128
- public set dateGrouping(value: DateGrouping) {
129
- if (!Util.isEnumMemberOrNull(DateGrouping, value)) {
130
- throw new Error("Sdk.FetchXml.attribute dateGrouping property must be an Sdk.FetchXml.DateGrouping value or null.");
131
- }
132
- this._dateGrouping = value;
133
- }
134
- /**
135
- *Gets or sets the userTimeZone property of the attribute
136
- */
137
- public get userTimeZone(): boolean {
138
- return this._userTimeZone;
139
- }
140
- public set userTimeZone(value: boolean) {
141
- if (!Util.isBooleanOrNull(value)) {
142
- throw new Error("Sdk.FetchXml.attribute userTimeZone property must be an boolean value or null.");
143
- }
144
- this._userTimeZone = value;
145
- }
146
-
147
- /** @description Sets the name property of the attribute attribute
148
- * @param {string} name The name value to apply to the attribute
149
- * @returns {Sdk.FetchXml.attribute}
150
- */
151
- public setName(name: string) {
152
- this.name = name;
153
- return this;
154
- }
155
-
156
- /** @description Sets the build property of the build attribute
157
- * @param {Sdk.FetchXml.Build | null} build The build value to apply to the attribute
158
- * @returns {Sdk.FetchXml.attribute}
159
- */
160
- public setBuild(build?: Build) {
161
- (build) ? this.build = build : this.build = null;
162
- return this;
163
- }
164
-
165
- /** @description Sets the addedBy property of the attribute attribute
166
- * @param {string | null} addedBy The addedBy value to apply to the attribute
167
- * @returns {Sdk.FetchXml.attribute}
168
- */
169
- public setAddedBy(addedBy?: string) {
170
- (addedBy) ? this.addedBy = addedBy : this.addedBy = null;
171
- return this;
172
- }
173
-
174
- /** @description Sets the alias property of the attribute attribute
175
- * @param {string} alias The alias value to apply to the attribute
176
- * @returns {Sdk.FetchXml.attribute}
177
- */
178
- public setAlias(alias?: string) {
179
- (alias) ? this.alias = alias : this.alias = null;
180
- return this;
181
- }
182
-
183
- /** @description Sets the aggregate property of the attribute attribute
184
- * @param {Sdk.FetchXml.Aggregate | null } aggregate The aggregate value to apply to the attribute
185
- * @returns {Sdk.FetchXml.attribute}
186
- */
187
-
188
- public setAggregate(aggregate?: Aggregate) {
189
- (aggregate) ? this.aggregate = aggregate : this.aggregate = null;
190
- return this;
191
- }
192
- /** @description Sets the groupBy property of the attribute attribute
193
- * @param {boolean | null} groupBy The groupBy value to apply to the attribute
194
- * @returns {Sdk.FetchXml.attribute}
195
- */
196
-
197
- public setGroupBy(groupBy?: boolean) {
198
- (groupBy) ? this.groupBy = groupBy : groupBy = null;
199
- return this;
200
- }
201
-
202
- /** @description Sets the dateGrouping property of the attribute attribute
203
- * @param {Sdk.FetchXml.DateGrouping | null} dateGrouping The dateGrouping value to apply to the attribute
204
- * @returns {Sdk.FetchXml.attribute}
205
- */
206
- public setDateGrouping(dateGrouping?: DateGrouping) {
207
- (dateGrouping) ? this.dateGrouping = dateGrouping : this.dateGrouping = null;
208
- return this;
209
- }
210
-
211
- /** @description Sets the userTimeZone property of the attribute attribute
212
- * @param {boolean | null} userTimeZone The userTimeZone value to apply to the attribute
213
- * @returns {Sdk.FetchXml.attribute}
214
- */
215
- public setUserTimeZone(userTimeZone?: boolean) {
216
- (userTimeZone) ? this.userTimeZone = userTimeZone : this.userTimeZone = null;
217
- return this;
218
- }
219
-
220
- //Internal use only
221
- toXml(doc: XMLDocument): Node {
222
- var aNode = doc.createElement("attribute");
223
- aNode.setAttribute("name", <string>this.name);
224
- if (this.build) {
225
- aNode.setAttribute("build", <string>this.build);
226
- }
227
- if (this.addedBy) {
228
- aNode.setAttribute("addedby", <string>this.addedBy);
229
- }
230
- if (this.alias) {
231
- aNode.setAttribute("alias", <string>this.alias);
232
- }
233
- if (this.aggregate) {
234
- aNode.setAttribute("aggregate", <string>this.aggregate);
235
- }
236
- if (Util.isBoolean(this.groupBy)) {
237
- aNode.setAttribute("groupby", (this.groupBy) ? "true" : "false");
238
- }
239
- if (this.dateGrouping) {
240
- aNode.setAttribute("dategrouping", <string>this.dateGrouping);
241
- }
242
- if (Util.isBoolean(this.userTimeZone)) {
243
- aNode.setAttribute("usertimezone", (this.userTimeZone) ? "true" : "false");
244
- }
245
- return aNode;
246
- }
247
-
248
- //Internal use only
249
- static attributeFromXml(xml) {
250
- var attObj = new attribute(xml.attributes.getNamedItem("name").nodeValue);
251
-
252
- Util.parseAttributes(xml, attObj, (attObj, name, value) => {
253
- switch (name) {
254
- case "build":
255
- case "alias":
256
- case "aggregate":
257
- attObj[name] = value;
258
- break;
259
- case "addedby":
260
- attObj.addedBy = value;
261
- break;
262
- case "dategrouping":
263
- attObj.dateGrouping = value;
264
- break;
265
- case "groupby":
266
- attObj.groupBy = Util.convertFetchBoolType(value);
267
- case "usertimezone":
268
- attObj.userTimeZone = Util.convertFetchBoolType(value);
269
- break;
270
- default:
271
- break;
272
-
273
- }
274
- });
275
-
276
- return attObj;
277
- }
278
- }
279
- @sealed
280
- export class condition {
281
- /**
282
- * Contains the data for a fetchXml condition element.
283
- * @param attribute The attribute to evaluate in the condition
284
- * @param operator The operator to use when evaluating the attribute
285
- * @param [values] The value(s) to apply in the comparison.
286
- */
287
- constructor(attribute: string, operator: Sdk.FetchXml.Operator, values?: Array<Sdk.FetchXml.value>) {
288
- //New keyword not required in JS
289
- if (!(this instanceof Sdk.FetchXml.condition))
290
- { return new Sdk.FetchXml.condition(attribute, operator, values); }
291
-
292
- if (attribute && operator) {
293
- this.attribute = attribute;
294
- this.operator = operator;
295
- }
296
- else {
297
- throw new Error("Sdk.FetchXml.condition constructor parameters attribute and operator are required.");
298
- }
299
- if (values)
300
- this.values = values;
301
- }
302
-
303
- private _aggregate: Sdk.FetchXml.Aggregate = null;
304
- private _alias: string = null;
305
- private _attribute: string = null;
306
- private _column: string = null;
307
- private _entityname: string = null;
308
- private _operator: Sdk.FetchXml.Operator = null;
309
- private _rowAggregate: Sdk.FetchXml.RowAggregate = null;
310
- private _uihidden: boolean = null;
311
- private _uiname: string = null;
312
- private _uitype: string = null;
313
- private _values: Array<Sdk.FetchXml.value> = [];
314
-
315
- /**
316
- * Gets or sets the aggregate value to apply to the condition.
317
- */
318
- public get aggregate(): Sdk.FetchXml.Aggregate {
319
- return this._aggregate;
320
- }
321
- public set aggregate(value: Sdk.FetchXml.Aggregate) {
322
- this._aggregate = value;
323
- }
324
- /**
325
- * Gets or sets the alias value to apply to the condition.
326
- */
327
- public get alias(): string {
328
- return this._alias;
329
- }
330
- public set alias(value: string) {
331
- this._alias = value;
332
- }
333
- /**
334
- * Gets or sets the attribute value to apply to the condition.
335
- */
336
- public get attribute(): string {
337
- return this._attribute;
338
- }
339
- public set attribute(value: string) {
340
- this._attribute = value;
341
- }
342
- /**
343
- * Gets or sets the column attribute value to apply to the condition.
344
- */
345
- public get column(): string {
346
- return this._column;
347
- }
348
- public set column(value: string) {
349
- this._column = value;
350
- }
351
- /**
352
- * Gets or sets the entityname attribute value to apply to the condition.
353
- */
354
- public get entityname(): string {
355
- return this._entityname;
356
- }
357
- public set entityname(value: string) {
358
- this._entityname = value;
359
- }
360
- /**
361
- * Gets or sets the operator attribute value to apply to the condition.
362
- */
363
- public get operator(): Sdk.FetchXml.Operator {
364
- return this._operator;
365
- }
366
- public set operator(value: Sdk.FetchXml.Operator) {
367
- this._operator = value;
368
- }
369
- /**
370
- * Gets or sets the rowAggregate attribute value to apply to the condition.
371
- */
372
- public get rowAggregate(): Sdk.FetchXml.RowAggregate {
373
- return this._rowAggregate;
374
- }
375
- public set rowAggregate(value: Sdk.FetchXml.RowAggregate) {
376
- this._rowAggregate = value;
377
- }
378
- /**
379
- * Gets or sets the uihidden attribute value to apply to the condition.
380
- */
381
- public get uihidden(): boolean {
382
- return this._uihidden;
383
- }
384
- public set uihidden(value: boolean) {
385
- this._uihidden = value;
386
- }
387
- /**
388
- * Gets or sets the uiname attribute value to apply to the condition.
389
- */
390
- public get uiname(): string {
391
- return this._uiname;
392
- }
393
- public set uiname(value: string) {
394
- this._uiname = value;
395
- }
396
- /**
397
- * Gets or sets the uitype attribute value to apply to the condition.
398
- */
399
- public get uitype(): string {
400
- return this._uitype;
401
- }
402
- public set uitype(value: string) {
403
- this._uitype = value;
404
- }
405
- /**
406
- * Gets or sets the array of values to be applied to the query results
407
- */
408
- public get values(): Array<Sdk.FetchXml.value> {
409
- return this._values;
410
- }
411
- public set values(value: Array<Sdk.FetchXml.value>) {
412
- if (!Sdk.FetchXml.Util.isValueArrayOrNull(value)) {
413
- throw new Error("Sdk.FetchXml.condition.values must be an array of Sdk.FetchXml.value or null.");
414
- }
415
- if (value == null) {
416
- this._values = [];
417
- } else {
418
- this._values = value;
419
- }
420
- }
421
- //Internal use only
422
- public get hash(): string {
423
- var s = this._attribute.concat(<string>this._operator,
424
- (this._aggregate ? <string>this._aggregate : ""),
425
- (this._alias ? this._alias : ""),
426
- (this._column ? this._column : ""),
427
- (this._entityname ? this._entityname : ""),
428
- (this._rowAggregate ? <string>this._rowAggregate : ""),
429
- (Sdk.FetchXml.Util.isNullOrUndefined(this._uihidden) ? "" : this._uihidden.toString()),
430
- (this._uiname ? this._uiname : ""),
431
- (this._uitype ? this._uitype : ""),
432
- Sdk.FetchXml.Util.getCollectionHash(this._values)
433
- );
434
- return s.hashCode();
435
- }
436
-
437
- /** @description Sets the value of the condition attribute
438
- * @param {string} attribute The attribute to evaluate in the condition.
439
- * @returns {Sdk.FetchXml.condition}
440
- */
441
- public setAttribute(attributeName) {
442
- this.attribute = attributeName;
443
- return this;
444
- }
445
-
446
- /** @description Sets the value of the condition attribute
447
- * @param {Sdk.FetchXml.Operator} operator The operator to use when evaluating the attribute.
448
- * @returns {Sdk.FetchXml.condition}
449
- */
450
- public setOperator(operator) {
451
- this.operator = operator;
452
- return this;
453
- }
454
-
455
- /** @description Sets the value of the condition operator
456
- * @param {Array} values The the value(s) to apply in the comparison.
457
- * @returns {Sdk.FetchXml.condition}
458
- */
459
- public setValues(values) {
460
- this.values = values;
461
- return this;
462
- }
463
-
464
- /** @description Adds a value to the values to apply in the comparison
465
- * @param {Sdk.FetchXml.value | any} value The the value to add to the values.
466
- * @returns {Sdk.FetchXml.condition}
467
- */
468
- public addValue(value) {
469
- if (Sdk.FetchXml.Util.isValue(value)) {
470
- this.values.push(value);
471
- }
472
- else {
473
- this.values.push(new Sdk.FetchXml.value(value));
474
- }
475
- return this;
476
- }
477
-
478
- /** @description Removes any values from the values collection by reference
479
- * @param {Sdk.FetchXml.value} value The value to remove from the values collection
480
- * @returns {Sdk.FetchXml.condition}
481
- */
482
- public removeValueByRef(value) {
483
- if (!Sdk.FetchXml.Util.isValue(value)) {
484
- throw new Error("Sdk.FetchXml.condition removeValueByRef method value parameter must be an Sdk.FetchXml.value.");
485
- }
486
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.values, value);
487
- return this;
488
- }
489
-
490
- /** @description Removes all matching values from the values collection
491
- * @param {Sdk.FetchXml.value} value The value to remove from the values collection
492
- * @returns {Sdk.FetchXml.condition}
493
- */
494
- public removeValue(value) {
495
- if (!Sdk.FetchXml.Util.isValue(value)) {
496
- throw new Error("Sdk.FetchXml.condition removeValue method value parameter must be an Sdk.FetchXml.value.");
497
- }
498
- Sdk.FetchXml.Util.removeCollectionValue(this.values, value);
499
- return this;
500
- }
501
-
502
- /** @description Removes all any values from the values collection with the specified value property
503
- * @param {object} value The value to remove from the values collection
504
- * @returns {Sdk.FetchXml.condition}
505
- */
506
- public removeValueByValue(value) {
507
- Sdk.FetchXml.Util.removeCollectionValueByProperty(this.values, "value", value);
508
- return this;
509
- }
510
-
511
- /** @description Sets the Aggregate to apply in the condition
512
- * @param {Sdk.FetchXml.Aggregate} aggregate The Aggregate to apply in the condition
513
- * @returns {Sdk.FetchXml.condition}
514
- */
515
- public setAggregate(aggregate) {
516
- this.aggregate = aggregate;
517
- return this;
518
- }
519
-
520
- /** @description Sets the Alias to apply in the condition
521
- * @param {string} alias The alias to apply in the condition
522
- * @returns {Sdk.FetchXml.condition}
523
- */
524
- public setAlias(alias) {
525
- this.alias = alias;
526
- return this;
527
- }
528
-
529
- /** @description Sets the Column to apply in the condition
530
- * @param {string} column The column to apply in the condition
531
- * @returns {Sdk.FetchXml.condition}
532
- */
533
- public setColumn(column) {
534
- this.column = column;
535
- return this;
536
- }
537
-
538
- /** @description Sets the entityname to apply in the condition
539
- * @param {string} entityname The entityname to apply in the condition
540
- * @returns {Sdk.FetchXml.condition}
541
- */
542
- public setEntityname(entityname) {
543
- this.entityname = entityname;
544
- return this;
545
- }
546
-
547
- /** @description Sets the rowAggregate to apply in the condition
548
- * @param {Sdk.FetchXml.RowAggregate} rowAggregate The rowAggregate to apply in the condition
549
- * @returns {Sdk.FetchXml.condition}
550
- */
551
- public setRowAggregate(rowAggregate) {
552
- this.rowAggregate = rowAggregate;
553
- return this;
554
- }
555
-
556
- /** @description Sets the uihidden to apply in the condition
557
- * @param {boolean | null} uihidden The uihidden to apply in the condition
558
- * @returns {Sdk.FetchXml.condition}
559
- */
560
- public setUIhidden(uihidden) {
561
- this.uihidden = uihidden;
562
- return this;
563
- }
564
-
565
- /** @description Sets the uiname to apply in the condition
566
- * @param {string} uihidden The uiname to apply in the condition
567
- * @returns {Sdk.FetchXml.condition}
568
- */
569
- public setUIname(uiname) {
570
- this.uiname = uiname;
571
- return this;
572
- }
573
-
574
- /** @description Sets the uitype to apply in the condition
575
- * @param {string} uitype The uitype to apply in the condition
576
- * @returns {Sdk.FetchXml.condition}
577
- */
578
- public setUItype(uitype) {
579
- this.uitype = uitype;
580
- return this;
581
- }
582
-
583
- //Internal use only
584
- toXml(doc: XMLDocument): Node {
585
-
586
- var cNode = doc.createElement("condition");
587
- if (this.aggregate) {
588
- cNode.setAttribute("aggregate", <string>this.aggregate);
589
- }
590
- if (this.alias) {
591
- cNode.setAttribute("alias", this.alias);
592
- }
593
- if (this.attribute) {
594
- cNode.setAttribute("attribute", this.attribute);
595
- }
596
- if (this.column) {
597
- cNode.setAttribute("column", this.column);
598
- }
599
- if (this.entityname) {
600
- cNode.setAttribute("entityname", this.entityname);
601
- }
602
- if (this.operator) {
603
- cNode.setAttribute("operator", <string>this.operator);
604
- }
605
- if (this.rowAggregate) {
606
- cNode.setAttribute("rowAggregate", <string>this.rowAggregate);
607
- }
608
- if (Sdk.FetchXml.Util.isBoolean(this.uihidden)) {
609
- cNode.setAttribute("uihidden", this.uihidden.toString());
610
- }
611
- if (this.uiname) {
612
- cNode.setAttribute("uiname", this.uiname);
613
- }
614
- if (this.uitype) {
615
- cNode.setAttribute("uitype", this.uitype);
616
- }
617
- /*
618
- Note from fetch.xsd:
619
- The attribute "value" is used for all operators that compare to a single value (for example, eq).
620
- The element "value" is used for operators that compare to multiple values (for example, in).
621
- Some operators require neither the attribute "value" or the element "value" (for example, null).
622
-
623
- Groupings below are guesses and not confirmed.
624
- */
625
- switch (this.operator) {
626
- //Operators used for single values
627
- case "begins-with":
628
- case "ends-with":
629
- case "eq":
630
- case "ge":
631
- case "gt":
632
- case "last-x-days":
633
- case "last-x-fiscal-periods":
634
- case "last-x-fiscal-years":
635
- case "last-x-hours":
636
- case "last-x-months":
637
- case "last-x-weeks":
638
- case "last-x-years":
639
- case "last-year":
640
- case "le":
641
- case "like":
642
- case "lt":
643
- case "ne":
644
- case "neq": //Is this the same as 'ne'?
645
- case "next-x-days":
646
- case "next-x-fiscal-periods":
647
- case "next-x-fiscal-years":
648
- case "next-x-hours":
649
- case "next-x-months":
650
- case "next-x-weeks":
651
- case "next-x-years":
652
- case "not-begin-with":
653
- case "not-end-with":
654
- case "not-like":
655
- case "olderthan-x-days":
656
- case "olderthan-x-hours":
657
- case "olderthan-x-minutes":
658
- case "olderthan-x-months":
659
- case "olderthan-x-weeks":
660
- case "olderthan-x-years":
661
- case "on":
662
- case "on-or-after":
663
- case "on-or-before":
664
- case "in-fiscal-period":
665
- case "in-fiscal-year":
666
-
667
- if (this.values.length == 1) {
668
- cNode.setAttribute("value", this.values[0].value);
669
- }
670
- else {
671
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
672
- throw new Error("Sdk.FetchXml.condition values property must contain single value when the Sdk.FetchXml.Operator." + enumPropertyName + " operator is used.");
673
- }
674
- break;
675
- //Operators used for multiple values
676
- case "between":
677
- case "in":
678
- case "not-between":
679
- case "not-in":
680
- case "in-fiscal-period-and-year":
681
- case "in-or-after-fiscal-period-and-year":
682
- case "in-or-before-fiscal-period-and-year":
683
- if (this.values.length > 1) {
684
- this.values.forEach(function (v) {
685
- cNode.appendChild(v.toXml(doc));
686
- });
687
- }
688
- else {
689
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
690
- throw new Error("Sdk.FetchXml.condition values property must contain multiple values when the Sdk.FetchXml.Operator." + enumPropertyName + " operator is used.");
691
- }
692
- break;
693
- //Operators that require no values
694
- case "above":
695
- case "eq-businessid":
696
- case "eq-or-above":
697
- case "eq-or-under":
698
- case "eq-userid": //?
699
- case "eq-userlanguage": //?
700
- case "eq-useroruserhierarchy":
701
- case "eq-useroruserhierarchyandteams":
702
- case "eq-useroruserteams":
703
- case "eq-userteams":
704
- case "last-fiscal-period":
705
- case "last-fiscal-year":
706
- case "last-month":
707
- case "last-seven-days":
708
- case "last-week":
709
- case "ne-businessid"://?
710
- case "ne-userid"://?
711
- case "next-fiscal-period":
712
- case "next-fiscal-year":
713
- case "next-month":
714
- case "next-seven-days":
715
- case "next-week":
716
- case "next-year":
717
- case "not-null":
718
- case "not-under":
719
- case "null":
720
- case "this-fiscal-period":
721
- case "this-fiscal-year":
722
- case "this-month":
723
- case "this-week":
724
- case "this-year":
725
- case "today":
726
- case "tomorrow":
727
- case "under":
728
- case "yesterday":
729
- //No value required
730
- if (this.values.length > 0) {
731
- var enumPropertyName = Sdk.FetchXml.Util.getEnumNameFromValue(Sdk.FetchXml.Operator, this.operator);
732
- console.log("Sdk.FetchXml.condition doesn't require values when the Sdk.FetchXml.Operator.%s operator is used. The values passed were ignored.", enumPropertyName);
733
- }
734
-
735
- break;
736
- default:
737
- throw new Error(this.operator + " is an unexpected Sdk.FetchXml.Operator value.");
738
- break;
739
- }
740
-
741
- return cNode;
742
- }
743
- //Internal use only
744
- static conditionFromXml(xml) {
745
- var attributeName = xml.attributes.getNamedItem("attribute").nodeValue;
746
- var operator = xml.attributes.getNamedItem("operator").nodeValue;
747
-
748
- var conditionObj = new Sdk.FetchXml.condition(<string>attributeName, <Operator>operator);
749
-
750
- Sdk.FetchXml.Util.parseAttributes(xml, conditionObj, (conditionObj, name, value) => {
751
- switch (name) {
752
- case "column":
753
- case "entityname":
754
- case "aggregate":
755
- case "alias":
756
- case "uiname":
757
- case "uitype":
758
- conditionObj[name] = value;
759
- break;
760
- case "rowaggregate":
761
- conditionObj.rowAggregate = value;
762
- break;
763
- case "uihidden":
764
- conditionObj.uihidden = Util.convertFetchBoolType(value);
765
- break;
766
- case "value":
767
- conditionObj.addValue(value);
768
- break;
769
- default:
770
- break;
771
- }
772
- });
773
-
774
- for (var i = 0; i < xml.childNodes.length; i++) {
775
-
776
- if (xml.childNodes[i].nodeName == "value") {
777
- conditionObj.addValue(value.valueFromXml(xml.childNodes[i]));
778
- }
779
-
780
- }
781
- return conditionObj;
782
- }
783
-
784
- }
785
- @sealed
786
- export class entity {
787
- /**
788
- * Contains the data for a fetchXml entity element.
789
- * @param name The logical name of the attribute
790
- * @param [attributes] The attributes to include with the entity
791
- * @param [orders] The orders to apply to the query
792
- * @param [filters] The filters to apply to the query
793
- */
794
- constructor(name: string, attributes?: Array<Sdk.FetchXml.attribute>, orders?: Array<Sdk.FetchXml.order>, filters?: Array<Sdk.FetchXml.filter>) {
795
- if (!(this instanceof Sdk.FetchXml.entity))
796
- { return new Sdk.FetchXml.entity(name, attributes, orders, filters); }
797
-
798
- this.name = name;
799
- if (attributes)
800
- this.attributes = attributes;
801
- if (orders)
802
- this.orders = orders;
803
- if (filters)
804
- this.filters = filters;
805
- }
806
-
807
- private _allAttributes: boolean = null;
808
- private _attributes: Array<Sdk.FetchXml.attribute> = [];
809
- private _orders: Array<Sdk.FetchXml.order> = [];
810
- private _linkEntities: Array<Sdk.FetchXml.linkEntity> = [];
811
- private _filters: Array<Sdk.FetchXml.filter> = [];
812
- private _name: string;
813
-
814
- /**
815
- * Gets or sets whether all attributes for the entity should be returned
816
- */
817
- public get allAttributes(): boolean {
818
- return this._allAttributes;
819
- }
820
- public set allAttributes(value: boolean) {
821
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
822
- throw new Error("Sdk.FetchXml.entity.allAttributes must be a boolean value or null.");
823
- }
824
- this._allAttributes = value;
825
- }
826
- /**
827
- * Gets or sets the array of attribute of the entity to be returned in the query results
828
- */
829
- public get attributes(): Array<Sdk.FetchXml.attribute> {
830
- return this._attributes;
831
- }
832
- public set attributes(value: Array<Sdk.FetchXml.attribute>) {
833
- if (!Sdk.FetchXml.Util.isAttributeArrayOrNull(value)) {
834
- throw new Error("Sdk.FetchXml.entity.attributes must be an array of Sdk.FetchXml.attribute or null.");
835
- }
836
- if (value == null) {
837
- this._attributes = [];
838
- } else {
839
- this._attributes = value;
840
- }
841
-
842
- }
843
- /**
844
- * Gets or sets the array of attribute of the entity to be returned in the query results
845
- */
846
- public get orders(): Array<Sdk.FetchXml.order> {
847
- return this._orders;
848
- }
849
- public set orders(value: Array<Sdk.FetchXml.order>) {
850
- if (!Sdk.FetchXml.Util.isOrderArrayOrNull(value)) {
851
- throw new Error("Sdk.FetchXml.entity.orders must be an array of Sdk.FetchXml.order or null.");
852
- }
853
- if (value == null) {
854
- this._orders = [];
855
- } else {
856
- this._orders = value;
857
- }
858
-
859
- }
860
- /**
861
- * Gets or sets the array of related entities to be returned in the query results
862
- */
863
- public get linkEntities(): Array<Sdk.FetchXml.linkEntity> {
864
- return this._linkEntities;
865
- }
866
- public set linkEntities(value: Array<Sdk.FetchXml.linkEntity>) {
867
- if (!Sdk.FetchXml.Util.isLinkEntityArrayOrNull(value)) {
868
- throw new Error("Sdk.FetchXml.entity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");
869
- }
870
- if (value == null) {
871
- this._linkEntities = [];
872
- } else {
873
- this._linkEntities = value;
874
- }
875
-
876
- }
877
- /**
878
- * Gets or sets the array of filters to be applied to the query results
879
- */
880
- public get filters(): Array<Sdk.FetchXml.filter> {
881
- return this._filters;
882
- }
883
- public set filters(value: Array<Sdk.FetchXml.filter>) {
884
- if (!Sdk.FetchXml.Util.isFilterArrayOrNull(value)) {
885
- throw new Error("Sdk.FetchXml.entity.filters must be an array of Sdk.FetchXml.filter or null.");
886
- }
887
- if (value == null) {
888
- this._filters = [];
889
- } else {
890
- this._filters = value;
891
- }
892
-
893
- }
894
- /**
895
- * Gets or sets the logical name of the entity
896
- */
897
- public get name(): string {
898
- return this._name;
899
- }
900
- public set name(value: string) {
901
- if (!Sdk.FetchXml.Util.isString(value)) {
902
- throw new Error("Sdk.FetchXml.entity.name must be a string.");
903
- }
904
- this._name = value;
905
-
906
- }
907
-
908
- /** @description Adds an attribute to the attribute collection
909
- * @param {Sdk.FetchXml.attribute | string} attributeOrAttributeName the attribute or attribute name to add
910
- * @returns {Sdk.FetchXml.entity}
911
- */
912
- public addAttribute(attributeOrAttributeName: Sdk.FetchXml.attribute | string) {
913
- if (Sdk.FetchXml.Util.isString(attributeOrAttributeName)) {
914
-
915
- // Some saved queries have duplicate attributes defined, so this is a bit more strict than it has to be.
916
- var exists = false;
917
- this.attributes.forEach(function (a) {
918
- if (a.name == attributeOrAttributeName) {
919
- exists = true;
920
- }
921
- });
922
- if (!exists) {
923
- this.attributes.push(new Sdk.FetchXml.attribute(<string>attributeOrAttributeName));
924
- }
925
- return this;
926
- }
927
- if (Sdk.FetchXml.Util.isAttribute(attributeOrAttributeName)) {
928
- var exists = false;
929
- this.attributes.forEach(function (a) {
930
- if (a.name == (<Sdk.FetchXml.attribute>attributeOrAttributeName).name) {
931
- exists = true;
932
- }
933
- });
934
- if (!exists) {
935
- this.attributes.push(<Sdk.FetchXml.attribute>attributeOrAttributeName);
936
- }
937
- }
938
- else {
939
- throw new Error("Sdk.FetchXml.entity addAttribute method attributeOrAttributeName parameter must be an Sdk.FetchXml.attribute or a string value.");
940
- }
941
- return this;
942
- }
943
-
944
- /** @description Removes an attribute from the attributes collection by name
945
- * @param {string} attributeName The name of the attribute to remove
946
- * @returns {Sdk.FetchXml.entity}
947
- */
948
- public removeAttributeByName(attributeName: string) {
949
- Sdk.FetchXml.Util.removeCollectionValueByProperty(this.attributes, "name", attributeName);
950
- }
951
-
952
- /** @description Removes an attribute from the attributes collection by reference
953
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove
954
- * @returns {Sdk.FetchXml.entity}
955
- */
956
- public removeAttributeByRef(attribute: Sdk.FetchXml.attribute) {
957
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.attributes, attribute);
958
- }
959
-
960
- /** @description Removes an attribute from the attributes collection
961
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove
962
- * @returns {Sdk.FetchXml.entity}
963
- */
964
- public removeAttribute(attribute: Sdk.FetchXml.attribute) {
965
- Sdk.FetchXml.Util.removeCollectionValue(this.attributes, attribute);
966
- }
967
-
968
- /** @description Adds an order to the orders collection
969
- * @param {Sdk.FetchXml.order | string} orderOrAttribute The order to add to the attributes collection or the Attribute property of a new order to create
970
- * @param {boolean} descending Whether the order is descending. True if descending, otherwise false
971
- * @param {string} alias The alias to set for the order
972
- * @returns {Sdk.FetchXml.entity}
973
- */
974
- public addOrder(orderOrAttribute: any, descending?, alias?) {
975
- if (Sdk.FetchXml.Util.isOrder(orderOrAttribute)) {
976
- this.orders.push(orderOrAttribute);
977
- return this;
978
- }
979
- if (Sdk.FetchXml.Util.isString(orderOrAttribute)) {
980
- this.orders.push(new Sdk.FetchXml.order(orderOrAttribute, descending, alias));
981
- }
982
- else {
983
- throw new Error("Sdk.FetchXml.entity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.");
984
- }
985
- return this;
986
- }
987
-
988
- /** @description Removes a order from the orders collection by reference
989
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
990
- * @returns {Sdk.FetchXml.entity}
991
- */
992
- public removeOrderByRef(order: Sdk.FetchXml.order) {
993
- if (!Sdk.FetchXml.Util.isOrder(order)) {
994
- throw new Error("Sdk.FetchXml.entity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");
995
- }
996
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.orders, order);
997
- return this;
998
- }
999
-
1000
- /** @description Removes a order from the orders collection by value
1001
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
1002
- * @returns {Sdk.FetchXml.entity}
1003
- */
1004
- public removeOrder(order) {
1005
- if (!Sdk.FetchXml.Util.isOrder(order)) {
1006
- throw new Error("Sdk.FetchXml.entity removeOrder method order parameter must be an Sdk.FetchXml.order.");
1007
- }
1008
- Sdk.FetchXml.Util.removeCollectionValue(this.orders, order);
1009
- return this;
1010
- }
1011
-
1012
- /** @description Sets the name property of the entity element
1013
- * @param {string} name The name value to apply to the entity
1014
- * @returns {Sdk.FetchXml.entity}
1015
- */
1016
- public setName(name: string) {
1017
- this.name = name;
1018
- return this;
1019
- }
1020
-
1021
- /** @description Sets the allAttributes property of the entity
1022
- * @param {boolean} [allAttributes] The allAttributes value to apply to the entity. The default is true;
1023
- * @returns {Sdk.FetchXml.entity}
1024
- */
1025
- public setAllAttributes(allAttributes?: boolean) {
1026
- if (Sdk.FetchXml.Util.isBoolean(allAttributes)) {
1027
- this.allAttributes = allAttributes;
1028
- }
1029
- else {
1030
- if (Sdk.FetchXml.Util.isNullOrUndefined(allAttributes)) {
1031
- this.allAttributes = true;
1032
- }
1033
- else {
1034
- throw new Error("Sdk.FetchXml.entity setAllAttributes method allAttributes parameter must be a boolean value or null.");
1035
- }
1036
- }
1037
-
1038
- return this;
1039
- }
1040
-
1041
- /** @description Adds an linkEntity to the linkEntities collection
1042
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to add to the entity
1043
- * @returns {Sdk.FetchXml.entity}
1044
- */
1045
- public addLinkEntity(linkEntity: Sdk.FetchXml.linkEntity) {
1046
- if (Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1047
- this.linkEntities.push(linkEntity);
1048
- return this;
1049
- }
1050
- else {
1051
- throw new Error("Sdk.FetchXml.entity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.");
1052
- }
1053
- return this;
1054
- }
1055
-
1056
- /** @description Removes a linkEntity from the linkEntities collection by reference
1057
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
1058
- * @returns {Sdk.FetchXml.entity}
1059
- */
1060
- public removeLinkEntityByRef(linkEntity: Sdk.FetchXml.linkEntity) {
1061
- if (!Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1062
- throw new Error("Sdk.FetchXml.entity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
1063
- }
1064
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.linkEntities, linkEntity);
1065
- return this;
1066
- }
1067
-
1068
- /** @description Removes a linkEntity from the linkEntities collection by value
1069
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
1070
- * @returns {Sdk.FetchXml.entity}
1071
- */
1072
- public removeLinkEntity(linkEntity: Sdk.FetchXml.linkEntity) {
1073
- if (!Sdk.FetchXml.Util.isLinkEntity(linkEntity)) {
1074
- throw new Error("Sdk.FetchXml.entity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
1075
- }
1076
- Sdk.FetchXml.Util.removeCollectionValue(this.linkEntities, linkEntity);
1077
- return this;
1078
- }
1079
-
1080
- /** @description Adds an filter to the filters collection
1081
- * @param {Sdk.FetchXml.filter} filter The filter to add to the entity
1082
- * @returns {Sdk.FetchXml.entity}
1083
- */
1084
- public addFilter(filter: Sdk.FetchXml.filter) {
1085
- if (Sdk.FetchXml.Util.isFilter(filter)) {
1086
- this.filters.push(filter);
1087
- return this;
1088
- }
1089
- else {
1090
- throw new Error("Sdk.FetchXml.entity addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
1091
- }
1092
- return this;
1093
- }
1094
-
1095
- /** @description Removes a filter from the filters collection by reference
1096
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
1097
- * @returns {Sdk.FetchXml.entity}
1098
- */
1099
- public removeFilterByRef(filter: Sdk.FetchXml.filter) {
1100
- if (!Sdk.FetchXml.Util.isFilter(filter)) {
1101
- throw new Error("Sdk.FetchXml.entity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
1102
- }
1103
- Sdk.FetchXml.Util.removeCollectionValueByRef(this.filters, filter);
1104
- return this;
1105
- }
1106
-
1107
- /** @description Removes a filter from the filters collection by value
1108
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
1109
- * @returns {Sdk.FetchXml.entity}
1110
- */
1111
- public removeFilter(filter: Sdk.FetchXml.filter) {
1112
- if (!Sdk.FetchXml.Util.isFilter(filter)) {
1113
- throw new Error("Sdk.FetchXml.entity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
1114
- }
1115
- Sdk.FetchXml.Util.removeCollectionValue(this.filters, filter);
1116
- return this;
1117
- }
1118
-
1119
- //internal use only
1120
- toXml(doc: XMLDocument): Node {
1121
- var entityNode = doc.createElement("entity");
1122
- if (this.allAttributes) {
1123
- entityNode.appendChild(doc.createElement("all-attributes"));
1124
- }
1125
- else {
1126
- this.attributes.forEach(function (a, i) {
1127
- entityNode.appendChild(a.toXml(doc));
1128
- });
1129
- }
1130
- this.orders.forEach(function (o, i) {
1131
- entityNode.appendChild(o.toXml(doc));
1132
- });
1133
-
1134
- this.linkEntities.forEach(function (l, i) {
1135
- entityNode.appendChild(l.toXml(doc));
1136
- });
1137
-
1138
- this.filters.forEach(function (f, i) {
1139
- entityNode.appendChild(f.toXml(doc));
1140
- });
1141
-
1142
- //Is required so no need to check
1143
- entityNode.setAttribute("name", this.name);
1144
-
1145
- return entityNode;
1146
- }
1147
- //Internal use only
1148
- static entityFromXml(xml) {
1149
- var entityObj = new Sdk.FetchXml.entity(xml.attributes.getNamedItem("name").nodeValue);
1150
- entityObj.allAttributes = (xml.getElementsByTagName("all-attributes").length == 1);
1151
-
1152
- for (var i = 0; i < xml.childNodes.length; i++) {
1153
-
1154
- if (xml.childNodes[i].nodeName == "attribute") {
1155
- entityObj.addAttribute(attribute.attributeFromXml(xml.childNodes[i]));
1156
- }
1157
- if (xml.childNodes[i].nodeName == "order") {
1158
-
1159
- entityObj.addOrder(order.orderFromXml(xml.childNodes[i]));
1160
- }
1161
- if (xml.childNodes[i].nodeName == "link-entity") {
1162
- entityObj.addLinkEntity(linkEntity.linkEntityFromXml(xml.childNodes[i]));
1163
- }
1164
- if (xml.childNodes[i].nodeName == "filter") {
1165
- entityObj.addFilter(filter.filterFromXml(xml.childNodes[i]));
1166
- }
1167
-
1168
- }
1169
-
1170
- return entityObj;
1171
- }
1172
-
1173
- }
1174
- @sealed
1175
- export class fetch {
1176
-
1177
- /**
1178
- * Contains the data for a fetchXml fetch element.
1179
- * @param entity The entity that is being queried
1180
- */
1181
- constructor(entity?: Sdk.FetchXml.entity) {
1182
- //new keyword not required
1183
- if (!(this instanceof Sdk.FetchXml.fetch))
1184
- { return new Sdk.FetchXml.fetch(entity); }
1185
- if (entity)
1186
- this.entity = entity;
1187
- }
1188
-
1189
- private _aggregate: boolean = null;
1190
- private _count: number = null;
1191
- private _distinct: boolean = null;
1192
- private _entity: Sdk.FetchXml.entity;
1193
- private _mapping: Sdk.FetchXml.Mapping = null;
1194
- private _minActiveRowVersion: boolean = null;
1195
- private _noLock: boolean = null;
1196
- private _order: Sdk.FetchXml.order = null;
1197
- private _outputFormat: Sdk.FetchXml.OutputFormat = null;
1198
- private _page: number = null;
1199
- private _pagingCookie: string = null;
1200
- private _returnTotalRecordCount: boolean = null;
1201
- private _top: number = null;
1202
- private _utcOffset: number = null;
1203
- private _version: string = null;
1204
-
1205
- /**
1206
- * Gets or sets the aggregate attribute of the fetch element.
1207
- */
1208
- public get aggregate(): boolean {
1209
- return this._aggregate;
1210
- }
1211
- public set aggregate(value: boolean) {
1212
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1213
- throw new Error("Sdk.FetchXml.fetch.aggregate must be a boolean value or null.");
1214
- }
1215
- this._aggregate = value;
1216
- }
1217
- /**
1218
- * Gets or sets the count attribute of the fetch element.
1219
- */
1220
- public get count(): number {
1221
- return this._count;
1222
- }
1223
- public set count(value: number) {
1224
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1225
- throw new Error("Sdk.FetchXml.fetch.count must be a number value or null.");
1226
- }
1227
- this._count = value;
1228
- }
1229
- /**
1230
- * Gets or sets the distinct attribute of the fetch element.
1231
- */
1232
- public get distinct(): boolean {
1233
- return this._distinct;
1234
- }
1235
- public set distinct(value: boolean) {
1236
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1237
- throw new Error("Sdk.FetchXml.fetch.distinct must be a boolean value or null.");
1238
- }
1239
- this._distinct = value;
1240
- }
1241
- /**
1242
- * Gets or sets the entity attribute of the fetch element.
1243
- */
1244
- public get entity(): Sdk.FetchXml.entity {
1245
- return this._entity;
1246
- }
1247
- public set entity(value: Sdk.FetchXml.entity) {
1248
- if (!Sdk.FetchXml.Util.isEntity(value)) {
1249
- throw new Error("Sdk.FetchXml.fetch.entity must be a Sdk.FetchXml.entity value.");
1250
- }
1251
- this._entity = value;
1252
- }
1253
- /**
1254
- * Gets or sets the mapping attribute of the fetch element.
1255
- */
1256
- public get mapping(): Sdk.FetchXml.Mapping {
1257
- return this._mapping;
1258
- }
1259
- public set mapping(value: Sdk.FetchXml.Mapping) {
1260
- if (!Sdk.FetchXml.Util.isEnumMemberOrNull(Sdk.FetchXml.Mapping, value)) {
1261
- throw new Error("Sdk.FetchXml.fetch.mapping must be a Sdk.FetchXml.Mapping value or null.");
1262
- }
1263
- this._mapping = value;
1264
- }
1265
- /**
1266
- * Gets or sets the minActiveRowVersion attribute of the fetch element.
1267
- */
1268
- public get minActiveRowVersion(): boolean {
1269
- return this._minActiveRowVersion;
1270
- }
1271
- public set minActiveRowVersion(value: boolean) {
1272
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1273
- throw new Error("Sdk.FetchXml.fetch.minActiveRowVersion must be a boolean value or null.");
1274
- }
1275
- this._minActiveRowVersion = value;
1276
- }
1277
- /**
1278
- * Gets or sets the noLock attribute of the fetch element.
1279
- */
1280
- public get noLock(): boolean {
1281
- return this._noLock;
1282
- }
1283
- public set noLock(value: boolean) {
1284
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1285
- throw new Error("Sdk.FetchXml.fetch.noLock must be a boolean value or null.");
1286
- }
1287
- this._noLock = value;
1288
- }
1289
- /**
1290
- * Gets or sets the order attribute of the fetch element.
1291
- */
1292
- public get order(): Sdk.FetchXml.order {
1293
- return this._order;
1294
- }
1295
- public set order(value: Sdk.FetchXml.order) {
1296
- if (!Sdk.FetchXml.Util.isOrderOrNull(value)) {
1297
- throw new Error("Sdk.FetchXml.fetch.order must be a Sdk.FetchXml.order value or null.");
1298
- }
1299
- this._order = value;
1300
- }
1301
- /**
1302
- * Gets or sets the outputFormat attribute of the fetch element.
1303
- */
1304
- public get outputFormat(): Sdk.FetchXml.OutputFormat {
1305
- return this._outputFormat;
1306
- }
1307
- public set outputFormat(value: Sdk.FetchXml.OutputFormat) {
1308
- if (!Sdk.FetchXml.Util.isEnumMemberOrNull(Sdk.FetchXml.OutputFormat, value)) {
1309
- throw new Error("Sdk.FetchXml.fetch.outputFormat must be a Sdk.FetchXml.OutputFormat value or null.");
1310
- }
1311
- this._outputFormat = value;
1312
- }
1313
- /**
1314
- * Gets or sets the page attribute of the fetch element.
1315
- */
1316
- public get page(): number {
1317
- return this._page;
1318
- }
1319
- public set page(value: number) {
1320
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1321
- throw new Error("Sdk.FetchXml.fetch.page must be a number value or null.");
1322
- }
1323
- this._page = value;
1324
- }
1325
- /**
1326
- * Gets or sets the pagingCookie attribute of the fetch element.
1327
- */
1328
- public get pagingCookie(): string {
1329
- return this._pagingCookie;
1330
- }
1331
- public set pagingCookie(value: string) {
1332
- if (!Sdk.FetchXml.Util.isStringOrNull(value)) {
1333
- throw new Error("Sdk.FetchXml.fetch.pagingCookie must be a string value or null.");
1334
- }
1335
- this._pagingCookie = value;
1336
- }
1337
- /**
1338
- * Gets or sets the returnTotalRecordCount attribute of the fetch element.
1339
- */
1340
- public get returnTotalRecordCount(): boolean {
1341
- return this._returnTotalRecordCount;
1342
- }
1343
- public set returnTotalRecordCount(value: boolean) {
1344
- if (!Sdk.FetchXml.Util.isBooleanOrNull(value)) {
1345
- throw new Error("Sdk.FetchXml.fetch.returnTotalRecordCount must be a boolean value or null.");
1346
- }
1347
- this._returnTotalRecordCount = value;
1348
- }
1349
- /**
1350
- * Gets or sets the top attribute of the fetch element.
1351
- */
1352
- public get top(): number {
1353
- return this._top;
1354
- }
1355
- public set top(value: number) {
1356
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1357
- throw new Error("Sdk.FetchXml.fetch.top must be a number value or null.");
1358
- }
1359
- this._top = value;
1360
- }
1361
- /**
1362
- * Gets or sets the utcOffset attribute of the fetch element.
1363
- */
1364
- public get utcOffset(): number {
1365
- return this._utcOffset;
1366
- }
1367
- public set utcOffset(value: number) {
1368
- if (!Sdk.FetchXml.Util.isNumberOrNull(value)) {
1369
- throw new Error("Sdk.FetchXml.fetch.utcOffset must be a number value or null.");
1370
- }
1371
- this._utcOffset = value;
1372
- }
1373
- /**
1374
- * Gets or sets the version attribute of the fetch element.
1375
- */
1376
- public get version(): string {
1377
- return this._version;
1378
- }
1379
- public set version(value: string) {
1380
- if (!Sdk.FetchXml.Util.isStringOrNull(value)) {
1381
- throw new Error("Sdk.FetchXml.fetch.version must be a string value or null.");
1382
- }
1383
- this._version = value;
1384
- }
1385
-
1386
- /** @description Sets the aggregate attribute of the fetch element
1387
- * @param {boolean | null} aggregate The aggregate value to apply to the fetch element
1388
- * @returns {Sdk.FetchXml.fetch}
1389
- */
1390
- public setAggregate(aggregate?: boolean) {
1391
- (aggregate) ? this.aggregate = aggregate : this.aggregate = null;
1392
- return this;
1393
- }
1394
-
1395
- /** @description Sets the count attribute of the fetch element
1396
- * @param {number | null} count The count value to apply to the fetch element
1397
- * @returns {Sdk.FetchXml.fetch}
1398
- */
1399
- public setCount(count?: number) {
1400
- (count) ? this.count = count : this.count = null;
1401
- return this;
1402
- }
1403
-
1404
- /** @description Sets the distinct attribute of the fetch element
1405
- * @param {boolean | null} distinct The distinct value to apply to the fetch element
1406
- * @returns {Sdk.FetchXml.fetch}
1407
- */
1408
- public setDistinct(distinct?: boolean) {
1409
- (distinct) ? this.distinct = distinct : this.distinct = null;
1410
- return this;
1411
- }
1412
-
1413
- /** @description Sets the aggregate entity of the fetch element
1414
- * @param {Sdk.FetchXml.entity} entity The entity value to apply to the fetch element
1415
- * @returns {Sdk.FetchXml.fetch}
1416
- */
1417
- public setEntity(entity: Sdk.FetchXml.entity) {
1418
- this.entity = entity;
1419
- return this;
1420
- }
1421
-
1422
- /** @description Sets the mapping attribute of the fetch element
1423
- * @param {Sdk.FetchXml.Mapping} mapping The mapping value to apply to the fetch element
1424
- * @returns {Sdk.FetchXml.fetch}
1425
- */
1426
- public setMapping(mapping?: Sdk.FetchXml.Mapping) {
1427
- (mapping) ? this.mapping = mapping : this.mapping = null;
1428
- return this;
1429
- }
1430
-
1431
- /** @description Sets the minActiveRowVersion attribute of the fetch element
1432
- * @param {boolean | null} minActiveRowVersion The minActiveRowVersion value to apply to the fetch element
1433
- * @returns {Sdk.FetchXml.fetch}
1434
- */
1435
- public setMinActiveRowVersion(minActiveRowVersion?: boolean) {
1436
- (minActiveRowVersion) ? this.minActiveRowVersion = minActiveRowVersion : this.minActiveRowVersion = null;
1437
- return this;
1438
- }
1439
-
1440
- /** @description Sets the noLock attribute of the fetch element
1441
- * @param {boolean | null} noLock The noLock value to apply to the fetch element
1442
- * @returns {Sdk.FetchXml.fetch}
1443
- */
1444
- public setNoLock(noLock: boolean = null) {
1445
- this.noLock = noLock;
1446
- return this;
1447
- }
1448
-
1449
- /** @description Sets the order attribute of the fetch element
1450
- * @param {Sdk.FetchXml.order | null} order The order value to apply to the fetch element
1451
- * @returns {Sdk.FetchXml.fetch}
1452
- */
1453
- public setOrder(order: Sdk.FetchXml.order = null) {
1454
- this.order = order;
1455
- return this;
1456
- }
1457
-
1458
- /** @description Sets the outputFormat attribute of the fetch element
1459
- * @param {Sdk.FetchXml.OutputFormat | null} outputFormat The outputFormat value to apply to the fetch element
1460
- * @returns {Sdk.FetchXml.fetch}
1461
- */
1462
- public setOutputFormat(outputFormat?: Sdk.FetchXml.OutputFormat) {
1463
- (outputFormat) ? this.outputFormat = outputFormat : this.outputFormat = null;
1464
- return this;
1465
- }
1466
-
1467
- /** @description Sets the page attribute of the fetch element
1468
- * @param {number | null} page The page value to apply to the fetch element
1469
- * @returns {Sdk.FetchXml.fetch}
1470
- */
1471
- public setPage(page?: number) {
1472
- (page) ? this.page = page : this.page = null;
1473
- return this;
1474
- }
1475
-
1476
- /** @description Sets the pagingCookie attribute of the fetch element
1477
- * @param {string | null} pagingCookie The pagingCookie value to apply to the fetch element
1478
- * @returns {Sdk.FetchXml.fetch}
1479
- */
1480
- public setPagingCookie(pagingCookie: string = null) {
1481
- this.pagingCookie = pagingCookie;
1482
- return this;
1483
- }
1484
-
1485
- /** @description Sets the returnTotalRecordCount attribute of the fetch element
1486
- * @param {boolean} returnTotalRecordCount The returnTotalRecordCount value to apply to the fetch element
1487
- * @returns {Sdk.FetchXml.fetch}
1488
- */
1489
- public setReturnTotalRecordCount(returnTotalRecordCount?: boolean) {
1490
- (returnTotalRecordCount) ? this.returnTotalRecordCount = returnTotalRecordCount : this.returnTotalRecordCount = null;
1491
- return this;
1492
- }
1493
-
1494
- /** @description Sets the top attribute of the fetch element
1495
- * @param {number | null} top The top value to apply to the fetch element
1496
- * @returns {Sdk.FetchXml.fetch}
1497
- */
1498
- public setTop(top?: number) {
1499
- (top) ? this.top = top : this.top = null;
1500
- return this;
1501
- }
1502
-
1503
- /** @description Sets the utcOffset attribute of the fetch element
1504
- * @param {number | null} utcOffset The utcOffset value to apply to the fetch element
1505
- * @returns {Sdk.FetchXml.fetch}
1506
- */
1507
- public setUtcOffset(utcOffset?: number) {
1508
- (utcOffset) ? this.utcOffset = utcOffset : this.utcOffset = null;
1509
- return this;
1510
- }
1511
-
1512
- /** @description Sets the version attribute of the fetch element
1513
- * @param {string | null} version The version value to apply to the fetch element
1514
- * @returns {Sdk.FetchXml.fetch}
1515
- */
1516
- public setVersion(version?: string) {
1517
- (version) ? this.version = version : this.version = null;
1518
- return this;
1519
- }
1520
-
1521
- /**
1522
- * Serializes the fetch query into a FetchXML string
1523
- */
1524
- public toXml(): string {
1525
-
1526
- var root = "<fetch />";
1527
- var doc = new DOMParser().parseFromString(root, "text/xml");
1528
- if (this.version) {
1529
- doc.documentElement.setAttribute("version", <string>this.version);
1530
- }
1531
- if (this.outputFormat) {
1532
- doc.documentElement.setAttribute("output-format", <string>this.outputFormat);
1533
- }
1534
- if (this.mapping) {
1535
- doc.documentElement.setAttribute("mapping", <string>this.mapping);
1536
- }
1537
- if (this.aggregate) {
1538
- doc.documentElement.setAttribute("aggregate", (this.aggregate) ? "true" : "false");
1539
- }
1540
- if (this.count) {
1541
- doc.documentElement.setAttribute("count", this.count.toString());
1542
- }
1543
- if (this.distinct) {
1544
- doc.documentElement.setAttribute("distinct", (this.distinct) ? "true" : "false");
1545
- }
1546
- if (this.entity) {
1547
- doc.documentElement.appendChild(this.entity.toXml(doc));
1548
- }
1549
-
1550
- if (this.minActiveRowVersion) {
1551
- doc.documentElement.setAttribute("min-active-row-version", (this.minActiveRowVersion) ? "true" : "false");
1552
- }
1553
- if (this.noLock) {
1554
- doc.documentElement.setAttribute("no-lock", (this.noLock) ? "true" : "false");
1555
- }
1556
- if (this.order) {
1557
- doc.documentElement.appendChild(this.order.toXml(doc));
1558
- }
1559
-
1560
- if (this.page) {
1561
- doc.documentElement.setAttribute("page", this.page.toString());
1562
- }
1563
- if (this.pagingCookie) {
1564
- doc.documentElement.setAttribute("paging-cookie", <string>this.pagingCookie); //Does this need special handling?
1565
- }
1566
- if (this.returnTotalRecordCount) {
1567
- doc.documentElement.setAttribute("returntotalrecordcount", (this.returnTotalRecordCount) ? "true" : "false");
1568
- }
1569
- if (this.top) {
1570
- doc.documentElement.setAttribute("top", this.top.toString());
1571
- }
1572
- if (this.utcOffset) {
1573
- doc.documentElement.setAttribute("utc-offset", this.utcOffset.toString());
1574
- }
1575
-
1576
- return new XMLSerializer().serializeToString(doc);
1577
- }
1578
- /**
1579
- * Instantiates a fetch object from a fetchXml string
1580
- * @param xml A FetchXML string
1581
- * @returns Sdk.FetchXml.fetch
1582
- */
1583
- public static fromXml(xml: string) {
1584
- var doc = new DOMParser().parseFromString(xml, "text/xml");
1585
- var fetchObj = new Sdk.FetchXml.fetch();
1586
- var errorMessage = "The XML string is not a valid fetchXML document";
1587
-
1588
- if (doc.documentElement.localName == "fetch") {
1589
-
1590
- Sdk.FetchXml.Util.parseAttributes(doc.documentElement, fetchObj, (fetchObj, name, value) => {
1591
- switch (name) {
1592
- case "count":
1593
- case "top":
1594
- case "page":
1595
- fetchObj[name] = parseInt(value, 10);
1596
- break;
1597
- case "utc-offset":
1598
- if (!isNaN(value)) {
1599
- fetchObj.utcOffset = parseInt(value, 10);
1600
- }
1601
- else {
1602
- fetchObj.utcOffset = null;
1603
- }
1604
- break;
1605
- case "paging-cookie":
1606
- fetchObj.pagingCookie = value;
1607
- break;
1608
- case "min-active-row-version":
1609
- fetchObj.minActiveRowVersion = (value == "true") ? true : false;
1610
- break;
1611
- case "output-format":
1612
- fetchObj.outputFormat = value;
1613
- break;
1614
- case "returntotalrecordcount":
1615
- fetchObj.returnTotalRecordCount = (value == "true") ? true : false;
1616
- break;
1617
- case "no-lock":
1618
- fetchObj.noLock = (value == "true") ? true : false;
1619
- break;
1620
- case "aggregate": //xs:boolean
1621
- case "distinct":
1622
- fetchObj[name] = (value == "true") ? true : false;
1623
- break;
1624
- default:
1625
- fetchObj[name] = value;
1626
- break;
1627
- }
1628
- });
1629
-
1630
- for (var i = 0; i < doc.documentElement.childNodes.length; i++) {
1631
-
1632
- if (doc.documentElement.childNodes[i].nodeName == "entity") {
1633
- fetchObj.entity = Sdk.FetchXml.entity.entityFromXml(doc.documentElement.childNodes[i]);
1634
- }
1635
- if (doc.documentElement.childNodes[i].nodeName == "order") {
1636
- fetchObj.order = Sdk.FetchXml.order.orderFromXml(doc.documentElement.childNodes[i]);
1637
- }
1638
- }
1639
-
1640
- }
1641
- else {
1642
- throw new Error(errorMessage);
1643
- }
1644
-
1645
- return fetchObj;
1646
- }
1647
-
1648
- }
1649
- @sealed
1650
- export class filter {
1651
- /** @description Contains the data for a fetchXml filter element.
1652
- * @param [type] The type of filter: 'and' or 'or'. Default is 'and'
1653
- * @param [conditions] An array of Sdk.FetchXml.condition to apply to the filter
1654
- * @param [filters] An array of Sdk.FetchXml.filter to apply to the filter
1655
- * @property conditions Gets or sets the array of Sdk.FetchXml.condition to apply in the filter
1656
- * @property filters Gets or sets the array of Sdk.FetchXml.filter to apply to the filter
1657
- * @property type Gets or sets the type of filter.
1658
- * @property isQuickFindFields Gets or sets the isQuickFindFields property of the filter
1659
- * @returns {Sdk.FetchXml.filter}
1660
- */
1661
- constructor(type?: string, conditions?: Array<condition>, filters?: Array<filter>) {
1662
- //new keyword is not required in JS
1663
- if (!(this instanceof filter))
1664
- { return new filter(type, conditions, filters); }
1665
- if (type)
1666
- this.type = type;
1667
- if (conditions)
1668
- this.conditions = conditions;
1669
- if (filters)
1670
- this.filters = filters;
1671
- }
1672
-
1673
- private _conditions: Array<condition> = [];
1674
- private _filters: Array<filter> = [];
1675
- private _type: FilterType = null;
1676
- private _isQuickFindFields: boolean = null;
1677
-
1678
- /**
1679
- * Gets or sets the array of condition to be applied to the query results
1680
- */
1681
- public get conditions(): Array<condition> {
1682
- return this._conditions;
1683
- }
1684
- public set conditions(value: Array<condition>) {
1685
- if (!Util.isFilterArrayOrNull(value)) {
1686
- throw new Error("Sdk.FetchXml.filter.conditions must be an array of Sdk.FetchXml.condition or null.");
1687
- }
1688
- if (value == null) {
1689
- this._conditions = [];
1690
- } else {
1691
- this._conditions = value;
1692
- }
1693
- }
1694
- /**
1695
- * Gets or sets the array of filters to be applied to the query results
1696
- */
1697
- public get filters(): Array<filter> {
1698
- return this._filters;
1699
- }
1700
- public set filters(value: Array<filter>) {
1701
- if (!Util.isFilterArrayOrNull(value)) {
1702
- throw new Error("Sdk.FetchXml.filter.filters must be an array of Sdk.FetchXml.filter or null.");
1703
- }
1704
- if (value == null) {
1705
- this._filters = [];
1706
- } else {
1707
- this._filters = value;
1708
- }
1709
- }
1710
- /**
1711
- * Gets or sets the type property of the filter
1712
- */
1713
- public get type(): FilterType {
1714
- return this._type;
1715
- }
1716
- public set type(value: FilterType) {
1717
- this._type = value;
1718
- }
1719
- /**
1720
- * Gets or sets the isQuickFindFields property of the filter
1721
- */
1722
- public get isQuickFindFields(): boolean {
1723
- return this._isQuickFindFields;
1724
- }
1725
- public set isQuickFindFields(value: boolean) {
1726
- this._isQuickFindFields = value;
1727
- }
1728
-
1729
- /** @description Adds a condition to the conditions collection
1730
- * @param {Sdk.FetchXml.attribute | Sdk.FetchXml.condition} attributeOrCondition When Sdk.FetchXml.condition the condition is added.
1731
- When Sdk.FetchXml.attribute, the attribute property of a new condition
1732
- * @param {Sdk.FetchXml.Operator} [operator] The operator property for a new condition. Required when the first parameter is an Sdk.FetchXml.attribute
1733
- * @param {Array} [values] The values to compare for a new condition.
1734
- * @returns {Sdk.FetchXml.filter}
1735
- */
1736
- public addCondition(attributeOrCondition: any, operator?, values?) {
1737
- if (Util.isCondition(attributeOrCondition)) {
1738
- this.conditions.push(attributeOrCondition);
1739
- }
1740
- else {
1741
- this.conditions.push(new condition(attributeOrCondition, operator, values));
1742
- }
1743
-
1744
- return this;
1745
- }
1746
-
1747
- /** @description Removes a condition from the conditions collection by reference
1748
- * @param {Sdk.FetchXml.condition} condition The condition to remove from the conditions collection
1749
- * @returns {Sdk.FetchXml.filter}
1750
- */
1751
- public removeConditionByRef(condition) {
1752
- if (!Util.isCondition(condition)) {
1753
- throw new Error("Sdk.FetchXml.filter removeConditionByRef method condition parameter must be an Sdk.FetchXml.condition.");
1754
- }
1755
- Util.removeCollectionValueByRef(this.conditions, condition);
1756
-
1757
- return this;
1758
- }
1759
-
1760
- /** @description Removes a condition from the conditions collection by value
1761
- * @param {Sdk.FetchXml.condition} condition The condition to remove from the conditions collection
1762
- * @returns {Sdk.FetchXml.filter}
1763
- */
1764
- public removeCondition(condition) {
1765
- if (!Util.isCondition(condition)) {
1766
- throw new Error("Sdk.FetchXml.filter removeCondition method condition parameter must be an Sdk.FetchXml.condition.");
1767
- }
1768
- Util.removeCollectionValue(this.conditions, condition);
1769
-
1770
- return this;
1771
- }
1772
-
1773
- /** @description Adds a filter to the filters collection
1774
- * @param {Sdk.FetchXml.filter} filter The filter to add to the filters collectio
1775
- * @returns {Sdk.FetchXml.filter}
1776
- */
1777
- public addFilter(filter) {
1778
- if (Util.isFilter(filter)) {
1779
- this.filters.push(filter);
1780
-
1781
- } else {
1782
- throw new Error("Sdk.FetchXml.filter addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
1783
- }
1784
- return this;
1785
- }
1786
-
1787
- /** @description Removes all references to a filter object
1788
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collectio
1789
- * @returns {Sdk.FetchXml.filter}
1790
- */
1791
- public removeFilterByRef(filter) {
1792
- if (!Util.isFilter(filter)) {
1793
- throw new Error("Sdk.FetchXml.filter removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
1794
- }
1795
- Util.removeCollectionValueByRef(this.filters, filter);
1796
-
1797
- return this;
1798
- }
1799
-
1800
- /** @description Removes all matching filters from the filters collection
1801
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collectio
1802
- * @returns {Sdk.FetchXml.filter}
1803
- */
1804
- public removeFilter(filter) {
1805
- if (!Util.isFilter(filter)) {
1806
- throw new Error("Sdk.FetchXml.filter removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
1807
- }
1808
- Util.removeCollectionValue(this.filters, filter);
1809
-
1810
- return this;
1811
- }
1812
-
1813
- /** @description Sets the isQuickFindFields property
1814
- * @param {boolean | null} value The value to set
1815
- * @returns {Sdk.FetchXml.filter}
1816
- */
1817
- public setIsQuickFindFields(value) {
1818
- this.isQuickFindFields = value;
1819
- return this;
1820
- }
1821
-
1822
- /** @description Sets the type property
1823
- * @param {Sdk.FetchXml.FilterType} value The value to set
1824
- * @returns {Sdk.FetchXml.filter}
1825
- */
1826
- public setType(value) {
1827
- this.type = value;
1828
- return this;
1829
- }
1830
-
1831
- //Internal use only
1832
- toXml(doc: XMLDocument): Node {
1833
- var fNode = doc.createElement("filter");
1834
- if (this.type) {
1835
- fNode.setAttribute("type", <string>this.type);
1836
- }
1837
- if (Util.isBoolean(this.isQuickFindFields)) {
1838
- fNode.setAttribute("isquickfindfields", this.isQuickFindFields.toString());
1839
- }
1840
- this.conditions.forEach(function (c) {
1841
- fNode.appendChild(c.toXml(doc));
1842
- });
1843
- this.filters.forEach(function (f) {
1844
- fNode.appendChild(f.toXml(doc));
1845
- });
1846
- return fNode;
1847
- }
1848
-
1849
- static filterFromXml(xml) {
1850
- var filterObj = new filter();
1851
-
1852
- Util.parseAttributes(xml, filterObj, (filterObj, name, value) => {
1853
- switch (name) {
1854
- case "type":
1855
- filterObj.type = value;
1856
- break;
1857
- case "isquickfindfields":
1858
- filterObj.isQuickFindFields = (value == "true" || value == "1") ? true : false;
1859
- break;
1860
- default:
1861
- break;
1862
- }
1863
- });
1864
-
1865
- for (var i = 0; i < xml.childNodes.length; i++) {
1866
-
1867
- if (xml.childNodes[i].nodeName == "condition") {
1868
- filterObj.addCondition(condition.conditionFromXml(xml.childNodes[i]));
1869
- }
1870
-
1871
- if (xml.childNodes[i].nodeName == "filter") {
1872
- filterObj.addFilter(filter.filterFromXml(xml.childNodes[i]));
1873
- }
1874
-
1875
- }
1876
-
1877
- return filterObj;
1878
- }
1879
-
1880
- }
1881
- @sealed
1882
- export class linkEntity {
1883
- /**
1884
- * Contains the data for a fetchXml link-entity element.
1885
- * @param name The logical name of the entity
1886
- * @param from The from property of the linkEntity
1887
- * @param to The to property of the linkEntity
1888
- * @param linktype The linktype property of the linkEntity
1889
- * @param alias The alias property of the linkEntity
1890
- */
1891
- constructor(name: string, from?: string, to?: string, linktype?: string, alias?: string) {
1892
- if (!(this instanceof linkEntity))
1893
- { return new linkEntity(name, from, to, linktype, alias); }
1894
-
1895
- this.name = name;
1896
- if (from)
1897
- this.from = from;
1898
- if (to)
1899
- this.to = to;
1900
- if (linktype)
1901
- this.linktype = linktype;
1902
- if (alias)
1903
- this.alias = alias;
1904
- }
1905
-
1906
- private _name: string = null;
1907
- private _alias: string = null;
1908
- private _from: string = null;
1909
- private _intersect: boolean = null;
1910
- private _linktype: string = null;
1911
- private _to: string = null;
1912
- private _visible: boolean = null;
1913
- private _allAttributes: boolean = null;
1914
- private _attributes: Array<attribute> = [];
1915
- private _orders: Array<order> = [];
1916
- private _linkEntities: Array<linkEntity> = [];
1917
- private _filters: Array<filter> = [];
1918
-
1919
- /**
1920
- * Gets or sets the name property of the linkEntity
1921
- */
1922
- public get name(): string {
1923
- return this._name;
1924
- }
1925
- public set name(value: string) {
1926
- this._name = value;
1927
- }
1928
- /**
1929
- * Gets or sets the alias property of the linkEntity
1930
- */
1931
- public get alias(): string {
1932
- return this._alias;
1933
- }
1934
- public set alias(value: string) {
1935
- this._alias = value;
1936
- }
1937
- /**
1938
- * Gets or sets the from property of the linkEntity
1939
- */
1940
- public get from(): string {
1941
- return this._from;
1942
- }
1943
- public set from(value: string) {
1944
- this._from = value;
1945
- }
1946
- /**
1947
- * Gets or sets the intersect property of the linkEntity
1948
- */
1949
- public get intersect(): boolean {
1950
- return this._intersect;
1951
- }
1952
- public set intersect(value: boolean) {
1953
- this._intersect = value;
1954
- }
1955
- /**
1956
- * Gets or sets the linktype property of the linkEntity
1957
- */
1958
- public get linktype(): string {
1959
- return this._linktype;
1960
- }
1961
- public set linktype(value: string) {
1962
- this._linktype = value;
1963
- }
1964
- /**
1965
- * Gets or sets the to property of the linkEntity
1966
- */
1967
- public get to(): string {
1968
- return this._to;
1969
- }
1970
- public set to(value: string) {
1971
- this._to = value;
1972
- }
1973
- /**
1974
- * Gets or sets the visible property of the linkEntity
1975
- */
1976
- public get visible(): boolean {
1977
- return this._visible;
1978
- }
1979
- public set visible(value: boolean) {
1980
- this._visible = value;
1981
- }
1982
- /**
1983
- * Gets or sets the allAttributes property of the linkEntity
1984
- */
1985
- public get allAttributes(): boolean {
1986
- return this._allAttributes;
1987
- }
1988
- public set allAttributes(value: boolean) {
1989
- this._allAttributes = value;
1990
- }
1991
- /**
1992
- * Gets or sets the array of attribute of the entity to be returned in the query results
1993
- */
1994
- public get attributes(): Array<attribute> {
1995
- return this._attributes;
1996
- }
1997
- public set attributes(value: Array<attribute>) {
1998
- if (!Util.isAttributeArrayOrNull(value)) {
1999
- throw new Error("Sdk.FetchXml.linkEntity.attributes must be an array of Sdk.FetchXml.attribute or null.");
2000
- }
2001
- if (value == null) {
2002
- this._attributes = [];
2003
- } else {
2004
- this._attributes = value;
2005
- }
2006
-
2007
- }
2008
- /**
2009
- * Gets or sets the array of attribute of the entity to be returned in the query results
2010
- */
2011
- public get orders(): Array<order> {
2012
- return this._orders;
2013
- }
2014
- public set orders(value: Array<order>) {
2015
- if (!Util.isOrderArrayOrNull(value)) {
2016
- throw new Error("Sdk.FetchXml.linkEntity.orders must be an array of Sdk.FetchXml.order or null.");
2017
- }
2018
- if (value == null) {
2019
- this._orders = [];
2020
- } else {
2021
- this._orders = value;
2022
- }
2023
-
2024
- }
2025
- /**
2026
- * Gets or sets the array of linkEntity to be applied to the query results
2027
- */
2028
- public get linkEntities(): Array<linkEntity> {
2029
- return this._linkEntities;
2030
- }
2031
- public set linkEntities(value: Array<linkEntity>) {
2032
- if (!Util.isLinkEntityArrayOrNull(value)) {
2033
- throw new Error("Sdk.FetchXml.linkEntity.linkEntities must be an array of Sdk.FetchXml.linkEntity or null.");
2034
- }
2035
- if (value == null) {
2036
- this._linkEntities = [];
2037
- } else {
2038
- this._linkEntities = value;
2039
- }
2040
- }
2041
- /**
2042
- * Gets or sets the array of filters to be applied to the query results
2043
- */
2044
- public get filters(): Array<filter> {
2045
- return this._filters;
2046
- }
2047
- public set filters(value: Array<filter>) {
2048
- if (!Util.isFilterArrayOrNull(value)) {
2049
- throw new Error("Sdk.FetchXml.linkEntity.filters must be an array of Sdk.FetchXml.filter or null.");
2050
- }
2051
- if (value == null) {
2052
- this._filters = [];
2053
- } else {
2054
- this._filters = value;
2055
- }
2056
-
2057
- }
2058
- //Internal use only
2059
- public get hash(): string {
2060
- var s = this._name.concat(
2061
- (this._alias ? this._alias : ""),
2062
- (this._from ? this._from : ""),
2063
- (Util.isNullOrUndefined(this._intersect) ? "" : this._intersect.toString()),
2064
- (this._linktype ? this._linktype : ""),
2065
- (this._to ? this._to : ""),
2066
- (Util.isNullOrUndefined(this._visible) ? "" : this._visible.toString()),
2067
- (Util.isNullOrUndefined(this._allAttributes) ? "" : this._allAttributes.toString()),
2068
- (Util.getCollectionHash(this._attributes)),
2069
- (Util.getCollectionHash(this._orders)),
2070
- (Util.getCollectionHash(this._linkEntities)),
2071
- (Util.getCollectionHash(this._filters))
2072
- );
2073
- return s.hashCode();
2074
- }
2075
-
2076
- /** @description Sets the alias property of the linkEntity attribute
2077
- * @param {string} alias The alias value to apply to the linkEntity
2078
- * @returns {Sdk.FetchXml.linkEntity}
2079
- */
2080
- public setAlias(alias) {
2081
- this.alias = alias;
2082
- return this;
2083
- }
2084
-
2085
- /** @description Sets the from property of the linkEntity attribute
2086
- * @param {string} from The from value to apply to the linkEntity
2087
- * @returns {Sdk.FetchXml.linkEntity}
2088
- */
2089
- public setFrom(from) {
2090
- this.from = from;
2091
- return this;
2092
- }
2093
-
2094
- /** @description Sets the intersect property of the linkEntity attribute
2095
- * @param {boolean | null} intersect The intersect value to apply to the linkEntity
2096
- * @returns {Sdk.FetchXml.linkEntity}
2097
- */
2098
- public setIntersect(intersect) {
2099
- this.intersect = intersect;
2100
- return this;
2101
- }
2102
-
2103
- /** @description Sets the name property of the linkEntity attribute
2104
- * @param {string} name The name value to apply to the linkEntity
2105
- * @returns {Sdk.FetchXml.linkEntity}
2106
- */
2107
- public setName(name) {
2108
- this.name = name;
2109
- return this;
2110
- }
2111
-
2112
- /** @description Sets the to property of the linkEntity attribute
2113
- * @param {string} to The to value to apply to the linkEntity
2114
- * @returns {Sdk.FetchXml.linkEntity}
2115
- */
2116
- public setTo(to) {
2117
- this.to = to;
2118
- return this;
2119
- }
2120
-
2121
- /** @description Sets the visible property of the linkEntity attribute
2122
- * @param {boolean | null} visible The visible value to apply to the linkEntity
2123
- * @returns {Sdk.FetchXml.linkEntity}
2124
- */
2125
- public setVisible(visible) {
2126
- this.visible = visible;
2127
- return this;
2128
- }
2129
-
2130
- /** @description Sets the allAttributes property of the linkEntity attribute
2131
- * @param {boolean} allAttributes The allAttributes value to apply to the linkEntity
2132
- * @returns {Sdk.FetchXml.linkEntity}
2133
- */
2134
- public setAllAttributes(allAttributes) {
2135
- this.allAttributes = allAttributes;
2136
- return this;
2137
- }
2138
-
2139
- /** @description Adds an linkEntity to the linkEntities collection
2140
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to add to the linkEntities collection
2141
- * @returns {Sdk.FetchXml.linkEntity}
2142
- */
2143
- public addLinkEntity(linkEntity) {
2144
- if (Util.isLinkEntity(linkEntity)) {
2145
- this.linkEntities.push(linkEntity);
2146
- return this;
2147
- }
2148
- throw new Error("Sdk.FetchXml.linkEntity addLinkEntity method linkEntity parameter must be a Sdk.FetchXml.linkEntity value.");
2149
-
2150
- return this;
2151
- }
2152
-
2153
- /** @description Removes a linkEntity from the linkEntities collection by reference
2154
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
2155
- * @returns {Sdk.FetchXml.linkEntity}
2156
- */
2157
- public removeLinkEntityByRef(linkEntity) {
2158
- if (!Util.isLinkEntity(linkEntity)) {
2159
- throw new Error("Sdk.FetchXml.linkEntity removeLinkEntityByRef method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
2160
- }
2161
- Util.removeCollectionValueByRef(this.linkEntities, linkEntity);
2162
-
2163
- return this;
2164
- }
2165
-
2166
- /** @description Removes a linkEntity from the linkEntities collection by value
2167
- * @param {Sdk.FetchXml.linkEntity} linkEntity The linkEntity to remove from the linkEntities collection
2168
- * @returns {Sdk.FetchXml.linkEntity}
2169
- */
2170
- public removeLinkEntity(linkEntity) {
2171
- if (!Util.isLinkEntity(linkEntity)) {
2172
- throw new Error("Sdk.FetchXml.linkEntity removeLinkEntity method linkEntity parameter must be an Sdk.FetchXml.linkEntity.");
2173
- }
2174
- Util.removeCollectionValue(this.linkEntities, linkEntity);
2175
-
2176
- return this;
2177
- }
2178
-
2179
- /** @description Adds an attribute to the attributes collection
2180
- * @param {Sdk.FetchXml.attribute | string} attribute The attribute to add to the attributes collectio
2181
- * @returns {Sdk.FetchXml.linkEntity}
2182
- */
2183
- public addAttribute(attribute) {
2184
- if (Util.isAttribute(attribute)) {
2185
- this.attributes.push(attribute);
2186
- return this;
2187
- }
2188
- if (Util.isString(attribute)) {
2189
- this.attributes.push(new attribute(attribute));
2190
- return this;
2191
- }
2192
- throw new Error("Sdk.FetchXml.linkEntity addAttribute method attribute parameter must be a Sdk.FetchXml.attribute value or a string.");
2193
-
2194
- return this;
2195
- }
2196
-
2197
- /** @description Removes a attribute from the attributes collection by reference
2198
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove from the attributes collection
2199
- * @returns {Sdk.FetchXml.linkEntity}
2200
- */
2201
- public removeAttributeByRef(attribute) {
2202
- if (!Util.isAttribute(attribute)) {
2203
- throw new Error("Sdk.FetchXml.linkEntity removeAttributeByRef method attribute parameter must be an Sdk.FetchXml.attribute.");
2204
- }
2205
- Util.removeCollectionValueByRef(this.attributes, attribute);
2206
-
2207
- return this;
2208
- }
2209
-
2210
- /** @description Removes a attribute from the attributes collection by value
2211
- * @param {Sdk.FetchXml.attribute} attribute The attribute to remove from the attributes collection
2212
- * @returns {Sdk.FetchXml.linkEntity}
2213
- */
2214
- public removeAttribute(attribute) {
2215
- if (!Util.isAttribute(attribute)) {
2216
- throw new Error("Sdk.FetchXml.linkEntity removeAttribute method attribute parameter must be an Sdk.FetchXml.attribute.");
2217
- }
2218
- Util.removeCollectionValue(this.attributes, attribute);
2219
-
2220
- return this;
2221
- }
2222
-
2223
- /** @description Removes a attribute from the attributes collection by name
2224
- * @param {string} attributeName Name of the attribute to remove from the attributes collection
2225
- * @returns {Sdk.FetchXml.linkEntity}
2226
- */
2227
- public removeAttributeByName(attributeName) {
2228
- if (!Util.isString(attributeName)) {
2229
- throw new Error("Sdk.FetchXml.linkEntity removeAttributeByName method attributeName parameter must be a string.");
2230
- }
2231
- Util.removeCollectionValueByProperty(this.attributes, "name", attributeName);
2232
- return this;
2233
- }
2234
-
2235
- /** @description Adds an order to the orders collection
2236
- * @param {Sdk.FetchXml.order | string} orderOrAttribute The order to add to the attributes collection or the Attribute property of a new order to create
2237
- * @param {boolean} [descending] Whether the order is descending. True if descending, otherwise false
2238
- * @param {string} [alias] The alias to set for the order
2239
- * @returns {Sdk.FetchXml.linkEntity}
2240
- */
2241
- public addOrder(orderOrAttribute: any, descending?, alias?) {
2242
- if (Util.isOrder(orderOrAttribute)) {
2243
- this.orders.push(orderOrAttribute);
2244
- return this;
2245
- }
2246
- if (Util.isString(orderOrAttribute)) {
2247
- this.orders.push(new order(orderOrAttribute, descending, alias));
2248
- return this;
2249
- }
2250
- throw new Error("Sdk.FetchXml.linkEntity addOrder method orderOrAttribute parameter must be a Sdk.FetchXml.order value or a string.");
2251
-
2252
- return this;
2253
- }
2254
-
2255
- /** @description Removes a order from the orders collection by reference
2256
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
2257
- * @returns {Sdk.FetchXml.linkEntity}
2258
- */
2259
- public removeOrderByRef(order) {
2260
- if (!Util.isOrder(order)) {
2261
- throw new Error("Sdk.FetchXml.linkEntity removeOrderByRef method order parameter must be an Sdk.FetchXml.order.");
2262
- }
2263
- Util.removeCollectionValueByRef(this.orders, order);
2264
- return this;
2265
- }
2266
-
2267
- /** @description Removes a order from the orders collection by value
2268
- * @param {Sdk.FetchXml.order} order The order to remove from the orders collection
2269
- * @returns {Sdk.FetchXml.linkEntity}
2270
- */
2271
- public removeOrder(order) {
2272
- if (!Util.isOrder(order)) {
2273
- throw new Error("Sdk.FetchXml.linkEntity removeOrder method order parameter must be an Sdk.FetchXml.order.");
2274
- }
2275
- Util.removeCollectionValue(this.orders, order);
2276
- return this;
2277
- }
2278
-
2279
- /** @description Adds an filter to the filters collection
2280
- * @param {Sdk.FetchXml.filter} filter The filter to add to the filters collection
2281
- * @returns {Sdk.FetchXml.linkEntity}
2282
- */
2283
- public addFilter(filter) {
2284
- if (Util.isFilter(filter)) {
2285
- this.filters.push(filter);
2286
- return this;
2287
- }
2288
-
2289
- throw new Error("Sdk.FetchXml.linkEntity addFilter method filter parameter must be a Sdk.FetchXml.filter value.");
2290
-
2291
- return this;
2292
- }
2293
-
2294
- /** @description Removes a filter from the filters collection by reference
2295
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
2296
- * @returns {Sdk.FetchXml.linkEntity}
2297
- */
2298
- public removeFilterByRef(filter) {
2299
- if (!Util.isFilter(filter)) {
2300
- throw new Error("Sdk.FetchXml.linkEntity removeFilterByRef method filter parameter must be an Sdk.FetchXml.filter.");
2301
- }
2302
- Util.removeCollectionValueByRef(this.filters, filter);
2303
-
2304
- return this;
2305
- }
2306
-
2307
- /** @description Removes a filter from the filters collection by value
2308
- * @param {Sdk.FetchXml.filter} filter The filter to remove from the filters collection
2309
- * @returns {Sdk.FetchXml.linkEntity}
2310
- */
2311
- public removeFilter(filter) {
2312
- if (!Util.isFilter(filter)) {
2313
- throw new Error("Sdk.FetchXml.linkEntity removeFilter method filter parameter must be an Sdk.FetchXml.filter.");
2314
- }
2315
- Util.removeCollectionValue(this.filters, filter);
2316
-
2317
- return this;
2318
- }
2319
-
2320
- //Internal use only
2321
- toXml(doc: XMLDocument): Node {
2322
-
2323
- var leNode = doc.createElement("link-entity");
2324
- if (this.alias) {
2325
- leNode.setAttribute("alias", this.alias);
2326
- }
2327
- if (this.allAttributes) {
2328
- leNode.appendChild(doc.createElement("all-attributes"));
2329
- }
2330
- if (this.from) {
2331
- leNode.setAttribute("from", this.from);
2332
- }
2333
- if (Util.isBoolean(this.intersect)) {
2334
- leNode.setAttribute("intersect", this.intersect.toString());
2335
- }
2336
- if (this.linktype) {
2337
- leNode.setAttribute("link-type", this.linktype);
2338
- }
2339
- if (this.name) {
2340
- leNode.setAttribute("name", this.name);
2341
- }
2342
- if (this.to) {
2343
- leNode.setAttribute("to", this.to);
2344
- }
2345
- if (Util.isBoolean(this.visible)) {
2346
- leNode.setAttribute("visible", this.visible.toString());
2347
- }
2348
- this.attributes.forEach(function (a) {
2349
- leNode.appendChild(a.toXml(doc));
2350
- });
2351
- this.orders.forEach(function (o) {
2352
- leNode.appendChild(o.toXml(doc));
2353
- });
2354
- this.linkEntities.forEach(function (l) {
2355
- leNode.appendChild(l.toXml(doc));
2356
- });
2357
- this.filters.forEach(function (f) {
2358
- leNode.appendChild(f.toXml(doc));
2359
- });
2360
-
2361
- return leNode;
2362
- }
2363
-
2364
- static linkEntityFromXml(xml) {
2365
- var name = xml.attributes.getNamedItem("name").nodeValue;
2366
- var linkEntityObj = new linkEntity(name);
2367
- linkEntityObj.allAttributes = (xml.getElementsByTagName("all-attributes").length == 1);
2368
-
2369
- Util.parseAttributes(xml, linkEntityObj, (linkEntityObj, name, value) => {
2370
- switch (name) {
2371
- case "to":
2372
- case "from":
2373
- case "alias":
2374
- linkEntityObj[name] = value;
2375
- break;
2376
- case "link-type":
2377
- linkEntityObj.linktype = value;
2378
- break;
2379
- case "visible":
2380
- case "intersect":
2381
- linkEntityObj[name] = (value == "true") ? true : false;
2382
- break;
2383
- default:
2384
- break;
2385
- }
2386
- });
2387
-
2388
- for (var i = 0; i < xml.childNodes.length; i++) {
2389
-
2390
- if (xml.childNodes[i].nodeName == "attribute") {
2391
- linkEntityObj.addAttribute(attribute.attributeFromXml(xml.childNodes[i]));
2392
- }
2393
-
2394
- if (xml.childNodes[i].nodeName == "order") {
2395
- linkEntityObj.addOrder(order.orderFromXml(xml.childNodes[i]));
2396
- }
2397
-
2398
- if (xml.childNodes[i].nodeName == "filter") {
2399
- linkEntityObj.addFilter(filter.filterFromXml(xml.childNodes[i]));
2400
- }
2401
-
2402
- if (xml.childNodes[i].nodeName == "link-entity") {
2403
- linkEntityObj.addLinkEntity(linkEntity.linkEntityFromXml(xml.childNodes[i]));
2404
- }
2405
- }
2406
-
2407
- return linkEntityObj;
2408
- }
2409
-
2410
- }
2411
- @sealed
2412
- export class order {
2413
- /**
2414
- * Contains the data for a fetchXml order element.
2415
- * @param attribute The logical name of the attribute
2416
- * @param descending Whether the order is decending. Default is false
2417
- * @param alias The alias to apply to the order
2418
- */
2419
- constructor(attribute?: string, descending?: boolean, alias?: string) {
2420
- // new keyword not required in JS
2421
- if (!(this instanceof order))
2422
- { return new order(attribute, descending, alias); }
2423
-
2424
- if (attribute)
2425
- this.attribute = attribute;
2426
- if (descending)
2427
- this.descending = descending;
2428
- if (alias)
2429
- this.alias = alias;
2430
- }
2431
-
2432
- private _attribute: string = null;
2433
- private _descending: boolean = null;
2434
- private _alias: string = null;
2435
-
2436
- /**
2437
- * Gets or sets logical name of the attribute
2438
- */
2439
- public get attribute(): string {
2440
- return this._attribute;
2441
- }
2442
- public set attribute(value: string) {
2443
- this._attribute = value;
2444
- }
2445
- /**
2446
- *Gets or sets whether the order is descending. Default is false
2447
- */
2448
- public get descending(): boolean {
2449
- return this._descending;
2450
- }
2451
- public set descending(value: boolean) {
2452
- this._descending = value;
2453
- }
2454
- /**
2455
- * Gets or sets the alias property of the order
2456
- */
2457
- public get alias(): string {
2458
- return this._alias;
2459
- }
2460
- public set alias(value: string) {
2461
- this._alias = value;
2462
- }
2463
- //Internal use only
2464
- public get hash(): string {
2465
- var s = "".concat(
2466
- (this._attribute ? this._attribute : ""),
2467
- (this._alias ? this._alias : ""),
2468
- this._descending.toString());
2469
- return s.hashCode();
2470
- }
2471
-
2472
- /** @description Sets the attribute property of the order attribute
2473
- * @param {string} attribute The attribute value to apply to the order
2474
- * @returns {Sdk.FetchXml.order}
2475
- */
2476
- public setAttribute(attribute) {
2477
- this.attribute = attribute;
2478
- return this;
2479
- }
2480
-
2481
- /** @description Sets the alias property of the order attribute
2482
- * @param {string} alias The alias value to apply to the order
2483
- * @returns {Sdk.FetchXml.order}
2484
- */
2485
- public setAlias(alias) {
2486
- this.alias = alias;
2487
- return this;
2488
- }
2489
-
2490
- /** @description Sets the descending property of the order attribute
2491
- * @param {boolean | null} descending The descending value to apply to the order
2492
- * @returns {Sdk.FetchXml.order}
2493
- */
2494
- public setDescending(descending) {
2495
- this.descending = descending;
2496
- return this;
2497
- }
2498
-
2499
- //Internal use only
2500
- toXml(doc: XMLDocument): Node {
2501
- var orderNode = doc.createElement("order");
2502
- if (this.attribute) {
2503
- orderNode.setAttribute("attribute", this.attribute);
2504
- }
2505
- if (this.alias) {
2506
- orderNode.setAttribute("alias", this.alias);
2507
- }
2508
- if (!Util.isNullOrUndefined(this.descending)) {
2509
- orderNode.setAttribute("descending", this.descending.toString());
2510
- }
2511
- return orderNode;
2512
- }
2513
-
2514
- static orderFromXml(xml) {
2515
- var orderObj = new order();
2516
- Util.parseAttributes(xml, orderObj, (orderObj, name, value) => {
2517
- switch (name) {
2518
- case "attribute":
2519
- orderObj.attribute = value;
2520
- break;
2521
- case "alias":
2522
- orderObj.alias = value;
2523
- break;
2524
- case "descending":
2525
- orderObj.descending = (value == "true") ? true : false;
2526
- break;
2527
- default:
2528
- break;
2529
- }
2530
- });
2531
- return orderObj;
2532
- }
2533
- }
2534
- @sealed
2535
- export class value {
2536
- /**
2537
- * Contains the data for a fetchXml value element.
2538
- * @param value The the value of the value
2539
- * @param [uiname] The uiname for the value
2540
- * @param [uitype] The uitype for the value
2541
- */
2542
- constructor(value: any, uiname?: string, uitype?: string) {
2543
- //New keyword not required in JS
2544
- if (!(this instanceof Sdk.FetchXml.value))
2545
- { return new value(value, uiname, uitype); }
2546
-
2547
- if (value)
2548
- this.value = value;
2549
- if (uiname)
2550
- this.uiname = uiname;
2551
- if (uitype)
2552
- this.uitype = uitype;
2553
- }
2554
-
2555
- private _value: any = null;
2556
- private _uiname: string = null;
2557
- private _uitype: string = null;
2558
-
2559
- /**
2560
- * Gets or sets the value for the value.
2561
- */
2562
- public get value(): any {
2563
- return this._value;
2564
- }
2565
- public set value(value: any) {
2566
- this._value = value;
2567
- }
2568
- /**
2569
- * Gets or sets the uiname to apply to the value
2570
- */
2571
- public get uiname(): string {
2572
- return this._uiname;
2573
- }
2574
- public set uiname(value: string) {
2575
- this._uiname = value;
2576
- }
2577
- /**
2578
- * Gets or sets the uitype to apply to the value
2579
- */
2580
- public get uitype(): string {
2581
- return this._uitype;
2582
- }
2583
- public set uitype(value: string) {
2584
- this._uitype = value;
2585
- }
2586
-
2587
- /** @description Sets the value to apply in the value
2588
- * @param {string} value The value to apply in the value
2589
- * @returns {Sdk.FetchXml.value}
2590
- */
2591
- public setValue(value) {
2592
- this.value = value;
2593
- return this;
2594
- }
2595
-
2596
- /** @description Sets the uiname to apply in the value
2597
- * @param {string} uiname The uiname to apply in the value
2598
- * @returns {Sdk.FetchXml.value}
2599
- */
2600
- public setUIname(value) {
2601
- this.uiname = value;
2602
- return this;
2603
- }
2604
-
2605
- /** @description Sets the uitype to apply in the value
2606
- * @param {string} uitype The uitype to apply in the value
2607
- * @returns {Sdk.FetchXml.value}
2608
- */
2609
- public setUItype(value) {
2610
- this.uitype = value;
2611
- return this;
2612
- }
2613
-
2614
- //Internal use only
2615
- toXml(doc: XMLDocument): Node {
2616
-
2617
- var vNode = doc.createElement("value");
2618
- if (this.uitype) {
2619
- vNode.setAttribute("uitype", this.uitype);
2620
- }
2621
- if (this.uiname) {
2622
- vNode.setAttribute("uiname", this.uiname);
2623
- }
2624
- vNode.appendChild(doc.createTextNode(this.value));
2625
- return vNode;
2626
- }
2627
-
2628
- static valueFromXml(xml) {
2629
-
2630
- var valueObj = new value(xml.textContent);
2631
- Util.parseAttributes(xml, valueObj, (object, name, value) => {
2632
- switch (name) {
2633
- case "uiname":
2634
- case "uitype":
2635
- object[name] = value;
2636
- break;
2637
- }
2638
- });
2639
-
2640
- return valueObj;
2641
- }
2642
-
2643
- }
2644
- export class Util {
2645
- public static isBoolean(obj) {
2646
- return (typeof obj === "boolean");
2647
- }
2648
- public static isBooleanOrNull(obj) {
2649
- return (Util.isNull(obj) || Util.isBoolean(obj));
2650
- }
2651
- public static isNumber(obj) {
2652
- return (typeof (obj) === "number");
2653
- }
2654
- public static isNumberOrNull(obj) {
2655
- return (Util.isNull(obj) || Util.isNumber(obj));
2656
- }
2657
- public static isNull(obj) {
2658
- return (obj === null);
2659
- }
2660
- public static isNullOrUndefined(obj) {
2661
- return (obj === null || typeof obj == "undefined");
2662
- }
2663
- public static isEnumMember(enumType, obj) {
2664
- for (var i in enumType) {
2665
- if (obj === enumType[i]) {
2666
- return true;
2667
- }
2668
- }
2669
- return false;
2670
- }
2671
- public static isEnumMemberOrNull(enumType, obj) {
2672
- return (Util.isNull(obj) || Util.isEnumMember(enumType, obj));
2673
- }
2674
- public static isString(obj) {
2675
- return (typeof obj === "string");
2676
- }
2677
- public static isStringOrNull(obj) {
2678
- return (Util.isNull(obj) || Util.isString(obj));
2679
- }
2680
- public static isOrder(obj) {
2681
- return (obj instanceof order);
2682
- }
2683
- public static isOrderOrNull(obj) {
2684
- return (Util.isNull(obj) || Util.isOrder(obj));
2685
- }
2686
- public static isOrderArray(obj) {
2687
- if (Array.isArray(obj)) {
2688
- obj.forEach(function (item) {
2689
- if (!Util.isOrder(item)) {
2690
- return false;
2691
- }
2692
- });
2693
- return true;
2694
- }
2695
- return false;
2696
- }
2697
- public static isOrderArrayOrNull(obj) {
2698
- return (Util.isNull(obj) || Util.isOrderArray(obj));
2699
- }
2700
- public static isEntity(obj) {
2701
- return (obj instanceof entity);
2702
- }
2703
- public static isAttribute(obj) {
2704
- return (obj instanceof attribute);
2705
- }
2706
- public static isAttributeArray(obj) {
2707
- if (Array.isArray(obj)) {
2708
- obj.forEach(function (item) {
2709
- if (!Util.isAttribute(item)) {
2710
- return false;
2711
- }
2712
- });
2713
- return true;
2714
- }
2715
- return false;
2716
- }
2717
- public static isAttributeArrayOrNull(obj) {
2718
- return (Util.isNull(obj) || Util.isAttributeArray(obj));
2719
- }
2720
- public static isLinkEntity(obj) {
2721
- return (obj instanceof linkEntity);
2722
- }
2723
- public static isLinkEntityOrNull(obj) {
2724
- return (Util.isNull(obj) || Util.isLinkEntity(obj));
2725
- }
2726
- public static isLinkEntityArray(obj) {
2727
- if (Array.isArray(obj)) {
2728
- obj.forEach(function (item) {
2729
- if (!Util.isLinkEntity(item)) {
2730
- return false;
2731
- }
2732
- });
2733
- return true;
2734
- }
2735
- return false;
2736
- }
2737
- public static isLinkEntityArrayOrNull(obj) {
2738
- return (Util.isNull(obj) || Util.isLinkEntityArray(obj));
2739
- }
2740
- public static isFilter(obj) {
2741
- return (obj instanceof filter);
2742
- }
2743
- public static isFilterOrNull(obj) {
2744
- return (Util.isNull(obj) || Util.isFilter(obj));
2745
- }
2746
- public static isFilterArray(obj) {
2747
- if (Array.isArray(obj)) {
2748
- obj.forEach(function (item) {
2749
- if (!Util.isFilter(item)) {
2750
- return false;
2751
- }
2752
- });
2753
- return true;
2754
- }
2755
- return false;
2756
- }
2757
- public static isFilterArrayOrNull(obj) {
2758
- return (Util.isNull(obj) || Util.isFilterArray(obj));
2759
- }
2760
- public static isCondition(obj) {
2761
- return (obj instanceof condition);
2762
- }
2763
- public static isConditionOrNull(obj) {
2764
- return (Util.isNull(obj) || Util.isCondition(obj));
2765
- }
2766
- public static isConditionArray(obj) {
2767
- if (Array.isArray(obj)) {
2768
- obj.forEach(function (item) {
2769
- if (!Util.isCondition(item)) {
2770
- return false;
2771
- }
2772
- });
2773
- return true;
2774
- }
2775
- return false;
2776
- }
2777
- public static isConditionArrayOrNull(obj) {
2778
- return (Util.isNull(obj) || Util.isConditionArray(obj));
2779
- }
2780
- public static isValue(obj) {
2781
- return (obj instanceof value);
2782
- }
2783
- public static isValueOrNull(obj) {
2784
- return (Util.isNull(obj) || Util.isValue(obj));
2785
- }
2786
- public static isValueArray(obj) {
2787
- if (Array.isArray(obj)) {
2788
- var returnValue = true;
2789
- obj.forEach(function (item) {
2790
- if (!Util.isValue(item)) {
2791
- returnValue = false;
2792
- }
2793
- });
2794
- return returnValue;
2795
- }
2796
- return false;
2797
- }
2798
- public static isValueArrayOrNull(obj) {
2799
- return (Util.isNull(obj) || Util.isValueArray(obj));
2800
- }
2801
- public static getEnumNameFromValue(enumtype, value) {
2802
- for (var i in enumtype) {
2803
- if (enumtype[i] == value) {
2804
- return i;
2805
- }
2806
- }
2807
- }
2808
- public static getCollectionHash(collection) {
2809
- var ch = [];
2810
- collection.forEach(function (c) {
2811
- ch.push(c.hash);
2812
- });
2813
- return ch.join();
2814
- }
2815
- public static removeCollectionValue(collection, value) {
2816
- Util.removeCollectionValueByProperty(collection, "hash", value);
2817
- }
2818
- public static removeCollectionValueByProperty(collection, propertyName, value) {
2819
- var matches = [];
2820
- collection.forEach(function (b, i) {
2821
- //Check if same values
2822
- if (b[propertyName] == value[propertyName]) {
2823
- matches.push(b);
2824
- }
2825
- });
2826
- matches.forEach(function (m) {
2827
- Util.removeCollectionValueByRef(collection, m);
2828
- });
2829
-
2830
- }
2831
- public static removeCollectionValueByRef(collection, value) {
2832
- var indexes = [];
2833
- collection.forEach(function (a, i) {
2834
- //check if same object
2835
- if (a === value) {
2836
- indexes.push(i);
2837
- }
2838
- });
2839
- if (indexes.length > 0) {
2840
- //Removing in reverse order
2841
- for (var i = indexes.length - 1; i >= 0; i--) {
2842
- collection.splice(indexes[i], 1);
2843
- }
2844
- }
2845
- }
2846
- public static convertFetchBoolType(value) {
2847
- switch (value) {
2848
- case "true":
2849
- case "1":
2850
- return true;
2851
- case "false":
2852
- case "0":
2853
- return false;
2854
- default:
2855
- throw new Error("Unexpected FetchBoolType value");
2856
- break;
2857
- }
2858
- }
2859
- public static parseAttributes(xml: Node, object: Object, switchFunction: Function) {
2860
- var atts = xml.attributes;
2861
- for (var i = 0; i < atts.length; i++) {
2862
- var name = atts[i].nodeName;
2863
- var value = atts[i].nodeValue;
2864
- switchFunction(object, name, value);
2865
- }
2866
- }
2867
- }
2868
- @frozen
2869
- export class Mapping {
2870
- static Internal = "internal";
2871
- static Logical = "logical";
2872
- }
2873
- @frozen
2874
- export class OutputFormat {
2875
- static Ado = "xml-ado";
2876
- static Auto = "xml-auto";
2877
- static Elements = "xml-elements";
2878
- static Raw = "xml-raw";
2879
- static Platform = "xml-platform";
2880
- }
2881
- @frozen
2882
- export class Build {
2883
-
2884
- static OnePoint504021 = "1.504021";
2885
- static OnePoint003017 = "1.003017";
2886
- }
2887
- @frozen
2888
- export class Aggregate {
2889
- static Count = "count";
2890
- static CountColumn = "countcolumn";
2891
- static Sum = "sum";
2892
- static Avg = "avg";
2893
- static Min = "min";
2894
- static Max = "max";
2895
- }
2896
- @frozen
2897
- export class RowAggregate {
2898
- static Countchildren = "countchildren";
2899
- }
2900
- @frozen
2901
- export class DateGrouping {
2902
- static Day = "day";
2903
- static Week = "week";
2904
- static Month = "month";
2905
- static Quarter = "quarter";
2906
- static Year = "year";
2907
- static FiscalPeriod = "fiscal-period";
2908
- static FiscalYear = "fiscal-year";
2909
- }
2910
- @frozen
2911
- export class Operator {
2912
- /** Returns all records in referenced record's hierarchical ancestry line.*/
2913
- static Above = "above";
2914
- /** The string occurs at the beginning of another string.*/
2915
- static BeginsWith = "begins-with";
2916
- /** The value is between two values.*/
2917
- static Between = "between";
2918
- /** The string ends with another string.*/
2919
- static EndsWith = "ends-with";
2920
- /** The values are compared for equality. */
2921
- static Equal = "eq";
2922
- /** The value is equal to the specified business ID. */
2923
- static EqualBusinessId = "eq-businessid";
2924
- /** Returns the referenced record and all records above it in the hierarchy.*/
2925
- static EqualOrAbove = "eq-or-above";
2926
- /** Returns the referenced record and all records below it in the hierarchy.*/
2927
- static EqualOrUnder = "eq-or-under";
2928
- /** The value is equal to the specified user ID.*/
2929
- static EqualUserId = "eq-userid";
2930
- /** The value is equal to the language for the user. */
2931
- static EqualUserLanguage = "eq-userlanguage";
2932
- /** When hierarchical security models are used; Equals current user or his reporting hierarchy*/
2933
- static EqualUserOrUserHierarchy = "eq-useroruserhierarchy";
2934
- /** When hierarchical security models are used; Equals current user and his teams or his reporting hierarchy and their teams*/
2935
- static EqualUserOrUserHierarchyAndTeams = "eq-useroruserhierarchyandteams";
2936
- /** The record is owned by a user or teams that the user is a member of.*/
2937
- static EqualUserOrUserTeams = "eq-useroruserteams";
2938
- /** The record is owned by teams that the user is a member of.*/
2939
- static EqualUserTeams = "eq-userteams";
2940
- /** The value is greater than or equal to the compared value.*/
2941
- static GreaterOrEqual = "ge";
2942
- /** The value is greater than the compared value.*/
2943
- static GreaterThan = "gt";
2944
- /** The value exists in a list of values.*/
2945
- static In = "in";
2946
- /** The value is within the specified fiscal period.*/
2947
- static InFiscalPeriod = "in-fiscal-period";
2948
- /** The value is within the specified fiscal period and year.*/
2949
- static InFiscalPeriodAndYear = "in-fiscal-period-and-year";
2950
- /** The value is within the specified year.*/
2951
- static InFiscalYear = "in-fiscal-year";
2952
- /** The value is within or after the specified fiscal period and year.*/
2953
- static InOrAfterFiscalPeriodAndYear = "in-or-after-fiscal-period-and-year";
2954
- /** The value is within or before the specified fiscal period and year.*/
2955
- static InOrBeforeFiscalPeriodAndYear = "in-or-before-fiscal-period-and-year";
2956
- /** The value is within the last fiscal period.*/
2957
- static LastFiscalPeriod = "last-fiscal-period";
2958
- /** The value is within the last fiscal year.*/
2959
- static LastFiscalYear = "last-fiscal-year";
2960
- /** The value is within the last month*/
2961
- static LastMonth = "last-month";
2962
- /** The value is within last seven days.*/
2963
- static LastSevenDays = "last-seven-days";
2964
- /** The value is within the previous week*/
2965
- static LastWeek = "last-week";
2966
- /** The value is within last X days.*/
2967
- static LastXDays = "last-x-days";
2968
- /** The value is within the last X fiscal periods.*/
2969
- static LastXFiscalPeriods = "last-x-fiscal-periods";
2970
- /** The value is within the last X fiscal years.*/
2971
- static LastXFiscalYears = "last-x-fiscal-years";
2972
- /** The value is within the last X hours.*/
2973
- static LastXHours = "last-x-hours";
2974
- /** The value is within the last X months.*/
2975
- static LastXMonths = "last-x-months";
2976
- /** The value is within the last X weeks.*/
2977
- static LastXWeeks = "last-x-weeks";
2978
- /** The value is within the last X years.*/
2979
- static LastXYears = "last-x-years";
2980
- /** The value is within the last year.*/
2981
- static LastYear = "last-year";
2982
- /** The value is less than or equal to the compared value.*/
2983
- static LessOrEqual = "le";
2984
- /** The character string is matched to the specified pattern.*/
2985
- static Like = "like";
2986
- /** The value is less than the compared value.*/
2987
- static LessThan = "lt";
2988
- /** The two values are not equal.*/
2989
- static NotEqual = "ne";
2990
- /** The value is not equal to the specified business ID.*/
2991
- static NotEqualBusinessId = "ne-businessid";
2992
- /** The value is not equal to the specified user ID.*/
2993
- static NotEqualUserId = "ne-userid";
2994
- /** Not Equal To*/
2995
- static Neq = "neq"; //Is this the same as 'ne'?
2996
- /** The value is within the next fiscal period.*/
2997
- static NextFiscalPeriod = "next-fiscal-period";
2998
- /** The value is within the next fiscal year.*/
2999
- static NextFiscalYear = "next-fiscal-year";
3000
- /** The value is within the next month.*/
3001
- static NextMonth = "next-month";
3002
- /** The value is within the next seven days.*/
3003
- static NextSevenDays = "next-seven-days";
3004
- /** The value is within the next week.*/
3005
- static NextWeek = "next-week";
3006
- /** The value is within the X days.*/
3007
- static NextXDays = "next-x-days";
3008
- /** The value is within the next X fiscal periods.*/
3009
- static NextXFiscalPeriods = "next-x-fiscal-periods";
3010
- /** The value is within the next X fiscal years.*/
3011
- static NextXFiscalYears = "next-x-fiscal-years";
3012
- /** The value is within the next X hours.*/
3013
- static NextXHours = "next-x-hours";
3014
- /** The value is within the next X nonths.*/
3015
- static NextXMonths = "next-x-months";
3016
- /** The value is within the next X weeks.*/
3017
- static NextXWeeks = "next-x-weeks";
3018
- /** The value is within the next X years.*/
3019
- static NextXYears = "next-x-years";
3020
- /** The value is within the next year.*/
3021
- static NextYear = "next-year";
3022
- /** The string does not begin with another string.*/
3023
- static NotBeginWith = "not-begin-with";
3024
- /** The value is not between two values.*/
3025
- static NotBetween = "not-between";
3026
- /** The string does not end with another string.*/
3027
- static NotEndWith = "not-end-with";
3028
- /** The given value is not matched to a value in a subquery or a list.*/
3029
- static NotIn = "not-in";
3030
- /** The character string does not match the specified pattern.*/
3031
- static NotLike = "not-like";
3032
- /** The value is not null.*/
3033
- static NotNull = "not-null";
3034
- /** Returns all records not below the referenced record in the hierarchy*/
3035
- static NotUnder = "not-under";
3036
- /** The value is null.*/
3037
- static Null = "null";
3038
- /** The value is older than the specified number of days. */
3039
- static OlderThanXDays = "olderthan-x-days";
3040
- /** The value is older than the specified number of hours. */
3041
- static OlderThanXHours = "olderthan-x-hours";
3042
- /** The value is older than the specified number of minutes. */
3043
- static OlderThanXMinutes = "olderthan-x-minutes";
3044
- /** The value is older than the specified number of months. */
3045
- static OlderThanXMonths = "olderthan-x-months";
3046
- /** The value is older than the specified number of weeks. */
3047
- static OlderThanXWeeks = "olderthan-x-weeks";
3048
- /** The value is older than the specified number of years. */
3049
- static OlderThanXYears = "olderthan-x-years";
3050
- /** The value is on a specified date.*/
3051
- static On = "on";
3052
- /** The value is on or after a specified date.*/
3053
- static OnOrAfter = "on-or-after";
3054
- /** The value is on or before a specified date.*/
3055
- static OnOrBefore = "on-or-before";
3056
- /** The value is within the current fiscal period.*/
3057
- static ThisFiscalPeriod = "this-fiscal-period";
3058
- /** The value is within the current fiscal year.*/
3059
- static ThisFiscalYear = "this-fiscal-year";
3060
- /** The value is within the current month.*/
3061
- static ThisMonth = "this-month";
3062
- /** The value is within the current week.*/
3063
- static ThisWeek = "this-week";
3064
- /** The value is within the current year.*/
3065
- static ThisYear = "this-year";
3066
- /** The value equals today’s date.*/
3067
- static Today = "today";
3068
- /** The value equals tomorrow’s date.*/
3069
- static Tomorrow = "tomorrow";
3070
- /** Returns all child records below the referenced record in the hierarchy*/
3071
- static Under = "under";
3072
- /** The value equals yesterday’s date.*/
3073
- static Yesterday = "yesterday";
3074
- }
3075
- @frozen
3076
- export class FilterType {
3077
- static And = "and";
3078
- static Or = "or";
3079
- }
3080
- }
3081
-
3082
- function sealed(constructor: Function) {
3083
- Object.seal(constructor);
3084
- Object.seal(constructor.prototype);
3085
- }
3086
- function frozen(constructor: Function) {
3087
- Object.freeze(constructor);
3088
- Object.freeze(constructor.prototype);
3089
- }
3090
-
3091
- /*
3092
- Hash Generator modified from
3093
- http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery
3094
- http://werxltd.com/wp/2010/05/13/javascript-implementation-of-javas-string-hashcode-method/
3095
- */
3096
-
3097
- interface String {
3098
- hashCode: () => string;
3099
- }
3100
-
3101
- String.prototype.hashCode = function (): string {
3102
- let hash = 0;
3103
- if (this.length == 0) return hash.toString();
3104
- for (let i = 0; i < this.length; i++) {
3105
- let char = this.charCodeAt(i);
3106
- hash = ((hash << 5) - hash) + char;
3107
- hash = hash & hash; // Convert to 32bit integer
3108
- }
3109
- return hash.toString();
3110
- };