import org.apache.commons.lang3.RandomStringUtils;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
+import org.onap.clamp.clds.config.LegacyOperationalPolicyController;
import org.onap.clamp.clds.tosca.update.ToscaConverterWithDictionarySupport;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
public OperationalPolicy(Loop loop, Service service, LoopElementModel loopElementModel,
ToscaConverterWithDictionarySupport toscaConverter) {
this(Policy.generatePolicyName("OPERATIONAL", service.getName(), service.getVersion(),
- RandomStringUtils.randomAlphanumeric(3), RandomStringUtils.randomAlphanumeric(3)), new JsonObject(),
+ loopElementModel.getPolicyModels().first().getPolicyAcronym() + '_'
+ + loopElementModel.getPolicyModels().first().getVersion(),
+ RandomStringUtils.randomAlphanumeric(3)), new JsonObject(),
new JsonObject(), loopElementModel.getPolicyModels().first(), loopElementModel, null, null);
this.setLoop(loop);
- this.updateJsonRepresentation(toscaConverter);
+ this.updateJsonRepresentation(toscaConverter, service);
}
/**
* Create an operational policy from a policy model.
*
- * @param loop The parent loop
- * @param service The loop service
- * @param policyModel The policy model
- * @param toscaConverter The tosca converter that must be used to create the Json representation
+ * @param loop The parent loop
+ * @param service The loop service
+ * @param policyModel The policy model
+ * @param toscaConverter The tosca converter that must be used to create the Json representation
* @throws IOException In case of issues with the legacy files (generated from resource files
*/
public OperationalPolicy(Loop loop, Service service, PolicyModel policyModel,
ToscaConverterWithDictionarySupport toscaConverter) throws IOException {
this(Policy.generatePolicyName("OPERATIONAL", service.getName(), service.getVersion(),
- RandomStringUtils.randomAlphanumeric(3), RandomStringUtils.randomAlphanumeric(3)), new JsonObject(),
+ policyModel.getPolicyAcronym() + '_' + policyModel.getVersion(),
+ RandomStringUtils.randomAlphanumeric(3)),
+ new JsonObject(),
new JsonObject(), policyModel, null, null, null);
this.setLoop(loop);
- this.updateJsonRepresentation(toscaConverter);
+ this.updateJsonRepresentation(toscaConverter, service);
}
public void setLoop(Loop loopName) {
}
@Override
- public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter) {
+ public void updateJsonRepresentation(ToscaConverterWithDictionarySupport toscaConverter, Service serviceModel) {
{
this.setJsonRepresentation(new JsonObject());
if (this.getPolicyModel() == null) {
// Generic Case
this.setJsonRepresentation(toscaConverter.convertToscaToJsonSchemaObject(
this.getPolicyModel().getPolicyModelTosca(),
- this.getPolicyModel().getPolicyModelType()));
+ this.getPolicyModel().getPolicyModelType(), serviceModel));
}
}
}
}
public Boolean isLegacy() {
- return (this.getPolicyModel() != null) && this.getPolicyModel().getPolicyModelType().contains("legacy");
+ return (this.getPolicyModel() != null) && this.getPolicyModel().getPolicyModelType().contains(
+ LegacyOperationalPolicyController.OPERATIONAL_POLICY_LEGACY);
}
/**