Search in sources :

Example 11 with ExecutionWindowRestRep

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

Example 12 with ExecutionWindowRestRep

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

Example 13 with ExecutionWindowRestRep

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

Example 14 with ExecutionWindowRestRep

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);
}
Also used : ExecutionWindowRestRep(com.emc.vipr.model.catalog.ExecutionWindowRestRep) Event(util.Event) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) DateTimeZone(org.joda.time.DateTimeZone) DateTime(org.joda.time.DateTime)

Example 15 with ExecutionWindowRestRep

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

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