diff options
Diffstat (limited to 'ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java')
-rw-r--r-- | ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java | 162 |
1 files changed, 162 insertions, 0 deletions
diff --git a/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java new file mode 100644 index 0000000..928f176 --- /dev/null +++ b/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java @@ -0,0 +1,162 @@ +package org.onap.ccsdk.dashboard.model.inventory; + +import java.util.Collection; +import java.util.Optional; + +import org.apache.commons.lang3.StringUtils; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; + +public class Service { + + /** Service ID of the Service */ + private final String serviceId; + /** Link to the Service */ + private final Link selfLink; + /** Creation date of the Service */ + private final String created; + /** Last modified date of the Service */ + private final String modified; + /** Link to the Service Type */ + private final Link typeLink; + /** vnfId of the Service */ + private final String vnfId; + /** Link to the vnf of the Service */ + private final Link vnfLink; + /** vnfType of the Service */ + private final String vnfType; + /** vnfLocation of the Service */ + private final String vnfLocation; + /** Reference to a Cloudify deployment */ + private final String deploymentRef; + /** Collection of ServiceComponent */ + private final Collection<ServiceComponent> components; + /** internal role based setting */ + private Optional<Boolean> canDeploy; + /** tenant name for this service */ + private String tenant; + + @JsonCreator + public Service (@JsonProperty("serviceId") String serviceId, + @JsonProperty("selfLink") Link selfLink, + @JsonProperty("created") String created, + @JsonProperty("modified") String modified, + @JsonProperty("typeLink") Link typeLink, + @JsonProperty("vnfId") String vnfId, + @JsonProperty("vnfLink") Link vnfLink, + @JsonProperty("vnfType") String vnfType, + @JsonProperty("vnfLocation") String vnfLocation, + @JsonProperty("deploymentRef") String deploymentRef, + @JsonProperty("components") Collection<ServiceComponent> components) { + this.serviceId = serviceId; + this.selfLink = selfLink; + this.created = created; + this.modified = modified; + this.typeLink = typeLink; + this.vnfId = vnfId; + this.vnfLink = vnfLink; + this.vnfType = vnfType; + this.vnfLocation = vnfLocation; + this.deploymentRef = deploymentRef; + this.components = components; + } + + public String getServiceId() { + return serviceId; + } + + public Link getSelfLink() { + return selfLink; + } + + public String getCreated() { + return created; + } + + public String getModified() { + return modified; + } + + public Link getTypeLink() { + return typeLink; + } + + public String getVnfId() { + return vnfId; + } + + public Link getVnfLink() { + return vnfLink; + } + + public String getVnfType() { + return vnfType; + } + + public String getVnfLocation() { + return vnfLocation; + } + + public String getDeploymentRef() { + return deploymentRef; + } + + public Collection<ServiceComponent> getComponents() { + return components; + } + + // Used for back end search, only searches the fields displayed in the front end. + public boolean contains(String searchString) { + if (StringUtils.containsIgnoreCase(this.getDeploymentRef(), searchString) || + StringUtils.containsIgnoreCase(this.getServiceId(), searchString) || + StringUtils.containsIgnoreCase(this.getCreated(), searchString) || + StringUtils.containsIgnoreCase(this.getModified(), searchString) || + StringUtils.containsIgnoreCase(this.getTenant(), searchString)) { + return true; + } + return false; + } + + public Optional<Boolean> getCanDeploy() { + return canDeploy; + } + + public void setCanDeploy(Optional<Boolean> canDeploy) { + this.canDeploy = canDeploy; + } + + public String getTenant() { + return tenant; + } + + public void setTenant(String tenant) { + this.tenant = tenant; + } + + public ServiceRef createServiceRef() { + return new ServiceRef(serviceId, + created, + modified); + } + /* + public static class ServiceRefBuilder { + private String serviceId; + private String created; + private String modified; + + public ServiceRefBuilder mapFromService(Service srvc) { + this.serviceId = srvc.getServiceId(); + this.created = srvc.getCreated(); + this.modified = srvc.getModified(); + return this; + } + + public ServiceRef build() { + return new ServiceRef(serviceId, + created, + modified); + } + } + */ +} |