Skip to content

Commit 2473e4e

Browse files
AppStaging
1 parent efdce08 commit 2473e4e

File tree

106 files changed

+13757
-6
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+13757
-6
lines changed

AppStaging/config/.apex_file_properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -5307,7 +5307,7 @@
53075307
"id": "01pL0000000DVpaIAG",
53085308
"lastModifiedById": "005E0000000Z5aRIAS",
53095309
"lastModifiedByName": "Melissa Prcic",
5310-
"lastModifiedDate": "2013-11-12 08:56:21",
5310+
"lastModifiedDate": "2013-11-12 12:22:28",
53115311
"manageableState": "unmanaged",
53125312
"symbolTable": {
53135313
"constructors": [
+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
// EXAMPLE
2+
/*
3+
4+
ActivityLogEntry a = new ActivityLogEntry ();
5+
a.contact = '003L000000FsQSz';
6+
a.opportunity = '006L0000003fNkz';
7+
a.entry_type = 'TEAM-START';
8+
a.action = 'Start Team';
9+
a.outcome = 'Complete';
10+
a.chatter_post = true;
11+
a.create ();
12+
13+
14+
*/
15+
// END EXAMPLE
16+
17+
// Activity Log must be consistent - enforced via this class
18+
19+
public with sharing class ActivityLogEntry {
20+
21+
// TODO - Add Custom Setting to supress all Chatter posts - this will be used for conversion
22+
public ID account_id;
23+
public ID campaign_id;
24+
public ID contact_id;
25+
public ID related_contact_1;
26+
public ID related_contact_2;
27+
28+
// --- new to be implemented
29+
public ID organizer_id;
30+
public ID leader_id;
31+
public ID team_id;
32+
// -- end new
33+
34+
public ID opportunity_id;
35+
public string entry_type;
36+
public string action;
37+
public string outcome;
38+
public boolean chatter_postable;
39+
public datetime entry_date_time;
40+
41+
private List < String > valid_log_entry_types;
42+
private ID activity_log_entry_id;
43+
44+
// init routine - required by constructors
45+
private void init () {
46+
valid_log_entry_types = new List <string> ( );
47+
48+
// ORGANIZING MODEL ACTIVITIES
49+
// TODO Make this custom setting with Type Key and Chatter Postability
50+
51+
valid_log_entry_types.add ( 'MEMBER-JOIN' ); // New Membership ( Team, Leader, Organizer, Contact (member), Membership Gift )
52+
valid_log_entry_types.add ( 'MEMBER-RENEW' ); // Membership Renewal ( Team, Leader, Organizer, Contact (member), Membership Gift )
53+
valid_log_entry_types.add ( 'MEMBER-LAPSE' ); // Membership Lapsed ( Team, Leader, Organizer, Contact (member) )
54+
valid_log_entry_types.add ( 'MEMBER-DROP' ); // Membership Dropped ( Team, Leader, Organizer, Contact (member) )
55+
56+
//building what is essentially a data warehouse file here is starting to feel super heavy and I'm not convinced that it's necessary. Are we really going to go to this as historical data
57+
//when we acquire a BI/Warehouse tool? will it be useable??
58+
59+
valid_log_entry_types.add ( 'ORG-AFF-START' ); // Affiliation Started ( Team, Leader, Organizer, Contact (member) )
60+
valid_log_entry_types.add ( 'ORG-AFF-END' ); // Affiliation Started ( Team, Leader, Organizer, Contact (member) )
61+
62+
// default fields
63+
64+
if ( chatter_postable == null ) {
65+
chatter_postable = false;
66+
}
67+
68+
activity_log_entry_id = null;
69+
}
70+
71+
// basic constructor
72+
public ActivityLogEntry () {
73+
init();
74+
}
75+
76+
// overloaded constructor with quick setup
77+
public ActivityLogEntry ( ID account, ID campaign, ID contact, ID related_contact_1, ID related_contact_2, ID organizer, ID leader, ID team, ID opportunity, String entry_type, String action, String outcome, Boolean post_chatter ) {
78+
this.account_id = account;
79+
this.campaign_id = campaign;
80+
this.contact_id = contact;
81+
this.related_contact_1 = related_contact_1;
82+
this.related_contact_2 = related_contact_2;
83+
this.organizer_id= organizer;
84+
this.leader_id= leader;
85+
this.team_id= team;
86+
this.opportunity_id = opportunity;
87+
this.entry_type = entry_type;
88+
this.action = action;
89+
this.outcome = outcome;
90+
this.chatter_postable = post_chatter;
91+
init();
92+
}
93+
94+
//overloaded constructor for Membership Activities
95+
public ActivityLogEntry (ID contact, ID organizer, ID leader, ID team, ID opportunity, String entry_type, String action, Boolean post_chatter) {
96+
this.contact_id = contact;
97+
this.organizer_id= organizer;
98+
this.leader_id= leader;
99+
this.team_id= team;
100+
this.opportunity_id = opportunity;
101+
this.entry_type = entry_type;
102+
this.action = action;
103+
this.chatter_postable = post_chatter;
104+
init();
105+
}
106+
107+
108+
// TODO create a bulk version of this (see Bulk cases)
109+
// Note: Chatter component relies on the fact that the actual User is initiating this transaction
110+
111+
public boolean create ( ) {
112+
113+
// check for type exceptions ??what does that mean
114+
system.debug('***************************************At least were in the Create Method');
115+
116+
// create the activity log entry
117+
Activity_Log__c al = new Activity_Log__c ();
118+
al.Account__c = account_id;
119+
al.Campaign__c = campaign_id;
120+
al.Contact__c = contact_id;
121+
al.Leader__c = (leader_id!='' ? leader_id : null);
122+
al.Organizer__c = (organizer_id!='' ? organizer_id : null);
123+
al.Team__c = (team_id!='' ? team_id : null);
124+
al.Related_Contact_1__c = related_contact_1;
125+
al.Related_Contact_2__c = related_contact_2;
126+
127+
al.Opportunity__c = (opportunity_id!='' ? opportunity_id : null);
128+
al.Type__c = entry_type;
129+
al.Action__c = action;
130+
al.Outcome__c = outcome;
131+
al.User__c = UserInfo.getUserId();
132+
133+
// insert the new record
134+
try {
135+
insert al;
136+
} catch (exception e) {
137+
system.debug('***************************************Entered the catch');
138+
throw new StandException(119);
139+
}
140+
141+
activity_log_entry_id = al.Id;
142+
143+
// whoa - chatter post
144+
// note: no account, campaign supported
145+
if ( chatter_postable ) {
146+
chatterHandler ( );
147+
148+
}
149+
150+
return true;
151+
}
152+
153+
private boolean chatterHandler ( ) {
154+
155+
string chatter_body;
156+
string chatter_taglist;
157+
string baseUrl = string.ValueOf(URL.getSalesforceBaseURL().toExternalForm());
158+
Account team = ([SELECT Name FROM Account WHERE Id =:this.team_id]);
159+
string team_name = team.name;
160+
161+
if ( this.entry_type == 'MEMBER-JOIN' ) {
162+
chatter_body = 'New Member on the ' + team_name +'!';
163+
chatter_taglist = '#' + team_name.replaceAll('\\s+', '') + ' #' + this.action.replaceAll('\\s+', '');
164+
return createChatterPost ( this.contact_id , chatter_body, chatter_taglist, baseUrl +'/' + this.activity_log_entry_id , 'view log entry' );
165+
} else if (this.entry_type == 'MEMBER-RENEW') {
166+
chatter_body = 'Renewed Member on the ' + team_name +'!';
167+
chatter_taglist = '#' + team_name.replaceAll('\\s+', '') + ' #' + this.action.replaceAll('\\s+', '');
168+
return createChatterPost ( this.contact_id , chatter_body, chatter_taglist, baseUrl +'/' + this.activity_log_entry_id , 'view log entry' );
169+
}
170+
171+
return false;
172+
}
173+
174+
private boolean createChatterPost ( ID obj_id, string body, string tag_list, string link_url, string link_title ) {
175+
176+
FeedItem post = new FeedItem();
177+
post.ParentId = obj_id;
178+
post.Body = body + '\r\n\r\n' + '{ ' + tag_list + ' }';
179+
post.LinkUrl = link_url;
180+
post.Title = link_title;
181+
182+
insert post;
183+
184+
return true;
185+
186+
}
187+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>24.0</apiVersion>
4+
<status>Active</status>
5+
</ApexClass>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
global class AffiliationUpdates implements Schedulable{
2+
3+
// debug console
4+
//affiliationupdates a = new affiliationupdates();
5+
//string sch = '0 0 2-3 * 1-12 ? *';
6+
// seconds, minutes, hours, day_of_month, Month, day_of_week, optional year
7+
//system.schedule('Affiliation Updates 1',sch,a);
8+
9+
10+
// below is the method used when it is scheduled and needs to execute a Schedulable class
11+
global void Execute(SchedulableContext SC) {
12+
UpdateAffiliations();
13+
}
14+
15+
// method to set Affiliations as Inactive for Contacts with Dropped memberships
16+
global void UpdateAffiliations() {
17+
String Melissa = 'is really great!';
18+
19+
// get list of Dropped Memberships
20+
List <membership__c> mList = new List<membership__c>([SELECT ID, Contact__c FROM membership__c WHERE Status2__c = 'Dropped']);
21+
22+
// list of Contacts with Dropped Memberships
23+
List <Id> cList = new List<Id>();
24+
for (membership__c m : mList) {
25+
cList.add(m.Contact__c);
26+
}
27+
28+
// list of Affiliations with Dropped Memberships
29+
List <npe5__Affiliation__c> aList = new List<npe5__Affiliation__c>([SELECT ID, npe5__contact__c FROM npe5__Affiliation__c WHERE npe5__Status__c = 'Active' AND (Affiliation__c = 'Team Leader' OR Affiliation__c = 'Team Member') AND npe5__contact__c IN : cList LIMIT 50]);
30+
31+
// run through all Affiliations and set End Date and Status
32+
for ( npe5__Affiliation__c a : aList ) {
33+
a.npe5__EndDate__c = System.today();
34+
a.npe5__Status__c = 'Inactive';
35+
}
36+
37+
// update the list of Affiliations
38+
update aList;
39+
}
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<ApexClass xmlns="http://soap.sforce.com/2006/04/metadata">
3+
<apiVersion>23.0</apiVersion>
4+
<packageVersions>
5+
<majorNumber>1</majorNumber>
6+
<minorNumber>55</minorNumber>
7+
<namespace>npe5</namespace>
8+
</packageVersions>
9+
<status>Active</status>
10+
</ApexClass>

0 commit comments

Comments
 (0)