use of com.serotonin.m2m2.rt.dataImage.DataPointRT in project ma-core-public by infiniteautomation.
the class ScriptExecutor method convertScriptContext.
/**
* @param context
* @return
* @throws DataPointStateException
*/
public static Map<String, IDataPointValueSource> convertScriptContext(List<ScriptContextVariable> context) throws DataPointStateException {
Map<String, IDataPointValueSource> converted = new HashMap<String, IDataPointValueSource>();
for (ScriptContextVariable contextEntry : context) {
DataPointRT point = Common.runtimeManager.getDataPoint(contextEntry.getDataPointId());
if (point == null) {
DataPointVO vo = DataPointDao.instance.get(contextEntry.getDataPointId());
if (vo == null)
throw new DataPointStateException(contextEntry.getDataPointId(), new TranslatableMessage("event.script.contextPointMissing", contextEntry.getVariableName(), contextEntry.getDataPointId()));
else
throw new DataPointStateException(contextEntry.getDataPointId(), new TranslatableMessage("event.script.contextPointDisabled", contextEntry.getVariableName(), contextEntry.getDataPointId()));
}
converted.put(contextEntry.getVariableName(), point);
}
return converted;
}
use of com.serotonin.m2m2.rt.dataImage.DataPointRT in project ma-core-public by infiniteautomation.
the class DataPointTagsDao method saveDataPointTags.
/**
* Only to be used when saving data point tags independently from the DataPointVO itself.
* The DataPointVO tags must not be null.
*
* @param dataPoint
*/
public void saveDataPointTags(DataPointVO dataPoint) {
Map<String, String> tags = dataPoint.getTags();
if (tags == null)
throw new IllegalArgumentException("Data point tags cannot be null");
this.doInTransaction(txStatus -> {
this.deleteTagsForDataPointId(dataPoint.getId());
this.insertTagsForDataPoint(dataPoint, tags);
DataPointRT rt = Common.runtimeManager.getDataPoint(dataPoint.getId());
if (rt != null) {
DataPointVO rtVo = rt.getVO();
rtVo.setTags(tags);
}
DataPointDao.instance.notifyTagsUpdated(dataPoint);
});
}
Aggregations