implemented toApproval flag

main
Said Gedik 2023-05-25 11:54:57 +02:00
parent 48f94b3353
commit 6e34a72a8b
2 changed files with 22 additions and 8 deletions

View File

@ -141,15 +141,17 @@ public class Change {
.filter(peopleFullName::equals) .filter(peopleFullName::equals)
.isPresent()); .isPresent());
try { try {
var currentState = getValue(entry, "State").getIntValue();
var inApproval = inApprovalList(api.getUser(), getValueStringByID(entry, "ChangeNr")); var inApproval = inApprovalList(api.getUser(), getValueStringByID(entry, "ChangeNr"));
var approveAndRejectFlag = approveAndReject(inApproval, getValue(entry, "State").getIntValue()); var approve_reject = flagApproval(inApproval, currentState);
change.setFlagApprove(approveAndRejectFlag); change.setFlagApprove(approve_reject);
change.setFlagReject(approveAndRejectFlag); change.setFlagReject(approve_reject);
var cancelFlag = cancel(getValueStringByID(entry, "SupportGroupId"), getValue(entry, "State").getIntValue()); var cancel = flagCancel(getValueStringByID(entry, "SupportGroupId"), currentState);
change.setFlagCancel(cancelFlag); change.setFlagCancel(cancel);
change.setFlagToApproval(flagToApproval(currentState));
} catch (ARException e) { } catch (ARException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -171,12 +173,12 @@ public class Change {
return approvers != null ? approvers.contains(user) : false; return approvers != null ? approvers.contains(user) : false;
} }
public boolean approveAndReject(boolean approval, int status) { public boolean flagApproval(boolean approval, int status) {
boolean approvableStatus = (status == 1 || status == 10); boolean approvableStatus = (status == 1 || status == 10);
return approval && approvableStatus; return approval && approvableStatus;
} }
public boolean cancel(String supportGroupId, int status) throws ARException { public boolean flagCancel(String supportGroupId, int status) throws ARException {
var queryRoles = new Query.QueryBuilder("CTM:SupportGroupFuncRoleLookUp").addFieldId("Role", 1000000014).build(); var queryRoles = new Query.QueryBuilder("CTM:SupportGroupFuncRoleLookUp").addFieldId("Role", 1000000014).build();
var role = api.queryFieldsById("\'Support Group ID\' = \"" + supportGroupId + "\"", queryRoles.getFieldIds(), queryRoles.getFormName(), null, 0, 0) var role = api.queryFieldsById("\'Support Group ID\' = \"" + supportGroupId + "\"", queryRoles.getFieldIds(), queryRoles.getFormName(), null, 0, 0)
.get(0).get(queryRoles.getFieldId("Role")).toString(); .get(0).get(queryRoles.getFieldId("Role")).toString();
@ -186,6 +188,9 @@ public class Change {
return approvableStatus && isChangeManager; return approvableStatus && isChangeManager;
} }
public boolean flagToApproval(int status) {
return status == 0;
}
/** /**
* Returns the {@link Value} of an entry based on the provided description. * Returns the {@link Value} of an entry based on the provided description.

View File

@ -31,6 +31,7 @@ public class ChangeItem {
private Date D2; private Date D2;
private Date D3; private Date D3;
private Date D4; private Date D4;
private boolean flagToApproval;
private boolean flagApprove; private boolean flagApprove;
private boolean flagReject; private boolean flagReject;
private boolean flagCancel; private boolean flagCancel;
@ -159,6 +160,14 @@ public class ChangeItem {
this.changeImplementerPersonId = changeImplementerPersonId; this.changeImplementerPersonId = changeImplementerPersonId;
} }
public boolean getFlagToApproval() {
return this.flagToApproval;
}
public void setFlagToApproval(boolean flagToApproval) {
this.flagToApproval = flagToApproval;
}
public boolean getFlagApprove() { public boolean getFlagApprove() {
return this.flagApprove; return this.flagApprove;
} }