Skip to content

Commit

Permalink
A few last pieces of cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jamessimone committed Nov 5, 2024
1 parent b776000 commit 0a7781d
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 12 deletions.
80 changes: 79 additions & 1 deletion rollup/app/permissionsets/See_Rollup_App.permissionset-meta.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8" ?>
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
<applicationVisibilities>
<application>Rollup</application>
Expand All @@ -8,6 +8,80 @@
<apexClass>Rollup</apexClass>
<enabled>true</enabled>
</classAccesses>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.Body0__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedJobId__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys0__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys1__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys2__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys3__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys4__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys5__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys6__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys7__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys8__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys9__c</field>
<readable>true</readable>
</fieldPermissions>
<fieldPermissions>
<editable>true</editable>
<field>RollupState__c.RelatedRecordKeys10__c</field>
<readable>true</readable>
</fieldPermissions>
<objectPermissions>
<allowCreate>true</allowCreate>
<allowDelete>true</allowDelete>
<allowEdit>true</allowEdit>
<allowRead>true</allowRead>
<modifyAllRecords>true</modifyAllRecords>
<object>RollupState__c</object>
<viewAllRecords>true</viewAllRecords>
</objectPermissions>
<description>Allows users to access the Rollup app</description>
<hasActivationRequired>false</hasActivationRequired>
<label>Apex Rollup: See Rollup App</label>
Expand All @@ -16,4 +90,8 @@
<tab>Recalculate_Rollup</tab>
<visibility>Visible</visibility>
</tabSettings>
<tabSettings>
<tab>RollupState__c</tab>
<visibility>Visible</visibility>
</tabSettings>
</PermissionSet>
2 changes: 1 addition & 1 deletion rollup/core/classes/Rollup.cls
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,7 @@ global without sharing virtual class Rollup implements RollupLogger.ToStringObje

for (Rollup__mdt rollupMetadata : rollupOperations) {
Op rollupOp = OP_NAME_TO_OP.get(rollupMetadata.RollupOperation__c.toUpperCase());
if (rollupMetadata.RollupGrouping__r.Id != null && rollupMetadata.CalcItem__c != null && rollupMetadata.CalcItem__c != SObjectType.toString()) {
if (rollupMetadata.RollupGrouping__r.Id != null && rollupMetadata.CalcItem__c != null && rollupMetadata.CalcItem__c != sObjectType.toString()) {
Schema.DescribeSObjectResult childDescribe = init.getDescribeFromName(rollupMetadata.CalcItem__c);
sObjectType = childDescribe.getSObjectType();
calcItemFields = childDescribe.fields.getMap();
Expand Down
8 changes: 3 additions & 5 deletions rollup/core/classes/RollupAsyncProcessor.cls
Original file line number Diff line number Diff line change
Expand Up @@ -445,11 +445,9 @@ global virtual without sharing class RollupAsyncProcessor extends Rollup impleme
}

protected virtual override String startAsyncWork() {
if (System.isQueueable() && (System.Limits.getQueueableJobs() == 1 || hasAlreadyAsyncEnqueued)) {
if (this.finalizer != null) {
this.finalizer.addCaboose(this);
return this.getNoProcessId();
}
if (this.finalizer != null && System.isQueueable() && (System.Limits.getQueueableJobs() == 1 || hasAlreadyAsyncEnqueued)) {
this.finalizer.addCaboose(this);
return this.getNoProcessId();
}
hasAlreadyAsyncEnqueued = hasAlreadyAsyncEnqueued || System.isBatch() || System.isQueueable() || System.isFuture();
return System.enqueueJob(this);
Expand Down
10 changes: 5 additions & 5 deletions rollup/core/classes/RollupParentResetProcessor.cls
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ public without sharing class RollupParentResetProcessor extends RollupFullBatchR
if (parentItems.isEmpty()) {
return;
}
this.logger.log('resetting parent fields for: ' + parentItems.size() + ' items', System.LoggingLevel.DEBUG);
Map<String, Schema.SObjectField> parentFields = parentItems.get(0).getSObjectType().getDescribe().fields.getMap();
for (Rollup__mdt rollupMeta : this.rollupMetas) {
Schema.SObjectField parentFieldToken = parentFields.get(rollupMeta.RollupFieldOnLookupObject__c);
Expand All @@ -97,6 +96,10 @@ public without sharing class RollupParentResetProcessor extends RollupFullBatchR
continue;
}
Object defaultVal = this.getDefaultValue(rollupMeta);
this.logger.log(
'resetting parent fields to: ' + defaultVal + ' for field: ' + parentFieldToken + ' for ' + parentItems.size() + ' items',
System.LoggingLevel.DEBUG
);
for (SObject parentItem : parentItems) {
this.getDML().updateField(parentFieldToken, parentItem, defaultVal);
}
Expand All @@ -111,10 +114,7 @@ public without sharing class RollupParentResetProcessor extends RollupFullBatchR
}

protected override String startAsyncWork() {
if (this.rollupControl.ShouldSkipResettingParentFields__c) {
return this.getNoProcessId();
}
return System.enqueueJob(new QueueableResetProcessor(this));
return this.rollupControl.ShouldSkipResettingParentFields__c ? this.getNoProcessId() : System.enqueueJob(new QueueableResetProcessor(this));
}

protected override Map<String, String> customizeToStringEntries(Map<String, String> props) {
Expand Down

0 comments on commit 0a7781d

Please sign in to comment.