Search in sources :

Example 6 with MaintenanceEventVO

use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.

the class MaintenanceEventTypeModelMapping method map.

@Override
public MaintenanceEventTypeModel map(Object o, PermissionHolder user, RestModelMapper mapper) {
    MaintenanceEventType type = (MaintenanceEventType) o;
    MaintenanceEventVO vo = MaintenanceEventDao.getInstance().get(type.getReferenceId1());
    MaintenanceEventTypeModel model;
    if (vo != null)
        model = new MaintenanceEventTypeModel(type, new MaintenanceEventModel(vo));
    else
        model = new MaintenanceEventTypeModel(type);
    return model;
}
Also used : MaintenanceEventVO(com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO) MaintenanceEventType(com.serotonin.m2m2.maintenanceEvents.MaintenanceEventType)

Example 7 with MaintenanceEventVO

use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsService method validate.

@Override
public ProcessResult validate(MaintenanceEventVO vo) {
    ProcessResult result = commonValidation(vo);
    PermissionHolder user = Common.getUser();
    permissionService.validatePermission(result, "togglePermission", user, vo.getTogglePermission());
    return result;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder)

Example 8 with MaintenanceEventVO

use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsService method update.

@Override
protected MaintenanceEventVO update(MaintenanceEventVO existing, MaintenanceEventVO vo) throws PermissionException, ValidationException {
    PermissionHolder user = Common.getUser();
    ensureEditPermission(user, existing);
    vo.setId(existing.getId());
    ensureValid(existing, vo);
    RTMDefinition.instance.saveMaintenanceEvent(vo);
    return vo;
}
Also used : PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder)

Example 9 with MaintenanceEventVO

use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsService method delete.

/**
 * Delete an event
 */
@Override
protected MaintenanceEventVO delete(MaintenanceEventVO vo) throws PermissionException, NotFoundException {
    PermissionHolder user = Common.getUser();
    ensureEditPermission(user, vo);
    RTMDefinition.instance.deleteMaintenanceEvent(vo.getId());
    return vo;
}
Also used : PermissionHolder(com.serotonin.m2m2.vo.permission.PermissionHolder)

Example 10 with MaintenanceEventVO

use of com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsJavascriptTestUtility method update.

@Override
public MaintenanceEventVO update(String existingXid, MaintenanceEventVO vo) throws NotFoundException, PermissionException, ValidationException {
    return this.runAs.runAs(permissions, () -> {
        MaintenanceEventVO existing = meService.get(existingXid);
        meService.ensureEditPermission(permissions, existing);
        // Don't change ID ever
        vo.setId(existing.getId());
        meService.ensureValid(vo);
        return vo;
    });
}
Also used : MaintenanceEventVO(com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO)

Aggregations

MaintenanceEventVO (com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO)17 ArrayList (java.util.ArrayList)9 ApiOperation (io.swagger.annotations.ApiOperation)8 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)8 MaintenanceEventModel (com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel)7 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)7 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)5 IDataPoint (com.serotonin.m2m2.vo.IDataPoint)5 PermissionHolder (com.serotonin.m2m2.vo.permission.PermissionHolder)5 NotFoundException (com.infiniteautomation.mango.util.exception.NotFoundException)4 HashMap (java.util.HashMap)4 List (java.util.List)4 MangoPermission (com.infiniteautomation.mango.permission.MangoPermission)3 ValidationException (com.infiniteautomation.mango.util.exception.ValidationException)3 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)3 URI (java.net.URI)3 HashSet (java.util.HashSet)3 HttpHeaders (org.springframework.http.HttpHeaders)3 ResponseEntity (org.springframework.http.ResponseEntity)3 MaintenanceEventsService (com.infiniteautomation.mango.spring.service.maintenanceEvents.MaintenanceEventsService)2