import com.att.eelf.configuration.EELFManager;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
+import java.io.IOException;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Transient;
import org.hibernate.annotations.TypeDef;
import org.hibernate.annotations.TypeDefs;
-import org.onap.clamp.clds.tosca.ToscaYamlToJsonConvertor;
-import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.tosca.update.UnknownComponentException;
import org.onap.clamp.dao.model.jsontype.StringJsonUserType;
import org.onap.clamp.loop.Loop;
import org.onap.clamp.loop.template.LoopElementModel;
* @param shared The flag indicate whether the MicroService is shared
*/
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared, LoopElementModel loopElementModel) {
- this(name, policyModel, shared, JsonUtils.GSON_JPA_MODEL
- .fromJson(new ToscaYamlToJsonConvertor().parseToscaYaml(policyModel.getPolicyModelTosca(),
- policyModel.getPolicyModelType()), JsonObject.class), loopElementModel,null,null);
+ this.name = name;
+ this.setPolicyModel(policyModel);
+ this.shared = shared;
+ try {
+ this.setJsonRepresentation(
+ Policy.generateJsonRepresentationFromToscaModel(policyModel.getPolicyModelTosca(),
+ policyModel.getPolicyModelType()));
+ } catch (UnknownComponentException | NullPointerException | IOException e) {
+ logger.error("Unable to generate the microservice policy Schema ... ", e);
+ this.setJsonRepresentation(new JsonObject());
+ }
+ this.setLoopElementModel(loopElementModel);
}
/**
* @param name The name of the MicroService
* @param policyModel The policy model type of the MicroService
* @param shared The flag indicate whether the MicroService is
- * shared
+ * shared
* @param jsonRepresentation The UI representation in json format
* @param loopElementModel The loop element model from which this instance should be created
* @param pdpGroup The Pdp Group info
* @param pdpSubgroup The Pdp Subgrouop info
*/
public MicroServicePolicy(String name, PolicyModel policyModel, Boolean shared,
- JsonObject jsonRepresentation, LoopElementModel loopElementModel, String pdpGroup, String pdpSubgroup) {
+ JsonObject jsonRepresentation, LoopElementModel loopElementModel, String pdpGroup,
+ String pdpSubgroup) {
this.name = name;
this.setPolicyModel(policyModel);
this.shared = shared;
if (other.name != null) {
return false;
}
- } else if (!name.equals(other.name)) {
+ }
+ else if (!name.equals(other.name)) {
return false;
}
return true;