Skip to content

Commit

Permalink
Merge pull request #437 from vlocityinc/beta
Browse files Browse the repository at this point in the history
Updates for New Minor Version of VBT
  • Loading branch information
Adam Rutland authored Feb 10, 2022
2 parents b0ca2ed + 928b1fe commit d5fdebd
Show file tree
Hide file tree
Showing 57 changed files with 30,526 additions and 570 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ node_modules/
vlocity-temp/
example_vlocity_build/
test/testJobRunning/
testJobRunning/
test/salesforce_sfdx_test/
testJobRunning/testBuildFile.*
.nyc_output/
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ RUN npm install --global sfdx-cli@7.45.1
RUN npm install --global publish-release

RUN npm install --global pkg-fetch
RUN pkg-fetch -n node10 -p win -a x64
#RUN pkg-fetch -n node10 -p win -a x64
RUN pkg-fetch -n node10 -p linux -a x64
RUN pkg-fetch -n node10 -p macos -a x64

Expand Down
139 changes: 83 additions & 56 deletions README.md

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions apex/DeactivateCards.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//include BaseUtilities.cls;

List < String > allCardsNames = new List < String > ();

for (Map < String, Object > obj : dataPackDataSet)
{
if (obj.get('VlocityRecordSObjectType') == 'vlocity_namespace__VlocityCard__c') {
allCardsNames.add((String)obj.get('Name'));
}
}


List < OmniUiCard > cards =[SELECT Id, Name, IsActive FROM OmniUiCard WHERE Name in : allCardsNames AND IsActive = true];

for (OmniUiCard temp : cards)
{
temp.IsActive = false;
}

if (cards.size() > 0) {
update cards;
}
24 changes: 24 additions & 0 deletions apex/DeactivateFlexCards.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
//include BaseUtilities.cls;

List<String> allFlexCardNames = new List<String>();

for (Map<String, Object> obj : dataPackDataSet)
{
if (obj.get('VlocityRecordSObjectType') == 'OmniUiCard')
{
allFlexCardNames.add((String)obj.get('Name'));
}

}

List<OmniUiCard> flexCards = [SELECT Id, Name, IsActive FROM OmniUiCard WHERE Name in :allFlexCardNames AND IsActive = true];

for (OmniUiCard temp : flexCards)
{
temp.IsActive = false;
}

if (flexCards.size() > 0)
{
update flexCards;
}
34 changes: 34 additions & 0 deletions apex/TestDeployedDRsVIPs.cls
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
String Acct1Id = '';
List < Account > accts =[SELECT Id, Name FROM Account WHERE Name = 'VBT_TestAutomation1'];
if (accts.size() > 0) {
Acct1Id = accts[0].Id;
Contact[] contacts = [SELECT Id, Name FROM Contact WHERE AccountId = : Acct1Id];
if (contacts.isEmpty()) {
upsert(new Contact(FirstName = 'VBT_', LastName = 'TestAutomation', AccountId = accts[0].Id));
}
} else {
Account newAcct = (new Account(Name = 'VBT_TestAutomation1'));
upsert newAcct;
upsert(new Contact(FirstName = 'VBT', LastName = 'TestAutomation', AccountId = newAcct.Id));
Acct1Id = newAcct.Id;
upsert(new Account(Name = 'VBT_TestAutomation2'));
upsert(new Account(Name = 'VBT_TestAutomation3'));
}

vlocity_namespace.DRProcessResult result = vlocity_namespace.DRGlobal.processObjectsJSON('{"Name":"TestAuto"}', 'datapacktest_Extract');
List < Object > outputDr1 = (List < Object >)result.convertToMap().get('returnResultsData');
System.assertEquals(outputDr1.size(), 2);
System.assert(JSON.serialize(outputDr1[0]).contains('VBT_TestAutomation1'));
System.assert(JSON.serialize(outputDr1[1]).contains('VBT_TestAutomation2'));

result = vlocity_namespace.DRGlobal.processObjectsJSON('{"Name":"TestAuto"}', 'datapacktest_Turbo');
String outputDrTurbo = JSON.serialize(result.convertToMap());
System.assert(outputDrTurbo.contains('VBT TestAutomation'));
System.assert(outputDrTurbo.contains(Acct1Id));


