in jobs-service/jobs-service-common/src/main/java/org/kie/kogito/jobs/service/json/JobDescriptionDeserializer.java [48:91]
public JobDescription deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException, JacksonException {
try {
JsonNode node = jp.getCodec().readTree(jp);
String jobDescriptionType = node.get("@type").asText();
switch (jobDescriptionType) {
case "ProcessInstanceJobDescription": {
ProcessInstanceJobDescriptionBuilder builder = ProcessInstanceJobDescription.newProcessInstanceJobDescriptionBuilder();
ofNullable(node.get("id")).ifPresent(e -> builder.id(e.textValue()));
ofNullable(node.get("priority")).ifPresent(e -> builder.priority(e.asInt()));
String expirationTimeType = node.get("expirationTime").get("@type").asText();
builder.expirationTime((ExpirationTime) ctxt.readTreeAsValue(node.get("expirationTime"), Class.forName(expirationTimeType)));
ofNullable(node.get("timerId")).ifPresent(e -> builder.timerId(e.textValue()));
ofNullable(node.get("processInstanceId")).ifPresent(e -> builder.processInstanceId(e.textValue()));
ofNullable(node.get("rootProcessInstanceId")).ifPresent(e -> builder.rootProcessInstanceId(e.textValue()));
ofNullable(node.get("processId")).ifPresent(e -> builder.processId(e.textValue()));
ofNullable(node.get("rootProcessId")).ifPresent(e -> builder.rootProcessId(e.textValue()));
ofNullable(node.get("nodeInstanceId")).ifPresent(e -> builder.nodeInstanceId(e.textValue()));
return builder.build();
}
case "UserTaskInstanceJobDescription": {
UserTaskInstanceJobDescriptionBuilder builder = UserTaskInstanceJobDescription.newUserTaskInstanceJobDescriptionBuilder();
ofNullable(node.get("id")).ifPresent(e -> builder.id(e.textValue()));
ofNullable(node.get("priority")).ifPresent(e -> builder.priority(e.asInt()));
String expirationTimeType = node.get("expirationTime").get("@type").asText();
builder.expirationTime((ExpirationTime) ctxt.readTreeAsValue(node.get("expirationTime"), Class.forName(expirationTimeType)));
ofNullable(node.get("userTaskInstanceId")).ifPresent(e -> builder.userTaskInstanceId(e.textValue()));
var metadata = new HashMap<String, Object>();
ofNullable(node.get("processId")).ifPresent(e -> metadata.put("ProcessId", e.textValue()));
ofNullable(node.get("processInstanceId")).ifPresent(e -> metadata.put("ProcessInstanceId", e.textValue()));
ofNullable(node.get("nodeInstanceId")).ifPresent(e -> metadata.put("NodeInstanceId", e.textValue()));
ofNullable(node.get("rootProcessInstanceId")).ifPresent(e -> metadata.put("RootProcessInstanceId", e.textValue()));
ofNullable(node.get("rootProcessId")).ifPresent(e -> metadata.put("RootProcessId", e.textValue()));
builder.metadata(metadata);
return builder.build();
}
}
} catch (ClassNotFoundException e1) {
throw new IllegalArgumentException("expiration time class not found", e1);
}
return null;
}