1 package org.onap.sdc.dcae.composition;
3 import java.lang.reflect.Type;
7 import javax.annotation.PostConstruct;
9 import org.onap.sdc.common.onaplog.OnapLoggerDebug;
10 import org.onap.sdc.common.onaplog.OnapLoggerError;
11 import org.onap.sdc.common.onaplog.Enums.LogLevel;
12 import org.springframework.beans.factory.annotation.Value;
13 import org.springframework.context.annotation.PropertySource;
14 import org.springframework.context.annotation.PropertySources;
15 import org.springframework.stereotype.Component;
17 import com.fasterxml.jackson.annotation.JsonIgnore;
18 import com.fasterxml.jackson.annotation.JsonProperty;
19 import com.google.gson.Gson;
20 import com.google.gson.reflect.TypeToken;
24 @PropertySource(value="classpath:application-fe.properties", ignoreResourceNotFound=true),
25 @PropertySource(value="file:${jetty.base}/config/dcae-be/application.properties", ignoreResourceNotFound=true)
28 public class CompositionConfig {
30 private static OnapLoggerError errLogger = OnapLoggerError.getInstance();
31 private static OnapLoggerDebug debugLogger = OnapLoggerDebug.getInstance();
33 @Value("${compositionConfig.flowTypes}")
34 private String flowTypes;
36 private Map<String, FlowType> flowTypesMap;
37 @Value("${compositionConfig.isRuleEditorActive}")
38 private boolean isRuleEditorActive;
40 // get flowTypes as the parsed keySet
41 public Set<String> getFlowTypes() {
42 return flowTypesMap.keySet();
45 @JsonProperty("isRuleEditorActive")
46 public boolean isRuleEditorActive() {
47 return isRuleEditorActive;
50 public Map<String, FlowType> getFlowTypesMap() {
54 public static class FlowType {
56 private String entryPointPhaseName;
57 private String lastPhaseName;
59 public String getEntryPointPhaseName() {
60 return entryPointPhaseName;
63 public void setEntryPointPhaseName(String entryPointPhaseName) {
64 this.entryPointPhaseName = entryPointPhaseName;
67 public String getLastPhaseName() {
71 public void setLastPhaseName(String lastPhaseName) {
72 this.lastPhaseName = lastPhaseName;
80 debugLogger.log(LogLevel.DEBUG, this.getClass().getName(), "Reading flow type definitions from configuration");
81 Type map = new TypeToken<Map<String, FlowType>>(){}.getType();
82 flowTypesMap = new Gson().fromJson(flowTypes, map);
83 } catch (Exception e) {
84 errLogger.log(LogLevel.ERROR, this.getClass().getName(), "Error – Failed to read flow type definitions");