diff --git a/demo/testcode.html b/demo/testcode.html index 5df6f86..dd3dea4 100644 --- a/demo/testcode.html +++ b/demo/testcode.html @@ -23,13 +23,7 @@
- List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(),
- (SELECT Id FROM Contacts)
- FROM Warehouse__c.Contacts__r
- WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20
- AND Date__kav NOT IN LAST_N_DAYS:80
- ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
- LIMIT 10];
+
delete myAccount;
Account a;
@@ -42,30 +36,30 @@
List<Opportunity> opps = [SELECT Id FROM Opportunity WHERE Id NOT IN :newRecordsMap.keySet()];
- String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' +
- 'otherstreet, othercity, otherstate, otherpostalcode, othercountry, mailinglatitude, mailinglongitude, otherlatitude, otherlongitude ' +
- 'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
- String.escapeSingleQuotes(SortFullExp) +
- ' NULLS LAST LIMIT 1000';
- String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, '
+
+ String queryText = 'SELECT Id, Name, ';
+ acctid = System.currentPageReference().getParameters().get('Id');
+ System.assert(true);
+ System.requestVersion();
- -------NEW LANGUAGE----------
+-------NEW_CODEBLOCK----------
@IsTest
private without sharing class myTestClass {
myMap?.get('Id');
}
System.URL.getCurrentRequestUrl();
- System.getCurrentRequestUrl();
+ URL.getCurrentRequestUrl();
public List<SelectOption> recordTypes { get; private set; }
- -------NEW LANGUAGE----------
+-------NEW_CODEBLOCK----------
Database.insert(myAccounts, false, AccessLevel.USER_MODE);
delete myAccount;
delete [SELECT Id FROM Account];
+ myAcct = (Account)myacct;
public String myString { get; set; }
@@ -78,6 +72,19 @@
@throws DMLException
*/
+ List<SObject> mylist = [SELECT Name, StreetAddress__c, COUNT(),
+ (SELECT Id FROM Contacts)
+ FROM Warehouse__c.Contacts__r
+ WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20
+ AND Date__kav NOT IN LAST_N_DAYS:80
+ ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
+ LIMIT 10];
+
+ String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingcountry, ' +
+ 'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
+ String.escapeSingleQuotes(SortFullExp) +
+ ' NULLS LAST LIMIT 1000';
+
/**
* @author {@link [David Schach](https://github.com/dschach)}
* @group Visualforce
@@ -87,10 +94,6 @@
public enum Season {WINTER, SPRING, SUMMER, FALL}
- /**
- * Extension Constructor
- * @param stdController `ActionPlan__c` Standard Controller
- */
public ActionPlanDetailController(ApexPages.StandardController stdController, Integer x, Double y) {
Map<Id, Map<String, Wrapper>> renew = new Map<Id, Map<String, SObject>>();
if (!Test.isRunningTest() && false) {
@@ -100,11 +103,7 @@
actionPlan = (ActionPlan__c) stdController.getRecord();
truestory = req.setHeader('X-Password', '{!$Credential.Password}');
}
-
- /**
- * Action on page load to ensure custom setting is created
- * @return `PageReference` null (required for page actions method)
- */
+
public PageReference onLoad() {
ActionPlansUtilities.onPageLoad();
return null;
@@ -112,6 +111,7 @@
/**
* Deletes the current Action Plan loaded and redirects to the AP List
+ * @return `PageReference` null (required for page actions method)
* @return `PageReference` Page to go to after deleting `ActionPlan__c`
*/
public PageReference deletePlan() {
@@ -234,24 +234,6 @@
return false;
}
- /**
- * The label of the Action Plan's parent record SObject
- * @return `String` Label of the object related to this Action Plan
- */
- public String getRelatedObjectLabel() {
- String objLabel = '';
-
- for (String f : ActionPlansUtilities.getCustomRelationshipFields()) {
- if (actionPlan.get(f) != null) {
- Id objId = (Id) actionPlan.get(f);
- Schema.DescribeSObjectResult dsr = objId.getSObjectType().getDescribe();
- objLabel = dsr.getLabel();
- break;
- }
- }
- return objLabel;
- }
-
/**
* The name of the parent record - show a different field based on SObject Type
* @return `String` name of the object related to this Action Plan
@@ -286,21 +268,6 @@
}
}
- /**
- * Convert AP Task Record Type Id to Record Type Name
- * @return Record Type Name
- */
- public String getRecordTypeName() {
- String toReturn = '';
- if (ActionPlansUtilities.taskUsesRecordTypes) {
- Map<Id, Schema.RecordTypeInfo> rtMapById = Task.SObjectType.getDescribe().getRecordTypeInfosById();
- if (!rtMapById.isEmpty() && rtMapById.containsKey(actionPlan.TaskRecordTypeID__c)) {
- return rtMapById.get(actionPlan.TaskRecordTypeID__c).getName();
- }
- }
- return toReturn;
- }
-
/**
* If we have no share object, we don't need to show a Share button
* @author {@link [David Schach](https://github.com/dschach)}
@@ -309,16 +276,6 @@
public Boolean getCanShare() {
return ActionPlansUtilities.canShareRecord(actionPlan.Id, actionPlan.OwnerId);
}
-
- /**
- * Does the user have permission to transfer? We query `UserRecordAccess` to find out.
- * @author {@link [David Schach](https://github.com/dschach)}
- * @return `Boolean` yes/no
- */
- public Boolean getCanTransfer() {
- return ActionPlansUtilities.getCanTransfer(actionPlan.Id);
- }
- }
@SuppressWarnings('PMD.AvoidGlobalModifier')
/**
@@ -343,23 +300,10 @@
SELECT
Id,
Description__c,
- Name,
- OwnerId,
- SkipDay__c,
- SkipWeekends__c,
TaskRecordTypeID__c,
(
SELECT
Type__c,
- Name,
- User__c,
- User__r.Name,
- Id,
- DaysFromStart__c,
- Action_Plan_Template__c,
- TController__r.Subject__c,
- Minutes_Reminder__c,
- TaskIndex__c,
Action_Plan_Template__r.TaskRecordTypeID__c
FROM aptTasks__r
ORDER BY TaskIndex__c ASC
@@ -376,19 +320,12 @@
templateNameOrIdToTemplate.put(apt.Id, apt);
}
- Set<Id> relatedIDs = new Set<Id>();
-
for (CreateActionPlanRequest r : requests) {
relatedIDs.add(r.relatedRecordID);
}
Map<Id, ActionPlan__c> actionPlansToInsert = new Map<Id, ActionPlan__c>();
-
- if (actionPlansToInsert.isEmpty()) {
- return resultIDs;
- }
-
insert actionPlansToInsert.values();
Map<String, APTask__c> planTaskIndexToTask = new Map<String, APTask__c>();
@@ -400,36 +337,18 @@
ActionPlan__c ap = actionPlansToInsert.get(r.relatedRecordID);
- ActionPlanTemplate__c actionPlanTemplate = templateNameOrIdToTemplate.get(r.templateNameOrID);
-
for (APTemplateTask__c aptTask : actionPlanTemplate.aptTasks__r) {
APTask__c apTask = new APTask__c();
apTask.User__c = ActionPlansBuilderUtilities.getAPTaskTemplateUser(ap, relObjectOwners, aptTask.User__c);
- apTask.DaysFromStart__c = aptTask.DaysFromStart__c;
- apTask.Comments__c = aptTask.Comments__c;
- apTask.Minutes_Reminder__c = aptTask.Minutes_Reminder__c;
apTask.SendEmail__c = aptTask.SendEmail__c;
- apTask.Action_Plan__c = ap.Id;
-
apTask.Status__c = ActionPlansUtilities.getTaskRecordTypeStatusDefaultValues().get(ActionPlansUtilities.getDefaultTaskRecordTypeId());
- if (apTask.Dependent__c != null && apTask.Dependent__c != 'None') {
- apTask.ActivityDate__c = null;
+ // create due date, calculate the due date of the tasks for skip weekends feature
+ if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
+ apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
} else {
- apTask.Controller__c = null;
-
- //set dependency taskId to none if none was selected
- if (apTask.Dependent__c == null) {
- apTask.Dependent__c = 'None';
- }
-
- // create due date, calculate the due date of the tasks for skip weekends feature
- if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
- apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
- } else {
- apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
- }
+ apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
}
planTaskIndexToTask.put(ap.Id + '' + apTask.TaskIndex__c, apTask);
}
@@ -437,19 +356,6 @@
Database.insert(new planTaskIndexToTask.values());
- // Now we have to update with the controlling/dependent task IDs
-
- List<APTask__c> dependentTasksToUpdate = new List<APTask__c>();
-
- for (APTask__c apTask : planTaskIndexToTask.values()) {
- String actionPlanPlusIndex = apTask.Action_Plan__c + '' + apTask.Dependent__c;
-
- if (planTaskIndexToTask.containsKey(actionPlanPlusIndex)) {
- apTask.Controller__c = planTaskIndexToTask.get(actionPlanPlusIndex).Id;
- dependentTasksToUpdate.add(apTask);
- }
- }
-
Database.update(dependentTasksToUpdate);
List<Task> myTasksWithOutEmail = new List<Task>();
@@ -468,8 +374,6 @@
ActionPlan__c insertedAP;
// check if task exists already
Task t = new Task();
- t.Subject = apTask.Subject__c;
- t.Priority = apTask.Priority__c;
t.OwnerId = apTask.User__c;
t.TaskAPTask__c = apTask.Id;
@@ -497,35 +401,17 @@
String f = s;
if (
!f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Contact__c') &&
- !f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Lead__c') &&
insertedAP.get(f) != null
) {
t.WhatId = (Id) insertedAP.get(f);
break;
}
}
-
- if (t.Id == null) {
- t.Status = apTask.Status__c;
- }
- t.ActivityDate = apTask.ActivityDate__c;
-
- if (apTask.Dependent__c == 'None') {
- if (apTask.SendEmail__c == true) {
- myNewTasksWithEmail.add(t);
- } else {
- myTasksWithOutEmail.add(t);
- }
- }
}
Database.DMLOptions dmlo1 = new Database.DMLOptions();
dmlo1.EmailHeader.triggerUserEmail = true;
- if (myTasksWithOutEmail.size() > 0) {
- Database.insert(myTasksWithOutEmail, dmlo2);
- }
-
Set<Id> relObjectIDs = new Set<Id>();
for (ActionPlan__c ap : actionPlansToInsert.values()) {
relObjectIDs.add(ap.Id);
@@ -562,7 +448,7 @@
}
- -------NEW LANGUAGE----------
+-------NEW_CODEBLOCK----------
/**
* SHOULD BE RECOGNIZED AS JAVA
@@ -583,13 +469,11 @@
}
- -------NEW LANGUAGE----------
+-------NEW_CODEBLOCK----------
public without sharing class AccountSampleTriggerHandler extends Database.schedulable, TriggerHandler, Database.Batchable<SObject> {
private List<Account> newRecords;
- private List<Account> oldRecords;
private Map<Id, Account> newRecordsMap;
- private Map<Id, Account> oldRecordsMap;
switch on context {
when 'BEFORE_INSERT' {
@@ -611,12 +495,10 @@
*/
public AccountSampleTriggerHandler(CustomType a, String className) {
this.newRecords = (List<Account>) Trigger.new;
- this.oldRecords = (List<Account>) Trigger.old;
this.newRecordsMap = (Map<Id, Account>) Trigger.newMap;
- this.oldRecordsMap = (Map<Id, Account>) Trigger.oldMap;
}
- public override sobject beforeInsert() {
+ public override sobject beforeInsert(String a, APTask__c b, DateTime c) {
method1();
}
@@ -624,7 +506,7 @@
private void method1() {
for (Account a : newRecords) {
- a.Name = a.Name.toUpperCase();
+ a.Name = a.Name.toUpperCase(a, b, c);
a.Name = new FooBar();
}
}
@@ -649,9 +531,7 @@
}
}
-public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> {
-
-}
+public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable<SObject> {}
public virtual class Marker {
public virtual void write() {
@@ -713,7 +593,6 @@
upsert myRecord__c;
Database.upsert(myRecord__c, false, AccessLevel.USER_MODE);
}
-