deletePreset
parent
29a2b7eba5
commit
6d05ff577c
|
|
@ -36,6 +36,7 @@ import com.nttdata.calender.packageType.PackageType;
|
|||
import com.nttdata.calender.planTimes.CalendarWeek;
|
||||
import com.nttdata.calender.planTimes.PlanTimes;
|
||||
import com.nttdata.calender.planTimes.PlanTimesRequest;
|
||||
import com.nttdata.calender.presets.DeletePresetRequest;
|
||||
import com.nttdata.calender.presets.EditUserPreferencesRequest;
|
||||
import com.nttdata.calender.presets.Preset;
|
||||
import com.nttdata.calender.presets.Presets;
|
||||
|
|
@ -339,6 +340,14 @@ public class KalenderRestController {
|
|||
return presets.getAll();
|
||||
}
|
||||
|
||||
@CrossOrigin("*")
|
||||
@PostMapping("api/deletePreset")
|
||||
@ResponseBody
|
||||
public Object deletePreset(@RequestBody DeletePresetRequest request) throws ARException, NotFoundError {
|
||||
Presets presets = new Presets(javaAPI);
|
||||
presets.deletePreset(request);
|
||||
return presets.getAll();
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@PostMapping("api/renamePreset")
|
||||
|
|
|
|||
|
|
@ -136,6 +136,25 @@ public class RemedyJavaAPI {
|
|||
return "Entry created successfully. ID: " + entryIdOut;
|
||||
}
|
||||
|
||||
public String deleteEntry(String formName, String entryId) throws ARException {
|
||||
// Specify 0 for the deleteOption as mentioned in the documentation
|
||||
int deleteOption = 0;
|
||||
|
||||
// Attempt to delete the entry
|
||||
server.deleteEntry(formName, entryId, deleteOption);
|
||||
|
||||
// Check for any status or warnings after the deletion
|
||||
var lastStatus = server.getLastStatus();
|
||||
if (!lastStatus.isEmpty()) {
|
||||
applicationLogger.warn("Warning after deleting entry: " + lastStatus);
|
||||
return "Warning: " + lastStatus.toString();
|
||||
}
|
||||
|
||||
applicationLogger.info("Entry with ID " + entryId + " deleted successfully from form " + formName);
|
||||
return "Entry deleted successfully. ID: " + entryId;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Takes an entry ID and a {@link Query} object with values and updates the
|
||||
* selected entry with the values provided in the query.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
package com.nttdata.calender.presets;
|
||||
|
||||
public class DeletePresetRequest {
|
||||
private String id;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -58,7 +58,8 @@ public class Presets {
|
|||
}
|
||||
|
||||
public Object initPresets() throws ARException, NotFoundError {
|
||||
List<Entry> entries = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", query.getFieldIds(), formName,
|
||||
List<Entry> entries = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", query.getFieldIds(),
|
||||
formName,
|
||||
null,
|
||||
0, 0);
|
||||
PresetsGetResponse response = new PresetsGetResponse();
|
||||
|
|
@ -73,7 +74,8 @@ public class Presets {
|
|||
allPresets();
|
||||
response.setPresets(presets);
|
||||
response.setSelectedPreset(entries.get(0).get(query.getFieldId("GUID")).toString());
|
||||
response.setUserPreferences(new UserPreferences(entries.get(0).get(query.getFieldId("Details")).toString(),
|
||||
response.setUserPreferences(
|
||||
new UserPreferences(entries.get(0).get(query.getFieldId("Details")).toString(),
|
||||
entries.get(0).get(query.getFieldId("View")).toString(),
|
||||
entries.get(0).get(query.getFieldId("Language")).toString()));
|
||||
}
|
||||
|
|
@ -94,7 +96,8 @@ public class Presets {
|
|||
var queryP = new Query.QueryBuilder(formUserPref)
|
||||
.addFieldValue("GUID", 364000001, new Value(guid.getGuid())).build();
|
||||
|
||||
var pref = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", queryP.getFieldIds(), formUserPref, null, 0,
|
||||
var pref = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", queryP.getFieldIds(), formUserPref,
|
||||
null, 0,
|
||||
0);
|
||||
|
||||
if (pref.isEmpty() || pref == null)
|
||||
|
|
@ -141,7 +144,8 @@ public class Presets {
|
|||
}
|
||||
|
||||
public void allPresets() throws ARException, NotFoundError {
|
||||
var entries = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", query.getFieldIds(), formName, null, 0,
|
||||
var entries = api.queryFieldsById("\'2\'==\"" + api.getUser() + "\"", query.getFieldIds(), formName,
|
||||
null, 0,
|
||||
0);
|
||||
|
||||
if (entries.isEmpty() || entries == null) {
|
||||
|
|
@ -149,12 +153,18 @@ public class Presets {
|
|||
} else {
|
||||
for (var v : entries) {
|
||||
presets.add(new Preset(v.get(query.getFieldId("InstanceId")).toString(),
|
||||
v.get(query.getFieldId("Name")).toString(), v.get(query.getFieldId("Definition")).toString(),
|
||||
v.get(query.getFieldId("Name")).toString(),
|
||||
v.get(query.getFieldId("Definition")).toString(),
|
||||
""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deletePreset(DeletePresetRequest request) throws ARException {
|
||||
var entries = api.queryFieldsById("\'179\'==\""+ request.getId() + "\"", null, formDefault, null, 0, 0).get(0);
|
||||
api.deleteEntry(formDefault, entries.getEntryId());
|
||||
}
|
||||
|
||||
public List<Preset> getAll() throws NotFoundError, ARException {
|
||||
allPresets();
|
||||
return this.presets;
|
||||
|
|
|
|||
Loading…
Reference in New Issue