Search in sources :

Example 11 with DataPointDao

use of com.serotonin.m2m2.db.dao.DataPointDao in project ma-core-public by infiniteautomation.

the class VarNames method contextToString.

public static String contextToString(List<IntStringPair> context) {
    DataPointDao dataPointDao = DataPointDao.instance;
    StringBuilder sb = new StringBuilder();
    boolean first = true;
    for (IntStringPair ivp : context) {
        DataPointVO dp = dataPointDao.getDataPoint(ivp.getKey(), false);
        if (first)
            first = false;
        else
            sb.append(", ");
        if (dp == null)
            sb.append("?=");
        else
            sb.append(dp.getExtendedName()).append("=");
        sb.append(ivp.getValue());
    }
    return sb.toString();
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao) IntStringPair(com.serotonin.db.pair.IntStringPair)

Example 12 with DataPointDao

use of com.serotonin.m2m2.db.dao.DataPointDao in project ma-core-public by infiniteautomation.

the class DeltamationCommon method validatePoint.

public static DataPointVO validatePoint(int pointId, String name, ProcessResult response, Integer dataType, boolean requireSettable) {
    DataPointDao points = DataPointDao.instance;
    DataPointVO point = points.getDataPoint(pointId);
    if (point == null) {
        response.addContextualMessage(name, "validate.noPoint");
        return null;
    }
    if (requireSettable && !point.getPointLocator().isSettable()) {
        response.addContextualMessage(name, "validate.pointNotSettable", point.getName());
    }
    if (dataType != null && point.getPointLocator().getDataTypeId() != dataType) {
        response.addContextualMessage(name, "validate.pointWrongType", point.getName());
    }
    return point;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao)

Example 13 with DataPointDao

use of com.serotonin.m2m2.db.dao.DataPointDao in project ma-modules-public by infiniteautomation.

the class DataPointRestController method getAllDataPoints.

@ApiOperation(value = "Get all data points", notes = "Only returns points available to logged in user")
@RequestMapping(method = RequestMethod.GET, produces = { "application/json" }, value = "/list")
public ResponseEntity<QueryArrayStream<DataPointVO>> getAllDataPoints(HttpServletRequest request, @ApiParam(value = "Limit the number of results", required = false) @RequestParam(value = "limit", required = false, defaultValue = "100") int limit) {
    RestProcessResult<QueryArrayStream<DataPointVO>> result = new RestProcessResult<QueryArrayStream<DataPointVO>>(HttpStatus.OK);
    User user = this.checkUser(request, result);
    if (result.isOk()) {
        ASTNode root = new ASTNode("limit", limit);
        if (user.isAdmin()) {
            // Admin Users Don't need to filter the results
            return result.createResponseEntity(getStream(root));
        } else {
            // We are going to filter the results, so we need to strip out the limit(limit,offset) or limit(limit) clause.
            DataPointStreamCallback callback = new DataPointStreamCallback(this, user);
            FilteredQueryStream<DataPointVO, DataPointModel, DataPointDao> stream = new FilteredQueryStream<DataPointVO, DataPointModel, DataPointDao>(DataPointDao.instance, this, root, callback);
            stream.setupQuery();
            return result.createResponseEntity(stream);
        }
    }
    return result.createResponseEntity();
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) RestProcessResult(com.serotonin.m2m2.web.mvc.rest.v1.message.RestProcessResult) DataPointStreamCallback(com.serotonin.m2m2.web.mvc.rest.v1.model.dataPoint.DataPointStreamCallback) DataPointModel(com.serotonin.m2m2.web.mvc.rest.v1.model.DataPointModel) User(com.serotonin.m2m2.vo.User) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao) ASTNode(net.jazdw.rql.parser.ASTNode) FilteredQueryStream(com.serotonin.m2m2.web.mvc.rest.v1.model.FilteredQueryStream) QueryArrayStream(com.serotonin.m2m2.web.mvc.rest.v1.model.QueryArrayStream) ApiOperation(com.wordnik.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 14 with DataPointDao

use of com.serotonin.m2m2.db.dao.DataPointDao in project ma-modules-public by infiniteautomation.

the class PointLinkVO method jsonWrite.

// 
// 
// Serialization
// 
@Override
public void jsonWrite(ObjectWriter writer) throws IOException, JsonException {
    DataPointDao dataPointDao = DataPointDao.instance;
    writer.writeEntry("xid", xid);
    DataPointVO dp = dataPointDao.getDataPoint(sourcePointId, false);
    if (dp != null)
        writer.writeEntry("sourcePointId", dp.getXid());
    dp = dataPointDao.getDataPoint(targetPointId, false);
    if (dp != null)
        writer.writeEntry("targetPointId", dp.getXid());
    writer.writeEntry("event", EVENT_CODES.getCode(event));
    writer.writeEntry("logLevel", ScriptLog.LOG_LEVEL_CODES.getCode(logLevel));
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao)

Example 15 with DataPointDao

use of com.serotonin.m2m2.db.dao.DataPointDao in project ma-modules-public by infiniteautomation.

the class ReportVO method getXidMapping.

public Map<String, String> getXidMapping() {
    DataPointDao dpd = DataPointDao.instance;
    Map<String, String> ans = new HashMap<String, String>();
    for (ReportPointVO vo : points) {
        // Check to see if point exists
        DataPointVO dp = dpd.get(vo.getPointId());
        if (dp != null)
            ans.put(dp.getXid(), vo.getPointKey());
    }
    return ans;
}
Also used : DataPointVO(com.serotonin.m2m2.vo.DataPointVO) DataPointDao(com.serotonin.m2m2.db.dao.DataPointDao) HashMap(java.util.HashMap)

Aggregations

DataPointDao (com.serotonin.m2m2.db.dao.DataPointDao)31 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)21 JsonArray (com.serotonin.json.type.JsonArray)8 TranslatableJsonException (com.serotonin.m2m2.i18n.TranslatableJsonException)8 User (com.serotonin.m2m2.vo.User)8 JsonObject (com.serotonin.json.type.JsonObject)6 TranslatableMessage (com.serotonin.m2m2.i18n.TranslatableMessage)6 ArrayList (java.util.ArrayList)6 JsonValue (com.serotonin.json.type.JsonValue)5 PointValueTime (com.serotonin.m2m2.rt.dataImage.PointValueTime)5 HashMap (java.util.HashMap)5 IntStringPair (com.serotonin.db.pair.IntStringPair)4 JsonString (com.serotonin.json.type.JsonString)4 DwrPermission (com.serotonin.m2m2.web.dwr.util.DwrPermission)4 InvalidArgumentException (com.serotonin.InvalidArgumentException)3 PointValueDao (com.serotonin.m2m2.db.dao.PointValueDao)3 ProcessResult (com.serotonin.m2m2.i18n.ProcessResult)3 ReportPointVO (com.serotonin.m2m2.reports.vo.ReportPointVO)3 AnnotatedPointValueTime (com.serotonin.m2m2.rt.dataImage.AnnotatedPointValueTime)3 DataPointSummary (com.serotonin.m2m2.vo.DataPointSummary)3