aboutsummaryrefslogtreecommitdiffstats
path: root/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/ServiceRequest.java
blob: 036c9ae316cea0b6e6179b6ebb830fdeab5c8041 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package org.onap.ccsdk.dashboard.model.inventory;

import java.util.ArrayList;
import java.util.Collection;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;

public class ServiceRequest {

	/** ID of the associated service type */
	public String typeId;
	/** Id of the associated VNF that this service is monitoring */
	public String vnfId;
	/** The type of the associated VNF that this service is monitoring */
	public String vnfType;
	/** Location identifier of the associated VNF that this service is monitoring */
	public String vnfLocation;
	/** Reference to a Cloudify deployment */
	public String deploymentRef;
	/** Collection of ServiceComponentRequest objects that this service is composed of */
	public Collection<ServiceComponentRequest> components;
	
	@JsonCreator
	public ServiceRequest(@JsonProperty("typeId") String typeId, 
			@JsonProperty("vnfId") String vnfId, 
			@JsonProperty("vnfType") String vnfType, 
			@JsonProperty("vnfLocation") String vnfLocation, 
			@JsonProperty("deploymentRef") String deploymentRef, 
			@JsonProperty("components") Collection<ServiceComponentRequest> components) {
		this.typeId = typeId;
		this.vnfId = vnfId;
		this.vnfType = vnfType;
		this.vnfLocation = vnfLocation;
		this.deploymentRef = deploymentRef;
		this.components = components;
	}

	public static ServiceRequest from(String typeId, Service service) {

		// Convert the Collection<ServiceComponent> in service to Collection<ServiceComponentRequest> for serviceRequest
		final Collection<ServiceComponent> serviceComponents = service.getComponents();
		final Collection<ServiceComponentRequest> serviceComponentRequests = new ArrayList<ServiceComponentRequest> ();

		for (ServiceComponent sc : serviceComponents) {
			serviceComponentRequests.add(ServiceComponentRequest.from(sc));
		}

		return new ServiceRequest(typeId, 
				service.getVnfId(), 
				service.getVnfType(), 
				service.getVnfLocation(), 
				service.getDeploymentRef(), 
				serviceComponentRequests
		);
	}
}