use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsDwr method saveMaintenanceEvent.
@DwrPermission(admin = true)
public ProcessResult saveMaintenanceEvent(int id, String xid, int dataSourceId, String alias, int alarmLevel, int scheduleType, boolean disabled, int activeYear, int activeMonth, int activeDay, int activeHour, int activeMinute, int activeSecond, String activeCron, int inactiveYear, int inactiveMonth, int inactiveDay, int inactiveHour, int inactiveMinute, int inactiveSecond, String inactiveCron) {
MaintenanceEventVO e = new MaintenanceEventVO();
e.setId(id);
e.setXid(xid);
e.setDataSourceId(dataSourceId);
e.setAlias(alias);
e.setAlarmLevel(alarmLevel);
e.setScheduleType(scheduleType);
e.setDisabled(disabled);
e.setActiveYear(activeYear);
e.setActiveMonth(activeMonth);
e.setActiveDay(activeDay);
e.setActiveHour(activeHour);
e.setActiveMinute(activeMinute);
e.setActiveSecond(activeSecond);
e.setActiveCron(activeCron);
e.setInactiveYear(inactiveYear);
e.setInactiveMonth(inactiveMonth);
e.setInactiveDay(inactiveDay);
e.setInactiveHour(inactiveHour);
e.setInactiveMinute(inactiveMinute);
e.setInactiveSecond(inactiveSecond);
e.setInactiveCron(inactiveCron);
ProcessResult response = new ProcessResult();
MaintenanceEventDao maintenanceEventDao = new MaintenanceEventDao();
if (StringUtils.isBlank(xid))
response.addContextualMessage("xid", "validate.required");
else if (!maintenanceEventDao.isXidUnique(xid, id))
response.addContextualMessage("xid", "validate.xidUsed");
e.validate(response);
// Save the maintenance event
if (!response.getHasMessages()) {
RTMDefinition.instance.saveMaintenanceEvent(e);
response.addData("meId", e.getId());
}
return response;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method setReadPermission.
@Override
void setReadPermission(MangoPermission permission, MaintenanceEventVO vo) {
// A user with read permission for all data points (and sources) in this event has read permission
if (permission != null) {
// Get the data points and add our roles to the read roles
for (int dpId : vo.getDataPoints()) {
DataPointVO dp = DataPointDao.getInstance().get(dpId);
dp.setReadPermission(permission);
DataPointDao.getInstance().update(dp.getId(), dp);
}
}
vo.setTogglePermission(permission);
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method updateVO.
@Override
MaintenanceEventVO updateVO(MaintenanceEventVO existing) {
MaintenanceEventVO copy = (MaintenanceEventVO) existing.copy();
copy.setName("new name");
List<Integer> dataPointIds = new ArrayList<>();
for (IDataPoint point : createMockDataPoints(10)) {
dataPointIds.add(point.getId());
}
copy.setDataPoints(dataPointIds);
return copy;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method setEditPermission.
@Override
void setEditPermission(MangoPermission permission, MaintenanceEventVO vo) {
// A user with edit permission for the sources of all points (and all data sources sources) in this event has edit permission
if (permission != null) {
// Get the data points and add our roles to the read roles
for (int dpId : vo.getDataPoints()) {
DataPointVO dp = DataPointDao.getInstance().get(dpId);
dp.setEditPermission(permission);
DataPointDao.getInstance().update(dp.getId(), dp);
DataSourceVO ds = DataSourceDao.getInstance().get(dp.getDataSourceId());
ds.setEditPermission(permission);
DataSourceDao.getInstance().update(ds.getId(), ds);
}
}
vo.setTogglePermission(permission);
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsServiceTest method newVO.
@Override
MaintenanceEventVO newVO(User owner) {
MaintenanceEventVO vo = new MaintenanceEventVO();
vo.setName(UUID.randomUUID().toString());
List<Integer> dataPointIds = new ArrayList<>();
for (IDataPoint point : createMockDataPoints(5)) {
dataPointIds.add(point.getId());
}
vo.setDataPoints(dataPointIds);
return vo;
}
Aggregations