[VID-3] Setting docker image tag
[vid.git] / vid / src / main / java / org / openecomp / vid / model / ServiceModel.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * VID
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.vid.model;
22
23 import java.util.Map;
24 import java.util.UUID;
25
26 import org.openecomp.vid.asdc.beans.tosca.ToscaModel;
27
28 /**
29  * The Class ServiceModel.
30  */
31 public class ServiceModel {
32
33         /** The service. */
34         private Service service;
35         
36         /** The vnfs. */
37         private Map<UUID, VNF> vnfs;
38         
39         /** The networks. */
40         private Map<UUID, Network> networks;
41
42         /**
43          * Instantiates a new service model.
44          */
45         public ServiceModel() {}
46         
47         /**
48          * Gets the service.
49          *
50          * @return the service
51          */
52         public Service getService() {
53                 return service;
54         }
55
56         /**
57          * Gets the vnfs.
58          *
59          * @return the vnfs
60          */
61         public Map<UUID, VNF> getVnfs() {
62                 return vnfs;
63         }
64
65         /**
66          * Gets the networks.
67          *
68          * @return the networks
69          */
70         public Map<UUID, Network> getNetworks() {
71                 return networks;
72         }
73
74         /**
75          * Sets the service.
76          *
77          * @param service the new service
78          */
79         public void setService(Service service) {
80                 this.service = service;
81         }
82
83         /**
84          * Sets the vnfs.
85          *
86          * @param vnfs the vnfs
87          */
88         public void setVnfs(Map<UUID, VNF> vnfs) {
89                 this.vnfs = vnfs;
90         }
91
92         /**
93          * Sets the networks.
94          *
95          * @param networks the networks
96          */
97         public void setNetworks(Map<UUID, Network> networks) {
98                 this.networks = networks;
99         }
100
101         /**
102          * Extract service.
103          *
104          * @param serviceToscaModel the service tosca model
105          * @param asdcServiceMetadata the asdc service metadata
106          * @return the service
107          */
108         public static Service extractService(ToscaModel serviceToscaModel, org.openecomp.vid.asdc.beans.Service asdcServiceMetadata) {
109                 
110                 final Service service = new Service();
111                 
112                 service.setCategory(serviceToscaModel.getMetadata().getCategory());
113                 service.setInvariantUuid(serviceToscaModel.getMetadata().getInvariantUUID());
114                 service.setName(serviceToscaModel.getMetadata().getName());
115                 service.setUuid(serviceToscaModel.getMetadata().getUUID());
116                 service.setDescription(serviceToscaModel.getMetadata().getDescription());
117                 service.setInputs(serviceToscaModel.gettopology_template().getInputs());
118                 
119                 //FIXME: ASDC is not sending the Version with the Tosca Model for 1610 - they should send it in 1702
120                 //THIS IS A TEMPORARY FIX, AT SOME POINT UNCOMMENT ME
121                 //service.setVersion(serviceToscaModel.getMetadata().getVersion());
122                 service.setVersion(asdcServiceMetadata.getVersion());
123
124                 return service;
125         }
126 }