Search in sources :

Example 71 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult 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)

Example 72 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class DataPointDwr method getTextRendererOptions.

/**
 * Get a list of available Chart Renderers for this point
 *
 * @param vo
 * @return
 */
@DwrPermission(user = true)
public ProcessResult getTextRendererOptions(int dataTypeId) {
    ProcessResult response = new ProcessResult();
    List<ImplDefinition> list = BaseTextRenderer.getImplementation(dataTypeId);
    response.addData("options", list);
    return response;
}
Also used : ImplDefinition(com.serotonin.m2m2.view.ImplDefinition) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 73 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class DataPointDwr method getPoints.

@DwrPermission(user = true)
public ProcessResult getPoints() {
    ProcessResult result = new ProcessResult();
    User user = Common.getUser();
    if (user == null) {
        result.addData("list", new ArrayList<DataPointVO>());
        return result;
    }
    DataSourceVO<?> ds = user.getEditDataSource();
    if (ds.getId() == Common.NEW_ID) {
        result.addData("list", new ArrayList<DataPointVO>());
        return result;
    }
    List<DataPointVO> points = DataPointDao.instance.getDataPoints(ds.getId(), DataPointNameComparator.instance, false);
    result.addData("list", points);
    return result;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) User(com.serotonin.m2m2.vo.User) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 74 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class DataPointDwr method remove.

/**
 * Delete a VO
 *
 * @param id
 * @return
 */
@Override
@DwrPermission(user = true)
public ProcessResult remove(int id) {
    ProcessResult response = new ProcessResult();
    try {
        DataPointVO dp = dao.get(id);
        if (dp != null)
            Common.runtimeManager.deleteDataPoint(dp);
    } catch (Exception e) {
        // Handle the exceptions.
        LOG.error(e);
        DataPointVO vo = dao.get(id);
        if (e instanceof DataIntegrityViolationException)
            response.addContextualMessage(vo.getName(), "table.edit.unableToDeleteDueToConstraints");
        else
            response.addContextualMessage(vo.getName(), "table.edit.unableToDelete", e.getMessage());
    }
    response.addData("id", id);
    return response;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) LicenseViolatedException(com.serotonin.m2m2.LicenseViolatedException) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 75 with ProcessResult

use of com.serotonin.m2m2.i18n.ProcessResult in project ma-core-public by infiniteautomation.

the class DataPointDwr method getChartRendererOptions.

/**
 * Get a list of available Chart Renderers for this point
 *
 * @param vo
 * @return
 */
@DwrPermission(user = true)
public ProcessResult getChartRendererOptions(int dataTypeId) {
    ProcessResult response = new ProcessResult();
    List<ImplDefinition> list = BaseChartRenderer.getImplementations(dataTypeId);
    response.addData("options", list);
    return response;
}
Also used : ImplDefinition(com.serotonin.m2m2.view.ImplDefinition) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)165 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)132 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)31 User (com.serotonin.m2m2.vo.User)31 ArrayList (java.util.ArrayList)28 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)27 JsonException (com.serotonin.json.JsonException)21 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)20 JsonObject (com.serotonin.json.type.JsonObject)13 HashMap (java.util.HashMap)12 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)11 StringStringPair (com.serotonin.db.pair.StringStringPair)9 RestProcessResult (com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult)9 IOException (java.io.IOException)9 ShouldNeverHappenException (com.serotonin.ShouldNeverHappenException)8 ProcessMessage (com.serotonin.m2m2.i18n.ProcessMessage)8 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)8 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)7 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7