Search in sources :

Example 1 with ExecutionWindowRestRep

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());
    }
}
Also used : Calendar(java.util.Calendar) ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) Util(play.mvc.Util)

Example 2 with ExecutionWindowRestRep

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));
    }
}
Also used : ExecutionWindowUpdateParam(com.emc.vipr.model.catalog.ExecutionWindowUpdateParam) ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) ValidationError(com.emc.vipr.model.catalog.ValidationError)

Example 3 with ExecutionWindowRestRep

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())));
}
Also used : ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep)

Example 4 with ExecutionWindowRestRep

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;
}
Also used : Calendar(java.util.Calendar) ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep)

Example 5 with ExecutionWindowRestRep

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;
}
Also used : ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) ViPRCatalogClient2(com.emc.vipr.client.ViPRCatalogClient2)

Aggregations

ExecutionWindowRestRep (com.emc.vipr.model.catalog.ExecutionWindowRestRep)16 Calendar (java.util.Calendar)2 DateTime (org.joda.time.DateTime)2 DateTimeZone (org.joda.time.DateTimeZone)2 Util (play.mvc.Util)2 ViPRCatalogClient2 (com.emc.vipr.client.ViPRCatalogClient2)1 ExecutionWindowCreateParam (com.emc.vipr.model.catalog.ExecutionWindowCreateParam)1 ExecutionWindowUpdateParam (com.emc.vipr.model.catalog.ExecutionWindowUpdateParam)1 OrderRestRep (com.emc.vipr.model.catalog.OrderRestRep)1 ValidationError (com.emc.vipr.model.catalog.ValidationError)1 DateTimeFormatter (org.joda.time.format.DateTimeFormatter)1 Event (util.Event)1