import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
-import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
-import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
-import org.hibernate.annotations.Type;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
import org.json.JSONObject;
import org.onap.clamp.clds.util.JsonUtils;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
-import org.onap.clamp.loop.common.AuditEntity;
-import org.onap.clamp.loop.template.MicroServiceModel;
import org.onap.clamp.policy.Policy;
import org.yaml.snakeyaml.Yaml;
@Entity
@Table(name = "micro_service_policies")
@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) })
-public class MicroServicePolicy extends AuditEntity implements Serializable, Policy {
+public class MicroServicePolicy extends Policy implements Serializable {
/**
* The serial version ID.
*/
@Column(name = "device_type_scope")
private String deviceTypeScope;
- @Expose
- @Type(type = "json")
- @Column(columnDefinition = "json", name = "properties")
- private JsonObject properties;
-
@Expose
@Column(name = "shared", nullable = false)
private Boolean shared;
@Column(columnDefinition = "MEDIUMTEXT", name = "policy_tosca", nullable = false)
private String policyTosca;
- @Expose
- @Type(type = "json")
- @Column(columnDefinition = "json", name = "json_representation", nullable = false)
- private JsonObject jsonRepresentation;
-
@ManyToMany(mappedBy = "microServicePolicies", fetch = FetchType.EAGER)
private Set<Loop> usedByLoops = new HashSet<>();
- @Expose
- @ManyToOne(fetch = FetchType.EAGER)
- @JoinColumn(name = "micro_service_model_id")
- private MicroServiceModel microServiceModel;
-
@Expose
@Column(name = "dcae_deployment_id")
private String dcaeDeploymentId;
this.modelType = modelType;
this.policyTosca = policyTosca;
this.shared = shared;
- this.jsonRepresentation = JsonUtils.GSON_JPA_MODEL
- .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca, modelType), JsonObject.class);
+ this.setJsonRepresentation(JsonUtils.GSON_JPA_MODEL
+ .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyTosca, modelType), JsonObject.class));
this.usedByLoops = usedByLoops;
}
this.policyTosca = policyTosca;
this.shared = shared;
this.usedByLoops = usedByLoops;
- this.jsonRepresentation = jsonRepresentation;
+ this.setJsonRepresentation(jsonRepresentation);
}
@Override
return name;
}
+ /**
+ * name setter.
+ *
+ * @param name the name to set
+ */
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
public String getModelType() {
return modelType;
}
this.modelType = modelType;
}
- public JsonObject getProperties() {
- return properties;
- }
-
- public void setProperties(JsonObject properties) {
- this.properties = properties;
- }
-
public Boolean getShared() {
return shared;
}
this.policyTosca = policyTosca;
}
- @Override
- public JsonObject getJsonRepresentation() {
- return jsonRepresentation;
- }
-
- void setJsonRepresentation(JsonObject jsonRepresentation) {
- this.jsonRepresentation = jsonRepresentation;
- }
-
public Set<Loop> getUsedByLoops() {
return usedByLoops;
}
}
/**
- * microServiceModel getter.
- *
- * @return the microServiceModel
- */
- public MicroServiceModel getMicroServiceModel() {
- return microServiceModel;
- }
-
- /**
- * microServiceModel setter.
+ * dcaeDeploymentId getter.
*
- * @param microServiceModel the microServiceModel to set
- */
- public void setMicroServiceModel(MicroServiceModel microServiceModel) {
- this.microServiceModel = microServiceModel;
- }
-
- /**
* @return the dcaeDeploymentId
*/
public String getDcaeDeploymentId() {
}
/**
+ * dcaeDeploymentId setter.
+ *
* @param dcaeDeploymentId the dcaeDeploymentId to set
*/
public void setDcaeDeploymentId(String dcaeDeploymentId) {
}
/**
+ * dcaeDeploymentStatusUrl getter.
+ *
* @return the dcaeDeploymentStatusUrl
*/
public String getDcaeDeploymentStatusUrl() {
}
/**
+ * dcaeDeploymentStatusUrl setter.
+ *
* @param dcaeDeploymentStatusUrl the dcaeDeploymentStatusUrl to set
*/
public void setDcaeDeploymentStatusUrl(String dcaeDeploymentStatusUrl) {
this.dcaeDeploymentStatusUrl = dcaeDeploymentStatusUrl;
}
- /**
- * name setter.
- *
- * @param name the name to set
- */
- public void setName(String name) {
- this.name = name;
- }
-
@Override
public int hashCode() {
final int prime = 31;
JsonObject policyProperties = new JsonObject();
policyDetails.add("properties", policyProperties);
- policyProperties.add(this.getMicroServicePropertyNameFromTosca(toscaJson), this.getProperties());
+ policyProperties.add(this.getMicroServicePropertyNameFromTosca(toscaJson), this.getConfigurationsJson());
String policyPayload = new GsonBuilder().setPrettyPrinting().create().toJson(policyPayloadResult);
logger.info("Micro service policy payload: " + policyPayload);
return policyPayload;