Search in sources :

Example 91 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 92 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)

Example 93 with DataPointVO

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

the class DataPointDwr method getFull.

/*
     * (non-Javadoc)
     * 
     * @see com.deltamation.mango.downtime.web.AbstractBasicDwr#getFull(int)
     */
@DwrPermission(user = true)
@Override
public ProcessResult getFull(int id) {
    DataPointVO vo;
    User user = Common.getUser();
    if (id == Common.NEW_ID) {
        vo = dao.getNewVo();
        // TODO Need to sort this out another way, this will wreck
        // when users have mulitple tabs open in a browser
        DataSourceVO<?> ds = user.getEditDataSource();
        vo.setXid(dao.generateUniqueXid());
        vo.setPointLocator(ds.createPointLocator());
        vo.setDataSourceId(ds.getId());
        vo.setDataSourceName(ds.getName());
        vo.setDataSourceTypeName(ds.getDefinition().getDataSourceTypeName());
        vo.setDataSourceXid(ds.getXid());
        vo.setDeviceName(ds.getName());
        vo.setEventDetectors(new ArrayList<AbstractPointEventDetectorVO<?>>(0));
        vo.defaultTextRenderer();
    } else {
        vo = dao.getFull(id);
    }
    // Should check permissions?
    // Permissions.ensureDataSourcePermission(user, vo.getDataSourceId());
    user.setEditPoint(vo);
    // TODO Need to deal with point value defaulter
    ProcessResult response = new ProcessResult();
    response.addData("vo", vo);
    return response;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) User(com.serotonin.m2m2.vo.User) AbstractPointEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 94 with DataPointVO

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

the class DataPointDwr method jsonExportUsingFilter.

/**
 * Export VOs based on a filter
 *
 * @param id
 * @return
 */
@SuppressWarnings("unchecked")
@DwrPermission(user = true)
public String jsonExportUsingFilter(Map<String, String> query, List<SortOption> sort, Integer start, Integer count, boolean or) {
    Map<String, Object> data = new LinkedHashMap<>();
    List<DataPointVO> vos = new ArrayList<>();
    ResultsWithTotal results = dao.dojoQuery(query, sort, start, count, or);
    List<DataPointVO> filteredPoints = (List<DataPointVO>) results.getResults();
    // Filter list on User Permissions
    User user = Common.getUser();
    for (DataPointVO vo : filteredPoints) {
        if (Permissions.hasDataPointReadPermission(user, vo)) {
            dao.loadRelationalData(vo);
            vos.add(vo);
        }
    }
    // Get the Full VO for the export
    data.put(keyName, vos);
    return EmportDwr.export(data, 3);
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) ResultsWithTotal(com.serotonin.m2m2.db.dao.ResultsWithTotal) User(com.serotonin.m2m2.vo.User) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 95 with DataPointVO

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

the class DataPointDwr method toggle.

@DwrPermission(user = true)
public ProcessResult toggle(int dataPointId) {
    DataPointVO dataPoint = DataPointDao.instance.getFull(dataPointId);
    Permissions.ensureDataSourcePermission(Common.getUser(), dataPoint.getDataSourceId());
    dataPoint.setEnabled(!dataPoint.isEnabled());
    Common.runtimeManager.saveDataPoint(dataPoint);
    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