Search in sources :

Example 21 with DwrPermission

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

the class GraphicalViewDwr method saveAnalogGraphicComponent.

@DwrPermission(user = true)
public ProcessResult saveAnalogGraphicComponent(String viewComponentId, double min, double max, boolean displayText, String imageSetId) {
    ProcessResult response = new ProcessResult();
    // Validate
    if (min >= max)
        response.addContextualMessage("graphicRendererAnalogMin", "viewEdit.graphic.invalidMinMax");
    ImageSet imageSet = getImageSet(imageSetId);
    if (imageSet == null)
        response.addContextualMessage("graphicRendererAnalogImageSet", "viewEdit.graphic.missingImageSet");
    if (!response.getHasMessages()) {
        AnalogGraphicComponent c = (AnalogGraphicComponent) getViewComponent(viewComponentId);
        c.setMin(min);
        c.setMax(max);
        c.setDisplayText(displayText);
        c.tsetImageSet(imageSet);
        resetPointComponent(c);
    }
    return response;
}
Also used : AnalogGraphicComponent(com.serotonin.m2m2.gviews.component.AnalogGraphicComponent) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageSet(com.serotonin.m2m2.view.ImageSet) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 22 with DwrPermission

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

the class GraphicalViewDwr method saveImageChartComponent.

@DwrPermission(user = true)
public ProcessResult saveImageChartComponent(String viewComponentId, String name, int width, int height, int durationType, int durationPeriods, int updatePeriodType, int updatePeriods, List<StringStringPair> childPointIds) {
    ProcessResult response = new ProcessResult();
    validateCompoundComponent(response, name);
    if (width < 1)
        response.addContextualMessage("imageChartWidth", "validate.greaterThanZero");
    if (height < 1)
        response.addContextualMessage("imageChartHeight", "validate.greaterThanZero");
    if (!Common.TIME_PERIOD_CODES.isValidId(durationType))
        response.addContextualMessage("imageChartDurationType", "validate.invalidValue");
    if (durationPeriods <= 0)
        response.addContextualMessage("imageChartDurationPeriods", "validate.greaterThanZero");
    if (!Common.TIME_PERIOD_CODES.isValidId(updatePeriodType))
        response.addContextualMessage("imageChartUpdatePeriodType", "validate.invalidValue");
    if (updatePeriods < 0)
        response.addContextualMessage("imageChartUpdatePeriods", "validate.cannotBeNegative");
    if (!response.getHasMessages()) {
        ImageChartComponent c = (ImageChartComponent) getViewComponent(viewComponentId);
        c.setName(name);
        c.setWidth(width);
        c.setHeight(height);
        c.setDurationType(durationType);
        c.setDurationPeriods(durationPeriods);
        c.setUpdatePeriodType(updatePeriodType);
        c.setUpdatePeriods(updatePeriods);
        saveCompoundPoints(c, childPointIds);
    }
    return response;
}
Also used : ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ImageChartComponent(com.serotonin.m2m2.gviews.component.ImageChartComponent) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 23 with DwrPermission

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

the class GraphicalViewDwr method setViewPoint.

/**
 * Allows the setting of a given data point. Overrides BaseDwr to resolve the point view id.
 *
 * @param pointId
 * @param valueStr
 * @return
 */
@DwrPermission(user = true)
public String setViewPoint(String viewComponentId, String valueStr) {
    User user = Common.getUser();
    GraphicalView view = GraphicalViewsCommon.getUserView(user);
    DataPointVO point = view.findDataPoint(viewComponentId);
    if (point != null) {
        // Check that setting is allowed.
        if (!view.isSetter(user))
            throw new PermissionException(new TranslatableMessage("permission.exception.setDataPoint", user.getUsername()), user);
        // Try setting the point.
        setPointImpl(point, valueStr, user);
    }
    return viewComponentId;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) PermissionException(com.serotonin.m2m2.vo.permission.PermissionException) ShareUser(com.serotonin.m2m2.view.ShareUser) AnonymousUser(com.serotonin.m2m2.vo.AnonymousUser) User(com.serotonin.m2m2.vo.User) TranslatableMessage(com.serotonin.m2m2.i18n.TranslatableMessage) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 24 with DwrPermission

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

the class GraphicalViewDwr method saveHtmlComponent.

// 
// Save view component
// 
@DwrPermission(user = true)
public void saveHtmlComponent(String viewComponentId, String content) {
    HtmlComponent c = (HtmlComponent) getViewComponent(viewComponentId);
    c.setContent(content);
}
Also used : HtmlComponent(com.serotonin.m2m2.gviews.component.HtmlComponent) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 25 with DwrPermission

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

the class GraphicalViewDwr method saveView.

@DwrPermission(user = true)
public ProcessResult saveView(String name, String xid, int anonymousAccess, String readPermission, String setPermission, String editPermission) {
    ProcessResult result = new ProcessResult();
    User user = Common.getUser();
    GraphicalView view = GraphicalViewsCommon.getUserEditView(user);
    view.setName(name);
    view.setXid(xid);
    view.setAnonymousAccess(anonymousAccess);
    view.setReadPermission(readPermission);
    view.setSetPermission(setPermission);
    view.setEditPermission(editPermission);
    view.validate(result);
    if (!result.getHasMessages()) {
        view.setUserId(user.getId());
        new GraphicalViewDao().saveView(view);
        result.addData("view", view);
    }
    return result;
}
Also used : ShareUser(com.serotonin.m2m2.view.ShareUser) AnonymousUser(com.serotonin.m2m2.vo.AnonymousUser) User(com.serotonin.m2m2.vo.User) 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