import cleanup

main
Julius Sula 2023-06-01 11:28:26 +02:00
parent cc003d9a6c
commit cca446650d
5 changed files with 69 additions and 105 deletions

View File

@ -16,7 +16,6 @@ import com.bmc.arsys.api.Field;
import com.bmc.arsys.api.OutputInteger;
import com.bmc.arsys.api.QualifierInfo;
import com.bmc.arsys.api.SortInfo;
import com.bmc.arsys.api.StatusInfo;
import com.bmc.arsys.api.Timestamp;
import com.bmc.arsys.api.Value;
import com.nttdata.calender.changes.Change;
@ -263,44 +262,6 @@ public class RemedyJavaAPI {
return statistics.get(0).getResult().getIntValue();
}
/**
* Prints a specific status type depending on the status list.
*
* @param statusList the information about the status
*/
public void printStatusList(List<StatusInfo> statusList) {
if (statusList == null || statusList.size() == 0) {
System.out.println("Status List is empty.");
return;
}
System.out.print("Message type: ");
switch (statusList.get(0).getMessageType()) {
case Constants.AR_RETURN_OK:
System.out.println("Note");
break;
case Constants.AR_RETURN_WARNING:
System.out.println("Warning");
break;
case Constants.AR_RETURN_ERROR:
System.out.println("Error");
break;
case Constants.AR_RETURN_FATAL:
System.out.println("Fatal Error");
break;
default:
System.out.println("Unknown (" +
statusList.get(0).getMessageType() + ")");
break;
}
System.out.println("Status List:");
for (int i = 0; i < statusList.size(); i++) {
System.out.println(statusList.get(i).getMessageText());
System.out.println(statusList.get(i).getAppendedText());
}
}
/**
* Modifies entries by entry ID and field ID with a new date.
*

View File

@ -3,7 +3,6 @@ package com.nttdata.calender.approval;
import org.springframework.stereotype.Service;
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.Entry;
import com.bmc.arsys.api.Value;
import com.nttdata.calender.api.Query;
import com.nttdata.calender.api.RemedyJavaAPI;
@ -41,40 +40,42 @@ public class Approval {
.addFieldValue("ApprovalAction", 1000003264, request.getApprovalActionValue())
.build();
/*
String user = remedyJavaAPI.getUser();
var queryChanges = new Query.QueryBuilder("ASF:WI_TAS_Paket")
.addFieldId("ChangeNr", 1000000182)
.addFieldId("ActualStatus", 7)
.build();
Entry change = remedyJavaAPI
.queryFieldsById("\'Infrastructure Change ID\' = \"" + request.getChangeNrValue().toString() + "\"",
queryChanges.getFieldIds(), queryChanges.getFormName(), null, 0, 0)
.get(0);
int approvalAction = queryUpdate.getFieldValue("ApprovalAction").getIntValue();
var actualStatus = change.get(queryChanges.getFieldId("ActualStatus"));
if (approvalAction == 1 || approvalAction == 2) {
if (inApprovalList(user, request.getChangeNr()))
return this.remedyJavaAPI.createEntry(queryUpdate);
else
return "user (" + user + ") has no authorization for approval.";
} else if (approvalAction == 3) {
if (request.getChangeNr().contains("PKG") && actualStatus.getIntValue() == 1)
return this.remedyJavaAPI.createEntry(queryUpdate);
else
return request.getChangeNr().contains("PKG")
? "actual status not set to 'request for authorization'."
: "is not a package (PKG)";
} else {
return "invalid approval status (must be 1, 2 or 3)";
}
*/
/*
* String user = remedyJavaAPI.getUser();
* var queryChanges = new Query.QueryBuilder("ASF:WI_TAS_Paket")
* .addFieldId("ChangeNr", 1000000182)
* .addFieldId("ActualStatus", 7)
* .build();
*
*
* Entry change = remedyJavaAPI
* .queryFieldsById("\'Infrastructure Change ID\' = \"" +
* request.getChangeNrValue().toString() + "\"",
* queryChanges.getFieldIds(), queryChanges.getFormName(), null, 0, 0)
* .get(0);
*
*
* int approvalAction =
* queryUpdate.getFieldValue("ApprovalAction").getIntValue();
* var actualStatus = change.get(queryChanges.getFieldId("ActualStatus"));
*
*
* if (approvalAction == 1 || approvalAction == 2) {
* if (inApprovalList(user, request.getChangeNr()))
* return this.remedyJavaAPI.createEntry(queryUpdate);
* else
* return "user (" + user + ") has no authorization for approval.";
* } else if (approvalAction == 3) {
* if (request.getChangeNr().contains("PKG") && actualStatus.getIntValue() == 1)
* return this.remedyJavaAPI.createEntry(queryUpdate);
* else
* return request.getChangeNr().contains("PKG")
* ? "actual status not set to 'request for authorization'."
* : "is not a package (PKG)";
* } else {
* return "invalid approval status (must be 1, 2 or 3)";
* }
*/
return this.remedyJavaAPI.createEntry(queryUpdate);
}
@ -87,16 +88,21 @@ public class Approval {
* @return True if the user is in the approval list, false otherwise
* @throws ARException If an error occurs during the query
*/
/*
public boolean inApprovalList(String user, String changeNr) throws ARException {
var queryApprovalList = new Query.QueryBuilder("ASF:OverviewConsole_TicketsJoinAPDetailSignature")
.addFieldId("Approvers", 13207).build();
var approversOI = remedyJavaAPI.queryFieldsById("\'Ticketnumber\' = \"" + changeNr + "\"",
queryApprovalList.getFieldIds(), queryApprovalList.getFormName(), null, 0, 0);
String approvers = approversOI.get(0).get(queryApprovalList.getFieldId("Approvers")).toString();
return approvers.contains(user);
}
*/
/*
* public boolean inApprovalList(String user, String changeNr) throws
* ARException {
* var queryApprovalList = new
* Query.QueryBuilder("ASF:OverviewConsole_TicketsJoinAPDetailSignature")
* .addFieldId("Approvers", 13207).build();
*
* var approversOI = remedyJavaAPI.queryFieldsById("\'Ticketnumber\' = \"" +
* changeNr + "\"",
* queryApprovalList.getFieldIds(), queryApprovalList.getFormName(), null, 0,
* 0);
*
* String approvers =
* approversOI.get(0).get(queryApprovalList.getFieldId("Approvers")).toString();
* return approvers.contains(user);
* }
*/
}

View File

@ -7,8 +7,6 @@ import java.util.Date;
import java.util.Optional;
import java.util.TimeZone;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.bmc.arsys.api.ARException;
@ -30,7 +28,6 @@ public class Change {
private Query queryChange;
private RemedyJavaAPI api;
private final static String formName = "ASF:WI_TAS_Paket";
private static Logger logger = LogManager.getLogger("logger");
/**
* Constructor for the {@link Change} class which gets autowired with the
@ -166,7 +163,7 @@ public class Change {
*
* @param approval The flag indicating whether the change item has been
* approved.
* @param state The current state of the change item.
* @param state The current state of the change item.
* @return {@code true} if the change item can be approved, {@code false}
* otherwise.
*/
@ -179,9 +176,11 @@ public class Change {
* 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.
* @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 {
@ -201,18 +200,21 @@ public class Change {
* 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.
* @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.
* 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.
* @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 {
@ -229,7 +231,8 @@ public class Change {
* Returns the {@link Value} of an entry based on the provided description.
*
* @param entry the {@link Entry} from which a value will be retrieved
* @param description the name of the field from which the value should be retrieved
* @param description the name of the field from which the value should be
* retrieved
* @return the value of the entry
*/
private Value getValue(Entry entry, String description) {
@ -241,7 +244,8 @@ public class Change {
* timestamp is null.
*
* @param entry the {@link Entry} containing the timestamp value
* @param description the description of the field containing the timestamp value
* @param description the description of the field containing the timestamp
* value
* @return the converted {@link Date} or null if the timestamp is null
*/
private Date timestampToDateById(Entry entry, String description) {

View File

@ -5,10 +5,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.web.client.HttpClientErrorException.NotFound;
import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.Entry;
import com.nttdata.calender.api.Query;

View File

@ -3,9 +3,6 @@ package com.nttdata.calender.supportgroup;
import java.util.ArrayList;
import java.util.stream.Collectors;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import com.bmc.arsys.api.ARException;
import com.nttdata.calender.api.Query;
import com.nttdata.calender.api.RemedyJavaAPI;