+ /**
+ * This method can generate a Json representation (json schema) for an operational policy.
+ * This is mainly to support a legacy case and a generic case.
+ *
+ * @param operationalPolicy The operational policy
+ * @param toscaConverter The tosca converter
+ * @return The Json Object with Json schema
+ */
+ public static JsonObject generateJsonRepresentation(OperationalPolicy operationalPolicy,
+ ToscaConverterWithDictionarySupport toscaConverter)
+ throws IOException {
+ JsonObject jsonReturned = new JsonObject();
+ if (operationalPolicy.getPolicyModel() == null) {
+ return new JsonObject();
+ }
+ if (operationalPolicy.isLegacy()) {
+ // Op policy Legacy case
+ LegacyOperationalPolicy.preloadConfiguration(jsonReturned, operationalPolicy.loop);
+ jsonReturned = OperationalPolicyRepresentationBuilder
+ .generateOperationalPolicySchema(operationalPolicy.loop.getModelService());
+ }
+ else {
+ // Generic Case
+ jsonReturned = toscaConverter.convertToscaToJsonSchemaObject(
+ operationalPolicy.getPolicyModel().getPolicyModelTosca(),
+ operationalPolicy.getPolicyModel().getPolicyModelType());
+ }
+
+ return jsonReturned;