use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ScheduledOrders method addNextExecutionWindow.
@Util
public static void addNextExecutionWindow() {
Calendar now = Calendar.getInstance();
ExecutionWindowRestRep nextWindow = ExecutionWindowUtils.getNextExecutionWindow(now);
if (nextWindow != null) {
Calendar nextWindowTime = ExecutionWindowUtils.calculateNextWindowTime(now, nextWindow);
renderArgs.put("nextWindowName", nextWindow.getName());
renderArgs.put("nextWindowTime", nextWindowTime.getTime());
}
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowsApi method update.
public static void update(String executionWindowId, ExecutionWindowInfo info) {
ExecutionWindowRestRep window = ExecutionWindowUtils.getExecutionWindow(uri(executionWindowId));
if (window != null) {
copyExecutionWindowInfoToExecutionWindow(info, window);
window.setId(URI.create(executionWindowId));
createForm(window).validate("executionWindowForm");
if (validation.hasErrors()) {
response.status = HttpStatus.SC_BAD_REQUEST;
ValidationError validationError = null;
renderApi(getValidationErrors());
} else {
ExecutionWindowUpdateParam updateParam = new ExecutionWindowUpdateParam();
map(updateParam, info);
ExecutionWindowUtils.updateExecutionWindow(uri(executionWindowId), updateParam);
info.setId(window.getId().toString());
renderApi(info);
}
} else {
notFound(Messages.get("ExecutionWindowsApi.windowWithId", executionWindowId));
}
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindows method resize.
public static void resize(@Required String id, @Required Long start, @Required Long end, @Required Integer timezoneOffsetInMinutes) {
ExecutionWindowRestRep executionWindow = ExecutionWindowUtils.getExecutionWindow(uri(id));
if (executionWindow == null) {
renderJSON(new CalResponse(false, MessagesUtils.get("executionWindow.notfound", id)));
}
ExecutionWindowForm executionWindowForm = new ExecutionWindowForm();
executionWindowForm.timezoneOffsetInMinutes = timezoneOffsetInMinutes == null ? 0 : timezoneOffsetInMinutes;
executionWindowForm.readFrom(executionWindow);
executionWindowForm.updateTimes(start, end);
boolean isOverlapping = isOverlapping(executionWindowForm);
if (isOverlapping) {
renderJSON(new CalResponse(false, MessagesUtils.get("executionWindow.overlapping", executionWindow.getName())));
}
executionWindowForm.save();
renderJSON(new CalResponse(true, MessagesUtils.get("executionWindow.saved.success", executionWindow.getName())));
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowUtils method getNextExecutionWindow.
public static ExecutionWindowRestRep getNextExecutionWindow(Collection<ExecutionWindowRestRep> windows, Calendar time) {
Calendar nextWindowTime = null;
ExecutionWindowRestRep nextWindow = null;
for (ExecutionWindowRestRep window : windows) {
Calendar windowTime = calculateNextWindowTime(time, window);
if (nextWindowTime == null || nextWindowTime.after(windowTime)) {
nextWindowTime = windowTime;
nextWindow = window;
}
}
return nextWindow;
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowUtils method getExecutionWindow.
public static ExecutionWindowRestRep getExecutionWindow(String name, URI tenantId) {
ViPRCatalogClient2 catalog = getCatalogClient();
List<ExecutionWindowRestRep> executionWindows = catalog.executionWindows().getByTenant(tenantId);
for (ExecutionWindowRestRep executionWindow : executionWindows) {
if (name.equals(executionWindow.getName())) {
return executionWindow;
}
}
return null;
}
Aggregations