cleaning code + adding transaction id
parent
022024219e
commit
330823b41d
|
|
@ -116,19 +116,27 @@ public class KalenderRestController {
|
|||
* @throws ARException
|
||||
* @throws JsonProcessingException if an exception occurs during JSON processing
|
||||
*/
|
||||
|
||||
@CrossOrigin("*")
|
||||
@GetMapping("/api/getUser")
|
||||
@ResponseBody
|
||||
public String getUserId() throws ARException {
|
||||
|
||||
public ResponseEntity<String> getUserId() throws ARException {
|
||||
var query = new Query.QueryBuilder("CTM:People LookUp")
|
||||
.addFieldId("Name", 1000000017)
|
||||
.build();
|
||||
|
||||
var name = this.javaAPI.queryFieldsById("\'4\'==\"" + javaAPI.getUser() + "\"", query.getFieldIds(),
|
||||
query.getFormName(), null, 0, 0).get(0);
|
||||
var results = this.javaAPI.queryFieldsById("'4'==\"" + javaAPI.getUser() + "\"", query.getFieldIds(),
|
||||
query.getFormName(), null, 0, 0);
|
||||
|
||||
if (results.isEmpty()) {
|
||||
// Handle the case where no results are found
|
||||
String errorMessage = "No user found with the given criteria.";
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("{\"error\": \"" + errorMessage + "\"}");
|
||||
}
|
||||
|
||||
var name = results.get(0);
|
||||
String jsonString = "{\"userId\": \"" + name.get(query.getFieldId("Name")) + "\"}";
|
||||
return jsonString;
|
||||
return ResponseEntity.ok(jsonString);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -208,7 +216,7 @@ public class KalenderRestController {
|
|||
@ResponseBody
|
||||
public ArrayList<ContractGetResponse> getContracts() throws ARException, NotFoundError {
|
||||
Contract contract = new Contract();
|
||||
System.out.println(javaAPI.getUser());
|
||||
// System.out.println(javaAPI.getUser());
|
||||
return contract.get(this.javaAPI);
|
||||
}
|
||||
|
||||
|
|
@ -254,7 +262,6 @@ public class KalenderRestController {
|
|||
@ResponseBody
|
||||
public ChangeResponse getChanges(@RequestBody ChangeRequest request)
|
||||
throws ARException, NotFoundError, ValidationError {
|
||||
|
||||
return change.get(request);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,8 +7,11 @@ import org.springframework.web.servlet.HandlerInterceptor;
|
|||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Calendar;
|
||||
|
||||
@Component
|
||||
public class RequestInterceptor implements HandlerInterceptor {
|
||||
|
|
@ -23,16 +26,23 @@ public class RequestInterceptor implements HandlerInterceptor {
|
|||
String currentDateTime = LocalDateTime.now().format(dateTimeFormatter);
|
||||
String out = currentDateTime + " - handling request: " + request.getRequestURI();
|
||||
logger.info(out);
|
||||
System.out.println(out);
|
||||
// System.out.println(out);
|
||||
return true; // Continue with the request
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex)
|
||||
throws Exception {
|
||||
|
||||
String currentDateTime = LocalDateTime.now().format(dateTimeFormatter);
|
||||
long transactionId = System.currentTimeMillis();
|
||||
|
||||
if (ex == null)
|
||||
System.out.println("Success in handling request: " + request.getRequestURI());
|
||||
System.out.println(
|
||||
"Transaction ID: " + transactionId + "\n" + currentDateTime + " [SUCCESS] handling request: "
|
||||
+ request.getRequestURI() + "\n");
|
||||
else
|
||||
System.out.println("Error in handling request: " + request.getRequestURI());
|
||||
System.err.println(currentDateTime + " [ERROR] handling request: " + request.getRequestURI() + "\n"
|
||||
+ ex.getMessage() + "\n");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,15 +92,11 @@ public class Change {
|
|||
var peopleFullName = processPeopleInfo(request);
|
||||
|
||||
var filter = request.getFilter();
|
||||
for (var v : filter.getFilterElement()) {
|
||||
System.out.println(v.getFilter() + ", " + v.getColumn() +", " + v.getCriteria());
|
||||
}
|
||||
var qualifier = filter.constructQualifier(queryChange, api);
|
||||
SortInfo sort = request.constructSortInfo(queryChange);
|
||||
|
||||
log.initLog("getChanges", api.getUser()); // Logging
|
||||
|
||||
System.out.println(qualifier);
|
||||
var entries = api.queryFieldsById(qualifier, this.queryChange.getFieldIds(),
|
||||
this.queryChange.getFormName(),
|
||||
sort, request.getSliceStart(),
|
||||
|
|
@ -151,7 +147,6 @@ public class Change {
|
|||
}
|
||||
}
|
||||
if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 9){
|
||||
System.out.println("\n++++++++"+getValueStringByID(entry, "CurrentStageNumber"));
|
||||
if(getValueStringByID(entry, "CurrentStageNumber").equals("1")){
|
||||
change.setState(9);
|
||||
}else{
|
||||
|
|
@ -195,8 +190,6 @@ public class Change {
|
|||
change.setPlanTime(convertPlanTime(ptHours, ptMinutes));
|
||||
changes.add(change);
|
||||
}
|
||||
|
||||
System.out.println(entries.size());
|
||||
api.freeImpersonatedUser();
|
||||
|
||||
return new ChangeResponse(entriesSize, changes);
|
||||
|
|
|
|||
|
|
@ -103,8 +103,6 @@ public class Filter {
|
|||
var column = current_filter.getColumn();
|
||||
var criterias = current_filter.getCriteria();
|
||||
|
||||
System.out.println(current_filter + " | ");
|
||||
|
||||
if (column.isEmpty() || criterias.length <= 0) {
|
||||
throw new ValidationError("Fields inside filter empty");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ public class Contract {
|
|||
this.contracts = new ArrayList<ContractGetResponse>();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Queries the Remedy AR Server using the provided `api` object to retrieve
|
||||
* Contract IDs
|
||||
|
|
@ -33,22 +32,20 @@ public class Contract {
|
|||
* ones in the `contracts` list.
|
||||
*
|
||||
* @param api the RemedyJavaAPI object used to connect to the Remedy AR Server
|
||||
* @return
|
||||
* @return
|
||||
* @throws ARException if an error occurs during the querying process
|
||||
* @throws NotFoundError if no contracts are found in the given context
|
||||
*/
|
||||
public ArrayList<ContractGetResponse> queryContracts(RemedyJavaAPI api) throws ARException, NotFoundError {
|
||||
ArrayList<ContractGetResponse> allContracts = new ArrayList<ContractGetResponse>();
|
||||
|
||||
|
||||
var queryContracts = new Query.QueryBuilder(formName_contracts)
|
||||
.addFieldId("Id", 179)
|
||||
.addFieldId("Name", 700008020).build();
|
||||
|
||||
System.out.println("\n### USER: "+api.getUser());
|
||||
|
||||
allContracts = api
|
||||
.queryFieldsById("\'4\' = \""+api.getUser()+"\"", queryContracts.getFieldIds(), formName_contracts, null,
|
||||
.queryFieldsById("\'4\' = \"" + api.getUser() + "\"", queryContracts.getFieldIds(), formName_contracts,
|
||||
null,
|
||||
0, 0)
|
||||
.stream()
|
||||
.map(entry -> new ContractGetResponse(
|
||||
|
|
@ -57,22 +54,16 @@ public class Contract {
|
|||
.distinct()
|
||||
.collect(Collectors.toCollection(ArrayList::new));
|
||||
|
||||
for (ContractGetResponse contractGetResponse : allContracts) {
|
||||
System.out.println(contractGetResponse.name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (allContracts.isEmpty()) {
|
||||
System.out.println("No contracts found in this context");
|
||||
System.out.println("No contracts found in this context");
|
||||
}
|
||||
return allContracts;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of contracts
|
||||
* @throws ARException
|
||||
* @throws NotFoundError
|
||||
* @throws ARException
|
||||
* @throws NotFoundError
|
||||
*/
|
||||
public ArrayList<ContractGetResponse> get(RemedyJavaAPI api) throws NotFoundError, ARException {
|
||||
return this.queryContracts(api);
|
||||
|
|
|
|||
|
|
@ -76,7 +76,6 @@ public class Presets {
|
|||
var guid = preference.get(0).get(prefQuery.getFieldId("GUID"));
|
||||
if (guid.toString() == null) {
|
||||
// IF GUID IS NULL PUT SYSTEM DEFAULT INSIDE
|
||||
System.out.println("GEHT REIN");
|
||||
var queryPreferenceNewValue = new Query.QueryBuilder(formUserPref)
|
||||
.addFieldValue("GUID", 364000001, new Value(sysdefGUID)).build();
|
||||
var pref = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"",
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ public class State {
|
|||
populateStateInfo(stateFields, stateStatusFields, configurationQuery, configurationStatusQuery);
|
||||
|
||||
// Print state information
|
||||
printStateInfo();
|
||||
// printStateInfo();
|
||||
}
|
||||
|
||||
private void populateStateInfo(List<Entry> stateFields, List<Entry> stateStatusFields,
|
||||
|
|
@ -135,7 +135,7 @@ public class State {
|
|||
implementerFlag = stateField.get(configurationQuery.getFieldId("implementerFlag")).toString()
|
||||
.equals("SETIMPLEMENTER_YES");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
}
|
||||
|
||||
String engName = stateField.get(configurationQuery.getFieldId("engName")).toString();
|
||||
|
|
|
|||
Loading…
Reference in New Issue