f518678b445dedf8ff71599e6758993b826f9075
[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 org.openecomp.mso.db.catalog.utils.MavenLikeVersioning;
24
25 import java.io.Serializable;
26 import java.sql.Timestamp;
27 import java.text.DateFormat;
28 import java.util.Map;
29 import java.util.Set;
30
31 public class Service extends MavenLikeVersioning implements Serializable {
32         
33         private static final long serialVersionUID = 768026109321305392L;
34
35         private String modelName;
36         private String description;
37         private String modelUUID;
38         private String modelInvariantUUID;
39         private Timestamp created;
40         private String toscaCsarArtifactUUID;
41         private String modelVersion;
42         private String category;
43         private String serviceType;
44         private String serviceRole;
45         private Map<String,ServiceRecipe> recipes;
46         private Set<ServiceToResourceCustomization> serviceResourceCustomizations;
47         
48         public Service() {}
49         
50         public String getModelName() {
51                 return modelName;
52         }
53         public void setModelName(String modelName) {
54                 this.modelName = modelName;
55         }
56         
57         public String getDescription() {
58                 return description;
59         }
60         public void setDescription(String description) {
61                 this.description = description;
62         }
63         
64         public Map<String, ServiceRecipe> getRecipes() {
65                 return recipes;
66         }
67         public void setRecipes(Map<String, ServiceRecipe> recipes) {
68                 this.recipes = recipes;
69         }
70         
71         public Timestamp getCreated() {
72                 return created;
73         }
74
75         public void setCreated(Timestamp created) {
76                 this.created = created;
77         }
78                 
79         public String getModelUUID() {
80                 return modelUUID;
81         }
82
83         public void setModelUUID(String modelUUID) {
84                 this.modelUUID = modelUUID;
85         }
86
87         public String getModelInvariantUUID() {
88                 return modelInvariantUUID;
89         }
90
91         public void setModelInvariantUUID(String modelInvariantUUID) {
92                 this.modelInvariantUUID = modelInvariantUUID;
93         }
94
95         public String getToscaCsarArtifactUUID() {
96                 return toscaCsarArtifactUUID;
97         }
98
99         public void setToscaCsarArtifactUUID(String toscaCsarArtifactUUID) {
100                 this.toscaCsarArtifactUUID = toscaCsarArtifactUUID;
101         }
102
103         public Set<ServiceToResourceCustomization> getServiceResourceCustomizations() {
104                 return serviceResourceCustomizations;
105         }
106
107         public void setServiceResourceCustomizations(Set<ServiceToResourceCustomization> serviceResourceCustomizations) {
108                 this.serviceResourceCustomizations = serviceResourceCustomizations;
109         }
110         
111         public String getModelVersion() {
112                 return modelVersion;
113         }
114
115         public void setModelVersion(String modelVersion) {
116                 this.modelVersion = modelVersion;
117         }
118
119     /**
120      * @return Returns the category.
121      */
122     public String getCategory() {
123         return category;
124     }
125
126     
127     /**
128      * @param category The category to set.
129      */
130     public void setCategory(String category) {
131         this.category = category;
132     }
133
134     public String getServiceType() {
135                 return serviceType;
136         }
137
138         public void setServiceType(String serviceType) {
139                 this.serviceType = serviceType;
140         }
141
142         public String getServiceRole() {
143                 return serviceRole;
144         }
145
146         public void setServiceRole(String serviceRole) {
147                 this.serviceRole = serviceRole;
148         }
149
150         @Override
151         public String toString() {
152                 StringBuilder sb = new StringBuilder();
153                 sb.append("SERVICE: name=").append(modelName).append(",modelVersion=").append(modelVersion)
154             .append(",description=").append(description).append(",modelInvariantUUID=").append(modelInvariantUUID)
155             .append(",toscaCsarArtifactUUID=").append(toscaCsarArtifactUUID).append(",serviceType=").append(serviceType)
156             .append(",serviceRole=").append(serviceRole);
157                 for (String recipeAction : recipes.keySet()) {
158                         ServiceRecipe recipe = recipes.get(recipeAction);
159                         sb.append("\n").append(recipe.toString());
160                 }
161                 
162                 for(ServiceToResourceCustomization serviceResourceCustomization : serviceResourceCustomizations) {
163                         sb.append("\n").append(serviceResourceCustomization.toString());
164                 }
165                 if (created != null) {
166                         sb.append (",created=");
167                         sb.append (DateFormat.getInstance().format(created));
168                 }
169                 return sb.toString();
170         }
171 }