Search in sources :

Example 76 with DwrPermission

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

the class DataPointDwr method storeEditLoggingProperties.

/**
 * Store the logging properties into the
 * current user's edit point.
 *
 * This is still being used on the page, but could be brought forward by putting the logging properties
 * into the DWR system
 *
 * @param type
 * @param period
 * @param periodType
 * @param intervalType
 * @param tolerance
 * @param discardExtremeValues
 * @param discardHighLimit
 * @param discardLowLimit
 * @param purgeOverride
 * @param purgeType
 * @param purgePeriod
 * @param defaultCacheSize
 */
@DwrPermission(user = true)
public void storeEditLoggingProperties(int type, int period, int periodType, int intervalType, double tolerance, boolean discardExtremeValues, double discardHighLimit, double discardLowLimit, boolean purgeOverride, int purgeType, int purgePeriod, int defaultCacheSize, boolean overrideIntervalLoggingSamples, int intervalLoggingSampleWindowSize) {
    DataPointVO dp = Common.getUser().getEditPoint();
    if (dp != null) {
        dp.setLoggingType(type);
        dp.setIntervalLoggingPeriod(period);
        dp.setIntervalLoggingPeriodType(periodType);
        dp.setIntervalLoggingType(intervalType);
        dp.setTolerance(tolerance);
        dp.setDiscardExtremeValues(discardExtremeValues);
        dp.setDiscardHighLimit(discardHighLimit);
        dp.setDiscardLowLimit(discardLowLimit);
        dp.setPurgeOverride(purgeOverride);
        dp.setPurgeType(purgeType);
        dp.setPurgePeriod(purgePeriod);
        dp.setDefaultCacheSize(defaultCacheSize);
        dp.setOverrideIntervalLoggingSamples(overrideIntervalLoggingSamples);
        dp.setIntervalLoggingSampleWindowSize(intervalLoggingSampleWindowSize);
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 77 with DwrPermission

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

the class DataPointDwr method storeEditProperties.

/**
 * This method is used to pre-stage the vo for saving by the custom modules.
 *
 * All of the general properties are saved into the "Session" here for use in the modules.
 *
 * @param newDp
 */
@SuppressWarnings("deprecation")
@DwrPermission(user = true)
public void storeEditProperties(DataPointVO newDp) {
    DataPointVO dp = Common.getUser().getEditPoint();
    if (dp != null) {
        // Do we want the details set here? (The ID Name,XID and Locator are stored via the modules)
        dp.setId(newDp.getId());
        dp.setXid(newDp.getXid());
        // dp.setPointLocator(newDp.getPointLocator());
        dp.setDeviceName(newDp.getDeviceName());
        dp.setEnabled(newDp.isEnabled());
        dp.setReadPermission(newDp.getReadPermission());
        dp.setSetPermission(newDp.getSetPermission());
        dp.setTemplateId(newDp.getTemplateId());
        dp.setDataSourceId(newDp.getDataSourceId());
        // General Properties
        dp.setEngineeringUnits(newDp.getEngineeringUnits());
        dp.setUseIntegralUnit(newDp.isUseIntegralUnit());
        dp.setUseRenderedUnit(newDp.isUseRenderedUnit());
        try {
            // These won't come back from the UI as they aren't converted
            dp.setUnit(UnitUtil.parseLocal(newDp.getUnitString()));
        } catch (Exception e) {
            LOG.warn(e.getMessage(), e);
            // For validation
            dp.setUnit(null);
        }
        dp.setUnitString(newDp.getUnitString());
        try {
            dp.setRenderedUnit(UnitUtil.parseLocal(newDp.getRenderedUnitString()));
        } catch (Exception e) {
            LOG.warn(e.getMessage(), e);
            dp.setRenderedUnit(null);
        }
        dp.setRenderedUnitString(newDp.getRenderedUnitString());
        try {
            dp.setIntegralUnit(UnitUtil.parseLocal(newDp.getIntegralUnitString()));
        } catch (Exception e) {
            LOG.warn(e.getMessage(), e);
            dp.setIntegralUnit(null);
        }
        dp.setIntegralUnitString(newDp.getIntegralUnitString());
        dp.setChartColour(newDp.getChartColour());
        dp.setPlotType(newDp.getPlotType());
        dp.setSimplifyType(newDp.getSimplifyType());
        dp.setSimplifyTolerance(newDp.getSimplifyTolerance());
        dp.setSimplifyTarget(newDp.getSimplifyTarget());
        // Logging Properties
        dp.setLoggingType(newDp.getLoggingType());
        dp.setIntervalLoggingPeriod(newDp.getIntervalLoggingPeriod());
        dp.setIntervalLoggingPeriodType(newDp.getIntervalLoggingPeriodType());
        dp.setIntervalLoggingType(newDp.getIntervalLoggingType());
        dp.setTolerance(newDp.getTolerance());
        dp.setDiscardExtremeValues(newDp.isDiscardExtremeValues());
        dp.setDiscardHighLimit(newDp.getDiscardHighLimit());
        dp.setDiscardLowLimit(newDp.getDiscardLowLimit());
        dp.setPurgeOverride(newDp.isPurgeOverride());
        dp.setPurgeType(newDp.getPurgeType());
        dp.setPurgePeriod(newDp.getPurgePeriod());
        dp.setDefaultCacheSize(newDp.getDefaultCacheSize());
        dp.setOverrideIntervalLoggingSamples(newDp.isOverrideIntervalLoggingSamples());
        dp.setIntervalLoggingSampleWindowSize(newDp.getIntervalLoggingSampleWindowSize());
        // Chart Renderer
        dp.setChartRenderer(newDp.getChartRenderer());
        dp.setRollup(newDp.getRollup());
        // Text Renderer
        dp.setTextRenderer(newDp.getTextRenderer());
        // Extreme sets
        dp.setPreventSetExtremeValues(newDp.isPreventSetExtremeValues());
        dp.setSetExtremeLowLimit(newDp.getSetExtremeLowLimit());
        dp.setSetExtremeHighLimit(newDp.getSetExtremeHighLimit());
    }
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataIntegrityViolationException(org.springframework.dao.DataIntegrityViolationException) LicenseViolatedException(com.serotonin.m2m2.LicenseViolatedException) DuplicateKeyException(org.springframework.dao.DuplicateKeyException) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 78 with DwrPermission

use of com.serotonin.m2m2.web.dwr.util.DwrPermission 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)

Example 79 with DwrPermission

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

the class DataPointDwr method getUnitsList.

@DwrPermission(user = true)
public ProcessResult getUnitsList() {
    ProcessResult result = new ProcessResult();
    List<DojoMemoryStoreListItem> pairs = new ArrayList<>();
    // Get SI Units
    int id = 0;
    for (Unit<?> unit : SI.getInstance().getUnits()) {
        pairs.add(new DojoMemoryStoreListItem(unit.toString(), id++));
    }
    // Get US Units
    for (Unit<?> unit : NonSI.getInstance().getUnits()) {
        pairs.add(new DojoMemoryStoreListItem(unit.toString(), id++));
    }
    List<String> addedUnits = UnitUtil.getAddedUnitLabels();
    for (String unit : addedUnits) {
        pairs.add(new DojoMemoryStoreListItem(unit, id++));
    }
    Collections.sort(pairs, new Comparator<DojoMemoryStoreListItem>() {

        @Override
        public int compare(DojoMemoryStoreListItem arg0, DojoMemoryStoreListItem arg1) {
            return arg0.getName().compareToIgnoreCase(arg1.getName());
        }
    });
    result.addData("units", pairs);
    return result;
}
Also used : DojoMemoryStoreListItem(com.serotonin.m2m2.web.dojo.DojoMemoryStoreListItem) ProcessResult(com.serotonin.m2m2.i18n.ProcessResult) ArrayList(java.util.ArrayList) DwrPermission(com.serotonin.m2m2.web.dwr.util.DwrPermission)

Example 80 with DwrPermission

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

the class DataPointEditDwr method addEventDetector.

@DwrPermission(user = true)
public AbstractPointEventDetectorVO<?> addEventDetector(String typeName, int newId) {
    DataPointVO dp = getDataPoint();
    EventDetectorDefinition<?> definition = ModuleRegistry.getEventDetectorDefinition(typeName);
    AbstractPointEventDetectorVO<?> ped = (AbstractPointEventDetectorVO<?>) definition.baseCreateEventDetectorVO();
    ped.setXid(EventDetectorDao.instance.generateUniqueXid());
    ped.setName("");
    ped.setId(newId);
    synchronized (dp) {
        ped.setSourceId(dp.getId());
        ped.njbSetDataPoint(dp);
        dp.getEventDetectors().add(ped);
    }
    return ped;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) AbstractPointEventDetectorVO(com.serotonin.m2m2.vo.event.detector.AbstractPointEventDetectorVO) 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