fetchContracts merge
parent
297bee8101
commit
df7e1013c4
|
|
@ -188,7 +188,8 @@ public class KalenderRestController {
|
|||
@GetMapping("/api/getContracts")
|
||||
@ResponseBody
|
||||
public ArrayList<ContractGetResponse> getContracts() throws ARException, NotFoundError {
|
||||
var contract = Contract.getInstance();
|
||||
Contract contract = new Contract();
|
||||
System.out.println(javaAPI.getUser());
|
||||
return contract.get(this.javaAPI);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ public class RemedyJavaAPI {
|
|||
// TODO: move to APIApplication.java or State.java - see where it fits
|
||||
State.getInstance().queryState(this);
|
||||
SupportGroup.getInstance().querySupportGroups(this);
|
||||
Contract.getInstance().queryContracts(this);
|
||||
}
|
||||
|
||||
public ARServerUser getServer() {
|
||||
|
|
|
|||
|
|
@ -14,23 +14,16 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
|
|||
* and retrieving a list of contracts based on matching id's.
|
||||
*/
|
||||
public class Contract {
|
||||
private static final String formName_contracts = "ASF:WI_CAL_CALENDARCONTRACTS4USER";
|
||||
private static final Contract INSTANCE = new Contract();
|
||||
private String formName_contracts = "ASF:WI_CAL_CALENDARCONTRACTS4USER";
|
||||
private ArrayList<ContractGetResponse> contracts;
|
||||
|
||||
/**
|
||||
* Private constructor that creates a new empty ArrayList of contracts.
|
||||
* public constructor that creates a new empty ArrayList of contracts.
|
||||
*/
|
||||
private Contract() {
|
||||
public Contract() {
|
||||
this.contracts = new ArrayList<ContractGetResponse>();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the singleton instance of the Contract class.
|
||||
*/
|
||||
public static Contract getInstance() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the Remedy AR Server using the provided `api` object to retrieve
|
||||
|
|
@ -40,12 +33,12 @@ public class Contract {
|
|||
* ones in the `contracts` list.
|
||||
*
|
||||
* @param api the RemedyJavaAPI object used to connect to the Remedy AR Server
|
||||
* @return
|
||||
* @throws ARException if an error occurs during the querying process
|
||||
* @throws NotFoundError if no contracts are found in the given context
|
||||
*/
|
||||
public void queryContracts(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||
public ArrayList<ContractGetResponse> queryContracts(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||
ArrayList<ContractGetResponse> allContracts = new ArrayList<ContractGetResponse>();
|
||||
api.impersonateUser("btwien_test");
|
||||
|
||||
|
||||
var queryContracts = new Query.QueryBuilder(formName_contracts)
|
||||
|
|
@ -73,7 +66,7 @@ public class Contract {
|
|||
if (allContracts.isEmpty()) {
|
||||
System.out.println("No contracts found in this context");
|
||||
}
|
||||
contracts = allContracts;
|
||||
return allContracts;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -82,7 +75,6 @@ public class Contract {
|
|||
* @throws NotFoundError
|
||||
*/
|
||||
public ArrayList<ContractGetResponse> get(RemedyJavaAPI api) throws NotFoundError, ARException {
|
||||
this.queryContracts(api);
|
||||
return contracts;
|
||||
return this.queryContracts(api);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue