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.OutputInteger;
import com.bmc.arsys.api.QualifierInfo; import com.bmc.arsys.api.QualifierInfo;
import com.bmc.arsys.api.SortInfo; import com.bmc.arsys.api.SortInfo;
import com.bmc.arsys.api.StatusInfo;
import com.bmc.arsys.api.Timestamp; import com.bmc.arsys.api.Timestamp;
import com.bmc.arsys.api.Value; import com.bmc.arsys.api.Value;
import com.nttdata.calender.changes.Change; import com.nttdata.calender.changes.Change;
@ -263,44 +262,6 @@ public class RemedyJavaAPI {
return statistics.get(0).getResult().getIntValue(); 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. * 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 org.springframework.stereotype.Service;
import com.bmc.arsys.api.ARException; import com.bmc.arsys.api.ARException;
import com.bmc.arsys.api.Entry;
import com.bmc.arsys.api.Value; import com.bmc.arsys.api.Value;
import com.nttdata.calender.api.Query; import com.nttdata.calender.api.Query;
import com.nttdata.calender.api.RemedyJavaAPI; import com.nttdata.calender.api.RemedyJavaAPI;
@ -42,39 +41,41 @@ public class Approval {
.build(); .build();
/* /*
String user = remedyJavaAPI.getUser(); * String user = remedyJavaAPI.getUser();
var queryChanges = new Query.QueryBuilder("ASF:WI_TAS_Paket") * var queryChanges = new Query.QueryBuilder("ASF:WI_TAS_Paket")
.addFieldId("ChangeNr", 1000000182) * .addFieldId("ChangeNr", 1000000182)
.addFieldId("ActualStatus", 7) * .addFieldId("ActualStatus", 7)
.build(); * .build();
*
*
Entry change = remedyJavaAPI * Entry change = remedyJavaAPI
.queryFieldsById("\'Infrastructure Change ID\' = \"" + request.getChangeNrValue().toString() + "\"", * .queryFieldsById("\'Infrastructure Change ID\' = \"" +
queryChanges.getFieldIds(), queryChanges.getFormName(), null, 0, 0) * request.getChangeNrValue().toString() + "\"",
.get(0); * queryChanges.getFieldIds(), queryChanges.getFormName(), null, 0, 0)
* .get(0);
*
int approvalAction = queryUpdate.getFieldValue("ApprovalAction").getIntValue(); *
var actualStatus = change.get(queryChanges.getFieldId("ActualStatus")); * 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); * if (approvalAction == 1 || approvalAction == 2) {
else * if (inApprovalList(user, request.getChangeNr()))
return "user (" + user + ") has no authorization for approval."; * return this.remedyJavaAPI.createEntry(queryUpdate);
} else if (approvalAction == 3) { * else
if (request.getChangeNr().contains("PKG") && actualStatus.getIntValue() == 1) * return "user (" + user + ") has no authorization for approval.";
return this.remedyJavaAPI.createEntry(queryUpdate); * } else if (approvalAction == 3) {
else * if (request.getChangeNr().contains("PKG") && actualStatus.getIntValue() == 1)
return request.getChangeNr().contains("PKG") * return this.remedyJavaAPI.createEntry(queryUpdate);
? "actual status not set to 'request for authorization'." * else
: "is not a package (PKG)"; * return request.getChangeNr().contains("PKG")
} else { * ? "actual status not set to 'request for authorization'."
return "invalid approval status (must be 1, 2 or 3)"; * : "is not a package (PKG)";
} * } else {
*/ * return "invalid approval status (must be 1, 2 or 3)";
* }
*/
return this.remedyJavaAPI.createEntry(queryUpdate); return this.remedyJavaAPI.createEntry(queryUpdate);
} }
@ -88,15 +89,20 @@ public class Approval {
* @throws ARException If an error occurs during the query * @throws ARException If an error occurs during the query
*/ */
/* /*
public boolean inApprovalList(String user, String changeNr) throws ARException { * public boolean inApprovalList(String user, String changeNr) throws
var queryApprovalList = new Query.QueryBuilder("ASF:OverviewConsole_TicketsJoinAPDetailSignature") * ARException {
.addFieldId("Approvers", 13207).build(); * var queryApprovalList = new
* Query.QueryBuilder("ASF:OverviewConsole_TicketsJoinAPDetailSignature")
var approversOI = remedyJavaAPI.queryFieldsById("\'Ticketnumber\' = \"" + changeNr + "\"", * .addFieldId("Approvers", 13207).build();
queryApprovalList.getFieldIds(), queryApprovalList.getFormName(), null, 0, 0); *
* var approversOI = remedyJavaAPI.queryFieldsById("\'Ticketnumber\' = \"" +
String approvers = approversOI.get(0).get(queryApprovalList.getFieldId("Approvers")).toString(); * changeNr + "\"",
return approvers.contains(user); * 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.Optional;
import java.util.TimeZone; 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.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.bmc.arsys.api.ARException; import com.bmc.arsys.api.ARException;
@ -30,7 +28,6 @@ public class Change {
private Query queryChange; private Query queryChange;
private RemedyJavaAPI api; private RemedyJavaAPI api;
private final static String formName = "ASF:WI_TAS_Paket"; 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 * 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 * @param approval The flag indicating whether the change item has been
* approved. * 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} * @return {@code true} if the change item can be approved, {@code false}
* otherwise. * otherwise.
*/ */
@ -179,9 +176,11 @@ public class Change {
* Determines if the change item can be canceled based on the support group ID * Determines if the change item can be canceled based on the support group ID
* and the current state. * and the current state.
* *
* @param supportGroupId The ID of the support group associated with the change item * @param supportGroupId The ID of the support group associated with the change
* @param state The current state of the change item * item
* @return {@code true} if the change item can be canceled, {@code false} otherwise. * @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 * @throws ARException if an error occurs during the operation
*/ */
public boolean flagCancel(String supportGroupId, int state) throws ARException { 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. * Determines if the change item has a permit based on the current state.
* *
* @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 has a permit, {@code false} otherwise. * @return {@code true} if the change item has a permit, {@code false}
* otherwise.
*/ */
public boolean flagPermit(int state) { public boolean flagPermit(int state) {
return state == 0; 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 user The username of the user to check
* @param changeNr The change number of the change item * @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 * @throws ARException if an error occurs during the operation
*/ */
public boolean inApprovalList(String user, String changeNr) throws ARException { 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. * 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 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 * @return the value of the entry
*/ */
private Value getValue(Entry entry, String description) { private Value getValue(Entry entry, String description) {
@ -241,7 +244,8 @@ public class Change {
* timestamp is null. * timestamp is null.
* *
* @param entry the {@link Entry} containing the timestamp value * @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 * @return the converted {@link Date} or null if the timestamp is null
*/ */
private Date timestampToDateById(Entry entry, String description) { private Date timestampToDateById(Entry entry, String description) {

View File

@ -5,10 +5,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Optional; 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.ARException;
import com.bmc.arsys.api.Entry; import com.bmc.arsys.api.Entry;
import com.nttdata.calender.api.Query; import com.nttdata.calender.api.Query;

View File

@ -3,9 +3,6 @@ package com.nttdata.calender.supportgroup;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.stream.Collectors; 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.bmc.arsys.api.ARException;
import com.nttdata.calender.api.Query; import com.nttdata.calender.api.Query;
import com.nttdata.calender.api.RemedyJavaAPI; import com.nttdata.calender.api.RemedyJavaAPI;