Skip to content

Commit 42e0404

Browse files
committed
progress
1 parent 7509d17 commit 42e0404

File tree

4 files changed

+473
-606
lines changed

4 files changed

+473
-606
lines changed

demo/testcode.html

Lines changed: 34 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,7 @@
2323

2424
<body class="hljs">
2525
<pre><code class="language-apex">
26-
List&lt;SObject&gt; mylist = [SELECT Name, StreetAddress__c, COUNT(),
27-
(SELECT Id FROM Contacts)
28-
FROM Warehouse__c.Contacts__r
29-
WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20
30-
AND Date__kav NOT IN LAST_N_DAYS:80
31-
ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
32-
LIMIT 10];
26+
3327

3428
delete myAccount;
3529
Account a;
@@ -42,30 +36,30 @@
4236

4337
List&lt;Opportunity&gt; opps = [SELECT Id FROM Opportunity WHERE Id NOT IN :newRecordsMap.keySet()];
4438

45-
String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, ' +
46-
'otherstreet, othercity, otherstate, otherpostalcode, othercountry, mailinglatitude, mailinglongitude, otherlatitude, otherlongitude ' +
47-
'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
48-
String.escapeSingleQuotes(SortFullExp) +
49-
' NULLS LAST LIMIT 1000';
50-
String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingstreet, mailingcity, mailingstate, mailingpostalcode, mailingcountry, '
39+
40+
String queryText = 'SELECT Id, Name, ';
41+
acctid = System.currentPageReference().getParameters().get('Id');
42+
System.assert(true);
43+
System.requestVersion();
5144
</code></pre>
52-
<p>-------NEW LANGUAGE----------</p>
45+
<p>-------NEW_CODEBLOCK----------</p>
5346
<pre><code class="language-apex">
5447
@IsTest
5548
private without sharing class myTestClass {
5649
myMap?.get('Id');
5750
}
5851
System.URL.getCurrentRequestUrl();
59-
System.getCurrentRequestUrl();
52+
URL.getCurrentRequestUrl();
6053

6154
public List&lt;SelectOption&gt; recordTypes { get; private set; }
6255
</code></pre>
63-
<p>-------NEW LANGUAGE----------</p>
56+
<p>-------NEW_CODEBLOCK----------</p>
6457
<pre><code class="language-apex">
6558

6659
Database.insert(myAccounts, false, AccessLevel.USER_MODE);
6760
delete myAccount;
6861
delete [SELECT Id FROM Account];
62+
myAcct = (Account)myacct;
6963

7064
public String myString { get; set; }
7165

@@ -78,6 +72,19 @@
7872
@throws DMLException
7973
*/
8074

