private static final String[] headers = new String[] {"Identity","Request","Approve","Deny"};
private Slot sUser;
private Slot sAsDelegate;
- private Slot sAsUser;
+ private Slot sAsUser;
public Model(AuthzEnv env) {
sUser = env.slot(NAME+".user");
final String asDelegate = trans.get(sAsDelegate, null);
final String approver;
if(asDelegate==null) {
- approver = trans.get(sAsUser,trans.user());
+ approver = trans.get(sAsUser,trans.user());
} else {
- approver = asDelegate;
+ approver = asDelegate;
}
ArrayList<AbsCell[]> rv = new ArrayList<>();
Identity iapprover = trans.org().getIdentity(trans,currApproverList.get(0).getApprover());
if(iapprover==null) {
- rv.add(new AbsCell[] {
- new TextCell(currApproverList.get(0).getApprover() + " is not part of Organization",
+ rv.add(new AbsCell[] {
+ new TextCell(currApproverList.get(0).getApprover() + " is not part of Organization",
new String[] {"colspan=4", "class=head"})
- });
+ });
} else {
- if (!iapprover.fullID().equals(trans.user())) {
-
- AbsCell[] approverHeader;
- // if (domainOfUser.equals(domainOfApprover)) {
- // approverHeader = new AbsCell[] {
- // new TextAndRefCell("Approvals Delegated to Me by ", currApproverFull,
- // TODO_ILM_INFO + currApproverShort,
- // true,
- // new String[] {"colspan=4", "class=head"})
- // };
- // } else {
- approverHeader = new AbsCell[] {
- new TextCell("Approvals Delegated to Me by " + iapprover.fullName()
- + '(' + iapprover.id() + ')',
- new String[] {"colspan=4", "class=head"})
- };
- // }
- rv.add(approverHeader);
- }
-
- // Sort by User Requesting
- Collections.sort(currApproverList, new Comparator<Approval>() {
- @Override
- public int compare(Approval a1, Approval a2) {
- return a1.getUser().compareTo(a2.getUser());
- }
- });
-
- String prevUser = null;
- boolean userOK=true;
- for (Approval appr : currApproverList) {
- if (++line<MAX_LINE) { // limit number displayed at one time.
- AbsCell userCell;
- String user = appr.getUser();
-
- if (user.equals(prevUser)) {
- userCell = AbsCell.Null;
- } else if (user.endsWith(trans.org().getRealm())){
- userOK=true;
- String title;
- Organization org = OrganizationFactory.obtain(trans.env(), user);
- if (org==null) {
- title="";
- userCell = new TextCell(user);
- } else {
- Identity au = org.getIdentity(trans, user);
- if (au!=null) {
- if(au.isPerson()) {
- userCell = new TextToolTipCell(au.fullName(),"Identity: " + au.id());
- } else {
- Identity managedBy = au.responsibleTo();
- if (managedBy==null) {
- title ="Identity: " + au.type();
- } else {
- title="Sponsor: " + managedBy.fullName();
- }
- userCell = new TextToolTipCell(au.fullID(),title);
- }
- } else {
- userOK=false;
- title="Not a User at " + org.getName();
- userCell = new TextToolTipCell(user,title);
- }
- }
- // userCell = new RefCell(prevUser,
- // TODO_ILM_INFO+user.substring(0, user.length()-domainOfApprover.length()),
- // true,
- // title);
-
- } else {
- userCell = new TextCell(prevUser==null?user:prevUser);
- }
+ if (!iapprover.fullID().equals(trans.user())) {
+
+ AbsCell[] approverHeader;
+ // if (domainOfUser.equals(domainOfApprover)) {
+ // approverHeader = new AbsCell[] {
+ // new TextAndRefCell("Approvals Delegated to Me by ", currApproverFull,
+ // TODO_ILM_INFO + currApproverShort,
+ // true,
+ // new String[] {"colspan=4", "class=head"})
+ // };
+ // } else {
+ approverHeader = new AbsCell[] {
+ new TextCell("Approvals Delegated to Me by " + iapprover.fullName()
+ + '(' + iapprover.id() + ')',
+ new String[] {"colspan=4", "class=head"})
+ };
+ // }
+ rv.add(approverHeader);
+ }
+
+ // Sort by User Requesting
+ Collections.sort(currApproverList, new Comparator<Approval>() {
+ @Override
+ public int compare(Approval a1, Approval a2) {
+ return a1.getUser().compareTo(a2.getUser());
+ }
+ });
+
+ String prevUser = null;
+ boolean userOK=true;
+ for (Approval appr : currApproverList) {
+ if (++line<MAX_LINE) { // limit number displayed at one time.
+ AbsCell userCell;
+ String user = appr.getUser();
+
+ if (user.equals(prevUser)) {
+ userCell = AbsCell.Null;
+ } else if (user.endsWith(trans.org().getRealm())){
+ userOK=true;
+ String title;
+ Organization org = OrganizationFactory.obtain(trans.env(), user);
+ if (org==null) {
+ title="";
+ userCell = new TextCell(user);
+ } else {
+ Identity au = org.getIdentity(trans, user);
+ if (au!=null) {
+ if(au.isPerson()) {
+ userCell = new TextToolTipCell(au.fullName(),"Identity: " + au.id());
+ } else {
+ Identity managedBy = au.responsibleTo();
+ if (managedBy==null) {
+ title ="Identity: " + au.type();
+ } else {
+ title="Sponsor: " + managedBy.fullName();
+ }
+ userCell = new TextToolTipCell(au.fullID(),title);
+ }
+ } else {
+ userOK=false;
+ title="Not a User at " + org.getName();
+ userCell = new TextToolTipCell(user,title);
+ }
+ }
+ // userCell = new RefCell(prevUser,
+ // TODO_ILM_INFO+user.substring(0, user.length()-domainOfApprover.length()),
+ // true,
+ // title);
+
+ } else {
+ userCell = new TextCell(user);
+ }
+ AbsCell[] sa = new AbsCell[] {
+ userCell,
+ new TextCell(appr.getMemo()),
+ userOK?new RadioCell("line."+ line,"approve", "approved|"+appr.getTicket()):new TextCell(""),
+ new RadioCell("line."+ line,"deny", "denied|"+appr.getTicket())
+ };
+ rv.add(sa);
prevUser=user;
- AbsCell[] sa = new AbsCell[] {
- userCell,
- new TextCell(appr.getMemo()),
- userOK?new RadioCell("line."+ line,"approve", "approved|"+appr.getTicket()):new TextCell(""),
- new RadioCell("line."+ line,"deny", "denied|"+appr.getTicket())
- };
- rv.add(sa);
- } else {
- ++numLeft;
- }
- }
- }
- if (numLeft>0) {
- msg = "After these, there will be " + numLeft + " approvals left to process";
- }
- if (rv.isEmpty()) {
- if (numLeft>0) {
- msg = "No Approvals to process at this time for user " + userParam +". You have "
- + numLeft + " other approvals to process.";
- } else {
- msg = "No Approvals to process at this time";
- }
- }
+ } else {
+ ++numLeft;
+ }
+ }
+ }
+ if (numLeft>0) {
+ msg = "After these, there will be " + numLeft + " approvals left to process";
+ }
+ if (rv.isEmpty()) {
+ if (numLeft>0) {
+ msg = "No Approvals to process at this time for user " + userParam +". You have "
+ + numLeft + " other approvals to process.";
+ } else {
+ msg = "No Approvals to process at this time";
+ }
+ }
}
} catch (Exception e) {
trans.error().log(e);