Map < String, Object > ipOutput = (Map < String, Object >) vlocity_namespace.IntegrationProcedureService.runIntegrationService('DataPackTest_DRExtractWithInput', new Map < String, Object > { 'Name' => 'TestAuto' }, new Map < String, Object > ());
System.assertEquals((String)ipOutput.get('accountId'), Acct1Id);
System.assertEquals((String)ipOutput.get('accountName'), 'VBT_TestAutomation1');
System.assertEquals((String)ipOutput.get('firstName'), 'VBT');
System.assertEquals((String)ipOutput.get('lastName'), 'TestAutomation');
8 changes: 4 additions & 4 deletions dataPacksJobs/TestJob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ expansionPath: testJobRunning
buildFile: testJobRunning/testBuildFile.resource
autoUpdateSettings: true
queries:
- VlocityDataPackType: VlocityUITemplate
query: Select Id, Name from %vlocity_namespace%__VlocityUITemplate__c where Name LIKE 'datapacktest-%' AND %vlocity_namespace%__Active__c = true
- VlocityDataPackType: VlocityUILayout
query: Select Id, Name from %vlocity_namespace%__VlocityUILayout__c where Name LIKE 'datapacktest-%'
- VlocityDataPackType: IntegrationProcedure
query: Select Id, %vlocity_namespace%__Type__c, %vlocity_namespace%__SubType__c from %vlocity_namespace%__OmniScript__c WHERE %vlocity_namespace%__IsActive__c = true AND %vlocity_namespace%__IsProcedure__c = true AND %vlocity_namespace%__ProcedureKey__c LIKE 'dataPackTest_%'
- VlocityDataPackType: VlocityCard
query: SELECT Id, Name FROM %vlocity_namespace%__VlocityCard__c WHERE Name LIKE 'datapacktest_%' AND %vlocity_namespace%__Active__c = true
preJobApex:
Deploy: TestJob.cls
preStepApex:
Expand Down
4 changes: 3 additions & 1 deletion lib/datapacks.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,9 @@ DataPacks.prototype.runDataPackProcess = async function(dataPackData, options) {

if (/(Ready|InProgress)/.test(result.Status)) {
dataPackData.processData = result;

if (dataPackData.processData.VlocityDataPackId && options.forceOldDataModel) {
dataPackData.processData.forceOldDataModel = true;
}
if (result.Async) {
await new Promise(resolve => setTimeout(resolve, 3000));
}
Expand Down
37 changes: 21 additions & 16 deletions lib/datapacksbuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,15 +238,9 @@ DataPacksBuilder.prototype.buildImport = async function(importPath, jobInfo, val
}
}

if (jobInfo.upgradeDataPackFields) {
jobInfo.platformObjectMappings = this.vlocity.datapacksutils.updateExpandedDefinitionNamespace(
yaml.safeLoad(fs.readFileSync(
path.join(__dirname, 'platformObjectMappings.yaml'),
'utf8'
))
);
if (!jobInfo.forceOldDataModel && (jobInfo.upgradeDataPackFields || this.vlocity.isOmniStudioInstalled)) {
dataPackImport.dataPacks.forEach(dataPack => {
if (Object.keys(jobInfo.platformObjectMappings).includes(dataPack.VlocityDataPackType)) {
if (Object.keys(this.vlocity.omnistudio.platformObjectMappings).includes(dataPack.VlocityDataPackType)) {
this.vlocity.datapacksutils.updateDataPackWithNewMappings(dataPack, jobInfo);
}
});
Expand Down Expand Up @@ -329,19 +323,30 @@ DataPacksBuilder.prototype.paginateItem = function(paginatedDataPack, currentSOb
currentSObject[keyField] = arrayOfPaginated[i];

var addingPaginatedDataPack = JSON.parse(JSON.stringify(paginatedDataPack));

if (i > 0 && paginationActions) {
if (paginationActions) {
Object.keys(paginationActions).forEach(function(field) {
var actions = paginationActions[field];
if (actions) {
if (actions.indexOf('Remove') != -1 && keyField != field) {
var dataField = self.vlocity.datapacksutils.getDataField(paginatedDataPack);

if (addingPaginatedDataPack.VlocityDataPackData[dataField][0][field]) {
delete addingPaginatedDataPack.VlocityDataPackData[dataField][0][field];
if (i == 0) {
if (actions.indexOf('Dependent') != -1 && keyField != field) {
var dataField = self.vlocity.datapacksutils.getDataField(paginatedDataPack);

if (addingPaginatedDataPack.VlocityDataPackData[dataField][0][field]) {
delete addingPaginatedDataPack.VlocityDataPackData[dataField][0][field];
}
}
} else {
if (actions.indexOf('Remove') != -1 && keyField != field) {
var dataField = self.vlocity.datapacksutils.getDataField(paginatedDataPack);

if (addingPaginatedDataPack.VlocityDataPackData[dataField][0][field]) {
delete addingPaginatedDataPack.VlocityDataPackData[dataField][0][field];
}
} else if (actions.indexOf('AddLookupRelationships') != -1) {
self.addLookupRelationships(addingPaginatedDataPack, field);
}
} else if (actions.indexOf('AddLookupRelationships') != -1) {
self.addLookupRelationships(addingPaginatedDataPack, field);
}
}
});
Expand Down
22 changes: 14 additions & 8 deletions lib/datapacksexpand.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ DataPacksExpand.prototype.getNameWithFields = function(nameFields, dataPackData,
} else if (dataPackData[key] && typeof dataPackData[key] === "string") {
return dataPackData[key].replace(/[/\\]+/g,' '); // do not allow directory slashes in names
} else if (dataPackData[key] != null && typeof dataPackData[key] === "object") {
return self.getDataPackFolder(null, dataPackData[key].VlocityRecordSObjectType, dataPackData[key], isUpgradeDataPackFields);
return self.getDataPackFolder(null, dataPackData[key].VlocityRecordSObjectType, dataPackData[key], self.vlocity.isOmniStudioInstalled);
}
});

Expand Down Expand Up @@ -111,29 +111,31 @@ DataPacksExpand.prototype.getDataPackFolder = function(dataPackType, sObjectType
return this.getNameWithFields(this.vlocity.datapacksutils.getFolderName(dataPackType, sObjectType, isUpgradeObjects), dataPackData);
};

DataPacksExpand.prototype.buildHierarchyKey = function(listDataBySourceKey, sortFields, listRec, depth) {
DataPacksExpand.prototype.buildHierarchyKey = function(listDataBySourceKey, sortFields, listRec, index, depth) {
var self = this;

if (!listRec.HierarchyKey) {

var parentField = sortFields[1];
var keyField = sortFields[2];
if(!self.vlocity.namespace){
if (!self.vlocity.namespace){
parentField = parentField.replace(/%vlocity_namespace%__/g,'');
keyField = keyField.replace(/%vlocity_namespace%__/g,'');
}
var thisKey = listRec[keyField].toString().padStart(10, '0');

var paddedIndex = index.toString().padStart(10, '0');

if (!listRec[parentField]) {
listRec.HierarchyKey = thisKey;
listRec.HierarchyKey = thisKey + "_" + paddedIndex;
} else {
var parentRecKey = listRec[parentField].VlocityMatchingRecordSourceKey;

if (depth > 3) {
VlocityUtils.error('Error Getting Hierarchy Key - Circular Reference found on object with Id', parentRecKey);
return '999999999';
} else if (listDataBySourceKey[parentRecKey]) {
var parentHierarchyKey = self.buildHierarchyKey(listDataBySourceKey, sortFields, listDataBySourceKey[parentRecKey], depth ? depth + 1 : 1);
var parentHierarchyKey = self.buildHierarchyKey(listDataBySourceKey, sortFields, listDataBySourceKey[parentRecKey], index, depth ? depth + 1 : 1);
listRec.HierarchyKey = parentHierarchyKey + thisKey;
}
}
Expand Down Expand Up @@ -161,9 +163,9 @@ DataPacksExpand.prototype.sortList = function(listData, dataPackType) {
}
});

listData.forEach(function(listRec) {
self.buildHierarchyKey(listDataBySourceKey, sortFields, listRec);
});
for (var i = 0; i < listData.length; i++) {
this.buildHierarchyKey(listDataBySourceKey, sortFields, listData[i], i);
}

sortFields = ['HierarchyKey'];
}
Expand Down Expand Up @@ -609,6 +611,10 @@ DataPacksExpand.prototype.preprocessSObjects = async function(currentData, dataP

var defaultFilterFields = self.vlocity.datapacksutils.getFilterFields(null, 'All');

if (jobInfo.removeMultiCurrency) {
defaultFilterFields.push("CurrencyIsoCode");
}

defaultFilterFields.forEach(function (field) {
if (field === 'HierarchyKey' || currentData.VlocityRecordSObjectType) {
delete currentData[field];
Expand Down
108 changes: 108 additions & 0 deletions lib/datapacksexpanddefinition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ DataPacks:
UniqueByName: true
MaxDeploy: 5
DefaultVisualforcePage: /one/one.app#/alohaRedirect/apex/%vlocity_namespace%__drmapper?id=%Id%
DecisionMatrix:
UniqueByName: true
ExportGroupSize: 1
MaxDeploy: 1
DecisionMatrixVersion:
ExportGroupSize: 1
MaxDeploy: 1
CalculationMatrixVersion:
FileName:
- Name
EntityFilter:
MaxDeploy: 1
IntegrationProcedure:
Expand Down Expand Up @@ -285,6 +295,7 @@ SObjects:
JsonFields:
- InputData__c
- OutputData__c
- OutputDataLong__c
ListFileName:
- _Rows
NonUnique: true
Expand Down Expand Up @@ -319,6 +330,28 @@ SObjects:
GlobalKey__c: Name
SourceKeyDefinition:
- Name
CalculationMatrix:
SourceKeyDefinition:
- Name
CalculationMatrixRow:
DiffKeys:
1:
- Name
JsonFields:
- InputData
- OutputData
ListFileName:
- _Rows
NonUnique: true
SortFields:
- Name=Header
- InputData
UnhashableFields:
- CalculationMatrixVersionId
CalculationMatrixVersion:
SourceKeyDefinition:
- VersionNumber
- CalculationMatrixId
CalculationProcedureStep__c:
DeletedDuringDeploy: true
DeltaCheckTextIdField:
Expand Down Expand Up @@ -393,6 +426,59 @@ SObjects:
- Name
UnhashableFields:
- LastSimulationInput__c
CalcProcStepRelationship:
DeletedDuringDeploy: true
CalculationProcedureStep:
DiffKeys:
1:
- OutputVariablesFormatText
2:
- FormulaExpressionText
FilterFields:
- CalculationProcedure
JsonFields:
- ConditionsUiFormattedText
- InputVariablesFormatText
- OutputVariablesFormatText
- OutputVariablesMappingText
- ReturnMessageValueSet
ListFileName:
- _Steps
SortFields:
- Stage
- StageStepSequence
UnhashableFields:
- CalculationProcedureVersionId
CalculationProcedureVariable:
DeletedDuringDeploy: true
DiffKeys:
1:
- Name
ListFileName:
- _Variables
UnhashableFields:
- CalculationProcedureVersionId
CalculationProcedureVersion:
DiffKeys:
1:
- _Version
FileName:
- _Version
JsonFields:
- Constants
- Variables
ReplacementFields:
GlobalKey__c: Name
SourceKeyDefinition:
- VersionNumber
- CalculationProcedureId
CalculationProcedure:
CalculationProcedureVersion__c: object
FilterFields:
- InputVariablesMetadata
- OutputVariablesMetadata
SourceKeyDefinition:
- Name
Catalog__c:
DeltaQueryChildren:
CatalogRelationship__c:
Expand Down Expand Up @@ -1454,6 +1540,28 @@ SObjects:
UnhashableFields:
- Author__c
- GlobalKey__c
OmniUiCard:
DataPackReferences:
- Type: VlocityUILayout
Field: PropertySetConfig.states.flyout.layout
- Type: DataRaptor
Field: PropertySetConfig.dataSource.value.bundle
- Type: ApexClass
Field: PropertySetConfig.dataSource.value.remoteClass
- Type: VlocityUITemplate
Field: PropertySetConfig.states.templateUrl
- Type: VlocityAction
Field: PropertySetConfig.states.definedActions.actions.id
PropertySetConfig: json
FilterFields:
- IsActive
JsonFields:
- DataSourceConfig
SourceKeyDefinition:
- Name
UnhashableFields:
- AuthorName
- OmniUiCardKey
VlocityDataStore__c:
SourceKeyDefinition:
- Name
Expand Down
Loading

0 comments on commit d5fdebd

Please sign in to comment.