This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<apex:page controller="StatsDemo" docType="html-5.0" lightningStylesheets="true"> | |
<apex:includeScript value="{!$Resource.jStat}"/> | |
<h1>Calculate</h1> | |
<apex:form> | |
<apex:pageBlock> | |
<apex:pageBlockSection> | |
<apex:input value="{!probability}" type="number" label="Probability" html-step="any" required="true"/><br></br> | |
<apex:input value="{!alpha}" type="number" label="Alpha" html-step="any" required="true"/><br></br> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public inherited sharing class RecipeController { | |
@AuraEnabled | |
public static List < Ingredient__c > generateGroceryList(Id recipeId){ | |
//load the ingredients and return them | |
} | |
@AuraEnabled | |
public static void addIngredient(String ingredientName, Integer measurementAmount, String measurementType, ID recipeId){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger RecipeTrigger on Recipe__c (before insert, after insert, before update, after update, before delete, after delete) { | |
if (trigger.isBefore && trigger.isInsert) { | |
RecipeUtil.handleBeforeInsert(trigger.new); | |
} | |
if (trigger.isAfter && trigger.isInsert) { | |
RecipeUtil.handleAfterInsert(trigger.new); | |
} | |
if (trigger.isBefore && trigger.isUpdate) { | |
RecipeUtil.handleBeforeUpdate(trigger.new, trigger.oldMap); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class RecipeUtil { | |
public static void handleBeforeInsert(List < Recipe__c > newRecipes) { | |
for (Recipe__c rec : newRecipes) { | |
if (rec.Name==null || rec.Active_Time__c==null || rec.Description__c==null || rec.Active_Time_Units__c==null || rec.Servings__c==null) { | |
rec.Draft__c = true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* A helper class for our Recipe Management App. This class contains static methods | |
that provide fuctionality related to recipes | |
*/ | |
public with sharing class RecipeHelper { | |
// takes ingredient details and creates a corresponding SOBject record with the provided recipe ID as the parent | |
public static void addIngredient (String ingredientName, Integer measurementAmount, String measurementType, ID recipeId) { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class RecipeUtil { | |
//Variables to store Trigger.oldMap & Trigger.newMap | |
List < Recipe__c > newRecipesList; | |
Map<ID, Recipe__c> newRecipesMap; | |
Map<ID, Recipe__c> oldRecipesMap; | |
//Constructor that takes in the map of old recipe records and new/updated recipe records and assigns them to class variables | |
public RecipeUtil(List < Recipe__c > newRecipes, Map<ID, Recipe__c> newTriggerRecipes, Map<ID, Recipe__c> oldTriggerRecipes) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger RecipeTrigger on Recipe__c (before insert, after insert, before update, after update) { | |
RecipeUtil rUtil = new RecipeUtil(trigger.new, trigger.newMap, trigger.oldMap); | |
if (Trigger.isBefore) { | |
if (Trigger.isInsert) { | |
rUtil.onBeforeInsert(); | |
} else if (Trigger.isUpdate) { | |
rUtil.onBeforeUpdate(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public with sharing class Recipe { | |
//class variables defined here | |
public Decimal activeMinutes; | |
public Double activeTime; | |
public String activeTimeUnits; | |
public String description; | |
public String name; | |
public String season; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A library of generic helper functions | |
global without sharing class HelperFunctions { | |
global static List<SObject> subsetSobjects (List<SObject> objectList, Integer startIndex, Integer count, Boolean precise) { | |
//given a list of sObjects a starting index and a count, returns the requested subset. | |
//If precise is true and the list is not long enough to provide the full requested subset, throws an error. If set to false, returns what is available | |
//The index must be less than the count | |
//validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Used to queue the updating of a list of SObjects | |
//Usage: | |
//ID jobID = System.enqueueJob(new QueueableObjectUpdater(<SOBJECTSTOUPDATE>)); | |
public class QueueableObjectUpdater implements Queueable { | |
public List < SObject > objectsToUpdate; | |
public List < SObject > objectsToQueueForUpdate; |
NewerOlder