Search in sources :

Example 16 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.

the class BaseDwr method forcePointRead.

@DwrPermission(user = true)
public void forcePointRead(int pointId) {
    User user = Common.getUser();
    DataPointVO point = DataPointDao.instance.getDataPoint(pointId, false);
    // Check permissions.
    Permissions.ensureDataPointReadPermission(user, point);
    Common.runtimeManager.forcePointRead(pointId);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) User(com.serotonin.m2m2.vo.User) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 17 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.

the class BaseDwr method setChart.

protected static void setChart(DataPointVO point, BasePointState state, HttpServletRequest request, Map<String, Object> model) {
    ChartRenderer chartRenderer = point.getChartRenderer();
    if (chartRenderer != null) {
        chartRenderer.addDataToModel(model, point);
        String snippet = chartRenderer.getChartSnippetFilename();
        state.setChart(generateContent(request, snippet, model));
    }
}
Also used : ChartRenderer(com.serotonin.m2m2.view.chart.ChartRenderer)

Example 18 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.

the class BaseDwr method setEvents.

protected static void setEvents(DataPointVO pointVO, User user, Map<String, Object> model, int limit) {
    int userId = 0;
    if (user != null)
        userId = user.getId();
    List<EventInstance> userEvents = Common.eventManager.getAllActiveUserEvents(userId);
    // EVENT_DAO.getPendingEventsForDataPoint(pointVO.getId(), userId);
    // Fill the list in reverse order so the latest is first
    List<EventInstance> list = null;
    if (userEvents.size() > 0) {
        for (int i = userEvents.size() - 1; i >= 0; i--) {
            EventInstance e = userEvents.get(i);
            if (e.getEventType().getDataPointId() == pointVO.getId()) {
                if (list == null)
                    list = new ArrayList<EventInstance>();
                list.add(e);
                if (list.size() == limit)
                    break;
            }
        }
    }
    if (list != null) {
        model.put(MODEL_ATTR_EVENTS, list);
        for (EventInstance event : list) {
            if (!event.isAcknowledged()) {
                model.put(MODEL_ATTR_HAS_UNACKED_EVENT, true);
                break;
            }
        }
    }
}
Also used : EventInstance(com.serotonin.m2m2.rt.event.EventInstance) ArrayList(java.util.ArrayList)

Example 19 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.

the class DataPointDetailsDwr method getStatsChartData.

@DwrPermission(user = true)
public ProcessResult getStatsChartData(int periodType, int period, boolean includeSum) {
    HttpServletRequest request = WebContextFactory.get().getHttpServletRequest();
    DataPointVO pointVO = Common.getUser(request).getEditPoint();
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("point", pointVO);
    StatisticsChartRenderer r = new StatisticsChartRenderer(periodType, period, includeSum);
    r.addDataToModel(model, pointVO);
    ProcessResult response = new ProcessResult();
    response.addData("stats", generateContent(request, "statsChart.jsp", model));
    addAsof(response);
    return response;
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) DataPointVO(com.serotonin.m2m2.vo.DataPointVO) StatisticsChartRenderer(com.serotonin.m2m2.view.chart.StatisticsChartRenderer) HashMap(java.util.HashMap) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 20 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO in project ma-core-public by infiniteautomation.

the class DataPointDwr method enableDisable.

@DwrPermission(user = true)
public ProcessResult enableDisable(int dataPointId, boolean enabled) {
    DataPointVO dataPoint = DataPointDao.instance.getDataPoint(dataPointId, false);
    Permissions.ensureDataSourcePermission(Common.getUser(), dataPoint.getDataSourceId());
    if (enabled)
        DataPointDao.instance.setEventDetectors(dataPoint);
    Common.runtimeManager.enableDataPoint(dataPoint, enabled);
    ProcessResult response = new ProcessResult();
    response.addData("id", dataPointId);
    response.addData("enabled", dataPoint.isEnabled());
    return response;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

DataPointVO (com.serotonin.m2m2.vo.DataPointVO)196 User (com.serotonin.m2m2.vo.User)62 ArrayList (java.util.ArrayList)53 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)48 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)40 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)40 HashMap (java.util.HashMap)35 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)33 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)32 PermissionException (com.serotonin.m2m2.vo.permission.PermissionException)30 NotFoundRestException (com.infiniteautomation.mango.rest.v2.exception.NotFoundRestException)29 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)28 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)26 DataPointDao (com.serotonin.m2m2.db.dao.DataPointDao)21 DataPointRT (com.serotonin.m2m2.rt.dataImage.DataPointRT)21 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)16 AbstractPointEventDetectorVO (com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO)15 List (java.util.List)15 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)14 IOException (java.io.IOException)12