ChildProgressStatusDTO child = readChildProgressStatus(jp);
return child.getProgressStatus();
}
public static ChildProgressStatusDTO readChildProgressStatus(JsonParser jp) throws IOException {
ProgressStatusDTO psd = new ProgressStatusDTO();
int allocatedSteps = 0;
while (jp.nextToken() != JsonToken.END_OBJECT) {
String fieldname = jp.getCurrentName();
jp.nextToken(); // move to value
if ("name".equals(fieldname)) {
psd.setName(jp.getText());
} else if ("id".equals(fieldname)) {
psd.setId(jp.getText());
} else if ("total-step-count".equals(fieldname)) {
psd.setTotalStepCount(jp.getIntValue());
} else if ("current-step-count".equals(fieldname)) {
psd.setCurrentStepCount(jp.getIntValue());
} else if ("complete".equals(fieldname)) {
psd.setCompleted(jp.getBooleanValue());
} else if ("allocated-steps".equals(fieldname)) {
allocatedSteps = jp.getIntValue();
} else if ("children".equals(fieldname)) {
while (jp.nextToken() != JsonToken.END_ARRAY) {
if (jp.getCurrentToken() == JsonToken.START_OBJECT) {
ProgressStatusDTO.ChildProgressStatusDTO child = readChildProgressStatus(jp);
psd.getChildren().add(child);
}
}
}
}
return new ChildProgressStatusDTO(allocatedSteps, psd);