StateChange exceptions
parent
03c40b294e
commit
e2db14835b
|
|
@ -46,17 +46,19 @@ public class KalenderRestController {
|
||||||
private final Implementer implementer;
|
private final Implementer implementer;
|
||||||
private final PackageType packageType;
|
private final PackageType packageType;
|
||||||
private final Approval approval;
|
private final Approval approval;
|
||||||
|
private final StateChange stateChange;
|
||||||
|
|
||||||
private static final Logger applicationLogger = LogManager.getLogger("application");
|
private static final Logger applicationLogger = LogManager.getLogger("application");
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
public KalenderRestController(RemedyJavaAPI javaAPI, Change change, Implementer implementer,
|
public KalenderRestController(RemedyJavaAPI javaAPI, Change change, Implementer implementer,
|
||||||
PackageType packageType, Approval approval) {
|
PackageType packageType, Approval approval, StateChange stateChange) {
|
||||||
this.javaAPI = javaAPI;
|
this.javaAPI = javaAPI;
|
||||||
this.change = change;
|
this.change = change;
|
||||||
this.implementer = implementer;
|
this.implementer = implementer;
|
||||||
this.packageType = packageType;
|
this.packageType = packageType;
|
||||||
this.approval = approval;
|
this.approval = approval;
|
||||||
|
this.stateChange = stateChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -70,9 +72,9 @@ public class KalenderRestController {
|
||||||
@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
@GetMapping("/api/getStates")
|
@GetMapping("/api/getStates")
|
||||||
@ResponseBody
|
@ResponseBody
|
||||||
public ArrayList<StateResponse> printState() throws JsonProcessingException {
|
public ArrayList<StateResponse> printState() {
|
||||||
var state = State.getInstance();
|
var state = State.getInstance();
|
||||||
return state.returnJson();
|
return state.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
|
|
@ -212,8 +214,7 @@ public class KalenderRestController {
|
||||||
*/
|
*/
|
||||||
@CrossOrigin("*")
|
@CrossOrigin("*")
|
||||||
@PostMapping("/api/updateState")
|
@PostMapping("/api/updateState")
|
||||||
public ResponseEntity<String> updateState(@RequestBody StateChangeRequest request,
|
public ResponseEntity<String> updateState(@RequestBody StateChangeRequest request) throws ARException {
|
||||||
@Autowired StateChange stateChange) throws ARException {
|
|
||||||
logRequest("/updateState", request.toString());
|
logRequest("/updateState", request.toString());
|
||||||
var response = stateChange.createStateChange(request);
|
var response = stateChange.createStateChange(request);
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,6 @@ import java.time.format.DateTimeFormatter;
|
||||||
import java.time.format.DateTimeParseException;
|
import java.time.format.DateTimeParseException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.apache.el.util.Validation;
|
|
||||||
|
|
||||||
import com.bmc.arsys.api.ARException;
|
import com.bmc.arsys.api.ARException;
|
||||||
import com.bmc.arsys.api.SortInfo;
|
import com.bmc.arsys.api.SortInfo;
|
||||||
import com.nttdata.calender.api.Query;
|
import com.nttdata.calender.api.Query;
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ import org.apache.logging.log4j.Logger;
|
||||||
|
|
||||||
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.fasterxml.jackson.core.JsonProcessingException;
|
|
||||||
import com.nttdata.calender.api.Query;
|
import com.nttdata.calender.api.Query;
|
||||||
import com.nttdata.calender.api.RemedyJavaAPI;
|
import com.nttdata.calender.api.RemedyJavaAPI;
|
||||||
|
|
||||||
|
|
@ -69,16 +68,11 @@ public class State {
|
||||||
* HashMap.
|
* HashMap.
|
||||||
*
|
*
|
||||||
* @param api Remedy API object
|
* @param api Remedy API object
|
||||||
|
* @throws ARException
|
||||||
*/
|
*/
|
||||||
public void queryState(RemedyJavaAPI api) {
|
public void queryState(RemedyJavaAPI api) throws ARException {
|
||||||
|
queryStateNames(api);
|
||||||
try {
|
queryPossibleStates(api);
|
||||||
queryStateNames(api);
|
|
||||||
queryPossibleStates(api);
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -153,26 +147,21 @@ public class State {
|
||||||
* @param nameQuery Query object of stateFields
|
* @param nameQuery Query object of stateFields
|
||||||
*/
|
*/
|
||||||
public void updateStateNames(List<Entry> stateFields, Query nameQuery) {
|
public void updateStateNames(List<Entry> stateFields, Query nameQuery) {
|
||||||
try {
|
stateFields.stream()
|
||||||
stateFields.stream()
|
.filter(entry -> Optional.ofNullable(entry.get(nameQuery.getFieldId("Locale")))
|
||||||
.filter(entry -> Optional.ofNullable(entry.get(nameQuery.getFieldId("Locale")))
|
.map(Object::toString)
|
||||||
.map(Object::toString)
|
.orElse("")
|
||||||
.orElse("")
|
.equals("de"))
|
||||||
.equals("de"))
|
.forEach(
|
||||||
.forEach(
|
entry -> {
|
||||||
entry -> {
|
var selectionCode = nameQuery.getFieldId("SelectionCode");
|
||||||
var selectionCode = nameQuery.getFieldId("SelectionCode");
|
var englishName = nameQuery.getFieldId("englishName");
|
||||||
var englishName = nameQuery.getFieldId("englishName");
|
var germanName = nameQuery.getFieldId("germanName");
|
||||||
var germanName = nameQuery.getFieldId("germanName");
|
|
||||||
|
|
||||||
this.getState().put(entry.get(selectionCode).getIntValue(),
|
this.getState().put(entry.get(selectionCode).getIntValue(),
|
||||||
new StateInfo(entry.get(englishName).toString(),
|
new StateInfo(entry.get(englishName).toString(),
|
||||||
entry.get(germanName).toString()));
|
entry.get(germanName).toString()));
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("Database entries for stateName in english and german in bad state");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -183,9 +172,8 @@ public class State {
|
||||||
*
|
*
|
||||||
* @return Array of JSON objects with integer representation of state and
|
* @return Array of JSON objects with integer representation of state and
|
||||||
* {@link StateInfo}
|
* {@link StateInfo}
|
||||||
* @throws JsonProcessingException if an error occurs during JSON processing
|
|
||||||
*/
|
*/
|
||||||
public ArrayList<StateResponse> returnJson() throws JsonProcessingException {
|
public ArrayList<StateResponse> get() {
|
||||||
var response = new ArrayList<StateResponse>();
|
var response = new ArrayList<StateResponse>();
|
||||||
this.state.forEach((key, value) -> {
|
this.state.forEach((key, value) -> {
|
||||||
response.add(new StateResponse(key, value.possibleState, value.stateNameEN, value.stateNameDE));
|
response.add(new StateResponse(key, value.possibleState, value.stateNameEN, value.stateNameDE));
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
package com.nttdata.calender.states;
|
package com.nttdata.calender.states;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import com.bmc.arsys.api.ARException;
|
import com.bmc.arsys.api.ARException;
|
||||||
import com.bmc.arsys.api.Value;
|
import com.bmc.arsys.api.Value;
|
||||||
|
|
@ -13,7 +13,7 @@ import com.nttdata.calender.api.RemedyJavaAPI;
|
||||||
* change entries on Remedy. It handles the logic of creating a new
|
* change entries on Remedy. It handles the logic of creating a new
|
||||||
* entry with the required field values.
|
* entry with the required field values.
|
||||||
*/
|
*/
|
||||||
@Component
|
@Service
|
||||||
public class StateChange {
|
public class StateChange {
|
||||||
static final String ACTION = "STATUSCHANGE";
|
static final String ACTION = "STATUSCHANGE";
|
||||||
static final String formName = "ASF:CHG_CAL_Interactions";
|
static final String formName = "ASF:CHG_CAL_Interactions";
|
||||||
|
|
@ -39,7 +39,6 @@ public class StateChange {
|
||||||
* @return String representing the created entry ID
|
* @return String representing the created entry ID
|
||||||
* @throws ARException when there's an error creating the entry
|
* @throws ARException when there's an error creating the entry
|
||||||
*/
|
*/
|
||||||
// TODO: implement changes from implementerChange
|
|
||||||
public String createStateChange(StateChangeRequest request) throws ARException {
|
public String createStateChange(StateChangeRequest request) throws ARException {
|
||||||
var query = new Query.QueryBuilder(formName)
|
var query = new Query.QueryBuilder(formName)
|
||||||
.addFieldValue("ChangeNr", 666000002, new Value(request.getChangeNr()))
|
.addFieldValue("ChangeNr", 666000002, new Value(request.getChangeNr()))
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ public class StateChangeRequest {
|
||||||
/**
|
/**
|
||||||
* Sets the change number.
|
* Sets the change number.
|
||||||
*
|
*
|
||||||
* @param changeNr String to set representing the change number
|
* @param changeNr String to set representing the change number
|
||||||
*/
|
*/
|
||||||
public void setChangeNr(String changeNr) {
|
public void setChangeNr(String changeNr) {
|
||||||
this.changeNr = changeNr;
|
this.changeNr = changeNr;
|
||||||
|
|
@ -22,7 +22,7 @@ public class StateChangeRequest {
|
||||||
/**
|
/**
|
||||||
* Sets the current state.
|
* Sets the current state.
|
||||||
*
|
*
|
||||||
* @param currentState an int to set representing the current state
|
* @param currentState an int to set representing the current state
|
||||||
*/
|
*/
|
||||||
public void setCurrentState(int currentState) {
|
public void setCurrentState(int currentState) {
|
||||||
this.currentState = currentState;
|
this.currentState = currentState;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue