@contrail/flexplm 1.3.2-alpha.c32d413 → 1.3.2
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.
- package/CHANGELOG.md +0 -4
- package/lib/entity-processor/base-entity-processor.d.ts +0 -10
- package/lib/entity-processor/base-entity-processor.js +0 -34
- package/lib/entity-processor/base-entity-processor.spec.js +0 -191
- package/lib/util/data-converter.js +6 -0
- package/lib/util/data-converter.spec.js +66 -0
- package/lib/util/type-conversion-utils-spec-mockData.js +0 -1
- package/lib/util/type-conversion-utils.d.ts +0 -1
- package/lib/util/type-conversion-utils.js +0 -16
- package/lib/util/type-conversion-utils.spec.js +0 -59
- package/package.json +1 -1
- package/src/entity-processor/base-entity-processor.spec.ts +0 -229
- package/src/entity-processor/base-entity-processor.ts +0 -68
- package/src/util/data-converter.spec.ts +79 -0
- package/src/util/data-converter.ts +4 -0
- package/src/util/type-conversion-utils-spec-mockData.ts +0 -1
- package/src/util/type-conversion-utils.spec.ts +0 -63
- package/src/util/type-conversion-utils.ts +0 -30
package/CHANGELOG.md
CHANGED
|
@@ -7,10 +7,6 @@ Versioning follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
## [1.3.2] - 2026-04-24
|
|
11
|
-
### Added
|
|
12
|
-
- Added `getEntityUsingIdentityService` method to `BaseEntityProcessor` for looking up entities via the identity service using a pool key and property criteria. Returns the resolved entity from the identity's `entityReference`, `undefined` if not found, or throws if multiple matches exist.
|
|
13
|
-
|
|
14
10
|
## [1.3.0] - 2026-04-15
|
|
15
11
|
### Added
|
|
16
12
|
- Added inbound thumbnail/primary content syncing from FlexPLM to VibeIQ via `ThumbnailUtil.syncThumbnailToVibeIQ`.
|
|
@@ -19,16 +19,6 @@ export declare abstract class BaseEntityProcessor {
|
|
|
19
19
|
inbound(event: EntityPayloadType): Promise<any>;
|
|
20
20
|
handleIncomingUpsert(event: EntityPayloadType): Promise<any>;
|
|
21
21
|
getInboundStatusMessage(statusObject: any): string;
|
|
22
|
-
getIdentityEntity(params: {
|
|
23
|
-
poolKey: string;
|
|
24
|
-
propertyName: string;
|
|
25
|
-
propertyValue: string;
|
|
26
|
-
}): Promise<any | undefined>;
|
|
27
|
-
getEntityUsingIdentityService(params: {
|
|
28
|
-
poolKey: string;
|
|
29
|
-
propertyName: string;
|
|
30
|
-
propertyValue: string;
|
|
31
|
-
}): Promise<any | undefined>;
|
|
32
22
|
queryEntityWithSubTypeCriteria(entityType: string, entityTypePath: string, propertyCriteria: any): Promise<any[]>;
|
|
33
23
|
getCriteriaForEntity(entityType: string, entityTypePath: string, propertyCriteria: any): Promise<any>;
|
|
34
24
|
getRootTypePropertyKeys(rootType: any, propertyCriteria?: any): string[];
|
|
@@ -136,40 +136,6 @@ class BaseEntityProcessor {
|
|
|
136
136
|
+ ', federatedId: ' + statusObject.federatedId
|
|
137
137
|
+ ', orgSlug: ' + this.orgSlug;
|
|
138
138
|
}
|
|
139
|
-
async getIdentityEntity(params) {
|
|
140
|
-
const { poolKey, propertyName, propertyValue } = params;
|
|
141
|
-
if (!poolKey || !propertyName || !propertyValue) {
|
|
142
|
-
throw new Error('poolKey, propertyName, and propertyValue must be defined');
|
|
143
|
-
}
|
|
144
|
-
const identityEntities = await this.entities.get({
|
|
145
|
-
entityName: 'identity',
|
|
146
|
-
criteria: {
|
|
147
|
-
poolKey,
|
|
148
|
-
propertyName,
|
|
149
|
-
propertyValue
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
if (!identityEntities || (Array.isArray(identityEntities) && identityEntities.length === 0)) {
|
|
153
|
-
return undefined;
|
|
154
|
-
}
|
|
155
|
-
if (Array.isArray(identityEntities) && identityEntities.length > 1) {
|
|
156
|
-
throw new Error('Multiple identity entities found for poolKey: ' + poolKey + ', ' + propertyName + ': ' + propertyValue);
|
|
157
|
-
}
|
|
158
|
-
return Array.isArray(identityEntities) ? identityEntities[0] : identityEntities;
|
|
159
|
-
}
|
|
160
|
-
async getEntityUsingIdentityService(params) {
|
|
161
|
-
const identityEntity = await this.getIdentityEntity(params);
|
|
162
|
-
if (!identityEntity) {
|
|
163
|
-
return undefined;
|
|
164
|
-
}
|
|
165
|
-
const entityReference = identityEntity.entityReference;
|
|
166
|
-
const [entityName, id] = entityReference.split(':');
|
|
167
|
-
const entity = await this.entities.get({
|
|
168
|
-
entityName,
|
|
169
|
-
id
|
|
170
|
-
});
|
|
171
|
-
return entity;
|
|
172
|
-
}
|
|
173
139
|
async queryEntityWithSubTypeCriteria(entityType, entityTypePath, propertyCriteria) {
|
|
174
140
|
if (!entityType || !entityTypePath) {
|
|
175
141
|
throw new Error('type and entityTypePath must be defined');
|
|
@@ -394,195 +394,4 @@ describe('BaseEntityProcessor', () => {
|
|
|
394
394
|
expect(result).toEqual({ status: 200, data: { message: 'No Changes to persist for entity: existing-1' } });
|
|
395
395
|
});
|
|
396
396
|
});
|
|
397
|
-
describe('getIdentityEntity', () => {
|
|
398
|
-
const config = {};
|
|
399
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
400
|
-
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
401
|
-
let btep;
|
|
402
|
-
let mockEntitiesGet;
|
|
403
|
-
beforeEach(() => {
|
|
404
|
-
btep = new TestBaseEntityProcessor(config, dc, mapFileUtil, 'item');
|
|
405
|
-
mockEntitiesGet = jest.fn();
|
|
406
|
-
btep.entities = { get: mockEntitiesGet };
|
|
407
|
-
});
|
|
408
|
-
it('should throw error when poolKey is missing', async () => {
|
|
409
|
-
await expect(btep.getIdentityEntity({
|
|
410
|
-
poolKey: '',
|
|
411
|
-
propertyName: 'itemNumber',
|
|
412
|
-
propertyValue: '12345'
|
|
413
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
414
|
-
});
|
|
415
|
-
it('should throw error when propertyName is missing', async () => {
|
|
416
|
-
await expect(btep.getIdentityEntity({
|
|
417
|
-
poolKey: 'item',
|
|
418
|
-
propertyName: '',
|
|
419
|
-
propertyValue: '12345'
|
|
420
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
421
|
-
});
|
|
422
|
-
it('should throw error when propertyValue is missing', async () => {
|
|
423
|
-
await expect(btep.getIdentityEntity({
|
|
424
|
-
poolKey: 'item',
|
|
425
|
-
propertyName: 'itemNumber',
|
|
426
|
-
propertyValue: ''
|
|
427
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
428
|
-
});
|
|
429
|
-
it('should return undefined when no identity entities are found (empty array)', async () => {
|
|
430
|
-
mockEntitiesGet.mockResolvedValue([]);
|
|
431
|
-
const result = await btep.getIdentityEntity({
|
|
432
|
-
poolKey: 'item',
|
|
433
|
-
propertyName: 'itemNumber',
|
|
434
|
-
propertyValue: '12345'
|
|
435
|
-
});
|
|
436
|
-
expect(result).toBeUndefined();
|
|
437
|
-
expect(mockEntitiesGet).toHaveBeenCalledWith({
|
|
438
|
-
entityName: 'identity',
|
|
439
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
440
|
-
});
|
|
441
|
-
});
|
|
442
|
-
it('should return undefined when identity entities result is null', async () => {
|
|
443
|
-
mockEntitiesGet.mockResolvedValue(null);
|
|
444
|
-
const result = await btep.getIdentityEntity({
|
|
445
|
-
poolKey: 'item',
|
|
446
|
-
propertyName: 'itemNumber',
|
|
447
|
-
propertyValue: '12345'
|
|
448
|
-
});
|
|
449
|
-
expect(result).toBeUndefined();
|
|
450
|
-
});
|
|
451
|
-
it('should throw error when multiple identity entities are found', async () => {
|
|
452
|
-
mockEntitiesGet.mockResolvedValue([
|
|
453
|
-
{ entityReference: 'item:1' },
|
|
454
|
-
{ entityReference: 'item:2' }
|
|
455
|
-
]);
|
|
456
|
-
await expect(btep.getIdentityEntity({
|
|
457
|
-
poolKey: 'item',
|
|
458
|
-
propertyName: 'itemNumber',
|
|
459
|
-
propertyValue: '12345'
|
|
460
|
-
})).rejects.toThrow('Multiple identity entities found for poolKey: item, itemNumber: 12345');
|
|
461
|
-
});
|
|
462
|
-
it('should return the identity entity when one is found (array)', async () => {
|
|
463
|
-
const identityEntity = { entityReference: 'item:1' };
|
|
464
|
-
mockEntitiesGet.mockResolvedValue([identityEntity]);
|
|
465
|
-
const result = await btep.getIdentityEntity({
|
|
466
|
-
poolKey: 'item',
|
|
467
|
-
propertyName: 'itemNumber',
|
|
468
|
-
propertyValue: '12345'
|
|
469
|
-
});
|
|
470
|
-
expect(result).toEqual(identityEntity);
|
|
471
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
472
|
-
});
|
|
473
|
-
it('should return the identity entity when result is a single object (not array)', async () => {
|
|
474
|
-
const identityEntity = { entityReference: 'item:5' };
|
|
475
|
-
mockEntitiesGet.mockResolvedValue(identityEntity);
|
|
476
|
-
const result = await btep.getIdentityEntity({
|
|
477
|
-
poolKey: 'item:material',
|
|
478
|
-
propertyName: 'materialNumber',
|
|
479
|
-
propertyValue: 'MAT-001'
|
|
480
|
-
});
|
|
481
|
-
expect(result).toEqual(identityEntity);
|
|
482
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
483
|
-
});
|
|
484
|
-
});
|
|
485
|
-
describe('getEntityUsingIdentityService', () => {
|
|
486
|
-
const config = {};
|
|
487
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
488
|
-
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
489
|
-
let btep;
|
|
490
|
-
let mockEntitiesGet;
|
|
491
|
-
beforeEach(() => {
|
|
492
|
-
btep = new TestBaseEntityProcessor(config, dc, mapFileUtil, 'item');
|
|
493
|
-
mockEntitiesGet = jest.fn();
|
|
494
|
-
btep.entities = { get: mockEntitiesGet };
|
|
495
|
-
});
|
|
496
|
-
it('should throw error when poolKey is missing', async () => {
|
|
497
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
498
|
-
poolKey: '',
|
|
499
|
-
propertyName: 'itemNumber',
|
|
500
|
-
propertyValue: '12345'
|
|
501
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
502
|
-
});
|
|
503
|
-
it('should throw error when propertyName is missing', async () => {
|
|
504
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
505
|
-
poolKey: 'item',
|
|
506
|
-
propertyName: '',
|
|
507
|
-
propertyValue: '12345'
|
|
508
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
509
|
-
});
|
|
510
|
-
it('should throw error when propertyValue is missing', async () => {
|
|
511
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
512
|
-
poolKey: 'item',
|
|
513
|
-
propertyName: 'itemNumber',
|
|
514
|
-
propertyValue: ''
|
|
515
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
516
|
-
});
|
|
517
|
-
it('should return undefined when no identity entities are found (empty array)', async () => {
|
|
518
|
-
mockEntitiesGet.mockResolvedValue([]);
|
|
519
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
520
|
-
poolKey: 'item',
|
|
521
|
-
propertyName: 'itemNumber',
|
|
522
|
-
propertyValue: '12345'
|
|
523
|
-
});
|
|
524
|
-
expect(result).toBeUndefined();
|
|
525
|
-
expect(mockEntitiesGet).toHaveBeenCalledWith({
|
|
526
|
-
entityName: 'identity',
|
|
527
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
528
|
-
});
|
|
529
|
-
});
|
|
530
|
-
it('should return undefined when identity entities result is null', async () => {
|
|
531
|
-
mockEntitiesGet.mockResolvedValue(null);
|
|
532
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
533
|
-
poolKey: 'item',
|
|
534
|
-
propertyName: 'itemNumber',
|
|
535
|
-
propertyValue: '12345'
|
|
536
|
-
});
|
|
537
|
-
expect(result).toBeUndefined();
|
|
538
|
-
});
|
|
539
|
-
it('should throw error when multiple identity entities are found', async () => {
|
|
540
|
-
mockEntitiesGet.mockResolvedValue([
|
|
541
|
-
{ entityReference: 'item:1' },
|
|
542
|
-
{ entityReference: 'item:2' }
|
|
543
|
-
]);
|
|
544
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
545
|
-
poolKey: 'item',
|
|
546
|
-
propertyName: 'itemNumber',
|
|
547
|
-
propertyValue: '12345'
|
|
548
|
-
})).rejects.toThrow('Multiple identity entities found for poolKey: item, itemNumber: 12345');
|
|
549
|
-
});
|
|
550
|
-
it('should return the entity when one identity entity is found (array)', async () => {
|
|
551
|
-
const mockEntity = { id: '1', name: 'Test Item' };
|
|
552
|
-
mockEntitiesGet
|
|
553
|
-
.mockResolvedValueOnce([{ entityReference: 'item:1' }])
|
|
554
|
-
.mockResolvedValueOnce(mockEntity);
|
|
555
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
556
|
-
poolKey: 'item',
|
|
557
|
-
propertyName: 'itemNumber',
|
|
558
|
-
propertyValue: '12345'
|
|
559
|
-
});
|
|
560
|
-
expect(result).toEqual(mockEntity);
|
|
561
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(2);
|
|
562
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(1, {
|
|
563
|
-
entityName: 'identity',
|
|
564
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
565
|
-
});
|
|
566
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(2, {
|
|
567
|
-
entityName: 'item',
|
|
568
|
-
id: '1'
|
|
569
|
-
});
|
|
570
|
-
});
|
|
571
|
-
it('should return the entity when identity result is a single object (not array)', async () => {
|
|
572
|
-
const mockEntity = { id: '5', name: 'Test Material' };
|
|
573
|
-
mockEntitiesGet
|
|
574
|
-
.mockResolvedValueOnce({ entityReference: 'item:5' })
|
|
575
|
-
.mockResolvedValueOnce(mockEntity);
|
|
576
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
577
|
-
poolKey: 'item:material',
|
|
578
|
-
propertyName: 'materialNumber',
|
|
579
|
-
propertyValue: 'MAT-001'
|
|
580
|
-
});
|
|
581
|
-
expect(result).toEqual(mockEntity);
|
|
582
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(2, {
|
|
583
|
-
entityName: 'item',
|
|
584
|
-
id: '5'
|
|
585
|
-
});
|
|
586
|
-
});
|
|
587
|
-
});
|
|
588
397
|
});
|
|
@@ -110,6 +110,9 @@ class DataConverter {
|
|
|
110
110
|
else if ('userList' === propertyType) {
|
|
111
111
|
value = await this.getUserListValue(prop, newData);
|
|
112
112
|
}
|
|
113
|
+
else if ('size_range' === propertyType) {
|
|
114
|
+
value = nd;
|
|
115
|
+
}
|
|
113
116
|
return value;
|
|
114
117
|
}
|
|
115
118
|
getEnumerationValue(prop, nd) {
|
|
@@ -291,6 +294,9 @@ class DataConverter {
|
|
|
291
294
|
else if ('userList' === propertyType) {
|
|
292
295
|
value = await this.setUserListValue(prop, nd);
|
|
293
296
|
}
|
|
297
|
+
else if ('size_range' === propertyType) {
|
|
298
|
+
value = nd;
|
|
299
|
+
}
|
|
294
300
|
return value;
|
|
295
301
|
}
|
|
296
302
|
setEnumerationKeys(prop, nd, matchByDisplay) {
|
|
@@ -902,3 +902,69 @@ describe('getUserListValue', () => {
|
|
|
902
902
|
expect(returnValue.lastName).toEqual('Smith');
|
|
903
903
|
});
|
|
904
904
|
});
|
|
905
|
+
describe('getFlexPLMValue size_range', () => {
|
|
906
|
+
const config = {
|
|
907
|
+
apiHost: 'host',
|
|
908
|
+
userName: () => 'user',
|
|
909
|
+
password: () => 'pass',
|
|
910
|
+
urlContext: 'xxx',
|
|
911
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
912
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
913
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
914
|
+
};
|
|
915
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
916
|
+
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
917
|
+
const sizeRangeProp = {
|
|
918
|
+
propertyType: 'size_range',
|
|
919
|
+
slug: 'sizeRange',
|
|
920
|
+
label: 'Size Range',
|
|
921
|
+
};
|
|
922
|
+
it('returns sizeRange object when value is present', async () => {
|
|
923
|
+
const newData = { sizeRange: { sizes: ['PRE', 'NB'] } };
|
|
924
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
925
|
+
expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
|
|
926
|
+
});
|
|
927
|
+
it('returns null when sizeRange is null', async () => {
|
|
928
|
+
const newData = { sizeRange: null };
|
|
929
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
930
|
+
expect(returnValue).toBeNull();
|
|
931
|
+
});
|
|
932
|
+
it('returns undefined when sizeRange is missing', async () => {
|
|
933
|
+
const newData = {};
|
|
934
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
935
|
+
expect(returnValue).toBeUndefined();
|
|
936
|
+
});
|
|
937
|
+
});
|
|
938
|
+
describe('getEntityValue size_range', () => {
|
|
939
|
+
const config = {
|
|
940
|
+
apiHost: 'host',
|
|
941
|
+
userName: () => 'user',
|
|
942
|
+
password: () => 'pass',
|
|
943
|
+
urlContext: 'xxx',
|
|
944
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
945
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
946
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
947
|
+
};
|
|
948
|
+
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
949
|
+
const dc = new data_converter_1.DataConverter(config, mapFileUtil);
|
|
950
|
+
const sizeRangeProp = {
|
|
951
|
+
propertyType: 'size_range',
|
|
952
|
+
slug: 'sizeRange',
|
|
953
|
+
label: 'Size Range',
|
|
954
|
+
};
|
|
955
|
+
it('returns sizeRange object when value is present', async () => {
|
|
956
|
+
const data = { sizeRange: { sizes: ['PRE', 'NB'] } };
|
|
957
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
958
|
+
expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
|
|
959
|
+
});
|
|
960
|
+
it('returns null when sizeRange is null', async () => {
|
|
961
|
+
const data = { sizeRange: null };
|
|
962
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
963
|
+
expect(returnValue).toBeNull();
|
|
964
|
+
});
|
|
965
|
+
it('returns undefined when sizeRange is missing', async () => {
|
|
966
|
+
const data = {};
|
|
967
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
968
|
+
expect(returnValue).toBeUndefined();
|
|
969
|
+
});
|
|
970
|
+
});
|
|
@@ -11,7 +11,6 @@ export declare class TypeConversionUtils {
|
|
|
11
11
|
static getMapKey(transformMapFile: any, mapFileUtil: MapFileUtil, entity: any, direction: string): Promise<string>;
|
|
12
12
|
static getEntityType(entity: any): any;
|
|
13
13
|
static getEntityClassFromObject(fileId: any, mapFileUtil: any, object: any): Promise<string>;
|
|
14
|
-
static getUniquenessPoolKeyFromObject(fileId: any, mapFileUtil: any, object: any): Promise<string>;
|
|
15
14
|
static getEntityTypePathFromOjbect(fileId: any, mapFileUtil: any, object: any): Promise<string>;
|
|
16
15
|
static getIdentifierPropertiesFromObject(fileId: any, mapFileUtil: MapFileUtil, object: any): Promise<string[]>;
|
|
17
16
|
static getInformationalPropertiesFromObject(fileId: any, mapFileUtil: MapFileUtil, object: any): Promise<string[]>;
|
|
@@ -118,22 +118,6 @@ class TypeConversionUtils {
|
|
|
118
118
|
}
|
|
119
119
|
return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
120
120
|
}
|
|
121
|
-
static async getUniquenessPoolKeyFromObject(fileId, mapFileUtil, object) {
|
|
122
|
-
let uniquenessPool;
|
|
123
|
-
if (fileId) {
|
|
124
|
-
const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
125
|
-
if (mapKey) {
|
|
126
|
-
const mapData = await map_utils_1.MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
|
|
127
|
-
if (mapData && mapData['uniquenessPool']) {
|
|
128
|
-
uniquenessPool = mapData['uniquenessPool'];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
if (uniquenessPool) {
|
|
133
|
-
return uniquenessPool;
|
|
134
|
-
}
|
|
135
|
-
return type_defaults_1.TypeDefaults.getDefaultEntityClass(object);
|
|
136
|
-
}
|
|
137
121
|
static async getEntityTypePathFromOjbect(fileId, mapFileUtil, object) {
|
|
138
122
|
let typePath = object['vibeIQTypePath'];
|
|
139
123
|
if (typePath) {
|
|
@@ -328,65 +328,6 @@ describe('conversion-utils', () => {
|
|
|
328
328
|
}
|
|
329
329
|
});
|
|
330
330
|
});
|
|
331
|
-
describe('getUniquenessPoolKeyFromObject', () => {
|
|
332
|
-
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
333
|
-
it('uses mapping-catName', async () => {
|
|
334
|
-
const expectedPool = 'catName-pool';
|
|
335
|
-
const object = {
|
|
336
|
-
flexPLMObjectClass: 'LCSLast',
|
|
337
|
-
flexPLMTypePath: 'Last\\catName'
|
|
338
|
-
};
|
|
339
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
340
|
-
.mockImplementation(async () => {
|
|
341
|
-
return mapping;
|
|
342
|
-
});
|
|
343
|
-
try {
|
|
344
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
345
|
-
expect(results).toEqual(expectedPool);
|
|
346
|
-
}
|
|
347
|
-
finally {
|
|
348
|
-
spy.mockRestore();
|
|
349
|
-
}
|
|
350
|
-
});
|
|
351
|
-
it('uses default-noMap', async () => {
|
|
352
|
-
const expectedClass = 'color';
|
|
353
|
-
const object = {
|
|
354
|
-
flexPLMObjectClass: 'LCSColor',
|
|
355
|
-
flexPLMTypePath: 'Color'
|
|
356
|
-
};
|
|
357
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
358
|
-
.mockImplementation(async () => {
|
|
359
|
-
return mapping;
|
|
360
|
-
});
|
|
361
|
-
const spyDefaults = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
362
|
-
.mockImplementation(() => expectedClass);
|
|
363
|
-
try {
|
|
364
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
365
|
-
expect(results).toEqual(expectedClass);
|
|
366
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
367
|
-
}
|
|
368
|
-
finally {
|
|
369
|
-
spy.mockRestore();
|
|
370
|
-
spyDefaults.mockRestore();
|
|
371
|
-
}
|
|
372
|
-
});
|
|
373
|
-
it('uses default-noFileId', async () => {
|
|
374
|
-
const expectedClass = 'color';
|
|
375
|
-
const object = {
|
|
376
|
-
flexPLMObjectClass: 'LCSColor',
|
|
377
|
-
};
|
|
378
|
-
const spyDefaults = jest.spyOn(type_defaults_1.TypeDefaults, 'getDefaultEntityClass')
|
|
379
|
-
.mockImplementation(() => expectedClass);
|
|
380
|
-
try {
|
|
381
|
-
const results = await type_conversion_utils_1.TypeConversionUtils.getUniquenessPoolKeyFromObject(null, mapFileUtil, object);
|
|
382
|
-
expect(results).toEqual(expectedClass);
|
|
383
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
384
|
-
}
|
|
385
|
-
finally {
|
|
386
|
-
spyDefaults.mockRestore();
|
|
387
|
-
}
|
|
388
|
-
});
|
|
389
|
-
});
|
|
390
331
|
describe('getEntityTypePathFromOjbect', () => {
|
|
391
332
|
const mapFileUtil = new transform_data_1.MapFileUtil(new sdk_1.Entities());
|
|
392
333
|
it('vibeIQTypePath', async () => {
|
package/package.json
CHANGED
|
@@ -457,233 +457,4 @@ describe('BaseEntityProcessor', () =>{
|
|
|
457
457
|
});
|
|
458
458
|
});
|
|
459
459
|
|
|
460
|
-
describe('getIdentityEntity', () => {
|
|
461
|
-
const config = {} as FCConfig;
|
|
462
|
-
const mapFileUtil = new MapFileUtil(new Entities());
|
|
463
|
-
const dc = new DataConverter(config, mapFileUtil);
|
|
464
|
-
let btep: TestBaseEntityProcessor;
|
|
465
|
-
let mockEntitiesGet: jest.Mock;
|
|
466
|
-
|
|
467
|
-
beforeEach(() => {
|
|
468
|
-
btep = new TestBaseEntityProcessor(config, dc, mapFileUtil, 'item');
|
|
469
|
-
mockEntitiesGet = jest.fn();
|
|
470
|
-
(btep as any).entities = { get: mockEntitiesGet };
|
|
471
|
-
});
|
|
472
|
-
|
|
473
|
-
it('should throw error when poolKey is missing', async () => {
|
|
474
|
-
await expect(btep.getIdentityEntity({
|
|
475
|
-
poolKey: '',
|
|
476
|
-
propertyName: 'itemNumber',
|
|
477
|
-
propertyValue: '12345'
|
|
478
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
479
|
-
});
|
|
480
|
-
|
|
481
|
-
it('should throw error when propertyName is missing', async () => {
|
|
482
|
-
await expect(btep.getIdentityEntity({
|
|
483
|
-
poolKey: 'item',
|
|
484
|
-
propertyName: '',
|
|
485
|
-
propertyValue: '12345'
|
|
486
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
487
|
-
});
|
|
488
|
-
|
|
489
|
-
it('should throw error when propertyValue is missing', async () => {
|
|
490
|
-
await expect(btep.getIdentityEntity({
|
|
491
|
-
poolKey: 'item',
|
|
492
|
-
propertyName: 'itemNumber',
|
|
493
|
-
propertyValue: ''
|
|
494
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
495
|
-
});
|
|
496
|
-
|
|
497
|
-
it('should return undefined when no identity entities are found (empty array)', async () => {
|
|
498
|
-
mockEntitiesGet.mockResolvedValue([]);
|
|
499
|
-
|
|
500
|
-
const result = await btep.getIdentityEntity({
|
|
501
|
-
poolKey: 'item',
|
|
502
|
-
propertyName: 'itemNumber',
|
|
503
|
-
propertyValue: '12345'
|
|
504
|
-
});
|
|
505
|
-
|
|
506
|
-
expect(result).toBeUndefined();
|
|
507
|
-
expect(mockEntitiesGet).toHaveBeenCalledWith({
|
|
508
|
-
entityName: 'identity',
|
|
509
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
510
|
-
});
|
|
511
|
-
});
|
|
512
|
-
|
|
513
|
-
it('should return undefined when identity entities result is null', async () => {
|
|
514
|
-
mockEntitiesGet.mockResolvedValue(null);
|
|
515
|
-
|
|
516
|
-
const result = await btep.getIdentityEntity({
|
|
517
|
-
poolKey: 'item',
|
|
518
|
-
propertyName: 'itemNumber',
|
|
519
|
-
propertyValue: '12345'
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
expect(result).toBeUndefined();
|
|
523
|
-
});
|
|
524
|
-
|
|
525
|
-
it('should throw error when multiple identity entities are found', async () => {
|
|
526
|
-
mockEntitiesGet.mockResolvedValue([
|
|
527
|
-
{ entityReference: 'item:1' },
|
|
528
|
-
{ entityReference: 'item:2' }
|
|
529
|
-
]);
|
|
530
|
-
|
|
531
|
-
await expect(btep.getIdentityEntity({
|
|
532
|
-
poolKey: 'item',
|
|
533
|
-
propertyName: 'itemNumber',
|
|
534
|
-
propertyValue: '12345'
|
|
535
|
-
})).rejects.toThrow('Multiple identity entities found for poolKey: item, itemNumber: 12345');
|
|
536
|
-
});
|
|
537
|
-
|
|
538
|
-
it('should return the identity entity when one is found (array)', async () => {
|
|
539
|
-
const identityEntity = { entityReference: 'item:1' };
|
|
540
|
-
mockEntitiesGet.mockResolvedValue([identityEntity]);
|
|
541
|
-
|
|
542
|
-
const result = await btep.getIdentityEntity({
|
|
543
|
-
poolKey: 'item',
|
|
544
|
-
propertyName: 'itemNumber',
|
|
545
|
-
propertyValue: '12345'
|
|
546
|
-
});
|
|
547
|
-
|
|
548
|
-
expect(result).toEqual(identityEntity);
|
|
549
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
550
|
-
});
|
|
551
|
-
|
|
552
|
-
it('should return the identity entity when result is a single object (not array)', async () => {
|
|
553
|
-
const identityEntity = { entityReference: 'item:5' };
|
|
554
|
-
mockEntitiesGet.mockResolvedValue(identityEntity);
|
|
555
|
-
|
|
556
|
-
const result = await btep.getIdentityEntity({
|
|
557
|
-
poolKey: 'item:material',
|
|
558
|
-
propertyName: 'materialNumber',
|
|
559
|
-
propertyValue: 'MAT-001'
|
|
560
|
-
});
|
|
561
|
-
|
|
562
|
-
expect(result).toEqual(identityEntity);
|
|
563
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(1);
|
|
564
|
-
});
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
describe('getEntityUsingIdentityService', () => {
|
|
568
|
-
const config = {} as FCConfig;
|
|
569
|
-
const mapFileUtil = new MapFileUtil(new Entities());
|
|
570
|
-
const dc = new DataConverter(config, mapFileUtil);
|
|
571
|
-
let btep: TestBaseEntityProcessor;
|
|
572
|
-
let mockEntitiesGet: jest.Mock;
|
|
573
|
-
|
|
574
|
-
beforeEach(() => {
|
|
575
|
-
btep = new TestBaseEntityProcessor(config, dc, mapFileUtil, 'item');
|
|
576
|
-
mockEntitiesGet = jest.fn();
|
|
577
|
-
(btep as any).entities = { get: mockEntitiesGet };
|
|
578
|
-
});
|
|
579
|
-
|
|
580
|
-
it('should throw error when poolKey is missing', async () => {
|
|
581
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
582
|
-
poolKey: '',
|
|
583
|
-
propertyName: 'itemNumber',
|
|
584
|
-
propertyValue: '12345'
|
|
585
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
586
|
-
});
|
|
587
|
-
|
|
588
|
-
it('should throw error when propertyName is missing', async () => {
|
|
589
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
590
|
-
poolKey: 'item',
|
|
591
|
-
propertyName: '',
|
|
592
|
-
propertyValue: '12345'
|
|
593
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
594
|
-
});
|
|
595
|
-
|
|
596
|
-
it('should throw error when propertyValue is missing', async () => {
|
|
597
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
598
|
-
poolKey: 'item',
|
|
599
|
-
propertyName: 'itemNumber',
|
|
600
|
-
propertyValue: ''
|
|
601
|
-
})).rejects.toThrow('poolKey, propertyName, and propertyValue must be defined');
|
|
602
|
-
});
|
|
603
|
-
|
|
604
|
-
it('should return undefined when no identity entities are found (empty array)', async () => {
|
|
605
|
-
mockEntitiesGet.mockResolvedValue([]);
|
|
606
|
-
|
|
607
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
608
|
-
poolKey: 'item',
|
|
609
|
-
propertyName: 'itemNumber',
|
|
610
|
-
propertyValue: '12345'
|
|
611
|
-
});
|
|
612
|
-
|
|
613
|
-
expect(result).toBeUndefined();
|
|
614
|
-
expect(mockEntitiesGet).toHaveBeenCalledWith({
|
|
615
|
-
entityName: 'identity',
|
|
616
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
617
|
-
});
|
|
618
|
-
});
|
|
619
|
-
|
|
620
|
-
it('should return undefined when identity entities result is null', async () => {
|
|
621
|
-
mockEntitiesGet.mockResolvedValue(null);
|
|
622
|
-
|
|
623
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
624
|
-
poolKey: 'item',
|
|
625
|
-
propertyName: 'itemNumber',
|
|
626
|
-
propertyValue: '12345'
|
|
627
|
-
});
|
|
628
|
-
|
|
629
|
-
expect(result).toBeUndefined();
|
|
630
|
-
});
|
|
631
|
-
|
|
632
|
-
it('should throw error when multiple identity entities are found', async () => {
|
|
633
|
-
mockEntitiesGet.mockResolvedValue([
|
|
634
|
-
{ entityReference: 'item:1' },
|
|
635
|
-
{ entityReference: 'item:2' }
|
|
636
|
-
]);
|
|
637
|
-
|
|
638
|
-
await expect(btep.getEntityUsingIdentityService({
|
|
639
|
-
poolKey: 'item',
|
|
640
|
-
propertyName: 'itemNumber',
|
|
641
|
-
propertyValue: '12345'
|
|
642
|
-
})).rejects.toThrow('Multiple identity entities found for poolKey: item, itemNumber: 12345');
|
|
643
|
-
});
|
|
644
|
-
|
|
645
|
-
it('should return the entity when one identity entity is found (array)', async () => {
|
|
646
|
-
const mockEntity = { id: '1', name: 'Test Item' };
|
|
647
|
-
mockEntitiesGet
|
|
648
|
-
.mockResolvedValueOnce([{ entityReference: 'item:1' }])
|
|
649
|
-
.mockResolvedValueOnce(mockEntity);
|
|
650
|
-
|
|
651
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
652
|
-
poolKey: 'item',
|
|
653
|
-
propertyName: 'itemNumber',
|
|
654
|
-
propertyValue: '12345'
|
|
655
|
-
});
|
|
656
|
-
|
|
657
|
-
expect(result).toEqual(mockEntity);
|
|
658
|
-
expect(mockEntitiesGet).toHaveBeenCalledTimes(2);
|
|
659
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(1, {
|
|
660
|
-
entityName: 'identity',
|
|
661
|
-
criteria: { poolKey: 'item', propertyName: 'itemNumber', propertyValue: '12345' }
|
|
662
|
-
});
|
|
663
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(2, {
|
|
664
|
-
entityName: 'item',
|
|
665
|
-
id: '1'
|
|
666
|
-
});
|
|
667
|
-
});
|
|
668
|
-
|
|
669
|
-
it('should return the entity when identity result is a single object (not array)', async () => {
|
|
670
|
-
const mockEntity = { id: '5', name: 'Test Material' };
|
|
671
|
-
mockEntitiesGet
|
|
672
|
-
.mockResolvedValueOnce({ entityReference: 'item:5' })
|
|
673
|
-
.mockResolvedValueOnce(mockEntity);
|
|
674
|
-
|
|
675
|
-
const result = await btep.getEntityUsingIdentityService({
|
|
676
|
-
poolKey: 'item:material',
|
|
677
|
-
propertyName: 'materialNumber',
|
|
678
|
-
propertyValue: 'MAT-001'
|
|
679
|
-
});
|
|
680
|
-
|
|
681
|
-
expect(result).toEqual(mockEntity);
|
|
682
|
-
expect(mockEntitiesGet).toHaveBeenNthCalledWith(2, {
|
|
683
|
-
entityName: 'item',
|
|
684
|
-
id: '5'
|
|
685
|
-
});
|
|
686
|
-
});
|
|
687
|
-
});
|
|
688
|
-
|
|
689
460
|
});
|
|
@@ -163,74 +163,6 @@ export abstract class BaseEntityProcessor {
|
|
|
163
163
|
+ ', orgSlug: ' + this.orgSlug;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
/** Looks up an identity record from the identity service based on the passed in criteria.
|
|
167
|
-
* If no identity record is found, returns undefined. If multiple are found, throws an error.
|
|
168
|
-
*
|
|
169
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
170
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
171
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
172
|
-
* @returns the identity entity, or undefined if no identity record is found
|
|
173
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
174
|
-
*/
|
|
175
|
-
async getIdentityEntity(params: {
|
|
176
|
-
poolKey: string,
|
|
177
|
-
propertyName: string,
|
|
178
|
-
propertyValue: string
|
|
179
|
-
}): Promise<any | undefined> {
|
|
180
|
-
const {poolKey, propertyName, propertyValue} = params;
|
|
181
|
-
if(!poolKey || !propertyName || !propertyValue){
|
|
182
|
-
throw new Error('poolKey, propertyName, and propertyValue must be defined');
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
const identityEntities = await this.entities.get({
|
|
186
|
-
entityName: 'identity',
|
|
187
|
-
criteria: {
|
|
188
|
-
poolKey,
|
|
189
|
-
propertyName,
|
|
190
|
-
propertyValue
|
|
191
|
-
}
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
if(!identityEntities || (Array.isArray(identityEntities) && identityEntities.length === 0)){
|
|
195
|
-
return undefined;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
if(Array.isArray(identityEntities) && identityEntities.length > 1){
|
|
199
|
-
throw new Error('Multiple identity entities found for poolKey: ' + poolKey + ', ' + propertyName + ': ' + propertyValue);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
return Array.isArray(identityEntities) ? identityEntities[0] : identityEntities;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/** Looks up an entity via the identity service. Uses {@link getIdentityEntity} to find the identity record,
|
|
206
|
-
* then resolves the entity reference to fetch and return the actual entity.
|
|
207
|
-
*
|
|
208
|
-
* @param params.poolKey the key to use for the identity service pool. This will be the subtype uniqueness is defined on, typically the root type. Ex: 'item' or 'item:material'
|
|
209
|
-
* @param params.propertyName the name of the property to use for the criteria. Ex: 'itemNumber'
|
|
210
|
-
* @param params.propertyValue the value of the property to use for the criteria. Ex: '12345'
|
|
211
|
-
* @returns the resolved entity, or undefined if no identity record is found
|
|
212
|
-
* @throws error if multiple identity entities are found, or if required parameters are missing
|
|
213
|
-
*/
|
|
214
|
-
async getEntityUsingIdentityService(params: {
|
|
215
|
-
poolKey: string,
|
|
216
|
-
propertyName: string,
|
|
217
|
-
propertyValue: string
|
|
218
|
-
}): Promise<any | undefined> {
|
|
219
|
-
const identityEntity = await this.getIdentityEntity(params);
|
|
220
|
-
if(!identityEntity){
|
|
221
|
-
return undefined;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
const entityReference = identityEntity.entityReference;
|
|
225
|
-
const [entityName, id] = entityReference.split(':');
|
|
226
|
-
|
|
227
|
-
const entity = await this.entities.get({
|
|
228
|
-
entityName,
|
|
229
|
-
id
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
return entity;
|
|
233
|
-
}
|
|
234
166
|
/**This will query for the entity, and handle post-processing
|
|
235
167
|
* of any critieria that is defined at the sub-type level.
|
|
236
168
|
* Because sub-type criteria can't be used in the search done
|
|
@@ -1038,4 +1038,83 @@ describe('getUserListValue', () =>{
|
|
|
1038
1038
|
expect(returnValue.lastName).toEqual('Smith');
|
|
1039
1039
|
});
|
|
1040
1040
|
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
describe('getFlexPLMValue size_range', () => {
|
|
1045
|
+
const config: FCConfig = {
|
|
1046
|
+
apiHost: 'host',
|
|
1047
|
+
userName: () => 'user',
|
|
1048
|
+
password: () => 'pass',
|
|
1049
|
+
urlContext: 'xxx',
|
|
1050
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
1051
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
1052
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
1053
|
+
};
|
|
1054
|
+
|
|
1055
|
+
const mapFileUtil = new MapFileUtil(new Entities());
|
|
1056
|
+
const dc = new DataConverter(config, mapFileUtil);
|
|
1057
|
+
|
|
1058
|
+
const sizeRangeProp = {
|
|
1059
|
+
propertyType: 'size_range',
|
|
1060
|
+
slug: 'sizeRange',
|
|
1061
|
+
label: 'Size Range',
|
|
1062
|
+
};
|
|
1063
|
+
|
|
1064
|
+
it('returns sizeRange object when value is present', async () => {
|
|
1065
|
+
const newData = { sizeRange: { sizes: ['PRE', 'NB'] } };
|
|
1066
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
1067
|
+
expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
|
|
1068
|
+
});
|
|
1069
|
+
|
|
1070
|
+
it('returns null when sizeRange is null', async () => {
|
|
1071
|
+
const newData = { sizeRange: null };
|
|
1072
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
1073
|
+
expect(returnValue).toBeNull();
|
|
1074
|
+
});
|
|
1075
|
+
|
|
1076
|
+
it('returns undefined when sizeRange is missing', async () => {
|
|
1077
|
+
const newData = {};
|
|
1078
|
+
const returnValue = await dc.getFlexPLMValue(sizeRangeProp, newData, true);
|
|
1079
|
+
expect(returnValue).toBeUndefined();
|
|
1080
|
+
});
|
|
1081
|
+
});
|
|
1082
|
+
|
|
1083
|
+
describe('getEntityValue size_range', () => {
|
|
1084
|
+
const config: FCConfig = {
|
|
1085
|
+
apiHost: 'host',
|
|
1086
|
+
userName: () => 'user',
|
|
1087
|
+
password: () => 'pass',
|
|
1088
|
+
urlContext: 'xxx',
|
|
1089
|
+
vibeEventEndpoint: '/rfa/vibeiq/vibeEvents',
|
|
1090
|
+
csrfEndpoint: '/servlet/rest/security/csrf',
|
|
1091
|
+
itemPreDevelopmentLifecycleStages: ['concept']
|
|
1092
|
+
};
|
|
1093
|
+
|
|
1094
|
+
const mapFileUtil = new MapFileUtil(new Entities());
|
|
1095
|
+
const dc = new DataConverter(config, mapFileUtil);
|
|
1096
|
+
|
|
1097
|
+
const sizeRangeProp = {
|
|
1098
|
+
propertyType: 'size_range',
|
|
1099
|
+
slug: 'sizeRange',
|
|
1100
|
+
label: 'Size Range',
|
|
1101
|
+
};
|
|
1102
|
+
|
|
1103
|
+
it('returns sizeRange object when value is present', async () => {
|
|
1104
|
+
const data = { sizeRange: { sizes: ['PRE', 'NB'] } };
|
|
1105
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
1106
|
+
expect(returnValue).toEqual({ sizes: ['PRE', 'NB'] });
|
|
1107
|
+
});
|
|
1108
|
+
|
|
1109
|
+
it('returns null when sizeRange is null', async () => {
|
|
1110
|
+
const data = { sizeRange: null };
|
|
1111
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
1112
|
+
expect(returnValue).toBeNull();
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('returns undefined when sizeRange is missing', async () => {
|
|
1116
|
+
const data = {};
|
|
1117
|
+
const returnValue = await dc.getEntityValue(sizeRangeProp, data);
|
|
1118
|
+
expect(returnValue).toBeUndefined();
|
|
1119
|
+
});
|
|
1041
1120
|
});
|
|
@@ -119,6 +119,8 @@ export class DataConverter {
|
|
|
119
119
|
value = nd;
|
|
120
120
|
} else if ('userList' === propertyType) {
|
|
121
121
|
value = await this.getUserListValue(prop, newData);
|
|
122
|
+
}else if ('size_range' === propertyType){
|
|
123
|
+
value = nd;
|
|
122
124
|
}
|
|
123
125
|
|
|
124
126
|
return value;
|
|
@@ -353,6 +355,8 @@ export class DataConverter {
|
|
|
353
355
|
// console.log('TODO-json');
|
|
354
356
|
} else if ('userList' === propertyType) {
|
|
355
357
|
value = await this.setUserListValue(prop, nd);
|
|
358
|
+
}else if ('size_range' === propertyType){
|
|
359
|
+
value = nd;
|
|
356
360
|
}
|
|
357
361
|
|
|
358
362
|
// console.log(value);
|
|
@@ -360,69 +360,6 @@ describe('conversion-utils', () => {
|
|
|
360
360
|
});
|
|
361
361
|
});
|
|
362
362
|
|
|
363
|
-
describe('getUniquenessPoolKeyFromObject', () =>{
|
|
364
|
-
const mapFileUtil = new MapFileUtil(new Entities());
|
|
365
|
-
|
|
366
|
-
it('uses mapping-catName', async () =>{
|
|
367
|
-
const expectedPool = 'catName-pool';
|
|
368
|
-
const object = {
|
|
369
|
-
flexPLMObjectClass: 'LCSLast',
|
|
370
|
-
flexPLMTypePath: 'Last\\catName'
|
|
371
|
-
};
|
|
372
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
373
|
-
.mockImplementation(async () =>{
|
|
374
|
-
return mapping;
|
|
375
|
-
});
|
|
376
|
-
try{
|
|
377
|
-
const results = await TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
378
|
-
expect(results).toEqual(expectedPool);
|
|
379
|
-
|
|
380
|
-
} finally {
|
|
381
|
-
spy.mockRestore();
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
|
-
|
|
385
|
-
it('uses default-noMap', async () =>{
|
|
386
|
-
const expectedClass = 'color';
|
|
387
|
-
const object = {
|
|
388
|
-
flexPLMObjectClass: 'LCSColor',
|
|
389
|
-
flexPLMTypePath: 'Color'
|
|
390
|
-
};
|
|
391
|
-
const spy = jest.spyOn(mapFileUtil, 'getMapFile')
|
|
392
|
-
.mockImplementation(async () =>{
|
|
393
|
-
return mapping;
|
|
394
|
-
});
|
|
395
|
-
const spyDefaults = jest.spyOn(TypeDefaults, 'getDefaultEntityClass')
|
|
396
|
-
.mockImplementation(() => expectedClass);
|
|
397
|
-
try{
|
|
398
|
-
const results = await TypeConversionUtils.getUniquenessPoolKeyFromObject(TRANSFORM_MAP_FILE, mapFileUtil, object);
|
|
399
|
-
expect(results).toEqual(expectedClass);
|
|
400
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
401
|
-
|
|
402
|
-
} finally {
|
|
403
|
-
spy.mockRestore();
|
|
404
|
-
spyDefaults.mockRestore();
|
|
405
|
-
}
|
|
406
|
-
});
|
|
407
|
-
|
|
408
|
-
it('uses default-noFileId', async () =>{
|
|
409
|
-
const expectedClass = 'color';
|
|
410
|
-
const object = {
|
|
411
|
-
flexPLMObjectClass: 'LCSColor',
|
|
412
|
-
};
|
|
413
|
-
const spyDefaults = jest.spyOn(TypeDefaults, 'getDefaultEntityClass')
|
|
414
|
-
.mockImplementation(() => expectedClass);
|
|
415
|
-
try{
|
|
416
|
-
const results = await TypeConversionUtils.getUniquenessPoolKeyFromObject(null, mapFileUtil, object);
|
|
417
|
-
expect(results).toEqual(expectedClass);
|
|
418
|
-
expect(spyDefaults).toBeCalledTimes(1);
|
|
419
|
-
|
|
420
|
-
} finally {
|
|
421
|
-
spyDefaults.mockRestore();
|
|
422
|
-
}
|
|
423
|
-
});
|
|
424
|
-
});
|
|
425
|
-
|
|
426
363
|
describe('getEntityTypePathFromOjbect', () =>{
|
|
427
364
|
const mapFileUtil = new MapFileUtil(new Entities());
|
|
428
365
|
|
|
@@ -224,36 +224,6 @@ export class TypeConversionUtils {
|
|
|
224
224
|
return TypeDefaults.getDefaultEntityClass(object);
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
/** Takes in a FlexPLM object and returns the correct VibeIQ uniqueness
|
|
228
|
-
* pool key. Order of precedence:
|
|
229
|
-
* Map file entry in 'typeConversion:flex2vibe:<value>:getUniquenessPool()'
|
|
230
|
-
* for value from 'objectClass'
|
|
231
|
-
* TypeDefaults.getDefaultEntityClass() function
|
|
232
|
-
*
|
|
233
|
-
* @param fileId id for mapFile
|
|
234
|
-
* @param mapFileUtil class to get mapfile
|
|
235
|
-
* @param object FlexPLM object
|
|
236
|
-
* @returns Promise<string>
|
|
237
|
-
*/
|
|
238
|
-
static async getUniquenessPoolKeyFromObject(fileId, mapFileUtil, object): Promise<string>{
|
|
239
|
-
let uniquenessPool;
|
|
240
|
-
|
|
241
|
-
if(fileId){
|
|
242
|
-
const mapKey = await this.getMapKeyFromObject(fileId, mapFileUtil, object, TypeConversionUtils.FLEX2VIBE_DIRECTION);
|
|
243
|
-
if(mapKey){
|
|
244
|
-
const mapData = await MapUtil.getFullMapSection(fileId, mapFileUtil, mapKey);
|
|
245
|
-
if(mapData && mapData['uniquenessPool']){
|
|
246
|
-
uniquenessPool = mapData['uniquenessPool'];
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
if(uniquenessPool){
|
|
252
|
-
return uniquenessPool;
|
|
253
|
-
}
|
|
254
|
-
return TypeDefaults.getDefaultEntityClass(object);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
227
|
/** Takes in a FlexPLM object and returns the correct VibeIQ
|
|
258
228
|
* type associated to the object. Order of precedence
|
|
259
229
|
* Property 'vibeIQTypePath'
|