X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fclamp%2Fclds%2Fmodel%2Fprop%2FModelProperties.java;h=7111f1dd56094b97531fafd9787da4b3f784cd1c;hb=0bc898a0d69d3206b55ef71685fbef642436b661;hp=9684eea86ca7e6d89c8d27fd37533d8026109258;hpb=f0c6215103464e860b756d9e781b7e4d34b30541;p=clamp.git diff --git a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java index 9684eea8..7111f1dd 100644 --- a/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java +++ b/src/main/java/org/onap/clamp/clds/model/prop/ModelProperties.java @@ -46,36 +46,35 @@ import org.onap.clamp.clds.service.CldsService; * Parse model properties. */ public class ModelProperties { - protected static final EELFLogger logger = EELFManager.getInstance() + protected static final EELFLogger logger = EELFManager.getInstance() .getLogger(CldsService.class); - protected static final EELFLogger auditLogger = EELFManager.getInstance() + protected static final EELFLogger auditLogger = EELFManager.getInstance() .getAuditLogger(); - private ModelBpmn modelBpmn; - private JsonNode modelJson; + private ModelBpmn modelBpmn; + private JsonNode modelJson; - private final String modelName; - private final String controlName; - private final String actionCd; + private final String modelName; + private final String controlName; + private final String actionCd; // Flag indicate whether it is triggered by Validation Test button from UI - private final boolean isTest; + private final boolean isTest; - private Global global; + private Global global; - private final Map modelElements = new ConcurrentHashMap<>(); + private final Map modelElements = new ConcurrentHashMap<>(); - private String currentModelElementId; - private String policyUniqueId; + private String currentModelElementId; + private String policyUniqueId; - private static final Object lock = new Object(); - private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); + private static final Object lock = new Object(); + private static Map, String> modelElementClasses = new ConcurrentHashMap<>(); static { synchronized (lock) { - modelElementClasses.put(Collector.class, Collector.getType()); modelElementClasses.put(Policy.class, Policy.getType()); - modelElementClasses.put(StringMatch.class, StringMatch.getType()); modelElementClasses.put(Tca.class, Tca.getType()); + modelElementClasses.put(Holmes.class, Holmes.getType()); } } @@ -84,21 +83,28 @@ public class ModelProperties { * parse them all - parse them on demand if requested.) * * @param modelName + * The model name coming form the UI * @param controlName + * The closed loop name coming from the UI * @param actionCd + * Type of operation PUT,UPDATE,DELETE * @param isTest - * @param modelBpmnPropText + * The test flag coming from the UI (for validation only, no + * query are physically executed) + * @param modelBpmnText + * The BPMN flow in JSON from the UI * @param modelPropText - * @throws JsonProcessingException + * The BPMN parameters for all boxes defined in modelBpmnTest * @throws IOException + * In case there is an issue with the JSON decoding */ - public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, - String modelBpmnPropText, String modelPropText) throws IOException { + public ModelProperties(String modelName, String controlName, String actionCd, boolean isTest, String modelBpmnText, + String modelPropText) throws IOException { this.modelName = modelName; this.controlName = controlName; this.actionCd = actionCd; this.isTest = isTest; - modelBpmn = ModelBpmn.create(modelBpmnPropText); + modelBpmn = ModelBpmn.create(modelBpmnText); modelJson = new ObjectMapper().readTree(modelPropText); instantiateMissingModelElements(); @@ -119,7 +125,7 @@ public class ModelProperties { // Parse the list of base Model Elements and build up the // ModelElements modelElementClasses.entrySet().stream().parallel() - .filter(entry -> (ModelElement.class.isAssignableFrom(entry.getKey()) + .filter(entry -> (AbstractModelElement.class.isAssignableFrom(entry.getKey()) && missingTypes.contains(entry.getValue()))) .forEach(entry -> { try { @@ -129,7 +135,7 @@ public class ModelProperties { .newInstance(this, modelBpmn, modelJson))); } catch (InstantiationException | NoSuchMethodException | IllegalAccessException | InvocationTargetException e) { - logger.warn("Unable to instantiate a ModelElement, exception follows: " + e); + logger.warn("Unable to instantiate a ModelElement, exception follows: ", e); } }); } @@ -183,8 +189,8 @@ public class ModelProperties { * @param type * @return */ - public ModelElement getModelElementByType(String type) { - ModelElement modelElement = modelElements.get(type); + public AbstractModelElement getModelElementByType(String type) { + AbstractModelElement modelElement = modelElements.get(type); if (modelElement == null) { throw new IllegalArgumentException("Invalid or not found ModelElement type: " + type); } @@ -338,14 +344,14 @@ public class ModelProperties { return global; } - public static final synchronized void registerModelElement(Class modelElementClass, + public static final synchronized void registerModelElement(Class modelElementClass, String type) { if (!modelElementClasses.containsKey(modelElementClass.getClass())) { modelElementClasses.put(modelElementClass, type); } } - public T getType(Class clazz) { + public T getType(Class clazz) { instantiateMissingModelElements(); String type = modelElementClasses.get(clazz); return (type != null ? (T) modelElements.get(type) : null);