DONE
parent
cbfa7287f5
commit
297bee8101
|
|
@ -182,13 +182,14 @@ public class KalenderRestController {
|
||||||
*
|
*
|
||||||
* @return {@link ArrayList} of {@link ContractGetResponse} objects
|
* @return {@link ArrayList} of {@link ContractGetResponse} objects
|
||||||
* @throws ARException if an AR exception occurs
|
* @throws ARException if an AR exception occurs
|
||||||
|
* @throws NotFoundError
|
||||||
*/
|
*/
|
||||||
@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
@GetMapping("/api/getContracts")
|
@GetMapping("/api/getContracts")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ArrayList<ContractGetResponse> getContracts() throws ARException {
|
public ArrayList<ContractGetResponse> getContracts() throws ARException, NotFoundError {
|
||||||
var contract = Contract.getInstance();
|
var contract = Contract.getInstance();
|
||||||
return contract.get();
|
return contract.get(this.javaAPI);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ public class RemedyJavaAPI {
|
||||||
public RemedyJavaAPI() throws ARException, NotFoundError {
|
public RemedyJavaAPI() throws ARException, NotFoundError {
|
||||||
server = new ARServerUser();
|
server = new ARServerUser();
|
||||||
// server.setServer("itsm-app-dev.asfinag.at");
|
// server.setServer("itsm-app-dev.asfinag.at");
|
||||||
server.setServer("itsm-app-dev-neu.asfinag.at");
|
server.setServer("itsm-app-test-neu.asfinag.at");
|
||||||
server.setUser("changecalender_integration");
|
server.setUser("changecalender_integration");
|
||||||
server.setPassword("VXrvLm4q#8P#MXthfZNc");
|
server.setPassword("VXrvLm4q#8P#MXthfZNc");
|
||||||
server.setPort(46262);
|
server.setPort(46262);
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,7 @@ import com.nttdata.calender.errorhandling.ErrorTypes.NotFoundError;
|
||||||
* and retrieving a list of contracts based on matching id's.
|
* and retrieving a list of contracts based on matching id's.
|
||||||
*/
|
*/
|
||||||
public class Contract {
|
public class Contract {
|
||||||
private static final String formName_changes = "ASF:WI_TAS_Paket";
|
private static final String formName_contracts = "ASF:WI_CAL_CALENDARCONTRACTS4USER";
|
||||||
private static final String formName_contracts = "CTR:ContractBase";
|
|
||||||
private static final Contract INSTANCE = new Contract();
|
private static final Contract INSTANCE = new Contract();
|
||||||
private ArrayList<ContractGetResponse> contracts;
|
private ArrayList<ContractGetResponse> contracts;
|
||||||
|
|
||||||
|
|
@ -45,25 +44,18 @@ public class Contract {
|
||||||
* @throws NotFoundError if no contracts are found in the given context
|
* @throws NotFoundError if no contracts are found in the given context
|
||||||
*/
|
*/
|
||||||
public void queryContracts(RemedyJavaAPI api) throws ARException, NotFoundError {
|
public void queryContracts(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||||
ArrayList<ContractGetResponse> allChanges = new ArrayList<ContractGetResponse>();
|
|
||||||
ArrayList<ContractGetResponse> allContracts = new ArrayList<ContractGetResponse>();
|
ArrayList<ContractGetResponse> allContracts = new ArrayList<ContractGetResponse>();
|
||||||
|
api.impersonateUser("btwien_test");
|
||||||
|
|
||||||
var queryChanges = new Query.QueryBuilder(formName_changes)
|
|
||||||
.addFieldId("Contract", 670031002).build();
|
|
||||||
|
|
||||||
allChanges = api.queryFieldsById("", queryChanges.getFieldIds(), formName_changes, null, 0, 0)
|
|
||||||
.stream()
|
|
||||||
.map(entry -> new ContractGetResponse(null,
|
|
||||||
entry.get(queryChanges.getFieldId("Contract")).toString()))
|
|
||||||
.distinct()
|
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
|
||||||
|
|
||||||
var queryContracts = new Query.QueryBuilder(formName_contracts)
|
var queryContracts = new Query.QueryBuilder(formName_contracts)
|
||||||
.addFieldId("Id", 179)
|
.addFieldId("Id", 179)
|
||||||
.addFieldId("Name", 8).build();
|
.addFieldId("Name", 700008020).build();
|
||||||
|
|
||||||
|
System.out.println("\n### USER: "+api.getUser());
|
||||||
|
|
||||||
allContracts = api
|
allContracts = api
|
||||||
.queryFieldsById("\'Contract ID+\' != \"\"", queryContracts.getFieldIds(), formName_contracts, null,
|
.queryFieldsById("\'4\' = \""+api.getUser()+"\"", queryContracts.getFieldIds(), formName_contracts, null,
|
||||||
0, 0)
|
0, 0)
|
||||||
.stream()
|
.stream()
|
||||||
.map(entry -> new ContractGetResponse(
|
.map(entry -> new ContractGetResponse(
|
||||||
|
|
@ -72,24 +64,25 @@ public class Contract {
|
||||||
.distinct()
|
.distinct()
|
||||||
.collect(Collectors.toCollection(ArrayList::new));
|
.collect(Collectors.toCollection(ArrayList::new));
|
||||||
|
|
||||||
for (var change : allChanges) {
|
for (ContractGetResponse contractGetResponse : allContracts) {
|
||||||
for (var contract : allContracts) {
|
System.out.println(contractGetResponse.name);
|
||||||
if (change.id.equals(contract.id)) {
|
|
||||||
this.contracts.add(contract);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (contracts.isEmpty()) {
|
|
||||||
throw new NotFoundError("No contracts found in this context");
|
if (allContracts.isEmpty()) {
|
||||||
|
System.out.println("No contracts found in this context");
|
||||||
}
|
}
|
||||||
|
contracts = allContracts;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return the list of contracts
|
* @return the list of contracts
|
||||||
|
* @throws ARException
|
||||||
|
* @throws NotFoundError
|
||||||
*/
|
*/
|
||||||
public ArrayList<ContractGetResponse> get() {
|
public ArrayList<ContractGetResponse> get(RemedyJavaAPI api) throws NotFoundError, ARException {
|
||||||
|
this.queryContracts(api);
|
||||||
return contracts;
|
return contracts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue