use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method edit.
public static void edit(@Required String id, @Required Integer timezoneOffsetInMinutes) {
ExecutionWindowRestRep executionWindow = ExecutionWindowUtils.getExecutionWindow(uri(id));
if (executionWindow == null) {
notFound();
}
ExecutionWindowForm executionWindowForm = new ExecutionWindowForm();
executionWindowForm.timezoneOffsetInMinutes = timezoneOffsetInMinutes == null ? 0 : timezoneOffsetInMinutes;
executionWindowForm.readFrom(executionWindow);
addDateTimeRenderArgs();
render(executionWindowForm);
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method isOverlapping.
@Util
public static boolean isOverlapping(ExecutionWindowForm executionWindowForm) {
if (executionWindowForm.length == null) {
return false;
}
ExecutionWindowRestRep tempExecutionWindow = new ExecutionWindowRestRep();
tempExecutionWindow.setName(Messages.get("ExecutionWindows.tempWindowLabel"));
executionWindowForm.writeTo(tempExecutionWindow);
return ExecutionWindowUtils.isOverlapping(tempExecutionWindow);
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method delete.
public static void delete(ExecutionWindowForm executionWindowForm) {
ExecutionWindowRestRep executionWindow = ExecutionWindowUtils.getExecutionWindow(uri(executionWindowForm.id));
if (executionWindow == null) {
notFound();
}
List<OrderRestRep> scheduledOrders = OrderUtils.getScheduledOrdersByExecutionWindow(uri(executionWindowForm.id));
if (Validation.hasErrors() || !scheduledOrders.isEmpty()) {
if (!scheduledOrders.isEmpty()) {
renderArgs.put("error", MessagesUtils.get("executionWindow.deleted.containsScheduledOrders", scheduledOrders.size()));
}
response.status = 400;
executionWindowForm.readFrom(executionWindow);
addDateTimeRenderArgs();
render("@edit", executionWindowForm);
}
ExecutionWindowUtils.deleteExecutionWindow(executionWindow);
renderText(MessagesUtils.get("executionWindow.deleted.success", executionWindow.getName()));
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method events.
public static void events(int timezoneOffsetInMinutes, String start, String end) {
// NOSONAR
List<ExecutionWindowRestRep> executionWindows = ExecutionWindowUtils.getExecutionWindows(uri(Models.currentAdminTenant()));
// ("Suppressing Sonar violation of Method invoking inefficient number constructor. Method events is invoked with int which is not inefficient")
DateTimeZone tz = TimeUtils.getLocalTimeZone(timezoneOffsetInMinutes);
DateTimeFormatter formatter = ISODateTimeFormat.date().withZone(tz);
DateTime startDateTime = DateTime.parse(start, formatter);
DateTime endDateTime = DateTime.parse(end, formatter);
List<Event> events = ExecutionWindowUtils.asEvents(executionWindows, startDateTime, endDateTime, tz);
renderJSON(events);
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method save.
public static void save(ExecutionWindowForm executionWindowForm) {
executionWindowForm.validate("executionWindowForm");
boolean isOverlapping = isOverlapping(executionWindowForm);
if (Validation.hasErrors() || isOverlapping) {
if (isOverlapping) {
renderArgs.put("error", MessagesUtils.get("executionWindow.overlapping"));
}
response.status = 400;
addDateTimeRenderArgs();
params.flash();
render("@edit", executionWindowForm);
} else {
ExecutionWindowRestRep executionWindow = executionWindowForm.save();
renderText(MessagesUtils.get("executionWindow.saved.success", executionWindow.getName()));
}
}
Aggregations