push addional code
[sdc.git] / openecomp-be / backend / openecomp-sdc-vendor-software-product-manager / src / main / java / org / openecomp / sdc / vendorsoftwareproduct / types / ValidationResponse.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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.sdc.vendorsoftwareproduct.types;
22
23 import org.apache.commons.collections4.CollectionUtils;
24 import org.apache.commons.collections4.MapUtils;
25 import org.openecomp.sdc.common.errors.ErrorCode;
26 import org.openecomp.sdc.datatypes.error.ErrorMessage;
27
28 import java.util.Collection;
29 import java.util.List;
30 import java.util.Map;
31
32 /**
33  * The type Validation response.
34  */
35 public class ValidationResponse {
36   private boolean valid = true;
37   private Collection<ErrorCode> vspErrors;
38   private Collection<ErrorCode> licensingDataErrors;
39   private Map<String, List<ErrorMessage>> uploadDataErrors;
40   private Map<String, List<ErrorMessage>> compilationErrors;
41   private QuestionnaireValidationResult questionnaireValidationResult;
42
43   /**
44    * Is valid boolean.
45    *
46    * @return the boolean
47    */
48   public boolean isValid() {
49     return valid;
50   }
51
52   /**
53    * Gets vsp errors.
54    *
55    * @return the vsp errors
56    */
57   public Collection<ErrorCode> getVspErrors() {
58     return vspErrors;
59   }
60
61   /**
62    * Sets vsp errors.
63    *
64    * @param vspErrors the vsp errors
65    */
66   public void setVspErrors(Collection<ErrorCode> vspErrors) {
67     this.vspErrors = vspErrors;
68     if (CollectionUtils.isNotEmpty(vspErrors)) {
69       valid = false;
70     }
71   }
72
73   /**
74    * Gets licensing data errors.
75    *
76    * @return the licensing data errors
77    */
78   public Collection<ErrorCode> getLicensingDataErrors() {
79     return licensingDataErrors;
80   }
81
82   /**
83    * Sets licensing data errors.
84    *
85    * @param licensingDataErrors the licensing data errors
86    */
87   public void setLicensingDataErrors(Collection<ErrorCode> licensingDataErrors) {
88     this.licensingDataErrors = licensingDataErrors;
89     if (CollectionUtils.isNotEmpty(licensingDataErrors)) {
90       valid = false;
91     }
92   }
93
94   /**
95    * Gets upload data errors.
96    *
97    * @return the upload data errors
98    */
99   public Map<String, List<ErrorMessage>> getUploadDataErrors() {
100     return uploadDataErrors;
101   }
102
103   /**
104    * Sets upload data errors.
105    *
106    * @param uploadDataErrors the upload data errors
107    */
108   public void setUploadDataErrors(Map<String, List<ErrorMessage>> uploadDataErrors) {
109     this.uploadDataErrors = uploadDataErrors;
110     if (MapUtils.isNotEmpty(uploadDataErrors)) {
111       valid = false;
112     }
113   }
114
115   /**
116    * Gets compilation errors.
117    *
118    * @return the compilation errors
119    */
120   public Map<String, List<ErrorMessage>> getCompilationErrors() {
121     return compilationErrors;
122   }
123
124   /**
125    * Sets compilation errors.
126    *
127    * @param compilationErrors the compilation errors
128    */
129   public void setCompilationErrors(Map<String, List<ErrorMessage>> compilationErrors) {
130     this.compilationErrors = compilationErrors;
131     if (MapUtils.isNotEmpty(compilationErrors)) {
132       valid = false;
133     }
134   }
135
136   /**
137    * Gets questionnaire validation result.
138    *
139    * @return the questionnaire validation result
140    */
141   public QuestionnaireValidationResult getQuestionnaireValidationResult() {
142     return questionnaireValidationResult;
143   }
144
145   /**
146    * Sets questionnaire validation result.
147    *
148    * @param questionnaireValidationResult the questionnaire validation result
149    */
150   public void setQuestionnaireValidationResult(
151       QuestionnaireValidationResult questionnaireValidationResult) {
152     this.questionnaireValidationResult = questionnaireValidationResult;
153     if (questionnaireValidationResult != null && !questionnaireValidationResult.isValid()) {
154       valid = false;
155     }
156   }
157 }