[AAF-21] Initial code import
[aaf/authz.git] / authz-batch / src / main / java / com / att / authz / helpers / Approver.java
diff --git a/authz-batch/src/main/java/com/att/authz/helpers/Approver.java b/authz-batch/src/main/java/com/att/authz/helpers/Approver.java
new file mode 100644 (file)
index 0000000..0cac97b
--- /dev/null
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2016 AT&T Intellectual Property. All rights reserved.
+ *******************************************************************************/
+package com.att.authz.helpers;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.att.authz.actions.Message;
+import com.att.authz.org.Organization;
+
+public class Approver {
+       public String name;
+       public Organization org;
+       public Map<String, Integer> userRequests;
+       
+       public Approver(String approver, Organization org) {
+               this.name = approver;
+               this.org = org;
+               userRequests = new HashMap<String, Integer>();
+       }
+       
+       public void addRequest(String user) {
+               if (userRequests.get(user) == null) {
+                   userRequests.put(user, 1);
+               } else {
+                       Integer curCount = userRequests.remove(user);
+                       userRequests.put(user, curCount+1);
+               }
+       }
+       
+       /**
+        * @param sb
+        * @return
+        */
+       public void build(Message msg) {
+               msg.clear();
+               msg.line("You have %d total pending approvals from the following users:", userRequests.size());
+               for (Map.Entry<String, Integer> entry : userRequests.entrySet()) {
+                       msg.line("  %s (%d)",entry.getKey(),entry.getValue());
+               }
+       }
+
+}