Search in sources :

Example 6 with MaintenanceEventModel

use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsRestController method getForSourcesByXid.

@ApiOperation(value = "Find Maintenance Events linked to data sources by source XIDs", notes = "Returns a map of source xids to a list of events that have this data source in thier list", response = Map.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "/query/get-for-sources-by-xids/{sourceXids}")
public Map<String, List<MaintenanceEventModel>> getForSourcesByXid(@PathVariable(required = true) List<String> sourceXids, HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
    Map<String, List<MaintenanceEventModel>> map = new HashMap<>();
    for (String xid : sourceXids) {
        List<MaintenanceEventModel> models = new ArrayList<>();
        map.put(xid, models);
        if (xid != null) {
            dao.getForDataSource(xid, new Consumer<MaintenanceEventVO>() {

                @Override
                public void accept(MaintenanceEventVO vo) {
                    MaintenanceEventModel model = new MaintenanceEventModel(vo);
                    fillDataPoints(model);
                    fillDataSources(model);
                    models.add(model);
                }
            });
        }
    }
    return map;
}
Also used : MaintenanceEventVO(com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO) MaintenanceEventModel(com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with MaintenanceEventModel

use of com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel in project ma-modules-public by infiniteautomation.

the class MaintenanceEventsRestController method getForSourcesByIds.

@ApiOperation(value = "Find Maintenance Events linked to data sources by source IDs", notes = "Returns a map of source ids to a list of events that have this data source in thier list", response = Map.class, responseContainer = "List")
@RequestMapping(method = RequestMethod.GET, value = "/query/get-for-sources-by-ids/{sourceIds}")
public Map<Integer, List<MaintenanceEventModel>> getForSourcesByIds(@PathVariable(required = true) List<Integer> sourceIds, HttpServletRequest request, @AuthenticationPrincipal PermissionHolder user) {
    Map<Integer, List<MaintenanceEventModel>> map = new HashMap<>();
    for (Integer id : sourceIds) {
        List<MaintenanceEventModel> models = new ArrayList<>();
        map.put(id, models);
        dao.getForDataSource(id, new Consumer<MaintenanceEventVO>() {

            @Override
            public void accept(MaintenanceEventVO vo) {
                MaintenanceEventModel model = new MaintenanceEventModel(vo);
                fillDataPoints(model);
                fillDataSources(model);
                models.add(model);
            }
        });
    }
    return map;
}
Also used : MaintenanceEventVO(com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO) MaintenanceEventModel(com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

MaintenanceEventModel (com.infiniteautomation.mango.rest.latest.model.MaintenanceEventModel)7 MaintenanceEventVO (com.serotonin.m2m2.maintenanceEvents.MaintenanceEventVO)7 ApiOperation (io.swagger.annotations.ApiOperation)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 ArrayList (java.util.ArrayList)4 HashMap (java.util.HashMap)4 List (java.util.List)4 URI (java.net.URI)3 HttpHeaders (org.springframework.http.HttpHeaders)3 ResponseEntity (org.springframework.http.ResponseEntity)3