Added oparent to sdc main
[sdc.git] / catalog-be / src / main / java / org / openecomp / sdc / be / components / upgrade / UpgradeStatus.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2019 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.sdc.be.components.upgrade;
22
23 import org.openecomp.sdc.be.dao.api.ActionStatus;
24 import org.openecomp.sdc.be.model.Component;
25 import org.openecomp.sdc.exception.ResponseFormat;
26
27 import java.util.ArrayList;
28 import java.util.List;
29
30 public class UpgradeStatus {
31     ActionStatus status;
32     ResponseFormat error;
33     
34     
35     List<ServiceInfo> componentToUpgradeStatus;
36
37     public ActionStatus getStatus() {
38         return status;
39     }
40
41     public void setStatus(ActionStatus status) {
42         this.status = status;
43     }
44
45     public List<ServiceInfo> getComponentToUpgradeStatus() {
46         return componentToUpgradeStatus;
47     }
48
49     public void setComponentToUpgradeStatus(List<ServiceInfo> componentToUpgradeStatus) {
50         this.componentToUpgradeStatus = componentToUpgradeStatus;
51     }
52
53     public void addServiceStatus(ServiceInfo info) {
54         checkAndCreate();
55         componentToUpgradeStatus.add(info);
56     }
57     public void addServiceStatus(String serviceId, ActionStatus status) {
58         checkAndCreate();
59         ServiceInfo info = new ServiceInfo(serviceId, status );
60         componentToUpgradeStatus.add(info);
61     }
62     public void addServiceStatus(Component component, ActionStatus status) {
63         checkAndCreate();
64         ServiceInfo info = new ServiceInfo(component.getUniqueId(), status );
65         info.setName(component.getName());
66         info.setVersion(component.getVersion());
67         componentToUpgradeStatus.add(info);
68     }
69
70     private void checkAndCreate() {
71         if (componentToUpgradeStatus == null) {
72             componentToUpgradeStatus = new ArrayList<>();
73         }
74     }
75
76     public ResponseFormat getError() {
77         return error;
78     }
79
80     public void setError(ResponseFormat error) {
81         this.error = error;
82     }
83     
84 }