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();
}
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;
}
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();
}
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));
}
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;
}
Aggregations