Fix CBA artifact recognition by SDC
[sdc.git] / openecomp-be / lib / openecomp-heat-lib / src / main / java / org / openecomp / sdc / heat / datatypes / manifest / FileData.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.heat.datatypes.manifest;
22
23 import java.util.ArrayList;
24 import java.util.Arrays;
25 import java.util.HashSet;
26 import java.util.List;
27 import java.util.Set;
28 import java.util.function.Predicate;
29
30 import lombok.AccessLevel;
31 import lombok.AllArgsConstructor;
32 import lombok.Data;
33 import lombok.Getter;
34 import lombok.Setter;
35 import org.apache.commons.collections4.CollectionUtils;
36
37 @Data
38 public class FileData {
39
40     protected static final Set<Type> heatFileTypes =
41             new HashSet<>(Arrays.asList(Type.HEAT, Type.HEAT_NET, Type.HEAT_VOL));
42
43     @Getter(AccessLevel.NONE)
44     @Setter(AccessLevel.NONE)
45     private Boolean isBase;
46     private String parentFile;
47     private String file;
48     private Type type;
49     private List<FileData> data;
50
51     public static Predicate<FileData> buildFileDataPredicateByType(Type... types) {
52         return fileData -> Arrays.asList(types).contains(fileData.getType());
53     }
54
55     public static boolean isHeatFile(Type type) {
56         return heatFileTypes.contains(type);
57     }
58
59     public Boolean getBase() {
60         return isBase;
61     }
62
63     public void setBase(Boolean base) {
64         isBase = base;
65     }
66
67     /**
68      * Add file data.
69      *
70      * @param data the data
71      */
72     public void addFileData(FileData data) {
73         if (CollectionUtils.isEmpty(this.data)) {
74             this.data = new ArrayList<>();
75         }
76         this.data.add(data);
77     }
78
79     @AllArgsConstructor
80     @Getter
81     public enum Type {
82         HEAT("HEAT"),
83         HEAT_ENV("HEAT_ENV"),
84         HEAT_NET("HEAT_NET"),
85         HEAT_VOL("HEAT_VOL"),
86         CHEF("CHEF"),
87         PUPPET("PUPPET"),
88         SHELL("SHELL"),
89         YANG("YANG"),
90         YANG_XML("YANG_XML"),
91         BPEL("BPEL"),
92         DG_XML("DG_XML"),
93         MURANO_PKG("MURANO_PKG"),
94         VENDOR_LICENSE("VENDOR_LICENSE"),
95         VF_LICENSE("VF_LICENSE"),
96         CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT("CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT"),
97         CONTROLLER_BLUEPRINT_ARCHIVE("CONTROLLER_BLUEPRINT_ARCHIVE"),
98         OTHER("OTHER"),
99         PNF_SW_INFORMATION("PNF_SW_INFORMATION");
100
101         private String displayName;
102
103         public static boolean isArtifact(Type fileType) {
104             return !Arrays.asList(HEAT, HEAT_ENV, HEAT_VOL).contains(fileType);
105         }
106
107         public static boolean canBeAssociated(Type fileType) {
108             return HEAT_VOL == fileType;
109         }
110     }
111 }