From 94c88cbf6442197c58ea1551600bf7d72f4b05cf Mon Sep 17 00:00:00 2001 From: Said Gedik Date: Tue, 11 Jun 2024 15:23:59 +0200 Subject: [PATCH] bug fixes --- .../com/nttdata/calender/changes/Change.java | 156 +++--------------- 1 file changed, 21 insertions(+), 135 deletions(-) diff --git a/backend/src/main/java/com/nttdata/calender/changes/Change.java b/backend/src/main/java/com/nttdata/calender/changes/Change.java index ee6831d..1500fc0 100644 --- a/backend/src/main/java/com/nttdata/calender/changes/Change.java +++ b/backend/src/main/java/com/nttdata/calender/changes/Change.java @@ -101,6 +101,7 @@ public class Change { log.initLog("getChanges", api.getUser()); // Logging + System.out.println(qualifier); var entries = api.queryFieldsById(qualifier, this.queryChange.getFieldIds(), this.queryChange.getFormName(), sort, request.getSliceStart(), @@ -112,43 +113,36 @@ public class Change { var entriesSize = api.getFormSize(qualifier, this.queryChange.getFormName()); var changes = new ArrayList(); - System.out.println("###ABGERUFEN"); + for (var entry : entries) { var change = new ChangeItem(entry.getEntryId()); boolean approval = getValueStringByID(entry, "Approval").equals("0") ? true : false; - // if (approval) { - // var queryApproval = new Query.QueryBuilder("CHG:ChangeAPDetailSignature") - // .addFieldId("Approvers", 13207).build(); + if (approval) { + var queryApproval = new Query.QueryBuilder("CHG:ChangeAPDetailSignature") + .addFieldId("Approvers", 13207).build(); - // String qual = "(\'1000000182\' = \"" + getValueStringByID(entry, "ChangeNr") - // + "\") AND (\'10000\' = \"" - // + getValueStringByID(entry, "ApprovalProcessName") - // + "\") AND (\'13207\' LIKE \"%" + api.getUser() + "%\")"; + String qual = "(\'1000000182\' = \"" + getValueStringByID(entry, "ChangeNr") + + "\") AND (\'10000\' = \"" + + getValueStringByID(entry, "ApprovalProcessName") + + "\") AND (\'13207\' LIKE \"%" + api.getUser() + "%\")"; - // var queryApprovalProcessName = api.queryFieldsById(qual, - // queryApproval.getFieldIds(), queryApproval.getFormName(), sort, 0, 0); + var queryApprovalProcessName = api.queryFieldsById(qual, + queryApproval.getFieldIds(), queryApproval.getFormName(), sort, 0, 0); - // log.qualifierLog(queryApproval.getFormName(), qual); + log.qualifierLog(queryApproval.getFormName(), qual); - // if (!queryApprovalProcessName.isEmpty() && queryApprovalProcessName != null - // && queryApprovalProcessName.size() > 0) - // change.setApproval(true); - // else - // change.setApproval(false); + if (!queryApprovalProcessName.isEmpty() && queryApprovalProcessName != null + && queryApprovalProcessName.size() > 0) + change.setApproval(true); + else + change.setApproval(false); - // } - if(approval){ - change.setApproval(true); - }else{ - change.setApproval(false); } - change.setChangeNr(getValueStringByID(entry, "ChangeNr")); change.setSupportGroup(getValueStringByID(entry, "SupportGroup")); change.setStatusReason(getValueStringByID(entry, "StatusReason")); - if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 10 || Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 9){ if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 10){ if(change.getStatusReason().equals("9000")){ @@ -158,7 +152,7 @@ public class Change { } } if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 9){ - // System.out.println("\n++++++++"+getValueStringByID(entry, "CurrentStageNumber")); + System.out.println("\n++++++++"+getValueStringByID(entry, "CurrentStageNumber")); if(getValueStringByID(entry, "CurrentStageNumber").equals("1")){ change.setState(9); }else{ @@ -172,9 +166,8 @@ public class Change { .orElse(-1)); } - - // System.out.println("\nStatus: "+change.getState()); + System.out.println("\nStatus: "+change.getState()); change.setPackageInstanceId(getValueStringByID(entry, "PackageInstanceId")); change.setResourceName(getValueStringByID(entry, "ResourceName")); @@ -197,18 +190,15 @@ public class Change { .map(Object::toString) .filter(peopleFullName::equals) .isPresent()); - // change.setPackageName(queryPackageName(getValueStringByID(entry, "PackageType").toString())); var ptMinutes = getValueStringByID(entry, "PlanTimeMinutes").isEmpty() ? "00" : getValueStringByID(entry, "PlanTimeMinutes"); var ptHours = getValueStringByID(entry, "PlanTimeHours").isEmpty() ? "00" : getValueStringByID(entry, "PlanTimeHours"); change.setPlanTime(convertPlanTime(ptHours, ptMinutes)); - - // change.setPackageName(queryPackageName(getValueStringByID(entry, "PackageType").toString())); changes.add(change); } - System.out.println("###FERTIG"); + System.out.println(entries.size()); api.freeImpersonatedUser(); @@ -265,110 +255,6 @@ public class Change { return totalHours; } - // #region approval flags - // /** - // * Determines if the change item can be approved based on the approval status - // * and the current state. - // * - // * @param approval The flag indicating whether the change item has been - // * approved. - // * @param state The current state of the change item. - // * @return {@code true} if the change item can be approved, {@code false} - // * otherwise. - // */ - // public boolean flagApproval(boolean approval, int state) { - // boolean approvableState = (state == 1 || state == 10); - // return approval && approvableState; - // } - - // /** - // * Determines if the change item can be canceled based on the support group ID - // * and the current state. - // * - // * @param supportGroupId The ID of the support group associated with the - // change item - // * @param state The current state of the change item - // * @return {@code true} if the change item can be canceled, {@code false} - // otherwise. - // * @throws ARException if an error occurs during the operation - // */ - // public boolean flagCancel(String supportGroupId, int state) throws - // ARException { - // 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) - // .get(0).get(queryRoles.getFieldId("Role")).toString(); - - // boolean approvableState = state == 1; - // boolean isChangeManager = role.equals("Change Manager"); - - // return approvableState && isChangeManager; - // } - - // /** - // * Determines if the change item has a permit based on the current state. - // * - // * @param state The current state of the change item. - // * @return {@code true} if the change item has a permit, {@code false} - // otherwise. - // */ - // public boolean flagPermit(int state) { - // return state == 0; - // } - - // /** - // * Checks if the logged in user is in the approval list for the specified - // change item. - // * - // * @param user The username of the user to check - // * @param changeNr The change number of the change item - // * @return {@code true} if the user is in the approval list, {@code false} - // otherwise. - // * @throws ARException if an error occurs during the operation - // */ - // public boolean inApprovalList(String user, String changeNr) throws - // ARException { - // var queryApprovalList = new - // Query.QueryBuilder("ASF:OverviewConsole_TicketsJoinAPDetailSignature") - // .addFieldId("Approvers", 13207).build(); - // var approversOI = api.queryFieldsById("\'Ticketnumber\' = \"" + changeNr + - // "\"", - // queryApprovalList.getFieldIds(), queryApprovalList.getFormName(), null, 0, - // 0); - // var approvers = approversOI.isEmpty() ? null - // : - // approversOI.get(0).get(queryApprovalList.getFieldId("Approvers")).toString(); - // return approvers != null ? approvers.contains(user) : false; - // } - // #endregion - - /** - * Queries and retrieves the package name based on the provided package type. - * Returns the package name as a string. - * - * @param packageType the type of the package - * @return the package name - * @throws ARException if an AR exception occurs - */ - private String queryPackageName(String packageType) throws ARException { - var queryPackage = new Query.QueryBuilder("CTR:GenericContractJoinCFG_Package") - .addFieldId("PackageName", 200000020).build(); - var packageNameList = api - .queryFieldsById("\'InstanceId_Package\' = \"" + packageType + "\"", - queryPackage.getFieldIds(), queryPackage.getFormName(), null, 0, 0); - Entry packageName = null; - - if (packageNameList != null && !packageNameList.isEmpty()) { - packageName = packageNameList.get(0); - return packageName.get(queryPackage.getFieldId("PackageName")).toString(); - } - - return ""; - } /** * Returns the {@link Value} of an entry based on the provided description. @@ -448,4 +334,4 @@ public class Change { } } -} +} \ No newline at end of file