logging querySupportGroup
parent
34393ea0a7
commit
42cca4d77b
|
|
@ -3,6 +3,9 @@ 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;
|
||||
|
|
@ -14,6 +17,8 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
|
|||
* It provides methods to query and retrieve the support groups.
|
||||
*/
|
||||
public class SupportGroup {
|
||||
private static final Logger applicationLogger = LogManager.getLogger("application");
|
||||
|
||||
private static final String formName = "CTM:Support Group";
|
||||
private static final String formAssoc = "CTM:Support Group Assoc LookUp";
|
||||
private static final String formLookUp = "CTM:PeopleUserSupportGroupFunctionalRoleLookup";
|
||||
|
|
@ -47,14 +52,23 @@ public class SupportGroup {
|
|||
public void querySupportGroups(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||
|
||||
api.impersonateUser("btwien_test");
|
||||
|
||||
applicationLogger.info("\n\n\nRequest: querySupportGroups (Initial)\nUser: " + api.getUser() + "\nAdmin? "
|
||||
+ (api.isAdministrator() ? "Yes" : "No"));
|
||||
|
||||
var querySupportGroups = new Query.QueryBuilder(formLookUp)
|
||||
.addFieldId("SupportGroup", 1000000015)
|
||||
.addFieldId("SupportGroupId", 1000000079)
|
||||
.build();
|
||||
|
||||
applicationLogger.info("\n\tForm: " + formLookUp);
|
||||
|
||||
String qualifier = "";
|
||||
if (api.isAdministrator()) {
|
||||
qualifier = "\'1000001859\' == 5000 OR \'1000001859\' == 6000";
|
||||
|
||||
this.supportGroups = api
|
||||
.queryFieldsById("\'1000001859\' == 5000 OR \'1000001859\' == 6000",
|
||||
.queryFieldsById(qualifier,
|
||||
querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0)
|
||||
.stream()
|
||||
|
|
@ -63,10 +77,13 @@ public class SupportGroup {
|
|||
entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
applicationLogger.info("\nFetched Support Groups");
|
||||
|
||||
} else {
|
||||
qualifier = "\'4\' == \"" + api.getUser() + "\" AND (\'1000001859\' == 5000 OR \'1000001859\' == 6000)";
|
||||
this.supportGroups = api
|
||||
.queryFieldsById("\'4\' == \"" + api.getUser() + "\" AND (\'1000001859\' == 5000 OR \'1000001859\' == 6000)",
|
||||
.queryFieldsById(
|
||||
qualifier,
|
||||
querySupportGroups.getFieldIds(),
|
||||
querySupportGroups.getFormName(), null, 0, 0)
|
||||
.stream()
|
||||
|
|
@ -75,9 +92,11 @@ public class SupportGroup {
|
|||
entry.get(querySupportGroups.getFieldId("SupportGroupId")).toString()))
|
||||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
applicationLogger.info("\nFetched Support Groups");
|
||||
}
|
||||
|
||||
if (this.supportGroups.isEmpty()) {
|
||||
applicationLogger.info("\nSupport Groups are empty");
|
||||
throw new NotFoundError("No support groups found in this context");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue