Search in sources :

Example 26 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveMultistateGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveMultistateGraphicComponent(String viewComponentId, List<IntStringPair> imageStates, int defaultImage, boolean displayText, String imageSetId) {
    ProcessResult response = new ProcessResult();
    // Validate
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
        response.addContextualMessage("graphicRendererMultistateImageSet", "viewEdit.graphic.missingImageSet");
    if (!response.getHasMessages()) {
        MultistateGraphicComponent c = (MultistateGraphicComponent) getViewComponent(viewComponentId);
        c.setImageStateList(imageStates);
        c.setDefaultImage(defaultImage);
        c.setDisplayText(displayText);
        c.tsetImageSet(imageSet);
        resetPointComponent(c);
    }
    return response;
}
Also used : MultistateGraphicComponent(com.serotonin.m2m2.gviews.component.MultistateGraphicComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageSet(com.serotonin.m2m2.view.ImageSet) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 27 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveDynamicGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveDynamicGraphicComponent(String viewComponentId, double min, double max, boolean displayText, String dynamicImageId) {
    ProcessResult response = new ProcessResult();
    // Validate
    if (min >= max)
        response.addContextualMessage("graphicRendererDynamicMin", "viewEdit.graphic.invalidMinMax");
    DynamicImage dynamicImage = getDynamicImage(dynamicImageId);
    if (dynamicImage == null)
        response.addContextualMessage("graphicRendererDynamicImage", "viewEdit.graphic.missingDynamicImage");
    if (!response.getHasMessages()) {
        DynamicGraphicComponent c = (DynamicGraphicComponent) getViewComponent(viewComponentId);
        c.setMin(min);
        c.setMax(max);
        c.setDisplayText(displayText);
        c.tsetDynamicImage(dynamicImage);
        resetPointComponent(c);
    }
    return response;
}
Also used : DynamicGraphicComponent(com.serotonin.m2m2.gviews.component.DynamicGraphicComponent) DynamicImage(com.serotonin.m2m2.view.DynamicImage) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 28 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method setPointComponentSettings.

@DwrPermission(user = true)
public ProcessResult setPointComponentSettings(String pointComponentId, int dataPointId, String name, boolean settable, String bkgdColorOverride, int updatePeriodType, int updatePeriods, boolean displayControls, int x, int y) {
    ProcessResult response = new ProcessResult();
    PointComponent pc = (PointComponent) getViewComponent(pointComponentId);
    User user = Common.getUser();
    DataPointVO dp = DataPointDao.instance.getDataPoint(dataPointId);
    if (dp == null || !Permissions.hasDataPointReadPermission(user, dp))
        response.addContextualMessage("settingsPointInfo", "validate.required");
    if (!Common.TIME_PERIOD_CODES.isValidId(updatePeriodType))
        response.addContextualMessage("settingsUpdatePeriodType", "validate.invalidValue");
    if (updatePeriods < 0)
        response.addContextualMessage("settingsUpdatePeriods", "validate.cannotBeNegative");
    if (x < 0)
        response.addContextualMessage("settingsX", "validate.cannotBeNegative");
    if (y < 0)
        response.addContextualMessage("settingsY", "validate.cannotBeNegative");
    if (!response.getHasMessages()) {
        pc.tsetDataPoint(dp);
        pc.setNameOverride(name);
        pc.setSettableOverride(settable && Permissions.hasDataPointSetPermission(user, dp));
        pc.setBkgdColorOverride(bkgdColorOverride);
        pc.setUpdatePeriodType(updatePeriodType);
        pc.setUpdatePeriods(updatePeriods);
        pc.setDisplayControls(displayControls);
        pc.setLocation(x, y);
        pc.validateDataPoint(user, false);
        response.addData("x", x);
        response.addData("y", y);
    }
    return response;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) ShareUser(com.serotonin.m2m2.view.ShareUser) AnonymousUser(com.serotonin.m2m2.vo.AnonymousUser) User(com.serotonin.m2m2.vo.User) PointComponent(com.serotonin.m2m2.gviews.component.PointComponent) SimplePointComponent(com.serotonin.m2m2.gviews.component.SimplePointComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 29 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveScriptComponent.

@DwrPermission(user = true)
public ProcessResult saveScriptComponent(String viewComponentId, String script) {
    ProcessResult response = new ProcessResult();
    // Validate
    if (StringUtils.isBlank(script))
        response.addContextualMessage("graphicRendererScriptScript", "viewEdit.graphic.missingScript");
    if (!response.getHasMessages()) {
        ScriptComponent c = (ScriptComponent) getViewComponent(viewComponentId);
        c.setScript(script);
        resetPointComponent(c);
    }
    return response;
}
Also used : ScriptComponent(com.serotonin.m2m2.gviews.component.ScriptComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 30 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission in project ma-modules-public by infiniteautomation.

the class GraphicalViewDwr method saveSimplePointComponent.

@DwrPermission(user = true)
public ProcessResult saveSimplePointComponent(String viewComponentId, boolean displayPointName, String styleAttribute) {
    SimplePointComponent c = (SimplePointComponent) getViewComponent(viewComponentId);
    c.setDisplayPointName(displayPointName);
    c.setStyleAttribute(styleAttribute);
    resetPointComponent(c);
    return new ProcessResult();
}
Also used : SimplePointComponent(com.serotonin.m2m2.gviews.component.SimplePointComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Aggregations

DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)220 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)126 User (com.serotonin.m2m2.vo.User)56 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)47 ArrayList (java.util.ArrayList)35 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)24 HashMap (java.util.HashMap)21 StringStringPair (com.serotonin.db.pair.StringStringPair)11 SystemSettingsDao (com.serotonin.m2m2.db.dao.SystemSettingsDao)11 DuplicateKeyException (org.springframework.dao.DuplicateKeyException)10 IOException (java.io.IOException)9 DateTime (org.joda.time.DateTime)9 DataIntegrityViolationException (org.springframework.dao.DataIntegrityViolationException)9 AbstractVO (com.serotonin.m2m2.vo.AbstractVO)8 AnonymousUser (com.serotonin.m2m2.vo.AnonymousUser)8 LinkedHashMap (java.util.LinkedHashMap)8 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)7 ShareUser (com.serotonin.m2m2.view.ShareUser)7 ResultsWithTotal (com.serotonin.m2m2.db.dao.ResultsWithTotal)6 ReportVO (com.serotonin.m2m2.reports.vo.ReportVO)6