+ protected OperationalPolicyYamlFormatter() {
+ }
+ /**
+ * Format Operational OpenLoop Policy yaml.
+ *
+ * @param prop
+ * @param modelElementId
+ * @param policyChain
+ * @return
+ * @throws BuilderException
+ * @throws UnsupportedEncodingException
+ */
+ public static String formatOpenLoopYaml(ModelProperties prop, String modelElementId,
+ PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
+ // get property objects
+ Global global = prop.getGlobal();
+ prop.setCurrentModelElementId(modelElementId);
+ prop.setPolicyUniqueId(policyChain.getPolicyId());
+ // convert values to SDC objects
+ Service service = new Service(global.getService());
+ Resource[] vfResources = convertToResources(global.getResourceVf(), ResourceType.VF);
+ // create builder
+ ControlLoopPolicyBuilder builder = ControlLoopPolicyBuilder.Factory.buildControlLoop(prop.getControlName(),
+ policyChain.getTimeout(), service, vfResources);
+ // builder.setTriggerPolicy(refProp.getStringValue("op.openloop.policy"));
+ // Build the specification
+ Results results = builder.buildSpecification();
+ validate(results);
+ return URLEncoder.encode(results.getSpecification(), "UTF-8");
+ }