field values date change
parent
e643c6c71a
commit
99907146ad
|
|
@ -288,9 +288,12 @@ public class KalenderRestController {
|
|||
httpRequest.setAttribute("formName", formName);
|
||||
|
||||
change.modifyTimestamp(request);
|
||||
httpRequest.setAttribute("listOfFieldValues", change.getListOfFieldValues());
|
||||
|
||||
return request;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Updates the state based on the provided {@link StateChangeRequest} object.
|
||||
* Returns a response entity with the updated state value.
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import java.text.ParseException;
|
|||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.TimeZone;
|
||||
|
||||
|
|
@ -32,6 +33,7 @@ public class Change {
|
|||
private Query queryChange;
|
||||
private RemedyJavaAPI api;
|
||||
private final static String formName = "ASF:WI_TAS_Paket";
|
||||
private ArrayList<String> listOfFieldValues;
|
||||
|
||||
/**
|
||||
* Constructor for the {@link Change} class which gets autowired with the
|
||||
|
|
@ -72,6 +74,17 @@ public class Change {
|
|||
.addFieldId("CurrentStageNumber", 301541700)
|
||||
.addFieldId("Plantime", 666000001)
|
||||
.build();
|
||||
this.listOfFieldValues = new ArrayList<>();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of field values.
|
||||
*
|
||||
* @return listOfFieldValues
|
||||
*/
|
||||
public List<String> getListOfFieldValues() {
|
||||
return new ArrayList<>(listOfFieldValues); // Return a copy to ensure immutability
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -138,23 +151,27 @@ public class Change {
|
|||
change.setChangeNr(getValueStringByID(entry, "ChangeNr"));
|
||||
change.setSupportGroup(getValueStringByID(entry, "SupportGroup"));
|
||||
change.setStatusReason(getValueStringByID(entry, "StatusReason"));
|
||||
if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 10 || Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 9){
|
||||
if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 10){
|
||||
if(change.getStatusReason().equals("9000")){
|
||||
if (Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1) == 10
|
||||
|| Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue)
|
||||
.orElse(-1) == 9) {
|
||||
if (Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue)
|
||||
.orElse(-1) == 10) {
|
||||
if (change.getStatusReason().equals("9000")) {
|
||||
change.setState(10);
|
||||
}else{
|
||||
} else {
|
||||
change.setState(101);
|
||||
}
|
||||
}
|
||||
if(Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue).orElse(-1)== 9){
|
||||
if(getValueStringByID(entry, "CurrentStageNumber").equals("1")){
|
||||
if (Optional.ofNullable(getValue(entry, "State")).map(Value::getIntValue)
|
||||
.orElse(-1) == 9) {
|
||||
if (getValueStringByID(entry, "CurrentStageNumber").equals("1")) {
|
||||
change.setState(9);
|
||||
}else{
|
||||
} else {
|
||||
change.setState(91);
|
||||
}
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
change.setState(Optional.ofNullable(getValue(entry, "State"))
|
||||
.map(Value::getIntValue)
|
||||
.orElse(-1));
|
||||
|
|
@ -246,7 +263,6 @@ public class Change {
|
|||
return totalHours;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the {@link Value} of an entry based on the provided description.
|
||||
*
|
||||
|
|
@ -302,6 +318,9 @@ public class Change {
|
|||
* @throws ValidationError
|
||||
*/
|
||||
public void modifyTimestamp(ChangeUpdateRequest request) throws ARException, ValidationError {
|
||||
// Clear the list before processing a new request
|
||||
listOfFieldValues.clear();
|
||||
|
||||
String entryId = request.getResourceId();
|
||||
String d2 = request.getD2();
|
||||
var dateConverter = new DateConverter();
|
||||
|
|
@ -312,10 +331,12 @@ public class Change {
|
|||
if (state == 0) {
|
||||
Query query = new Query.QueryBuilder("ASF:WI_TAS_Paket")
|
||||
.addFieldValue("d2", 1000000350, new Value(ts)).build();
|
||||
collectFieldValues(query); // Collect field values
|
||||
api.modifyEntry(entryId, query);
|
||||
} else {
|
||||
Query queryInfrastructureChange = new Query.QueryBuilder("CHG:Infrastructure Change")
|
||||
.addFieldValue("d2", 1000000350, new Value(ts)).build();
|
||||
collectFieldValues(queryInfrastructureChange); // Collect field values
|
||||
|
||||
var change = api.queryFieldsById("\'Infrastructure Change ID\' = \"" + changeNr + "\"",
|
||||
queryInfrastructureChange.getFieldIds(),
|
||||
|
|
@ -323,6 +344,11 @@ public class Change {
|
|||
|
||||
api.modifyEntry(change.get(0).getEntryId(), queryInfrastructureChange);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectFieldValues(Query query) {
|
||||
for (var entry : query.getFieldValues()) {
|
||||
listOfFieldValues.add(entry.getFieldId() + ": " + entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue