Skip to content

Commit 3377efe

Browse files
chore: flexcard name update
1 parent 6a401d7 commit 3377efe

File tree

3 files changed

+36
-80
lines changed

3 files changed

+36
-80
lines changed

src/migration/dataraptor.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,6 @@ export class DataRaptorMigrationTool extends BaseMigrationTool implements Migrat
386386
const drItems = dataRaptorItemsMap.get(drName);
387387
if (drItems) {
388388
for (const drItem of drItems) {
389-
// Logger.log(dataRaptor[this.namespacePrefix + 'Formula__c']);
390389
const formula = drItem[this.getItemFieldKey('Formula__c')];
391390
if (formula) {
392391
try {

src/migration/flexcard.ts

Lines changed: 34 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
8989

9090
// Perform Records Migration from VlocityCard__c to OmniUiCard
9191
async migrate(): Promise<MigrationResult[]> {
92-
// Get All the Active VlocityCard__c records
93-
const allCards = await this.getAllActiveCards();
92+
const allCards = await this.getAllCards();
9493

9594
Logger.log(this.messages.getMessage('foundFlexCardsToMigrate', [allCards.length]));
9695

@@ -156,7 +155,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
156155
public async assess(): Promise<FlexCardAssessmentInfo[]> {
157156
try {
158157
Logger.log(this.messages.getMessage('startingFlexCardAssessment'));
159-
const flexCards = await this.getAllActiveCards();
158+
const flexCards = await this.getAllCards();
160159
Logger.log(this.messages.getMessage('foundFlexCardsToAssess', [flexCards.length]));
161160

162161
const flexCardsAssessmentInfos = await this.processCardComponents(flexCards);
@@ -234,20 +233,10 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
234233
'Ready for migration';
235234
flexCardAssessmentInfo.name = this.allVersions ? `${cleanedName}_${version}` : cleanedName;
236235
if (cleanedName !== originalName) {
237-
if (!this.IS_STANDARD_DATA_MODEL) {
238-
flexCardAssessmentInfo.warnings.push(
239-
this.messages.getMessage('cardNameChangeMessage', [originalName, cleanedName])
240-
);
241-
assessmentStatus = getUpdatedAssessmentStatus(assessmentStatus, 'Warnings');
242-
} else {
243-
flexCardAssessmentInfo.warnings.push(
244-
this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')
245-
);
246-
flexCardAssessmentInfo.errors.push(
247-
this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')
248-
);
249-
assessmentStatus = 'Needs Manual Intervention';
250-
}
236+
flexCardAssessmentInfo.warnings.push(
237+
this.messages.getMessage('cardNameChangeMessage', [originalName, cleanedName])
238+
);
239+
assessmentStatus = getUpdatedAssessmentStatus(assessmentStatus, 'Warnings');
251240
}
252241

253242
// Check for duplicate names
@@ -404,23 +393,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
404393

405394
// Add warning if child card name will change
406395
if (childCardName !== cleanedChildCardName) {
407-
if (!this.IS_STANDARD_DATA_MODEL) {
408-
flexCardAssessmentInfo.warnings.push(
409-
this.messages.getMessage('cardNameChangeMessage', [childCardName, cleanedChildCardName])
410-
);
411-
flexCardAssessmentInfo.migrationStatus = getUpdatedAssessmentStatus(
412-
flexCardAssessmentInfo.migrationStatus,
413-
'Warnings'
414-
);
415-
} else {
416-
flexCardAssessmentInfo.warnings.push(
417-
this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')
418-
);
419-
flexCardAssessmentInfo.errors.push(
420-
this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')
421-
);
422-
flexCardAssessmentInfo.migrationStatus = 'Needs Manual Intervention';
423-
}
396+
flexCardAssessmentInfo.warnings.push(
397+
this.messages.getMessage('cardNameChangeMessage', [childCardName, cleanedChildCardName])
398+
);
399+
flexCardAssessmentInfo.migrationStatus = getUpdatedAssessmentStatus(
400+
flexCardAssessmentInfo.migrationStatus,
401+
'Warnings'
402+
);
424403
}
425404
}
426405
} catch (err) {
@@ -694,8 +673,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
694673
}
695674
}
696675

697-
// Query all cards that are active
698-
private async getAllActiveCards(): Promise<AnyJson[]> {
676+
private async getAllCards(): Promise<AnyJson[]> {
699677
//DebugTimer.getInstance().lap('Query Vlocity Cards');
700678
const filters = new Map<string, any>();
701679

@@ -740,7 +718,7 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
740718
}
741719
}
742720

743-
// Upload All the VlocityCard__c records to OmniUiCard
721+
// Upload All the VlocityCard__c records to OmniUiCard for custom model and update references for standard
744722
private async uploadAllCards(
745723
cards: any[],
746724
progressBar: ReturnType<typeof createProgressBar>
@@ -789,42 +767,13 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
789767
}
790768
}
791769

792-
const isChildCardUpdated: boolean = this.updateChildCards(card);
793-
794-
if (this.IS_STANDARD_DATA_MODEL && isChildCardUpdated) {
795-
originalRecords.set(recordId, card);
796-
797-
cardsUploadInfo.set(recordId, {
798-
referenceId: recordId,
799-
hasErrors: true,
800-
success: false,
801-
errors: [this.messages.getMessage('needManualInterventionAsSpecialCharsInChildFlexcardName')],
802-
warnings: [],
803-
});
804-
805-
return;
806-
}
770+
this.updateChildCards(card);
807771
}
808772

809773
// Perform the transformation
810774
const invalidIpNames = new Map<string, string>();
811775
const transformedCard = this.mapVlocityCardRecord(card, cardsUploadInfo, invalidIpNames); // This only has the card structure, card definition is not there
812776

813-
if (this.IS_STANDARD_DATA_MODEL) {
814-
if (transformedCard['Name'] != card['Name']) {
815-
originalRecords.set(recordId, card);
816-
817-
cardsUploadInfo.set(recordId, {
818-
referenceId: recordId,
819-
hasErrors: true,
820-
success: false,
821-
errors: [this.messages.getMessage('needManualInterventionAsSpecialCharsInFlexcardName')],
822-
warnings: [],
823-
});
824-
return;
825-
}
826-
}
827-
828777
// Verify duplicated names
829778
let transformedCardName: string;
830779
if (this.allVersions) {
@@ -1051,11 +1000,9 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10511000
return childs;
10521001
}
10531002

1054-
private updateChildCards(card: AnyJson): boolean {
1003+
private updateChildCards(card: AnyJson): void {
10551004
const definition = JSON.parse(card[this.getFieldKey('Definition__c')]);
1056-
if (!definition) return false;
1057-
1058-
let hasNameChanges = false;
1005+
if (!definition) return;
10591006

10601007
for (let state of definition.states || []) {
10611008
if (state.childCards && Array.isArray(state.childCards)) {
@@ -1065,14 +1012,12 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
10651012
// Check if any child card name was changed
10661013
for (let i = 0; i < originalChildCards.length; i++) {
10671014
if (originalChildCards[i] !== state.childCards[i]) {
1068-
hasNameChanges = true;
10691015
}
10701016
}
10711017
}
10721018
}
10731019

10741020
card[this.getFieldKey('Definition__c')] = JSON.stringify(definition);
1075-
return hasNameChanges;
10761021
}
10771022

10781023
// Maps an indivitdual VlocityCard__c record to an OmniUiCard record.
@@ -1125,6 +1070,18 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
11251070
mappedObject[CardMappings.Author__c] = this.cleanName(mappedObject[CardMappings.Author__c]);
11261071
mappedObject[CardMappings.Active__c] = false;
11271072

1073+
if (this.IS_STANDARD_DATA_MODEL) {
1074+
if (mappedObject['OmniUiCardKey']) {
1075+
mappedObject['OmniUiCardKey'] =
1076+
mappedObject['Name'] +
1077+
'/' +
1078+
mappedObject[CardMappings.Author__c] +
1079+
'/' +
1080+
mappedObject[CardMappings.Version__c] +
1081+
'.0';
1082+
}
1083+
}
1084+
11281085
// Update the datasource
11291086
const datasource = JSON.parse(mappedObject[CardMappings.Datasource__c] || '{}');
11301087
if (datasource.dataSource) {
@@ -1146,8 +1103,10 @@ export class CardMigrationTool extends BaseMigrationTool implements MigrationToo
11461103
mappedObject[CardMappings.Datasource__c] = JSON.stringify(datasource);
11471104
}
11481105

1149-
const isCardActive: boolean = cardRecord[`${this.namespacePrefix}Active__c`];
1150-
this.ensureCommunityTargets(mappedObject, isCardActive);
1106+
if (!this.IS_STANDARD_DATA_MODEL) {
1107+
const isCardActive: boolean = cardRecord[this.getFieldKey('Active__c')];
1108+
this.ensureCommunityTargets(mappedObject, isCardActive);
1109+
}
11511110

11521111
// Update all dependencies comprehensively
11531112
this.updateAllDependenciesWithRegistry(mappedObject, invalidIpNames);

src/migration/omniscript.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,6 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
12721272
? filters.set('OmniProcessId', recordId)
12731273
: filters.set(this.namespacePrefix + 'OmniScriptId__c', recordId);
12741274

1275-
// const queryFilterStr = ` Where ${this.namespacePrefix}OmniScriptId__c = '${omniScriptData.keys().next().value}'`;
12761275
return await QueryTools.queryWithFilter(
12771276
this.connection,
12781277
this.getQueryNamespace(),
@@ -1290,7 +1289,6 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
12901289
? filters.set('OmniProcessId', recordId)
12911290
: filters.set(this.namespacePrefix + 'OmniScriptId__c', recordId);
12921291

1293-
// const queryFilterStr = ` Where ${this.namespacePrefix}OmniScriptId__c = '${omniScriptData.keys().next().value}'`;
12941292
return await QueryTools.queryWithFilter(
12951293
this.connection,
12961294
this.getQueryNamespace(),
@@ -1516,10 +1514,10 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
15161514

15171515
if (
15181516
cleanFieldName === 'ParentElementId__c' &&
1519-
parentElementUploadResponse.has(elementRecord[`${this.namespacePrefix}ParentElementId__c`])
1517+
parentElementUploadResponse.has(elementRecord[this.getElementFieldKey('ParentElementId__c')])
15201518
) {
15211519
mappedObject[ElementMappings[cleanFieldName]] = parentElementUploadResponse.get(
1522-
elementRecord[`${this.namespacePrefix}ParentElementId__c`]
1520+
elementRecord[this.getElementFieldKey('ParentElementId__c')]
15231521
).id;
15241522
}
15251523
}

0 commit comments

Comments
 (0)