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.tosca;
22 import java.lang.reflect.Field;
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.HashMap;
26 import java.util.List;
28 import org.openecomp.sdc.be.datatypes.components.ResourceMetadataDataDefinition;
29 import org.openecomp.sdc.be.datatypes.enums.ComponentTypeEnum;
30 import org.openecomp.sdc.be.datatypes.enums.ResourceTypeEnum;
31 import org.openecomp.sdc.be.model.Component;
33 public class ToscaUtils {
35 private ToscaUtils() {
38 public static boolean isNotComplexVfc(Component component) {
39 if (ComponentTypeEnum.RESOURCE == component.getComponentType()) {
40 ResourceTypeEnum resourceType = ((ResourceMetadataDataDefinition) component.getComponentMetadataDefinition().getMetadataDataDefinition())
42 if (ResourceTypeEnum.CVFC == resourceType) {
45 if (component.getComponentMetadataDefinition() != null && component.getComponentMetadataDefinition().getMetadataDataDefinition() != null
46 && component.getComponentMetadataDefinition().getMetadataDataDefinition().getDescription() != null) {
47 if (component.getComponentMetadataDefinition().getMetadataDataDefinition().getDescription()
48 .equalsIgnoreCase("Nested VF in service")) {
56 public static Map<String, Object> objectToMap(Object objectToConvert, Class<?> clazz) throws IllegalAccessException {
57 Map<String, Object> map = new HashMap<>();
58 List<Field> fields = new ArrayList<>();
59 fields = getAllFields(fields, clazz);
60 for (Field field : fields) {
61 field.setAccessible(true);
62 map.put(field.getName(), field.get(objectToConvert));
67 private static List<Field> getAllFields(List<Field> fields, Class<?> type) {
68 fields.addAll(Arrays.asList(type.getDeclaredFields()));
69 if (type.getSuperclass() != null) {
70 return getAllFields(fields, type.getSuperclass());
75 public static class SubstitutionEntry {
77 private String fullName = "";
78 private String sourceName = "";
79 private String owner = "";
81 SubstitutionEntry(String fullName, String sourceName, String owner) {
82 if (fullName != null) {
83 this.fullName = fullName;
85 if (sourceName != null) {
86 this.sourceName = sourceName;
93 public String getFullName() {
97 public void setFullName(String fullName) {
98 this.fullName = fullName;
101 public String getSourceName() {
105 public void setSourceName(String sourceName) {
106 this.sourceName = sourceName;
109 public String getOwner() {
113 public void setOwner(String owner) {