forked from apache/incubator-kie-kogito-runtimes
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[KOGITO-9810] Supporting nested properties (apache#3229)
* [KOGITO-9810] Supporting nested properties * Revert "[KOGITO-9810] Supporting nested properties" This reverts commit 8df264f. * [KOGITO-9810] Alternative approach * [KOGITO-9810] Fixing image test
- Loading branch information
1 parent
994995f
commit dfbd63a
Showing
13 changed files
with
245 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...onpath-expression/src/main/java/org/kie/kogito/expr/jsonpath/JsonPathJacksonProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.kie.kogito.expr.jsonpath; | ||
|
||
import com.jayway.jsonpath.Configuration; | ||
import com.jayway.jsonpath.spi.mapper.JacksonMappingProvider; | ||
|
||
public class JsonPathJacksonProvider extends JacksonMappingProvider { | ||
|
||
@Override | ||
public <T> T map(Object source, Class<T> targetType, Configuration configuration) { | ||
return targetType.isAssignableFrom(source.getClass()) ? targetType.cast(source) : super.map(source, targetType, configuration); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
...kogito-jackson-utils/src/main/java/org/kie/kogito/jackson/utils/FunctionBaseJsonNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.kie.kogito.jackson.utils; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import com.fasterxml.jackson.core.JsonGenerator; | ||
import com.fasterxml.jackson.core.JsonPointer; | ||
import com.fasterxml.jackson.core.JsonToken; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.SerializerProvider; | ||
import com.fasterxml.jackson.databind.jsontype.TypeSerializer; | ||
import com.fasterxml.jackson.databind.node.BaseJsonNode; | ||
import com.fasterxml.jackson.databind.node.JsonNodeType; | ||
import com.fasterxml.jackson.databind.node.MissingNode; | ||
|
||
public class FunctionBaseJsonNode extends BaseJsonNode { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
@Override | ||
public JsonToken asToken() { | ||
return JsonToken.START_OBJECT; | ||
} | ||
|
||
@Override | ||
public boolean isObject() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public <T extends JsonNode> T deepCopy() { | ||
return (T) this; | ||
} | ||
|
||
@Override | ||
public JsonNode get(int index) { | ||
return MissingNode.getInstance(); | ||
} | ||
|
||
@Override | ||
public JsonNode path(String fieldName) { | ||
return get(fieldName); | ||
} | ||
|
||
@Override | ||
public JsonNode path(int index) { | ||
return MissingNode.getInstance(); | ||
} | ||
|
||
@Override | ||
protected JsonNode _at(JsonPointer ptr) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public JsonNodeType getNodeType() { | ||
return JsonNodeType.OBJECT; | ||
} | ||
|
||
@Override | ||
public String asText() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public JsonNode findValue(String fieldName) { | ||
return get(fieldName); | ||
} | ||
|
||
@Override | ||
public JsonNode findParent(String fieldName) { | ||
return null; | ||
} | ||
|
||
@Override | ||
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar) { | ||
foundSoFar.add(findValue(fieldName)); | ||
return foundSoFar; | ||
} | ||
|
||
@Override | ||
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar) { | ||
foundSoFar.add(findValue(fieldName).asText()); | ||
return foundSoFar; | ||
} | ||
|
||
@Override | ||
public List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar) { | ||
foundSoFar.add(findParent(fieldName)); | ||
return foundSoFar; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
return true; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return 0; | ||
} | ||
|
||
@Override | ||
public void serialize(JsonGenerator jgen, SerializerProvider provider) throws IOException { | ||
// not serialize | ||
} | ||
|
||
@Override | ||
public void serializeWithType(JsonGenerator jgen, | ||
SerializerProvider provider, | ||
TypeSerializer typeSer) throws IOException { | ||
// not serialize | ||
} | ||
|
||
} |
Oops, something went wrong.