@@ -10,6 +10,7 @@ import { MigrationResult, MigrationTool, TransformData, UploadRecordResult } fro
1010import { ObjectMapping } from './interfaces' ;
1111import { NetUtils , RequestMethod } from '../utils/net' ;
1212import { Connection , Logger , Messages } from '@salesforce/core' ;
13+ import { UX } from '@salesforce/command' ;
1314
1415export class OmniScriptMigrationTool extends BaseMigrationTool implements MigrationTool {
1516
@@ -25,8 +26,8 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
2526 static readonly OMNIPROCESSELEMENT_NAME = 'OmniProcessElement' ;
2627 static readonly OMNIPROCESSCOMPILATION_NAME = 'OmniProcessCompilation' ;
2728
28- constructor ( exportType : OmniScriptExportType , namespace : string , connection : Connection , logger : Logger , messages : Messages ) {
29- super ( namespace , connection , logger , messages ) ;
29+ constructor ( exportType : OmniScriptExportType , namespace : string , connection : Connection , logger : Logger , messages : Messages , ux : UX ) {
30+ super ( namespace , connection , logger , messages , ux ) ;
3031 this . exportType = exportType ;
3132 }
3233
@@ -59,7 +60,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
5960 async truncate ( ) : Promise < void > {
6061 const objectName = OmniScriptMigrationTool . OMNIPROCESS_NAME ;
6162
62- const allIds = await this . deactivateRecord ( objectName , false ) ;
63+ const allIds = await this . deactivateRecord ( objectName ) ;
6364 await this . truncateElements ( objectName , allIds . os . parents ) ;
6465 await this . truncateElements ( objectName , allIds . os . childs ) ;
6566 await this . truncateElements ( objectName , allIds . ip . parents ) ;
@@ -71,11 +72,11 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
7172
7273 let success : boolean = await NetUtils . delete ( this . connection , ids ) ;
7374 if ( ! success ) {
74- throw new Error ( this . messages . getMessage ( 'couldNotTruncate ' ) . formatUnicorn ( objectName ) ) ;
75+ throw new Error ( this . messages . getMessage ( 'couldNotTruncateOmnniProcess ' ) . formatUnicorn ( objectName ) ) ;
7576 }
7677 }
7778
78- async deactivateRecord ( objectName : string , isReusable : boolean ) : Promise < { os : { parents : string [ ] , childs : string [ ] } , ip : { parents : string [ ] , childs : string [ ] } } > {
79+ async deactivateRecord ( objectName : string ) : Promise < { os : { parents : string [ ] , childs : string [ ] } , ip : { parents : string [ ] , childs : string [ ] } } > {
7980 DebugTimer . getInstance ( ) . lap ( 'Truncating ' + objectName + ' (' + this . exportType + ')' ) ;
8081
8182 const filters = new Map < string , any > ( ) ;
@@ -88,8 +89,6 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
8889 filters . set ( 'IsIntegrationProcedure' , false ) ;
8990 }
9091
91- // filters.set('IsOmniScriptEmbeddable', isReusable);
92-
9392 // const ids: string[] = await QueryTools.queryIds(this.connection, objectName, filters);
9493 const rows = await QueryTools . query ( this . connection , objectName , [ 'Id' , 'IsIntegrationProcedure' , 'IsOmniScriptEmbeddable' ] , filters , sorting ) ;
9594 if ( rows . length === 0 ) {
@@ -127,13 +126,17 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
127126 const omniscripts = await this . getAllOmniScripts ( ) ;
128127
129128 // Variables to be returned After Migration
130- var originalOsRecords = new Map < string , any > ( ) ;
131- var osUploadInfo = new Map < string , UploadRecordResult > ( ) ;
129+ let done = 0 ;
130+ let originalOsRecords = new Map < string , any > ( ) ;
131+ let osUploadInfo = new Map < string , UploadRecordResult > ( ) ;
132+ const total = omniscripts . length ;
132133
133134 for ( let omniscript of omniscripts ) {
134135 const mappedRecords = [ ] ,
135136 originalRecords = new Map < string , AnyJson > ( ) ;
136137
138+ this . reportProgress ( total , done ) ;
139+
137140 // Record is Active, Elements can't be Added, Modified or Deleted for that OS/IP
138141 omniscript [ `${ this . namespacePrefix } IsActive__c` ] = false ;
139142
@@ -184,6 +187,7 @@ export class OmniScriptMigrationTool extends BaseMigrationTool implements Migrat
184187 originalOsRecords = new Map ( [ ...Array . from ( originalOsRecords . entries ( ) ) , ...Array . from ( originalRecords . entries ( ) ) ] ) ;
185188 osUploadInfo = new Map ( [ ...Array . from ( osUploadInfo . entries ( ) ) , ...Array . from ( osUploadResponse . entries ( ) ) ] ) ;
186189
190+ done ++ ;
187191 } ;
188192
189193 const objectMigrationResults : MigrationResult [ ] = [ ] ;
0 commit comments