use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsDwr method getMaintenanceEvent.
@DwrPermission(admin = true)
public ProcessResult getMaintenanceEvent(int id) {
ProcessResult response = new ProcessResult();
MaintenanceEventVO me;
boolean activated = false;
if (id == Common.NEW_ID) {
DateTime dt = new DateTime();
me = new MaintenanceEventVO();
me.setXid(new MaintenanceEventDao().generateUniqueXid());
me.setActiveYear(dt.getYear());
me.setInactiveYear(dt.getYear());
me.setActiveMonth(dt.getMonthOfYear());
me.setInactiveMonth(dt.getMonthOfYear());
} else {
me = new MaintenanceEventDao().getMaintenanceEvent(id);
MaintenanceEventRT rt = RTMDefinition.instance.getRunningMaintenanceEvent(me.getId());
if (rt != null)
activated = rt.isEventActive();
}
response.addData("me", me);
response.addData("activated", activated);
return response;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventsDwr method getMaintenanceEvents.
@DwrPermission(admin = true)
public ProcessResult getMaintenanceEvents() {
ProcessResult response = new ProcessResult();
final Translations translations = getTranslations();
List<MaintenanceEventVO> events = new MaintenanceEventDao().getMaintenanceEvents();
Collections.sort(events, new Comparator<MaintenanceEventVO>() {
@Override
public int compare(MaintenanceEventVO m1, MaintenanceEventVO m2) {
return m1.getDescription().translate(translations).compareTo(m1.getDescription().translate(translations));
}
});
response.addData(MODEL_ATTR_EVENTS, events);
List<IntStringPair> dataSources = new ArrayList<IntStringPair>();
for (DataSourceVO<?> ds : DataSourceDao.instance.getDataSources()) dataSources.add(new IntStringPair(ds.getId(), ds.getName()));
response.addData("dataSources", dataSources);
return response;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventEmportDefinition method doImport.
@Override
public void doImport(JsonValue jsonValue, ImportContext importContext) throws JsonException {
MaintenanceEventDao maintenanceEventDao = new MaintenanceEventDao();
JsonObject maintenanceEvent = jsonValue.toJsonObject();
String xid = maintenanceEvent.getString("xid");
if (StringUtils.isBlank(xid))
xid = maintenanceEventDao.generateUniqueXid();
MaintenanceEventVO vo = maintenanceEventDao.getMaintenanceEvent(xid);
if (vo == null) {
vo = new MaintenanceEventVO();
vo.setXid(xid);
}
try {
importContext.getReader().readInto(vo, maintenanceEvent);
// Now validate it. Use a new response object so we can distinguish errors in this vo from other errors.
ProcessResult voResponse = new ProcessResult();
vo.validate(voResponse);
if (voResponse.getHasMessages())
// Too bad. Copy the errors into the actual response.
importContext.copyValidationMessages(voResponse, "emport.maintenanceEvent.prefix", xid);
else {
// Sweet. Save it.
boolean isnew = vo.isNew();
RTMDefinition.instance.saveMaintenanceEvent(vo);
importContext.addSuccessMessage(isnew, "emport.maintenanceEvent.prefix", xid);
}
} catch (TranslatableJsonException e) {
importContext.getResult().addGenericMessage("emport.maintenanceEvent.prefix", xid, e.getMsg());
} catch (JsonException e) {
importContext.getResult().addGenericMessage("emport.maintenanceEvent.prefix", xid, importContext.getJsonExceptionMessage(e));
}
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventDao method toRecord.
@Override
protected Record toRecord(MaintenanceEventVO me) {
Record record = table.newRecord();
record.set(table.xid, me.getXid());
record.set(table.alias, me.getName());
record.set(table.alarmLevel, me.getAlarmLevel().value());
record.set(table.scheduleType, me.getScheduleType());
record.set(table.disabled, boolToChar(me.isDisabled()));
record.set(table.activeYear, me.getActiveYear());
record.set(table.activeMonth, me.getActiveMonth());
record.set(table.activeDay, me.getActiveDay());
record.set(table.activeHour, me.getActiveHour());
record.set(table.activeMinute, me.getActiveMinute());
record.set(table.activeSecond, me.getActiveSecond());
record.set(table.activeCron, me.getActiveCron());
record.set(table.inactiveYear, me.getInactiveYear());
record.set(table.inactiveMonth, me.getInactiveMonth());
record.set(table.inactiveDay, me.getInactiveDay());
record.set(table.inactiveHour, me.getInactiveHour());
record.set(table.inactiveMinute, me.getInactiveMinute());
record.set(table.inactiveSecond, me.getInactiveSecond());
record.set(table.inactiveCron, me.getInactiveCron());
record.set(table.timeoutPeriods, me.getTimeoutPeriods());
record.set(table.timeoutPeriodType, me.getTimeoutPeriodType());
record.set(table.togglePermissionId, me.getTogglePermission().getId());
return record;
}
use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.
the class MaintenanceEventDao method getForDataPoint.
/**
* Get all maintenance events that have this data point in their list OR the its data source in the list
*/
public void getForDataPoint(String dataPointXid, Consumer<MaintenanceEventVO> callback) {
DataPointVO vo = dataPointDao.getByXid(dataPointXid);
if (vo == null)
return;
getForDataPoint(vo, callback);
}
Aggregations