2 * ============LICENSE_START=======================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.openecomp.sdc.be.model;
23 import java.util.List;
25 import lombok.NoArgsConstructor;
27 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
28 import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
29 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
34 public class ComponentParametersView {
36 private boolean ignoreUsers = false;
37 private boolean ignoreGroups = false;
38 private boolean ignoreComponentInstances = false;
39 private boolean ignoreComponentInstancesProperties = false;
40 private boolean ignoreComponentInstancesAttributes = false;
41 private boolean ignoreProperties = false;
42 private boolean ignoreAttributes = false;
43 private boolean ignoreCapabilities = false;
44 private boolean ignoreRequirements = false;
45 private boolean ignoreCategories = false;
46 private boolean ignoreAllVersions = false;
47 private boolean ignoreAdditionalInformation = false;
48 private boolean ignoreArtifacts = false;
49 private boolean ignoreInterfaces = false;
50 private boolean ignoreInterfaceInstances = false;
51 private boolean ignoreComponentInstancesInterfaces = false;
52 private boolean ignoreDerivedFrom = false;
53 private boolean ignoreInputs = false;
54 private boolean ignoreOutputs = false;
55 private boolean ignoreComponentInstancesInputs = false;
56 private boolean ignoreComponentInstancesOutputs = false;
57 private boolean ignoreCapabiltyProperties = false;
58 private boolean ignoreServicePath = true;
59 private boolean ignorePolicies = false;
60 private boolean ignoreNodeFilterRequirements = false;
61 private boolean ignoreNodeFilter = false;
62 private boolean ignoreSubstitutionFilter = false;
63 private boolean ignoreDataType = false;
65 public ComponentParametersView(boolean setAllToIgnore) {
72 public ComponentParametersView(List<String> filters) {
75 for (String fieldName : filters) {
76 switch (ComponentFieldsEnum.findByValue(fieldName)) {
78 this.setIgnoreProperties(false);
81 this.setIgnoreInputs(false);
84 this.setIgnoreOutputs(false);
87 this.setIgnoreUsers(false);
90 this.setIgnoreCategories(false);
93 this.setIgnoreUsers(false);
94 this.setIgnoreCategories(false);
95 this.setIgnoreAllVersions(false);
96 this.setIgnoreDerivedFrom(false);
99 case NON_EXCLUDED_GROUPS:
100 this.setIgnoreGroups(false);
102 case COMPONENT_INSTANCES:
103 this.setIgnoreComponentInstances(false);
104 this.setIgnoreCapabilities(false);
105 this.setIgnoreRequirements(false);
106 this.setIgnoreNodeFilter(false);
107 this.setIgnoreSubstitutionFilter(false);
108 this.setIgnoreCapabiltyProperties(false);
109 this.setIgnoreInterfaces(false);
110 this.setIgnoreComponentInstancesInterfaces(false);
112 case COMPONENT_INSTANCES_PROPERTIES:
113 this.setIgnoreComponentInstances(false); //we need this in order to get the calculate capabilities requirements
114 this.setIgnoreComponentInstancesProperties(false);
117 this.setIgnoreComponentInstances(false);//we need this in order to get the calculate capabilities requirements
118 this.setIgnoreCapabilities(false);
119 this.setIgnoreCapabiltyProperties(false);
122 this.setIgnoreComponentInstances(false);
123 this.setIgnoreRequirements(false);
126 this.setIgnoreAllVersions(false);
128 case ADDITIONAL_INFORMATION:
129 this.setIgnoreAdditionalInformation(false);
132 case DEPLOYMENT_ARTIFACTS:
133 case TOSCA_ARTIFACTS:
134 case SERVICE_API_ARTIFACTS:
135 this.setIgnoreArtifacts(false);
138 this.setIgnoreInterfaces(false);
141 this.setIgnoreDerivedFrom(false);
144 this.setIgnoreAttributes(false);
146 case COMPONENT_INSTANCES_ATTRIBUTES:
147 this.setIgnoreComponentInstances(false);
148 this.setIgnoreComponentInstancesAttributes(false);
150 case COMPONENT_INSTANCE_INPUTS:
151 this.setIgnoreComponentInstances(false);
152 this.setIgnoreComponentInstancesInputs(false);
154 case INSTANCE_CAPABILTY_PROPERTIES:
155 this.setIgnoreCapabiltyProperties(false);
157 case FORWARDING_PATHS:
158 this.setIgnoreServicePath(false);
161 case NON_EXCLUDED_POLICIES:
162 this.setIgnorePolicies(false);
165 this.setIgnoreNodeFilterRequirements(false);
166 this.setIgnoreNodeFilter(false);
168 case SUBSTITUTION_FILTER:
169 this.setIgnoreSubstitutionFilter(false);
171 case COMPONENT_INSTANCES_INTERFACES:
172 this.setIgnoreComponentInstances(false);
173 this.setIgnoreInterfaces(false);
174 this.setIgnoreComponentInstancesInterfaces(false);
177 this.setIgnoreDataType(false);
186 ///////////////////////////////////////////////////////////////
187 // When adding new member, please update the filter method.
188 ///////////////////////////////////////////////////////////////
189 public Component filter(Component component, ComponentTypeEnum componentType) {
192 component.setCreatorUserId(null);
193 component.setCreatorFullName(null);
194 component.setLastUpdaterUserId(null);
195 component.setLastUpdaterFullName(null);
198 component.setGroups(null);
200 if (ignoreComponentInstances) {
201 component.setComponentInstances(null);
202 component.setComponentInstancesRelations(null);
204 if (ignoreComponentInstancesProperties) {
205 component.setComponentInstancesProperties(null);
207 if (ignoreProperties && componentType == ComponentTypeEnum.RESOURCE) {
208 ((Resource) component).setProperties(null);
210 if (ignoreAttributes) {
211 component.setAttributes(null);
213 if (ignoreCapabilities) {
214 component.setCapabilities(null);
216 if (ignoreRequirements) {
217 component.setRequirements(null);
219 if (ignoreCategories) {
220 component.setCategories(null);
222 if (ignoreAllVersions) {
223 component.setAllVersions(null);
225 if (ignoreAdditionalInformation && componentType == ComponentTypeEnum.RESOURCE) {
226 ((Resource) component).setAdditionalInformation(null);
228 if (ignoreArtifacts) {
229 component.setArtifacts(null);
230 component.setSpecificComponetTypeArtifacts(null);
231 component.setDeploymentArtifacts(null);
232 component.setToscaArtifacts(null);
234 if (ignoreNodeFilterRequirements) {
235 component.setNodeFilterComponents(null);
237 if (ignoreInterfaces && ignoreInterfaceInstances &&
238 componentType == ComponentTypeEnum.RESOURCE) {
239 component.setInterfaces(null);
241 if (ignoreDerivedFrom && componentType == ComponentTypeEnum.RESOURCE) {
242 ((Resource) component).setDerivedFrom(null);
244 if (ignoreComponentInstancesAttributes) {
245 component.setComponentInstancesAttributes(null);
248 component.setInputs(null);
251 component.setOutputs(null);
253 if (ignoreComponentInstancesInputs) {
254 component.setComponentInstancesInputs(null);
256 if (ignoreComponentInstancesOutputs) {
257 component.setComponentInstancesOutputs(null);
259 if (ignoreServicePath && componentType == ComponentTypeEnum.SERVICE) {
260 ((Service) component).setForwardingPaths(null);
262 if (ignoreNodeFilter) {
263 component.setNodeFilterComponents(null);
265 if (ignoreSubstitutionFilter) {
266 component.setSubstitutionFilterComponents(null);
268 if (ignoreDataType) {
269 component.setDataTypes(null);
274 public void disableAll() {
277 ignorePolicies = true;
278 ignoreComponentInstances = true;
279 ignoreComponentInstancesProperties = true;
280 ignoreProperties = true;
281 ignoreAttributes = true;
282 ignoreCapabilities = true;
283 ignoreRequirements = true;
284 ignoreCategories = true;
285 ignoreAllVersions = true;
286 ignoreAdditionalInformation = true;
287 ignoreArtifacts = true;
288 ignoreInterfaces = true;
289 ignoreInterfaceInstances = true;
290 ignoreDerivedFrom = true;
292 ignoreOutputs = true;
293 ignoreComponentInstancesAttributes = true;
294 ignoreComponentInstancesInputs = true;
295 ignoreComponentInstancesOutputs = true;
296 ignoreCapabiltyProperties = true;
297 ignoreServicePath = true;
298 ignoreNodeFilterRequirements = true;
299 ignoreNodeFilter = true;
300 ignoreSubstitutionFilter = true;
301 ignoreDataType = true;
304 public void setIgnoreGroups(boolean ignoreGroups) {
305 this.ignoreGroups = ignoreGroups;
307 this.ignoreCapabiltyProperties = ignoreGroups;
308 this.ignoreCapabilities = ignoreGroups;
312 public JsonParseFlagEnum detectParseFlag() {
313 JsonParseFlagEnum parseFlag;
314 if (isIgnoreComponentInstances()) {
315 parseFlag = JsonParseFlagEnum.ParseMetadata;
317 parseFlag = JsonParseFlagEnum.ParseAll;