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