Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #1888 from andrea11/jq
Browse files Browse the repository at this point in the history
Update jq dependency to latest stable version
  • Loading branch information
apanicker-nflx committed Sep 28, 2020
2 parents ea76796 + 5a95b5f commit f921b7e
Show file tree
Hide file tree
Showing 22 changed files with 11,975 additions and 72,049 deletions.
4,410 changes: 570 additions & 3,840 deletions cassandra-persistence/dependencies.lock

Large diffs are not rendered by default.

3,626 changes: 365 additions & 3,261 deletions client/dependencies.lock

Large diffs are not rendered by default.

635 changes: 9 additions & 626 deletions common/dependencies.lock

Large diffs are not rendered by default.

4,149 changes: 626 additions & 3,523 deletions contribs/dependencies.lock

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@

package com.netflix.conductor.contribs.json;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.cache.CacheBuilder;
Expand All @@ -26,17 +38,8 @@
import com.netflix.conductor.core.execution.WorkflowExecutor;
import com.netflix.conductor.core.execution.tasks.WorkflowSystemTask;
import net.thisptr.jackson.jq.JsonQuery;
import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;

@Singleton
public class JsonJqTransform extends WorkflowSystemTask {
Expand All @@ -46,14 +49,16 @@ public class JsonJqTransform extends WorkflowSystemTask {
private static final String OUTPUT_RESULT = "result";
private static final String OUTPUT_RESULT_LIST = "resultList";
private static final String OUTPUT_ERROR = "error";

private final Scope rootScope;
private final ObjectMapper objectMapper;
private final LoadingCache<String, JsonQuery> queryCache = createQueryCache();

@Inject
public JsonJqTransform(ObjectMapper objectMapper) {
super(NAME);
this.objectMapper = objectMapper;
this.rootScope = Scope.newEmptyScope();
this.rootScope.loadFunctions(Scope.class.getClassLoader());
}

@Override
Expand All @@ -72,7 +77,10 @@ public void start(Workflow workflow, Task task, WorkflowExecutor executor) {
try {
final JsonNode input = objectMapper.valueToTree(taskInput);
final JsonQuery query = queryCache.get(queryExpression);
final List<JsonNode> result = query.apply(input);

final Scope childScope = Scope.newChildScope(rootScope);

final List<JsonNode> result = query.apply(childScope, input);

task.setStatus(Task.Status.COMPLETED);
if (result == null) {
Expand Down
Loading

0 comments on commit f921b7e

Please sign in to comment.