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=========================================================
20 package org.openecomp.sdc.be.model;
22 import java.util.List;
24 import lombok.NoArgsConstructor;
26 import org.openecomp.sdc.be.dao.jsongraph.types.JsonParseFlagEnum;
27 import org.openecomp.sdc.be.datatypes.enums.ComponentFieldsEnum;
28 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
33 public class ComponentParametersView {
35 private boolean ignoreUsers = false;
36 private boolean ignoreGroups = false;
37 private boolean ignoreComponentInstances = false;
38 private boolean ignoreComponentInstancesProperties = false;
39 private boolean ignoreComponentInstancesAttributes = false;
40 private boolean ignoreProperties = false;
41 private boolean ignoreAttributes = false;
42 private boolean ignoreCapabilities = false;
43 private boolean ignoreRequirements = false;
44 private boolean ignoreCategories = false;
45 private boolean ignoreAllVersions = false;
46 private boolean ignoreAdditionalInformation = false;
47 private boolean ignoreArtifacts = false;
48 private boolean ignoreInterfaces = false;
49 private boolean ignoreInterfaceInstances = false;
50 private boolean ignoreComponentInstancesInterfaces = false;
51 private boolean ignoreDerivedFrom = false;
52 private boolean ignoreInputs = false;
53 private boolean ignoreOutputs = false;
54 private boolean ignoreComponentInstancesInputs = false;
55 private boolean ignoreComponentInstancesOutputs = false;
56 private boolean ignoreCapabiltyProperties = false;
57 private boolean ignoreServicePath = true;
58 private boolean ignorePolicies = false;
59 private boolean ignoreNodeFilterRequirements = false;
60 private boolean ignoreNodeFilter = false;
61 private boolean ignoreSubstitutionFilter = false;
62 private boolean ignoreDataType = false;
64 public ComponentParametersView(boolean setAllToIgnore) {
71 public ComponentParametersView(List<String> filters) {
73 for (String fieldName : filters) {
74 switch (ComponentFieldsEnum.findByValue(fieldName)) {
76 this.setIgnoreProperties(false);
79 this.setIgnoreInputs(false);
82 this.setIgnoreOutputs(false);
85 this.setIgnoreUsers(false);
88 this.setIgnoreCategories(false);
91 this.setIgnoreUsers(false);
92 this.setIgnoreCategories(false);
93 this.setIgnoreAllVersions(false);
94 this.setIgnoreDerivedFrom(false);
97 case NON_EXCLUDED_GROUPS:
98 this.setIgnoreGroups(false);
100 case COMPONENT_INSTANCES:
101 this.setIgnoreComponentInstances(false);
102 this.setIgnoreCapabilities(false);
103 this.setIgnoreRequirements(false);
104 this.setIgnoreNodeFilter(false);
105 this.setIgnoreSubstitutionFilter(false);
106 this.setIgnoreCapabiltyProperties(false);
107 this.setIgnoreInterfaces(false);
108 this.setIgnoreComponentInstancesInterfaces(false);
110 case COMPONENT_INSTANCES_PROPERTIES:
111 this.setIgnoreComponentInstances(false); //we need this in order to get the calculate capabilities requirements
112 this.setIgnoreComponentInstancesProperties(false);
115 this.setIgnoreComponentInstances(false);//we need this in order to get the calculate capabilities requirements
116 this.setIgnoreCapabilities(false);
117 this.setIgnoreCapabiltyProperties(false);
120 this.setIgnoreComponentInstances(false);
121 this.setIgnoreRequirements(false);
124 this.setIgnoreAllVersions(false);
126 case ADDITIONAL_INFORMATION:
127 this.setIgnoreAdditionalInformation(false);
130 case DEPLOYMENT_ARTIFACTS:
131 case TOSCA_ARTIFACTS:
132 case SERVICE_API_ARTIFACTS:
133 this.setIgnoreArtifacts(false);
136 this.setIgnoreInterfaces(false);
139 this.setIgnoreDerivedFrom(false);
142 this.setIgnoreAttributes(false);
144 case COMPONENT_INSTANCES_ATTRIBUTES:
145 this.setIgnoreComponentInstances(false);
146 this.setIgnoreComponentInstancesAttributes(false);
148 case COMPONENT_INSTANCE_INPUTS:
149 this.setIgnoreComponentInstances(false);
150 this.setIgnoreComponentInstancesInputs(false);
152 case COMPONENT_INSTANCE_OUTPUTS:
153 this.setIgnoreComponentInstances(false);
154 this.setIgnoreComponentInstancesOutputs(false);
156 case INSTANCE_CAPABILTY_PROPERTIES:
157 this.setIgnoreCapabiltyProperties(false);
159 case FORWARDING_PATHS:
160 this.setIgnoreServicePath(false);
163 case NON_EXCLUDED_POLICIES:
164 this.setIgnorePolicies(false);
167 this.setIgnoreNodeFilterRequirements(false);
168 this.setIgnoreNodeFilter(false);
170 case SUBSTITUTION_FILTER:
171 this.setIgnoreSubstitutionFilter(false);
173 case COMPONENT_INSTANCES_INTERFACES:
174 this.setIgnoreComponentInstances(false);
175 this.setIgnoreInterfaces(false);
176 this.setIgnoreComponentInstancesInterfaces(false);
179 this.setIgnoreDataType(false);
186 ///////////////////////////////////////////////////////////////
188 // When adding new member, please update the filter method.
190 ///////////////////////////////////////////////////////////////
191 public Component filter(Component component, ComponentTypeEnum componentType) {
193 component.setCreatorUserId(null);
194 component.setCreatorFullName(null);
195 component.setLastUpdaterUserId(null);
196 component.setLastUpdaterFullName(null);
199 component.setGroups(null);
201 if (ignoreComponentInstances) {
202 component.setComponentInstances(null);
203 component.setComponentInstancesRelations(null);
205 if (ignoreComponentInstancesProperties) {
206 component.setComponentInstancesProperties(null);
208 if (ignoreProperties && componentType == ComponentTypeEnum.RESOURCE) {
209 ((Resource) component).setProperties(null);
211 if (ignoreAttributes) {
212 component.setAttributes(null);
214 if (ignoreCapabilities) {
215 component.setCapabilities(null);
217 if (ignoreRequirements) {
218 component.setRequirements(null);
220 if (ignoreCategories) {
221 component.setCategories(null);
223 if (ignoreAllVersions) {
224 component.setAllVersions(null);
226 if (ignoreAdditionalInformation && componentType == ComponentTypeEnum.RESOURCE) {
227 ((Resource) component).setAdditionalInformation(null);
229 if (ignoreArtifacts) {
230 component.setArtifacts(null);
231 component.setSpecificComponetTypeArtifacts(null);
232 component.setDeploymentArtifacts(null);
233 component.setToscaArtifacts(null);
235 if (ignoreNodeFilterRequirements) {
236 component.setNodeFilterComponents(null);
238 if (ignoreInterfaces && ignoreInterfaceInstances && 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.setSubstitutionFilter(null);
268 if (ignoreDataType) {
269 component.setDataTypes(null);
274 public void disableAll() {
277 ignoreComponentInstances = true;
278 ignoreComponentInstancesProperties = true;
279 ignoreComponentInstancesAttributes = 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 ignoreComponentInstancesInterfaces = true;
291 ignoreDerivedFrom = true;
293 ignoreOutputs = true;
294 ignoreComponentInstancesInputs = true;
295 ignoreComponentInstancesOutputs = true;
296 ignoreCapabiltyProperties = true;
297 ignoreServicePath = true;
298 ignorePolicies = true;
299 ignoreNodeFilterRequirements = true;
300 ignoreNodeFilter = true;
301 ignoreSubstitutionFilter = true;
302 ignoreDataType = true;
305 public void setIgnoreGroups(boolean ignoreGroups) {
306 this.ignoreGroups = ignoreGroups;
308 this.ignoreCapabiltyProperties = ignoreGroups;
309 this.ignoreCapabilities = ignoreGroups;
313 public JsonParseFlagEnum detectParseFlag() {
314 JsonParseFlagEnum parseFlag;
315 if (isIgnoreComponentInstances()) {
316 parseFlag = JsonParseFlagEnum.ParseMetadata;
318 parseFlag = JsonParseFlagEnum.ParseAll;