-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Urgent order option does what it's supposed to now. Implemented admin…
… email, only for urgent orders Still need to do queued admin notifications and improve email quality
- Loading branch information
Showing
6 changed files
with
204 additions
and
16 deletions.
There are no files selected for viewing
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
package utilities; | ||
|
||
import java.util.Set; | ||
|
||
import entities.Ticket; | ||
import entities.User; | ||
|
||
public class AdminNotificationQueue extends Thread { | ||
/* | ||
This class functions similarly to the regular notification queue. | ||
There are enough differences in admin and client notifications, | ||
however, that it seemed like it deserved a seperate class. | ||
*/ | ||
private String instructions=""; | ||
private int threadWaitTime; | ||
private User admin; | ||
private Ticket[] tickets; | ||
|
||
// The tickets parameter will most likely be relevant only when using this class to | ||
// dispatch emails immediately with threads | ||
public AdminNotificationQueue(User admin, String initialization, Ticket[] tickets) | ||
{ | ||
instructions=initialization; | ||
this.admin=admin; | ||
this.tickets=tickets; | ||
} | ||
|
||
public void run() { | ||
try { | ||
String threadName = instructions+admin.getID(); | ||
Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); | ||
Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]); | ||
boolean match = false; | ||
System.out.println("Admin Notification Queue: Chacking active threads for match with "+threadName+"..."); | ||
for (int i=0; i<threadArray.length; i++) { | ||
if(threadArray[i].getName().equals(threadName)) { | ||
match=true; | ||
} | ||
} | ||
System.out.println(match ? " Match!" : " No match"); | ||
if(match){ | ||
System.out.println("Redundant Admin Notification Queue thread ("+threadName+") will terminate"); | ||
return; //should kill thread | ||
} | ||
else { | ||
Thread.currentThread().setName(threadName); | ||
// Finally do the thing we came for | ||
switch(instructions){ | ||
case "adminUrgentRequest": | ||
new Mail(admin).sendUrgentRequest(tickets); | ||
break; | ||
default: | ||
System.out.println("Admin notification queue could not recognize instructions"); | ||
} | ||
} | ||
} catch(Exception e) { | ||
e.printStackTrace(); | ||
} finally { | ||
|
||
} | ||
} | ||
} |
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