From cef5b582ed8f2f9a64203e737234e29434314b36 Mon Sep 17 00:00:00 2001 From: sebdet Date: Tue, 21 Jan 2020 12:40:59 +0100 Subject: Modify the template model Add loopElement to loopTemplate so that operational policy can be added into the template as well Issue-ID: CLAMP-555 Change-Id: I298c05f7f92536e4dab840983c41b0f7ee22daac Signed-off-by: sebdet --- .../java/org/onap/clamp/loop/CsarInstaller.java | 3 - src/main/java/org/onap/clamp/loop/Loop.java | 4 +- .../onap/clamp/loop/template/LoopElementModel.java | 222 +++++++++++++++++++++ .../loop/template/LoopElementModelsRepository.java | 31 +++ .../org/onap/clamp/loop/template/LoopTemplate.java | 41 ++-- .../template/LoopTemplateLoopElementModel.java | 194 ++++++++++++++++++ .../template/LoopTemplateLoopElementModelId.java | 102 ++++++++++ .../clamp/loop/template/MicroServiceModel.java | 217 -------------------- .../template/MicroServiceModelsRepository.java | 31 --- .../org/onap/clamp/loop/template/PolicyModel.java | 39 ++-- .../loop/template/TemplateMicroServiceModel.java | 194 ------------------ .../loop/template/TemplateMicroServiceModelId.java | 102 ---------- src/main/java/org/onap/clamp/policy/Policy.java | 147 ++++++++++++-- .../policy/microservice/MicroServicePolicy.java | 90 ++------- .../microservice/MicroServicePolicyService.java | 2 +- .../policy/operational/OperationalPolicy.java | 82 +++----- 16 files changed, 767 insertions(+), 734 deletions(-) create mode 100644 src/main/java/org/onap/clamp/loop/template/LoopElementModel.java create mode 100644 src/main/java/org/onap/clamp/loop/template/LoopElementModelsRepository.java create mode 100644 src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModel.java create mode 100644 src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModelId.java delete mode 100644 src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java delete mode 100644 src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java delete mode 100644 src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java delete mode 100644 src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java (limited to 'src/main/java/org/onap') diff --git a/src/main/java/org/onap/clamp/loop/CsarInstaller.java b/src/main/java/org/onap/clamp/loop/CsarInstaller.java index 38a6f931..ab8069f3 100644 --- a/src/main/java/org/onap/clamp/loop/CsarInstaller.java +++ b/src/main/java/org/onap/clamp/loop/CsarInstaller.java @@ -52,8 +52,6 @@ import org.onap.clamp.policy.operational.OperationalPolicy; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Propagation; -import org.springframework.transaction.annotation.Transactional; /** * This class will be instantiated by spring config, and used by Sdc Controller. @@ -129,7 +127,6 @@ public class CsarInstaller { * @throws SdcArtifactInstallerException The SdcArtifactInstallerException * @throws InterruptedException The InterruptedException */ - @Transactional(propagation = Propagation.REQUIRES_NEW) public void installTheLoop(CsarHandler csar, Service service) throws SdcArtifactInstallerException, InterruptedException { try { diff --git a/src/main/java/org/onap/clamp/loop/Loop.java b/src/main/java/org/onap/clamp/loop/Loop.java index 38378304..6b9a924b 100644 --- a/src/main/java/org/onap/clamp/loop/Loop.java +++ b/src/main/java/org/onap/clamp/loop/Loop.java @@ -127,8 +127,8 @@ public class Loop extends AuditEntity implements Serializable { @Expose @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }, fetch = FetchType.EAGER) - @JoinTable(name = "loops_microservicepolicies", joinColumns = @JoinColumn(name = "loop_id"), - inverseJoinColumns = @JoinColumn(name = "microservicepolicy_id")) + @JoinTable(name = "loops_to_microservicepolicies", joinColumns = @JoinColumn(name = "loop_name"), + inverseJoinColumns = @JoinColumn(name = "microservicepolicy_name")) private Set microServicePolicies = new HashSet<>(); @Expose diff --git a/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java new file mode 100644 index 00000000..c22ca1a6 --- /dev/null +++ b/src/main/java/org/onap/clamp/loop/template/LoopElementModel.java @@ -0,0 +1,222 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2018 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop.template; + +import com.google.gson.annotations.Expose; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.Id; +import javax.persistence.JoinColumn; +import javax.persistence.JoinTable; +import javax.persistence.ManyToMany; +import javax.persistence.OneToMany; +import javax.persistence.Table; + +import org.hibernate.annotations.SortNatural; +import org.onap.clamp.loop.common.AuditEntity; + +/** + * This class represents a micro service model for a loop template. + */ + +@Entity +@Table(name = "loop_element_models") +public class LoopElementModel extends AuditEntity implements Serializable { + public static final String DEFAULT_GROUP_NAME = "DEFAULT"; + /** + * The serial version id. + */ + private static final long serialVersionUID = -286522707701376645L; + + @Id + @Expose + @Column(nullable = false, name = "name", unique = true) + private String name; + + /** + * Here we store the blueprint coming from DCAE. + */ + @Column(nullable = false, name = "blueprint_yaml") + private String blueprint; + + /** + * The type of element + */ + @Column(nullable = false, name = "loop_element_type") + private String loopElementType; + + /** + * This variable is used to store the type mentioned in the micro-service + * blueprint. + */ + @Expose + @ManyToMany(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) + @JoinTable(name = "loopelementmodels_to_policymodels", + joinColumns = @JoinColumn(name = "loop_element_name", referencedColumnName = "name"), + inverseJoinColumns = { @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), + @JoinColumn(name = "policy_model_version", referencedColumnName = "version") }) + @SortNatural + private SortedSet policyModels = new TreeSet<>(); + + @OneToMany(fetch = FetchType.LAZY, mappedBy = "loopElementModel", orphanRemoval = true) + private Set usedByLoopTemplates = new HashSet<>(); + + /** + * policyModels getter. + * + * @return the policyModel + */ + public SortedSet getPolicyModels() { + return policyModels; + } + + /** + * Method to add a new policyModel to the list. + * + * @param policyModel + */ + public void addPolicyModel(PolicyModel policyModel) { + policyModels.add(policyModel); + policyModel.getUsedByElementModels().add(this); + } + + /** + * name getter. + * + * @return the name + */ + public String getName() { + return name; + } + + /** + * name setter. + * + * @param name the name to set + */ + public void setName(String name) { + this.name = name; + } + + /** + * blueprint getter. + * + * @return the blueprint + */ + public String getBlueprint() { + return blueprint; + } + + /** + * blueprint setter. + * + * @param blueprint the blueprint to set + */ + public void setBlueprint(String blueprint) { + this.blueprint = blueprint; + } + + /** + * @return the loopElementType + */ + public String getLoopElementType() { + return loopElementType; + } + + /** + * @param loopElementType the loopElementType to set + */ + public void setLoopElementType(String loopElementType) { + this.loopElementType = loopElementType; + } + + /** + * usedByLoopTemplates getter. + * + * @return the usedByLoopTemplates + */ + public Set getUsedByLoopTemplates() { + return usedByLoopTemplates; + } + + /** + * Default constructor for serialization. + */ + public LoopElementModel() { + } + + /** + * Constructor. + * + * @param name The name id + * @param loopElementType The type of loop element + * @param blueprint The blueprint defined for dcae that contains the + * policy type to use + */ + public LoopElementModel(String name, String loopElementType, String blueprint) { + this.name = name; + this.loopElementType = loopElementType; + this.blueprint = blueprint; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + LoopElementModel other = (LoopElementModel) obj; + if (name == null) { + if (other.name != null) { + return false; + } + } else if (!name.equals(other.name)) { + return false; + } + return true; + } + +} diff --git a/src/main/java/org/onap/clamp/loop/template/LoopElementModelsRepository.java b/src/main/java/org/onap/clamp/loop/template/LoopElementModelsRepository.java new file mode 100644 index 00000000..27b82189 --- /dev/null +++ b/src/main/java/org/onap/clamp/loop/template/LoopElementModelsRepository.java @@ -0,0 +1,31 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop.template; + +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface LoopElementModelsRepository extends JpaRepository { +} diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java index 10367e77..20574ff6 100644 --- a/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplate.java @@ -72,7 +72,7 @@ public class LoopTemplate extends AuditEntity implements Serializable { @Expose @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loopTemplate", orphanRemoval = true) @SortNatural - private SortedSet microServiceModelUsed = new TreeSet<>(); + private SortedSet loopElementModelsUsed = new TreeSet<>(); @Expose @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) @@ -138,12 +138,12 @@ public class LoopTemplate extends AuditEntity implements Serializable { } /** - * microServiceModelUsed getter. + * loopElementModelsUsed getter. * - * @return the microServiceModelUsed + * @return the loopElementModelsUsed */ - public SortedSet getMicroServiceModelUsed() { - return microServiceModelUsed; + public SortedSet getLoopElementModelsUsed() { + return loopElementModelsUsed; } /** @@ -165,29 +165,30 @@ public class LoopTemplate extends AuditEntity implements Serializable { } /** - * Add a microService model to the current template, the microservice is added - * at the end of the list so the flowOrder is computed automatically. + * Add a loopElement to the current template, the loopElementModel is added at + * the end of the list so the flowOrder is computed automatically. * - * @param microServiceModel The microserviceModel to add + * @param loopElementModel The loopElementModel to add */ - public void addMicroServiceModel(MicroServiceModel microServiceModel) { - TemplateMicroServiceModel jointEntry = new TemplateMicroServiceModel(this, microServiceModel, - this.microServiceModelUsed.size()); - this.microServiceModelUsed.add(jointEntry); - microServiceModel.getUsedByLoopTemplates().add(jointEntry); + public void addLoopElementModel(LoopElementModel loopElementModel) { + LoopTemplateLoopElementModel jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel, + this.loopElementModelsUsed.size()); + this.loopElementModelsUsed.add(jointEntry); + loopElementModel.getUsedByLoopTemplates().add(jointEntry); } /** - * Add a microService model to the current template, the flow order must be + * Add a loopElement model to the current template, the flow order must be * specified manually. * - * @param microServiceModel The microserviceModel to add - * @param listPosition The position in the flow + * @param loopElementModel The loopElementModel to add + * @param listPosition The position in the flow */ - public void addMicroServiceModel(MicroServiceModel microServiceModel, Integer listPosition) { - TemplateMicroServiceModel jointEntry = new TemplateMicroServiceModel(this, microServiceModel, listPosition); - this.microServiceModelUsed.add(jointEntry); - microServiceModel.getUsedByLoopTemplates().add(jointEntry); + public void addLoopElementModel(LoopElementModel loopElementModel, Integer listPosition) { + LoopTemplateLoopElementModel jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel, + listPosition); + this.loopElementModelsUsed.add(jointEntry); + loopElementModel.getUsedByLoopTemplates().add(jointEntry); } /** diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModel.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModel.java new file mode 100644 index 00000000..aca16bc0 --- /dev/null +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModel.java @@ -0,0 +1,194 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop.template; + +import com.google.gson.annotations.Expose; + +import java.io.Serializable; + +import javax.persistence.CascadeType; +import javax.persistence.Column; +import javax.persistence.EmbeddedId; +import javax.persistence.Entity; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.MapsId; +import javax.persistence.Table; + +@Entity +@Table(name = "looptemplates_to_loopelementmodels") +public class LoopTemplateLoopElementModel implements Serializable, Comparable { + + /** + * Serial ID. + */ + private static final long serialVersionUID = 5924989899078094245L; + + @EmbeddedId + private LoopTemplateLoopElementModelId loopTemplateLoopElementModelId; + + @ManyToOne(fetch = FetchType.LAZY) + @MapsId("loopTemplateName") + @JoinColumn(name = "loop_template_name") + private LoopTemplate loopTemplate; + + @Expose + @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) + @MapsId("loopElementModelName") + @JoinColumn(name = "loop_element_model_name") + private LoopElementModel loopElementModel; + + @Expose + @Column(nullable = false, name = "flow_order") + private Integer flowOrder; + + /** + * Default constructor for serialization. + */ + public LoopTemplateLoopElementModel() { + + } + + /** + * Constructor. + * + * @param loopTemplate The loop template object + * @param loopElementModel The loopElementModel object + * @param flowOrder The position of the micro service in the flow + */ + public LoopTemplateLoopElementModel(LoopTemplate loopTemplate, LoopElementModel loopElementModel, + Integer flowOrder) { + this.loopTemplate = loopTemplate; + this.loopElementModel = loopElementModel; + this.flowOrder = flowOrder; + this.loopTemplateLoopElementModelId = new LoopTemplateLoopElementModelId(loopTemplate.getName(), + loopElementModel.getName()); + } + + /** + * loopTemplate getter. + * + * @return the loopTemplate + */ + public LoopTemplate getLoopTemplate() { + return loopTemplate; + } + + /** + * loopTemplate setter. + * + * @param loopTemplate the loopTemplate to set + */ + public void setLoopTemplate(LoopTemplate loopTemplate) { + this.loopTemplate = loopTemplate; + } + + /** + * loopElementModel getter. + * + * @return the loopElementModel + */ + public LoopElementModel getLoopElementModel() { + return loopElementModel; + } + + /** + * loopElementModel setter. + * + * @param loopElementModel the loopElementModel to set + */ + public void setLoopElementModel(LoopElementModel loopElementModel) { + this.loopElementModel = loopElementModel; + } + + /** + * flowOrder getter. + * + * @return the flowOrder + */ + public Integer getFlowOrder() { + return flowOrder; + } + + /** + * flowOrder setter. + * + * @param flowOrder the flowOrder to set + */ + public void setFlowOrder(Integer flowOrder) { + this.flowOrder = flowOrder; + } + + @Override + public int compareTo(LoopTemplateLoopElementModel arg0) { + // Reverse it, so that by default we have the latest + if (getFlowOrder() == null) { + return 1; + } + if (arg0.getFlowOrder() == null) { + return -1; + } + return arg0.getFlowOrder().compareTo(this.getFlowOrder()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((loopTemplate == null) ? 0 : loopTemplate.hashCode()); + result = prime * result + ((loopElementModel == null) ? 0 : loopElementModel.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + LoopTemplateLoopElementModel other = (LoopTemplateLoopElementModel) obj; + if (loopTemplate == null) { + if (other.loopTemplate != null) { + return false; + } + } else if (!loopTemplate.equals(other.loopTemplate)) { + return false; + } + if (loopElementModel == null) { + if (other.loopElementModel != null) { + return false; + } + } else if (!loopElementModel.equals(other.loopElementModel)) { + return false; + } + return true; + } + +} diff --git a/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModelId.java b/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModelId.java new file mode 100644 index 00000000..3e2f8ad4 --- /dev/null +++ b/src/main/java/org/onap/clamp/loop/template/LoopTemplateLoopElementModelId.java @@ -0,0 +1,102 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP CLAMP + * ================================================================================ + * Copyright (C) 2019 AT&T Intellectual Property. All rights + * reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END============================================ + * =================================================================== + * + */ + +package org.onap.clamp.loop.template; + +import com.google.gson.annotations.Expose; + +import java.io.Serializable; + +import javax.persistence.Column; +import javax.persistence.Embeddable; + +@Embeddable +public class LoopTemplateLoopElementModelId implements Serializable { + + /** + * Serial ID. + */ + private static final long serialVersionUID = 4089888115504914773L; + + @Expose + @Column(name = "loop_template_name") + private String loopTemplateName; + + @Expose + @Column(name = "loop_element_model_name") + private String loopElementModelName; + + /** + * Default constructor for serialization. + */ + public LoopTemplateLoopElementModelId() { + + } + + /** + * Constructor. + * + * @param loopTemplateName The loop template name id + * @param microServiceModelName THe micro Service name id + */ + public LoopTemplateLoopElementModelId(String loopTemplateName, String microServiceModelName) { + this.loopTemplateName = loopTemplateName; + this.loopElementModelName = microServiceModelName; + } + + /** + * loopTemplateName getter. + * + * @return the loopTemplateName + */ + public String getLoopTemplateName() { + return loopTemplateName; + } + + /** + * loopTemplateName setter. + * + * @param loopTemplateName the loopTemplateName to set + */ + public void setLoopTemplateName(String loopTemplateName) { + this.loopTemplateName = loopTemplateName; + } + + /** + * microServiceModelName getter. + * + * @return the microServiceModelName + */ + public String getLoopElementModelName() { + return loopElementModelName; + } + + /** + * loopElementModelName setter. + * + * @param loopElementModelName the loopElementModelName to set + */ + public void setLoopElementModelName(String loopElementModelName) { + this.loopElementModelName = loopElementModelName; + } +} diff --git a/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java b/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java deleted file mode 100644 index 1e2b140e..00000000 --- a/src/main/java/org/onap/clamp/loop/template/MicroServiceModel.java +++ /dev/null @@ -1,217 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2018 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.clamp.loop.template; - -import com.google.gson.annotations.Expose; - -import java.io.Serializable; -import java.util.HashSet; -import java.util.Set; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.Id; -import javax.persistence.JoinColumn; -import javax.persistence.JoinColumns; -import javax.persistence.ManyToOne; -import javax.persistence.OneToMany; -import javax.persistence.Table; - -import org.onap.clamp.loop.common.AuditEntity; - -/** - * This class represents a micro service model for a loop template. - */ - -@Entity -@Table(name = "micro_service_models") -public class MicroServiceModel extends AuditEntity implements Serializable { - - /** - * The serial version id. - */ - private static final long serialVersionUID = -286522707701376645L; - - @Id - @Expose - @Column(nullable = false, name = "name", unique = true) - private String name; - - /** - * This variable is used to store the type mentioned in the micro-service - * blueprint. - */ - @Expose - @Column(nullable = false, name = "policy_type") - private String policyType; - - @Column(nullable = false, name = "blueprint_yaml") - private String blueprint; - - @Expose - @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) - @JoinColumns({ @JoinColumn(name = "policy_model_type", referencedColumnName = "policy_model_type"), - @JoinColumn(name = "policy_model_version", referencedColumnName = "version") }) - private PolicyModel policyModel; - - @OneToMany(fetch = FetchType.LAZY, mappedBy = "microServiceModel", orphanRemoval = true) - private Set usedByLoopTemplates = new HashSet<>(); - - /** - * policyModel getter. - * - * @return the policyModel - */ - public PolicyModel getPolicyModel() { - return policyModel; - } - - /** - * policyModel setter. - * - * @param policyModel the policyModel to set - */ - public void setPolicyModel(PolicyModel policyModel) { - this.policyModel = policyModel; - } - - /** - * name getter. - * - * @return the name - */ - public String getName() { - return name; - } - - /** - * name setter. - * - * @param name the name to set - */ - public void setName(String name) { - this.name = name; - } - - /** - * policyType getter. - * - * @return the policyType - */ - public String getPolicyType() { - return policyType; - } - - /** - * policyType setter. - * - * @param policyType the policyType to set - */ - public void setPolicyType(String policyType) { - this.policyType = policyType; - } - - /** - * blueprint getter. - * - * @return the blueprint - */ - public String getBlueprint() { - return blueprint; - } - - /** - * blueprint setter. - * - * @param blueprint the blueprint to set - */ - public void setBlueprint(String blueprint) { - this.blueprint = blueprint; - } - - /** - * usedByLoopTemplates getter. - * - * @return the usedByLoopTemplates - */ - public Set getUsedByLoopTemplates() { - return usedByLoopTemplates; - } - - /** - * Default constructor for serialization. - */ - public MicroServiceModel() { - } - - /** - * Constructor. - * - * @param name The name id - * @param policyType The policy model type like - * onap.policies.controlloop.operational.common.Apex - * @param blueprint The blueprint defined for dcae that contains the policy - * type to use - * @param policyModel The policy model for the policy type mentioned here - */ - public MicroServiceModel(String name, String policyType, String blueprint, PolicyModel policyModel) { - this.name = name; - this.policyType = policyType; - this.blueprint = blueprint; - this.policyModel = policyModel; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((name == null) ? 0 : name.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - MicroServiceModel other = (MicroServiceModel) obj; - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - return true; - } - -} diff --git a/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java b/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java deleted file mode 100644 index 2b187048..00000000 --- a/src/main/java/org/onap/clamp/loop/template/MicroServiceModelsRepository.java +++ /dev/null @@ -1,31 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.clamp.loop.template; - -import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; - -@Repository -public interface MicroServiceModelsRepository extends JpaRepository { -} diff --git a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java index e6580bee..00d58a82 100644 --- a/src/main/java/org/onap/clamp/loop/template/PolicyModel.java +++ b/src/main/java/org/onap/clamp/loop/template/PolicyModel.java @@ -26,11 +26,15 @@ package org.onap.clamp.loop.template; import com.google.gson.annotations.Expose; import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.FetchType; import javax.persistence.Id; import javax.persistence.IdClass; +import javax.persistence.ManyToMany; import javax.persistence.Table; import org.onap.clamp.loop.common.AuditEntity; @@ -74,9 +78,15 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable @Column(name = "policy_acronym") private String policyAcronym; - @Expose - @Column(name = "policy_variant") - private String policyVariant; + @ManyToMany(mappedBy = "policyModels", fetch = FetchType.EAGER) + private Set usedByElementModels = new HashSet<>(); + + /** + * @return the usedByElementModels + */ + public Set getUsedByElementModels() { + return usedByElementModels; + } /** * policyModelTosca getter. @@ -151,24 +161,6 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable this.policyAcronym = policyAcronym; } - /** - * policyVariant getter. - * - * @return the policyVariant value - */ - public String getPolicyVariant() { - return policyVariant; - } - - /** - * policyVariant setter. - * - * @param policyVariant The policyVariant to set - */ - public void setPolicyVariant(String policyVariant) { - this.policyVariant = policyVariant; - } - /** * Default constructor for serialization. */ @@ -181,16 +173,13 @@ public class PolicyModel extends AuditEntity implements Serializable, Comparable * @param policyType The policyType (referenced in the blueprint) * @param policyModelTosca The policy tosca model in yaml * @param version the version like 1.0.0 - * @param policyAcronym Short policy name if it exists * @param policyVariant Subtype for policy if it exists (could be used by UI) */ - public PolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym, - String policyVariant) { + public PolicyModel(String policyType, String policyModelTosca, String version, String policyAcronym) { this.policyModelType = policyType; this.policyModelTosca = policyModelTosca; this.version = version; this.policyAcronym = policyAcronym; - this.policyVariant = policyVariant; } @Override diff --git a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java deleted file mode 100644 index 7547c1f7..00000000 --- a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModel.java +++ /dev/null @@ -1,194 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.clamp.loop.template; - -import com.google.gson.annotations.Expose; - -import java.io.Serializable; - -import javax.persistence.CascadeType; -import javax.persistence.Column; -import javax.persistence.EmbeddedId; -import javax.persistence.Entity; -import javax.persistence.FetchType; -import javax.persistence.JoinColumn; -import javax.persistence.ManyToOne; -import javax.persistence.MapsId; -import javax.persistence.Table; - -@Entity -@Table(name = "templates_microservicemodels") -public class TemplateMicroServiceModel implements Serializable, Comparable { - - /** - * Serial ID. - */ - private static final long serialVersionUID = 5924989899078094245L; - - @EmbeddedId - private TemplateMicroServiceModelId templateMicroServiceModelId; - - @ManyToOne(fetch = FetchType.LAZY) - @MapsId("loopTemplateName") - @JoinColumn(name = "loop_template_name") - private LoopTemplate loopTemplate; - - @Expose - @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH }) - @MapsId("microServiceModelName") - @JoinColumn(name = "micro_service_model_name") - private MicroServiceModel microServiceModel; - - @Expose - @Column(nullable = false, name = "flow_order") - private Integer flowOrder; - - /** - * Default constructor for serialization. - */ - public TemplateMicroServiceModel() { - - } - - /** - * Constructor. - * - * @param loopTemplate The loop template object - * @param microServiceModel The microServiceModel object - * @param flowOrder The position of the micro service in the flow - */ - public TemplateMicroServiceModel(LoopTemplate loopTemplate, MicroServiceModel microServiceModel, - Integer flowOrder) { - this.loopTemplate = loopTemplate; - this.microServiceModel = microServiceModel; - this.flowOrder = flowOrder; - this.templateMicroServiceModelId = new TemplateMicroServiceModelId(loopTemplate.getName(), - microServiceModel.getName()); - } - - /** - * loopTemplate getter. - * - * @return the loopTemplate - */ - public LoopTemplate getLoopTemplate() { - return loopTemplate; - } - - /** - * loopTemplate setter. - * - * @param loopTemplate the loopTemplate to set - */ - public void setLoopTemplate(LoopTemplate loopTemplate) { - this.loopTemplate = loopTemplate; - } - - /** - * microServiceModel getter. - * - * @return the microServiceModel - */ - public MicroServiceModel getMicroServiceModel() { - return microServiceModel; - } - - /** - * microServiceModel setter. - * - * @param microServiceModel the microServiceModel to set - */ - public void setMicroServiceModel(MicroServiceModel microServiceModel) { - this.microServiceModel = microServiceModel; - } - - /** - * flowOrder getter. - * - * @return the flowOrder - */ - public Integer getFlowOrder() { - return flowOrder; - } - - /** - * flowOrder setter. - * - * @param flowOrder the flowOrder to set - */ - public void setFlowOrder(Integer flowOrder) { - this.flowOrder = flowOrder; - } - - @Override - public int compareTo(TemplateMicroServiceModel arg0) { - // Reverse it, so that by default we have the latest - if (getFlowOrder() == null) { - return 1; - } - if (arg0.getFlowOrder() == null) { - return -1; - } - return arg0.getFlowOrder().compareTo(this.getFlowOrder()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((loopTemplate == null) ? 0 : loopTemplate.hashCode()); - result = prime * result + ((microServiceModel == null) ? 0 : microServiceModel.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - TemplateMicroServiceModel other = (TemplateMicroServiceModel) obj; - if (loopTemplate == null) { - if (other.loopTemplate != null) { - return false; - } - } else if (!loopTemplate.equals(other.loopTemplate)) { - return false; - } - if (microServiceModel == null) { - if (other.microServiceModel != null) { - return false; - } - } else if (!microServiceModel.equals(other.microServiceModel)) { - return false; - } - return true; - } - -} diff --git a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java b/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java deleted file mode 100644 index 74c76897..00000000 --- a/src/main/java/org/onap/clamp/loop/template/TemplateMicroServiceModelId.java +++ /dev/null @@ -1,102 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP CLAMP - * ================================================================================ - * Copyright (C) 2019 AT&T Intellectual Property. All rights - * reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END============================================ - * =================================================================== - * - */ - -package org.onap.clamp.loop.template; - -import com.google.gson.annotations.Expose; - -import java.io.Serializable; - -import javax.persistence.Column; -import javax.persistence.Embeddable; - -@Embeddable -public class TemplateMicroServiceModelId implements Serializable { - - /** - * Serial ID. - */ - private static final long serialVersionUID = 4089888115504914773L; - - @Expose - @Column(name = "loop_template_name") - private String loopTemplateName; - - @Expose - @Column(name = "micro_service_model_name") - private String microServiceModelName; - - /** - * Default constructor for serialization. - */ - public TemplateMicroServiceModelId() { - - } - - /** - * Constructor. - * - * @param loopTemplateName The loop template name id - * @param microServiceModelName THe micro Service name id - */ - public TemplateMicroServiceModelId(String loopTemplateName, String microServiceModelName) { - this.loopTemplateName = loopTemplateName; - this.microServiceModelName = microServiceModelName; - } - - /** - * loopTemplateName getter. - * - * @return the loopTemplateName - */ - public String getLoopTemplateName() { - return loopTemplateName; - } - - /** - * loopTemplateName setter. - * - * @param loopTemplateName the loopTemplateName to set - */ - public void setLoopTemplateName(String loopTemplateName) { - this.loopTemplateName = loopTemplateName; - } - - /** - * microServiceModelName getter. - * - * @return the microServiceModelName - */ - public String getMicroServiceModelName() { - return microServiceModelName; - } - - /** - * microServiceModelName setter. - * - * @param microServiceModelName the microServiceModelName to set - */ - public void setMicroServiceModelName(String microServiceModelName) { - this.microServiceModelName = microServiceModelName; - } -} diff --git a/src/main/java/org/onap/clamp/policy/Policy.java b/src/main/java/org/onap/clamp/policy/Policy.java index fc097bd6..c6568205 100644 --- a/src/main/java/org/onap/clamp/policy/Policy.java +++ b/src/main/java/org/onap/clamp/policy/Policy.java @@ -24,37 +24,148 @@ package org.onap.clamp.policy; import com.google.gson.JsonObject; +import com.google.gson.annotations.Expose; import java.io.UnsupportedEncodingException; -public interface Policy { +import javax.persistence.Column; +import javax.persistence.FetchType; +import javax.persistence.JoinColumn; +import javax.persistence.ManyToOne; +import javax.persistence.MappedSuperclass; - String getName(); +import org.hibernate.annotations.Type; +import org.hibernate.annotations.TypeDef; +import org.hibernate.annotations.TypeDefs; +import org.onap.clamp.dao.model.jsontype.StringJsonUserType; +import org.onap.clamp.loop.common.AuditEntity; +import org.onap.clamp.loop.template.LoopElementModel; - JsonObject getJsonRepresentation(); +@MappedSuperclass +@TypeDefs({ @TypeDef(name = "json", typeClass = StringJsonUserType.class) }) +public abstract class Policy extends AuditEntity { - String createPolicyPayload() throws UnsupportedEncodingException; + @Expose + @Type(type = "json") + @Column(columnDefinition = "json", name = "json_representation", nullable = false) + private JsonObject jsonRepresentation; + + @Expose + @Type(type = "json") + @Column(columnDefinition = "json", name = "configurations_json") + private JsonObject configurationsJson; + + @Expose + @ManyToOne(fetch = FetchType.EAGER) + @JoinColumn(name = "loop_element_model_id") + private LoopElementModel loopElementModel; + + @Expose + @Column(name = "pdp_group") + private String pdpGroup; + + public abstract String createPolicyPayload() throws UnsupportedEncodingException; + + /** + * Name getter. + * + * @return the name + */ + public abstract String getName(); + + /** + * Name setter. + * + */ + public abstract void setName(String name); + + /** + * jsonRepresentation getter. + * + * @return the jsonRepresentation + */ + public JsonObject getJsonRepresentation() { + return jsonRepresentation; + } + + /** + * jsonRepresentation setter. + * + * @param jsonRepresentation The jsonRepresentation to set + */ + public void setJsonRepresentation(JsonObject jsonRepresentation) { + this.jsonRepresentation = jsonRepresentation; + } + + /** + * configurationsJson getter. + * + * @return The configurationsJson + */ + public JsonObject getConfigurationsJson() { + return configurationsJson; + } + + /** + * configurationsJson setter. + * + * @param configurationsJson the configurationsJson to set + */ + public void setConfigurationsJson(JsonObject configurationsJson) { + this.configurationsJson = configurationsJson; + } + + /** + * loopElementModel getter. + * + * @return the loopElementModel + */ + public LoopElementModel getLoopElementModel() { + return loopElementModel; + } + + /** + * loopElementModel setter. + * + * @param loopElementModel the loopElementModel to set + */ + public void setLoopElementModel(LoopElementModel loopElementModel) { + this.loopElementModel = loopElementModel; + } + + /** + * pdpGroup getter. + * + * @return the pdpGroup + */ + public String getPdpGroup() { + return pdpGroup; + } + + /** + * pdpGroup setter. + * + * @param pdpGroup the pdpGroup to set + */ + public void setPdpGroup(String pdpGroup) { + this.pdpGroup = pdpGroup; + } /** * Generate the policy name. * - * @param policyType - * The policy type - * @param serviceName - * The service name - * @param serviceVersion - * The service version - * @param resourceName - * The resource name - * @param blueprintFilename - * The blueprint file name + * @param policyType The policy type + * @param serviceName The service name + * @param serviceVersion The service version + * @param resourceName The resource name + * @param blueprintFilename The blueprint file name * @return The generated policy name */ - static String generatePolicyName(String policyType, String serviceName, String serviceVersion, String resourceName, - String blueprintFilename) { + public static String generatePolicyName(String policyType, String serviceName, String serviceVersion, + String resourceName, String blueprintFilename) { StringBuilder buffer = new StringBuilder(policyType).append("_").append(serviceName).append("_v") - .append(serviceVersion).append("_").append(resourceName).append("_") - .append(blueprintFilename.replaceAll(".yaml", "")); + .append(serviceVersion).append("_").append(resourceName).append("_") + .append(blueprintFilename.replaceAll(".yaml", "")); return buffer.toString().replace('.', '_').replaceAll(" ", ""); } diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java index 3e4dd8fd..445c1d5d 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicy.java @@ -40,13 +40,10 @@ import javax.persistence.Column; 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; @@ -54,15 +51,13 @@ import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor; 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. */ @@ -88,11 +83,6 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol @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; @@ -100,19 +90,9 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol @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 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; @@ -141,8 +121,8 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol 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; } @@ -171,7 +151,7 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol this.policyTosca = policyTosca; this.shared = shared; this.usedByLoops = usedByLoops; - this.jsonRepresentation = jsonRepresentation; + this.setJsonRepresentation(jsonRepresentation); } @Override @@ -179,6 +159,16 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol return name; } + /** + * name setter. + * + * @param name the name to set + */ + @Override + public void setName(String name) { + this.name = name; + } + public String getModelType() { return modelType; } @@ -187,14 +177,6 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol this.modelType = modelType; } - public JsonObject getProperties() { - return properties; - } - - public void setProperties(JsonObject properties) { - this.properties = properties; - } - public Boolean getShared() { return shared; } @@ -211,15 +193,6 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol this.policyTosca = policyTosca; } - @Override - public JsonObject getJsonRepresentation() { - return jsonRepresentation; - } - - void setJsonRepresentation(JsonObject jsonRepresentation) { - this.jsonRepresentation = jsonRepresentation; - } - public Set getUsedByLoops() { return usedByLoops; } @@ -245,24 +218,8 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol } /** - * 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() { @@ -270,6 +227,8 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol } /** + * dcaeDeploymentId setter. + * * @param dcaeDeploymentId the dcaeDeploymentId to set */ public void setDcaeDeploymentId(String dcaeDeploymentId) { @@ -277,6 +236,8 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol } /** + * dcaeDeploymentStatusUrl getter. + * * @return the dcaeDeploymentStatusUrl */ public String getDcaeDeploymentStatusUrl() { @@ -284,21 +245,14 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol } /** + * 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; @@ -362,7 +316,7 @@ public class MicroServicePolicy extends AuditEntity implements Serializable, Pol 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; diff --git a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java index 346cdf62..c431767f 100644 --- a/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java +++ b/src/main/java/org/onap/clamp/policy/microservice/MicroServicePolicyService.java @@ -73,7 +73,7 @@ public class MicroServicePolicyService implements PolicyService