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 ExecutionWindowMapper method map.
public static ExecutionWindowRestRep map(ExecutionWindow from) {
if (from == null) {
return null;
}
ExecutionWindowRestRep to = new ExecutionWindowRestRep();
mapDataObjectFields(from, to);
to.setDayOfMonth(from.getDayOfMonth());
to.setDayOfWeek(from.getDayOfWeek());
to.setExecutionWindowLength(from.getExecutionWindowLength());
to.setExecutionWindowLengthType(from.getExecutionWindowLengthType());
to.setExecutionWindowType(from.getExecutionWindowType());
to.setHourOfDayInUTC(from.getHourOfDayInUTC());
to.setLastDayOfMonth(from.getLastDayOfMonth());
to.setMinuteOfHourInUTC(from.getMinuteOfHourInUTC());
to.setTenant(toRelatedResource(ResourceTypeEnum.TENANT, uri(from.getTenant())));
return to;
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowUtils method isOverlapping.
public static boolean isOverlapping(ExecutionWindowRestRep newExecutionWindow) {
DateTimeZone tz = DateTimeZone.UTC;
List<ExecutionWindowRestRep> executionWindows = ExecutionWindowUtils.getExecutionWindows();
DateTime startOfWeek = getStartOfWeek(tz);
DateTime endDateTime = startOfWeek.plusDays(31);
List<Event> events = asEvents(executionWindows, startOfWeek, endDateTime, tz);
List<Event> newEvents = asEvents(newExecutionWindow, startOfWeek, endDateTime, tz, 365);
for (Event event : events) {
for (Event newEvent : newEvents) {
if (isOverlapping(event, newEvent)) {
if (Logger.isDebugEnabled()) {
Logger.debug("Overlapping events: " + event + " and " + event);
}
return true;
}
}
}
return false;
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowsApi method create.
public static void create(ExecutionWindowInfo info) {
ExecutionWindowRestRep window = new ExecutionWindowRestRep();
copyExecutionWindowInfoToExecutionWindow(info, window);
createForm(window).validate("executionWindowForm");
if (validation.hasErrors()) {
response.status = HttpStatus.SC_BAD_REQUEST;
renderApi(getValidationErrors());
} else {
ExecutionWindowCreateParam createParam = new ExecutionWindowCreateParam();
map(createParam, info);
ExecutionWindowUtils.createExecutionWindow(createParam);
info.setId(window.getId().toString());
renderApi(info);
}
}
use of com.emc.vipr.model.catalog.ExecutionWindowRestRep in project coprhd-controller by CoprHD.
the class ExecutionWindowsApi method delete.
public static void delete(String executionWindowId) {
ExecutionWindowRestRep window = ExecutionWindowUtils.getExecutionWindow(uri(executionWindowId));
if (window != null) {
ExecutionWindowUtils.deleteExecutionWindow(window);
renderApi(executionWindowId);
} else {
notFound(Messages.get("ExecutionWindowsApi.windowWithId", executionWindowId));
}
}
Aggregations