Search in sources :

Example 96 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO 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 97 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO 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 98 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO 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 99 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO 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 100 with DataPointVO

use of com.serotonin.m2m2.vo.DataPointVO 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

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