|
|
@ -19,11 +19,9 @@ import com.google.common.util.concurrent.Futures; |
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
import com.google.common.util.concurrent.ListenableFuture; |
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
import com.google.common.util.concurrent.MoreExecutors; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.thingsboard.common.util.JacksonUtil; |
|
|
|
|
|
import org.thingsboard.script.api.ScriptType; |
|
|
import org.thingsboard.script.api.ScriptType; |
|
|
import org.thingsboard.script.api.tbel.TbelInvokeService; |
|
|
import org.thingsboard.script.api.tbel.TbelInvokeService; |
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
import org.thingsboard.server.common.data.id.TenantId; |
|
|
import org.thingsboard.server.common.data.kv.KvEntry; |
|
|
|
|
|
|
|
|
|
|
|
import javax.script.ScriptException; |
|
|
import javax.script.ScriptException; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
@ -53,9 +51,8 @@ public class CalculatedFieldTbelScriptEngine implements CalculatedFieldScriptEng |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ListenableFuture<Object> executeScriptAsync(Map<String, ArgumentEntry> arguments) { |
|
|
public ListenableFuture<Object> executeScriptAsync(Object[] args) { |
|
|
log.trace("execute script async, arguments {}", arguments); |
|
|
log.trace("Executing script async, args {}", args); |
|
|
Object[] args = arguments.values().stream().map(ArgumentEntry::getValue).toArray(); |
|
|
|
|
|
return Futures.transformAsync(tbelInvokeService.invokeScript(tenantId, null, this.scriptId, args), |
|
|
return Futures.transformAsync(tbelInvokeService.invokeScript(tenantId, null, this.scriptId, args), |
|
|
o -> { |
|
|
o -> { |
|
|
try { |
|
|
try { |
|
|
@ -73,8 +70,8 @@ public class CalculatedFieldTbelScriptEngine implements CalculatedFieldScriptEng |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public ListenableFuture<Map<String, Object>> executeToMapAsync(Map<String, ArgumentEntry> arguments) { |
|
|
public ListenableFuture<Map<String, Object>> executeToMapAsync(Object[] args) { |
|
|
return Futures.transformAsync(executeScriptAsync(arguments), this::executeToMapTransform, MoreExecutors.directExecutor()); |
|
|
return Futures.transformAsync(executeScriptAsync(args), this::executeToMapTransform, MoreExecutors.directExecutor()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
|