Merge "Reorder modifiers"
[so.git] / mso-catalog-db / src / main / java / org / openecomp / mso / db / catalog / beans / Service.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.mso.db.catalog.beans;
22
23 import java.io.Serializable;
24 import java.sql.Timestamp;
25 import java.text.DateFormat;
26 import java.util.HashMap;
27 import java.util.HashSet;
28 import java.util.Map;
29 import java.util.Set;
30
31 import org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
32
33 public class Service extends MavenLikeVersioning implements Serializable {
34         
35         private static final long serialVersionUID = 768026109321305392L;
36
37         private String modelName = null;
38         private String description = null;
39         private String modelUUID = null;
40         private String modelInvariantUUID = null;
41         private Timestamp created = null;
42         private String toscaCsarArtifactUUID = null;
43         private String modelVersion = null;
44         private String category = null;
45         private String serviceType = null;
46         private String serviceRole = null;
47         private String environmentContext = null;
48         private String workloadContext = null;
49         private Map<String,ServiceRecipe> recipes = new HashMap<>();
50         private Set<ServiceToResourceCustomization> serviceResourceCustomizations = new HashSet<>();
51         
52         public Service() {}
53         
54         public String getModelName() {
55                 return modelName;
56         }
57         public void setModelName(String modelName) {
58                 this.modelName = modelName;
59         }
60         
61         public String getDescription() {
62                 return description;
63         }
64         public void setDescription(String description) {
65                 this.description = description;
66         }
67         
68         public Map<String, ServiceRecipe> getRecipes() {
69                 return recipes;
70         }
71         public void setRecipes(Map<String, ServiceRecipe> recipes) {
72                 this.recipes = recipes;
73         }
74         
75         public Timestamp getCreated() {
76                 return created;
77         }
78
79         public void setCreated(Timestamp created) {
80                 this.created = created;
81         }
82                 
83         public String getModelUUID() {
84                 return modelUUID;
85         }
86
87         public void setModelUUID(String modelUUID) {
88                 this.modelUUID = modelUUID;
89         }
90
91         public String getModelInvariantUUID() {
92                 return modelInvariantUUID;
93         }
94
95         public void setModelInvariantUUID(String modelInvariantUUID) {
96                 this.modelInvariantUUID = modelInvariantUUID;
97         }
98
99         public String getToscaCsarArtifactUUID() {
100                 return toscaCsarArtifactUUID;
101         }
102
103         public void setToscaCsarArtifactUUID(String toscaCsarArtifactUUID) {
104                 this.toscaCsarArtifactUUID = toscaCsarArtifactUUID;
105         }
106
107         public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() {
108                 return serviceResourceCustomizations;
109         }
110
111         public void setServiceResourceCustomizations(Set<ServiceToResourceCustomization> serviceResourceCustomizations) {
112                 this.serviceResourceCustomizations = serviceResourceCustomizations;
113         }
114         
115         public String getModelVersion() {
116                 return modelVersion;
117         }
118
119         public void setModelVersion(String modelVersion) {
120                 this.modelVersion = modelVersion;
121         }
122
123     /**
124      * @return Returns the category.
125      */
126     public String getCategory() {
127         return category;
128     }
129
130     
131     /**
132      * @param category The category to set.
133      */
134     public void setCategory(String category) {
135         this.category = category;
136     }
137
138     public String getServiceType() {
139                 return serviceType;
140         }
141
142         public void setServiceType(String serviceType) {
143                 this.serviceType = serviceType;
144         }
145
146         public String getServiceRole() {
147                 return serviceRole;
148         }
149
150         public void setServiceRole(String serviceRole) {
151                 this.serviceRole = serviceRole;
152         }
153         public String getEnvironmentContext() {
154                 return this.environmentContext;
155         }
156         public void setEnvironmentContext(String environmentContext) {
157                 this.environmentContext = environmentContext;
158         }
159
160         public String getWorkloadContext() {
161                 return this.workloadContext;
162         }
163         public void setWorkloadContext(String workloadContext) {
164                 this.workloadContext = workloadContext;
165         }
166
167         @Override
168         public String toString() {
169                 StringBuilder sb = new StringBuilder();
170                 sb.append("SERVICE: name=").append(modelName).append(",modelVersion=").append(modelVersion)
171                         .append(",description=").append(description).append(",modelInvariantUUID=").append(modelInvariantUUID)
172
173                         .append(",toscaCsarArtifactUUID=").append(toscaCsarArtifactUUID).append(",serviceType=").append(serviceType)
174                         .append(",serviceRole=").append(serviceRole).append(",envtContext=").append(this.environmentContext)
175                         .append(",workloadContext=").append(this.workloadContext);
176                 for (String recipeAction : recipes.keySet()) {
177                         ServiceRecipe recipe = recipes.get(recipeAction);
178                         sb.append("\n").append(recipe.toString());
179                 }
180                 
181                 for(ServiceToResourceCustomization serviceResourceCustomization : serviceResourceCustomizations) {
182                         sb.append("\n").append(serviceResourceCustomization.toString());
183                 }
184                 if (created != null) {
185                         sb.append (",created=");
186                         sb.append (DateFormat.getInstance().format(created));
187                 }
188                 return sb.toString();
189         }
190 }