@DwrPermission(user = true)
public ProcessResult validateScript(String script, int sourcePointId, int targetPointId) {
ProcessResult response = new ProcessResult();
TranslatableMessage message;
ScriptExecutor scriptExecutor = new ScriptExecutor();
DataPointRT point = Common.runtimeManager.getDataPoint(sourcePointId);
if (point == null)
message = new TranslatableMessage("event.pointLink.sourceUnavailable");
else {
Map<String, IDataPointValueSource> context = new HashMap<String, IDataPointValueSource>();
context.put(PointLinkRT.CONTEXT_VAR_NAME, point);
int targetDataType = new DataPointDao().getDataPoint(targetPointId).getPointLocator().getDataTypeId();
try {
PointValueTime pvt = scriptExecutor.execute(script, context, System.currentTimeMillis(),
targetDataType, -1);
if (pvt.getValue() == null)
message = new TranslatableMessage("event.pointLink.nullResult");
else if (pvt.getTime() == -1)
message = new TranslatableMessage("pointLinks.validate.success", pvt.getValue());