package org.onap.clamp.loop.template;
import com.google.gson.annotations.Expose;
-
import java.io.Serializable;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-
import javax.persistence.CascadeType;
import javax.persistence.Column;
+import javax.persistence.Convert;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
-
import org.hibernate.annotations.SortNatural;
import org.onap.clamp.loop.common.AuditEntity;
import org.onap.clamp.loop.service.Service;
@Column(columnDefinition = "MEDIUMTEXT", name = "blueprint_yaml")
private String blueprint;
- @Column(columnDefinition = "MEDIUMTEXT", name = "svg_representation")
- private String svgRepresentation;
-
@Expose
- @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER, mappedBy = "loopTemplate", orphanRemoval = true)
+ @OneToMany(
+ cascade = CascadeType.ALL,
+ fetch = FetchType.EAGER,
+ mappedBy = "loopTemplate",
+ orphanRemoval = true)
@SortNatural
private SortedSet<LoopTemplateLoopElementModel> loopElementModelsUsed = new TreeSet<>();
@Expose
- @ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH })
+ @ManyToOne(
+ fetch = FetchType.EAGER,
+ cascade = {CascadeType.PERSIST, CascadeType.MERGE, CascadeType.REFRESH})
@JoinColumn(name = "service_uuid")
private Service modelService;
@Column(name = "unique_blueprint", columnDefinition = "boolean default false")
private boolean uniqueBlueprint;
+ /**
+ * Type of Loop allowed to be created.
+ */
+ @Expose
+ @Column(name = "allowed_loop_type")
+ @Convert(converter = LoopTypeConvertor.class)
+ private LoopType allowedLoopType = LoopType.CLOSED;
+
/**
* name getter.
- *
+ *
* @return the name
*/
public String getName() {
/**
* name setter.
- *
+ *
* @param name the name to set
*/
public void setName(String name) {
/**
* blueprint getter.
- *
+ *
* @return the blueprint
*/
public String getBlueprint() {
/**
* dcaeBlueprintId getter.
- *
+ *
* @return the dcaeBlueprintId
*/
public String getDcaeBlueprintId() {
/**
* dcaeBlueprintId setter.
- *
+ *
* @param dcaeBlueprintId the dcaeBlueprintId to set
*/
public void setDcaeBlueprintId(String dcaeBlueprintId) {
/**
* blueprint setter.
- *
+ *
* @param blueprint the blueprint to set
*/
public void setBlueprint(String blueprint) {
}
}
- /**
- * svgRepresentation getter.
- *
- * @return the svgRepresentation
- */
- public String getSvgRepresentation() {
- return svgRepresentation;
- }
-
- /**
- * svgRepresentation setter.
- *
- * @param svgRepresentation the svgRepresentation to set
- */
- public void setSvgRepresentation(String svgRepresentation) {
- this.svgRepresentation = svgRepresentation;
- }
-
/**
* loopElementModelsUsed getter.
- *
+ *
* @return the loopElementModelsUsed
*/
public SortedSet<LoopTemplateLoopElementModel> getLoopElementModelsUsed() {
/**
* maximumInstancesAllowed getter.
- *
+ *
* @return the maximumInstancesAllowed
*/
public Integer getMaximumInstancesAllowed() {
/**
* maximumInstancesAllowed setter.
- *
+ *
* @param maximumInstancesAllowed the maximumInstancesAllowed to set
*/
public void setMaximumInstancesAllowed(Integer maximumInstancesAllowed) {
this.maximumInstancesAllowed = maximumInstancesAllowed;
}
+ /**
+ * allowedLoopType getter.
+ *
+ * @return the allowedLoopType Type of Loop allowed to be created
+ */
+ public LoopType getAllowedLoopType() {
+ return allowedLoopType;
+ }
+
+ /**
+ * allowedLoopType setter.
+ *
+ * @param allowedLoopType the allowedLoopType to set
+ */
+ public void setAllowedLoopType(LoopType allowedLoopType) {
+ this.allowedLoopType = allowedLoopType;
+ }
+
/**
* Add list of loopElements to the current template, each loopElementModel is
* added at the end of the list so the flowOrder is computed automatically.
- *
+ *
* @param loopElementModels The loopElementModel set to add
*/
public void addLoopElementModels(Set<LoopElementModel> loopElementModels) {
/**
* Add a loopElement to the current template, the loopElementModel is added at
* the end of the list so the flowOrder is computed automatically.
- *
+ *
* @param loopElementModel The loopElementModel to add
*/
public void addLoopElementModel(LoopElementModel loopElementModel) {
- LoopTemplateLoopElementModel jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel,
- this.loopElementModelsUsed.size());
- this.loopElementModelsUsed.add(jointEntry);
- loopElementModel.getUsedByLoopTemplates().add(jointEntry);
+ this.addLoopElementModel(loopElementModel,this.loopElementModelsUsed.size());
}
/**
* Add a loopElement model to the current template, the flow order must be
* specified manually.
- *
+ *
* @param loopElementModel The loopElementModel to add
* @param listPosition The position in the flow
*/
public void addLoopElementModel(LoopElementModel loopElementModel, Integer listPosition) {
- LoopTemplateLoopElementModel jointEntry = new LoopTemplateLoopElementModel(this, loopElementModel,
- listPosition);
+ LoopTemplateLoopElementModel jointEntry =
+ new LoopTemplateLoopElementModel(this, loopElementModel, listPosition);
this.loopElementModelsUsed.add(jointEntry);
loopElementModel.getUsedByLoopTemplates().add(jointEntry);
}
/**
* modelService getter.
- *
+ *
* @return the modelService
*/
public Service getModelService() {
/**
* modelService setter.
- *
+ *
* @param modelService the modelService to set
*/
public void setModelService(Service modelService) {
/**
* uniqueBlueprint getter.
- *
+ *
* @return the uniqueBlueprint
*/
public boolean getUniqueBlueprint() {
/**
* Constructor.
- *
+ *
* @param name The loop template name id
* @param blueprint The blueprint containing all microservices (legacy
* case)
- * @param svgRepresentation The svg representation of that loop template
* @param maxInstancesAllowed The maximum number of instances that can be
* created from that template
* @param service The service associated to that loop template
*/
- public LoopTemplate(String name, String blueprint, String svgRepresentation, Integer maxInstancesAllowed,
- Service service) {
+ public LoopTemplate(String name, String blueprint, Integer maxInstancesAllowed, Service service) {
this.name = name;
this.setBlueprint(blueprint);
- this.svgRepresentation = svgRepresentation;
this.maximumInstancesAllowed = maxInstancesAllowed;
this.modelService = service;
* @param blueprintFileName The blueprint file name
* @return The generated loop template name
*/
- public static String generateLoopTemplateName(String serviceName, String serviceVersion, String resourceName,
- String blueprintFileName) {
+ public static String generateLoopTemplateName(String serviceName, String serviceVersion,
+ String resourceName, String blueprintFileName) {
StringBuilder buffer = new StringBuilder("LOOP_TEMPLATE_").append(serviceName).append("_v")
.append(serviceVersion).append("_").append(resourceName).append("_")
.append(blueprintFileName.replaceAll(".yaml", ""));