75+
List&lt;SObject&gt; mylist = [SELECT Name, StreetAddress__c, COUNT(),
76+
(SELECT Id FROM Contacts)
77+
FROM Warehouse__c.Contacts__r
78+
WHERE DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi') < 20
79+
AND Date__kav NOT IN LAST_N_DAYS:80
80+
ORDER BY DISTANCE(Location__c, GEOLOCATION(37.775,-122.418), 'mi')
81+
LIMIT 10];
82+
83+
String queryText = 'SELECT Id, Name, AccountId, FirstName, LastName, mailingcountry, ' +
84+
'FROM Contact WHERE AccountId = :acctid ORDER BY ' +
85+
String.escapeSingleQuotes(SortFullExp) +
86+
' NULLS LAST LIMIT 1000';
87+
8188
/**
8289
* @author {@link [David Schach](https://github.com/dschach)}
8390
* @group Visualforce
@@ -87,10 +94,6 @@
8794

8895
public enum Season {WINTER, SPRING, SUMMER, FALL}
8996

90-
/**
91-
* Extension Constructor
92-
* @param stdController `ActionPlan__c` Standard Controller
93-
*/
9497
public ActionPlanDetailController(ApexPages.StandardController stdController, Integer x, Double y) {
9598
Map&ltId, Map&ltString, Wrapper&gt&gt renew = new Map&ltId, Map&ltString, SObject&gt&gt();
9699
if (!Test.isRunningTest() && false) {
@@ -100,18 +103,15 @@
100103
actionPlan = (ActionPlan__c) stdController.getRecord();
101104
truestory = req.setHeader('X-Password', '{!$Credential.Password}');
102105
}
103-
104-
/**
105-
* Action on page load to ensure custom setting is created
106-
* @return `PageReference` null (required for page actions method)
107-
*/
106+
108107
public PageReference onLoad() {
109108
ActionPlansUtilities.onPageLoad();
110109
return null;
111110
}
112111

113112
/**
114113
* Deletes the current Action Plan loaded and redirects to the AP List
114+
* @return `PageReference` null (required for page actions method)
115115
* @return `PageReference` Page to go to after deleting `ActionPlan__c`
116116
*/
117117
public PageReference deletePlan() {
@@ -234,24 +234,6 @@
234234
return false;
235235
}
236236

237-
/**
238-
* The label of the Action Plan's parent record SObject
239-
* @return `String` Label of the object related to this Action Plan
240-
*/
241-
public String getRelatedObjectLabel() {
242-
String objLabel = '';
243-
244-
for (String f : ActionPlansUtilities.getCustomRelationshipFields()) {
245-
if (actionPlan.get(f) != null) {
246-
Id objId = (Id) actionPlan.get(f);
247-
Schema.DescribeSObjectResult dsr = objId.getSObjectType().getDescribe();
248-
objLabel = dsr.getLabel();
249-
break;
250-
}
251-
}
252-
return objLabel;
253-
}
254-
255237
/**
256238
* The name of the parent record - show a different field based on SObject Type
257239
* @return `String` name of the object related to this Action Plan
@@ -286,21 +268,6 @@
286268
}
287269
}
288270

289-
/**
290-
* Convert AP Task Record Type Id to Record Type Name
291-
* @return Record Type Name
292-
*/
293-
public String getRecordTypeName() {
294-
String toReturn = '';
295-
if (ActionPlansUtilities.taskUsesRecordTypes) {
296-
Map&lt;Id, Schema.RecordTypeInfo&gt; rtMapById = Task.SObjectType.getDescribe().getRecordTypeInfosById();
297-
if (!rtMapById.isEmpty() && rtMapById.containsKey(actionPlan.TaskRecordTypeID__c)) {
298-
return rtMapById.get(actionPlan.TaskRecordTypeID__c).getName();
299-
}
300-
}
301-
return toReturn;
302-
}
303-
304271
/**
305272
* If we have no share object, we don't need to show a Share button
306273
* @author {@link [David Schach](https://github.com/dschach)}
@@ -309,16 +276,6 @@
309276
public Boolean getCanShare() {
310277
return ActionPlansUtilities.canShareRecord(actionPlan.Id, actionPlan.OwnerId);
311278
}
312-
313-
/**
314-
* Does the user have permission to transfer? We query `UserRecordAccess` to find out.
315-
* @author {@link [David Schach](https://github.com/dschach)}
316-
* @return `Boolean` yes/no
317-
*/
318-
public Boolean getCanTransfer() {
319-
return ActionPlansUtilities.getCanTransfer(actionPlan.Id);
320-
}
321-
}
322279

