aboutsummaryrefslogtreecommitdiffstats
path: root/ccsdk-app-common/src/main/java/org/onap/ccsdk/dashboard/model/inventory/Service.java
blob: 928f176b8223cc2471839ad96fbcdbecdd5e2af9 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
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);
		}
	}
	*/
}