/** Parses execution options from a json object. Unrecognized elements are ignored. */ public static ExecutionOptions fromJson(ObjectNode node) { ExecutionOptions ret = new ExecutionOptions(); JsonNode x = node.get("timeLimit"); if (x != null) { ret.timeLimit = x.asLong(); } x = node.get("asynchronous"); if (x != null) { ret.asynchronous = x.asLong(); } return ret; }
/** Parses the entity, client identification and execution options from the given json object */ protected void parse(ObjectNode node) { entityVersion = new EntityVersion(); JsonNode x = node.get("entity"); if (x != null && !(x instanceof NullNode)) { entityVersion.setEntity(x.asText()); } x = node.get("entityVersion"); if (x != null && !(x instanceof NullNode)) { entityVersion.setVersion(x.asText()); } // TODO: clientIdentification x = node.get("execution"); if (x != null) { execution = ExecutionOptions.fromJson((ObjectNode) x); } }
/** Returns a JSON representation of this */ @Override public JsonNode toJson() { ObjectNode node = getFactory().objectNode(); node.put("entity", entityVersion.getEntity()); if (entityVersion.getVersion() != null) node.put("entityVersion", entityVersion.getVersion()); if (client != null) { node.set("client", client.toJson()); } if (execution != null) { node.set("execution", execution.toJson()); } if (getOperation() != null) { node.put("op", getOperation().name()); } return node; }