323280
@SuppressWarnings('PMD.AvoidGlobalModifier')
324281
/**
@@ -343,23 +300,10 @@
343300
SELECT
344301
Id,
345302
Description__c,
346-
Name,
347-
OwnerId,
348-
SkipDay__c,
349-
SkipWeekends__c,
350303
TaskRecordTypeID__c,
351304
(
352305
SELECT
353306
Type__c,
354-
Name,
355-
User__c,
356-
User__r.Name,
357-
Id,
358-
DaysFromStart__c,
359-
Action_Plan_Template__c,
360-
TController__r.Subject__c,
361-
Minutes_Reminder__c,
362-
TaskIndex__c,
363307
Action_Plan_Template__r.TaskRecordTypeID__c
364308
FROM aptTasks__r
365309
ORDER BY TaskIndex__c ASC
@@ -376,19 +320,12 @@
376320
templateNameOrIdToTemplate.put(apt.Id, apt);
377321
}
378322

379-
Set&lt;Id&gt; relatedIDs = new Set&lt;Id&gt;();
380-
381323
for (CreateActionPlanRequest r : requests) {
382324
relatedIDs.add(r.relatedRecordID);
383325
}
384326

385327
Map&lt;Id, ActionPlan__c&gt; actionPlansToInsert = new Map&lt;Id, ActionPlan__c&gt;();
386328

387-
388-
if (actionPlansToInsert.isEmpty()) {
389-
return resultIDs;
390-
}
391-
392329
insert actionPlansToInsert.values();
393330

394331
Map&lt;String, APTask__c&gt; planTaskIndexToTask = new Map&lt;String, APTask__c&gt;();
@@ -400,56 +337,25 @@
400337

401338
ActionPlan__c ap = actionPlansToInsert.get(r.relatedRecordID);
402339

403-
ActionPlanTemplate__c actionPlanTemplate = templateNameOrIdToTemplate.get(r.templateNameOrID);
404-
405340
for (APTemplateTask__c aptTask : actionPlanTemplate.aptTasks__r) {
406341
APTask__c apTask = new APTask__c();
407342
apTask.User__c = ActionPlansBuilderUtilities.getAPTaskTemplateUser(ap, relObjectOwners, aptTask.User__c);
408-
apTask.DaysFromStart__c = aptTask.DaysFromStart__c;
409-
apTask.Comments__c = aptTask.Comments__c;
410-
apTask.Minutes_Reminder__c = aptTask.Minutes_Reminder__c;
411343
apTask.SendEmail__c = aptTask.SendEmail__c;
412344

413-
apTask.Action_Plan__c = ap.Id;
414-
415345
apTask.Status__c = ActionPlansUtilities.getTaskRecordTypeStatusDefaultValues().get(ActionPlansUtilities.getDefaultTaskRecordTypeId());
416346

417-
if (apTask.Dependent__c != null && apTask.Dependent__c != 'None') {
418-
apTask.ActivityDate__c = null;
347+
// create due date, calculate the due date of the tasks for skip weekends feature
348+
if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
349+
apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
419350
} else {
420-
apTask.Controller__c = null;
421-
422-
//set dependency taskId to none if none was selected
423-
if (apTask.Dependent__c == null) {
424-
apTask.Dependent__c = 'None';
425-
}
426-
427-
// create due date, calculate the due date of the tasks for skip weekends feature
428-
if (ap.SkipWeekends__c == true && ap.SkipDay__c != null) {
429-
apTask.ActivityDate__c = ActionPlansUtilities.adjustTaskDueDate(ap.StartDate__c, apTask.DaysFromStart__c.intValue(), ap.SkipDay__c);
430-
} else {
431-
apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
432-
}
351+
apTask.ActivityDate__c = ap.StartDate__c.addDays(apTask.DaysFromStart__c.intValue());
433352
}
434353
planTaskIndexToTask.put(ap.Id + '' + apTask.TaskIndex__c, apTask);
435354
}
436355
}
437356

438357
Database.insert(new planTaskIndexToTask.values());
439358

440-
// Now we have to update with the controlling/dependent task IDs
441-
442-
List&lt;APTask__c&gt; dependentTasksToUpdate = new List&lt;APTask__c&gt;();
443-
444-
for (APTask__c apTask : planTaskIndexToTask.values()) {
445-
String actionPlanPlusIndex = apTask.Action_Plan__c + '' + apTask.Dependent__c;
446-
447-
if (planTaskIndexToTask.containsKey(actionPlanPlusIndex)) {
448-
apTask.Controller__c = planTaskIndexToTask.get(actionPlanPlusIndex).Id;
449-
dependentTasksToUpdate.add(apTask);
450-
}
451-
}
452-
453359
Database.update(dependentTasksToUpdate);
454360

455361
List&lt;Task&gt; myTasksWithOutEmail = new List&lt;Task&gt;();
@@ -468,8 +374,6 @@
468374
ActionPlan__c insertedAP;
469375
// check if task exists already
470376
Task t = new Task();
471-
t.Subject = apTask.Subject__c;
472-
t.Priority = apTask.Priority__c;
473377
t.OwnerId = apTask.User__c;
474378
t.TaskAPTask__c = apTask.Id;
475379

@@ -497,35 +401,17 @@
497401
String f = s;
498402
if (
499403
!f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Contact__c') &&
500-
!f.equalsIgnoreCase(ActionPlansUtilities.namespacePrefix + 'Lead__c') &&
501404
insertedAP.get(f) != null
502405
) {
503406
t.WhatId = (Id) insertedAP.get(f);
504407
break;
505408
}
506409
}
507-
508-
if (t.Id == null) {
509-
t.Status = apTask.Status__c;
510-
}
511-
t.ActivityDate = apTask.ActivityDate__c;
512-
513-
if (apTask.Dependent__c == 'None') {
514-
if (apTask.SendEmail__c == true) {
515-
myNewTasksWithEmail.add(t);
516-
} else {
517-
myTasksWithOutEmail.add(t);
518-
}
519-
}
520410
}
521411

522412
Database.DMLOptions dmlo1 = new Database.DMLOptions();
523413
dmlo1.EmailHeader.triggerUserEmail = true;
524414

525-
if (myTasksWithOutEmail.size() &gt; 0) {
526-
Database.insert(myTasksWithOutEmail, dmlo2);
527-
}
528-
529415
Set&lt;Id&gt; relObjectIDs = new Set&lt;Id&gt;();
530416
for (ActionPlan__c ap : actionPlansToInsert.values()) {
531417
relObjectIDs.add(ap.Id);
@@ -562,7 +448,7 @@
562448

563449
}
564450
</code></pre>
565-
<p>-------NEW LANGUAGE----------</p>
451+
<p>-------NEW_CODEBLOCK----------</p>
566452
<pre><code class="language-apex">
567453
/**
568454
* SHOULD BE RECOGNIZED AS JAVA
@@ -583,13 +469,11 @@
583469
}
584470

585471
</code></pre>
586-
<p>-------NEW LANGUAGE----------</p>
472+
<p>-------NEW_CODEBLOCK----------</p>
587473
<pre><code class="">
588474
public without sharing class AccountSampleTriggerHandler extends Database.schedulable, TriggerHandler, Database.Batchable&lt;SObject&gt; {
589475
private List&lt;Account&gt; newRecords;
590-
private List&lt;Account&gt; oldRecords;
591476
private Map&lt;Id, Account&gt; newRecordsMap;
592-
private Map&lt;Id, Account&gt; oldRecordsMap;
593477

594478
switch on context {
595479
when 'BEFORE_INSERT' {
@@ -611,20 +495,18 @@
611495
*/
612496
public AccountSampleTriggerHandler(CustomType a, String className) {
613497
this.newRecords = (List&lt;Account&gt;) Trigger.new;
614-
this.oldRecords = (List&lt;Account&gt;) Trigger.old;
615498
this.newRecordsMap = (Map&lt;Id, Account&gt;) Trigger.newMap;
616-
this.oldRecordsMap = (Map&lt;Id, Account&gt;) Trigger.oldMap;
617499
}
618500

619-
public override sobject beforeInsert() {
501+
public override sobject beforeInsert(String a, APTask__c b, DateTime c) {
620502
method1();
621503
}
622504

623505
//public override void afterUpdate(){}
624506

625507
private void method1() {
626508
for (Account a : newRecords) {
627-
a.Name = a.Name.toUpperCase();
509+
a.Name = a.Name.toUpperCase(a, b, c);
628510
a.Name = new FooBar();
629511
}
630512
}
@@ -649,9 +531,7 @@
649531
}
650532
}
651533

652-
public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable&lt;SObject&gt; {
653-
654-
}
534+
public without sharing class AccountSampleTriggerHandler extends Database.schedulable, Batchable&lt;SObject&gt; {}
655535

656536
public virtual class Marker {
657537
public virtual void write() {
@@ -713,7 +593,6 @@
713593
upsert myRecord__c;
714594
Database.upsert(myRecord__c, false, AccessLevel.USER_MODE);
715595
}
716-
717596
</code></pre>
718597
</body>
719598
</html>

0 commit comments

Comments
 (0)