package org.onap.clamp.clds.model.prop;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.HashSet;
import org.onap.clamp.clds.model.CldsModel;
import org.onap.clamp.clds.service.CldsService;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
/**
* Parse model properties.
*/
public class ModelProperties {
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 Tca tca;
+ private Global global;
- private final Map<String, ModelElement> modelElements = new ConcurrentHashMap<>();
+ private final Map<String, AbstractModelElement> 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<Class<? extends ModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
+ private static final Object lock = new Object();
+ private static Map<Class<? extends AbstractModelElement>, 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());
}
}
* 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,
+ 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();
// 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 {
.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);
}
});
}
Global global = new Global(modelJson);
vfs = global.getResourceVf();
} catch (IOException e) {
- // VF is null
+ logger.warn("no VF found", e);
}
String vf = null;
if (vfs != null && !vfs.isEmpty()) {
* @throws IOException
*/
public static ModelProperties create(DelegateExecution execution) throws IOException {
- // String modelProp = (String) execution.getVariable("modelProp");
String modelProp = new String((byte[]) execution.getVariable("modelProp"));
String modelBpmnProp = (String) execution.getVariable("modelBpmnProp");
String modelName = (String) execution.getVariable("modelName");
String controlName = (String) execution.getVariable("controlName");
String actionCd = (String) execution.getVariable("actionCd");
- boolean isTest = (boolean)execution.getVariable("isTest");
+ boolean isTest = (boolean) execution.getVariable("isTest");
return new ModelProperties(modelName, controlName, actionCd, isTest, modelBpmnProp, modelProp);
}
* @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);
}
return actionCd;
}
- /**
- * @return the isTest
- */
- public boolean isTest() {
- return isTest;
- }
+ /**
+ * @return the isTest
+ */
+ public boolean isTest() {
+ return isTest;
+ }
/**
* @return the isCreateRequest
return global;
}
- public static final synchronized void registerModelElement(Class<? extends ModelElement> modelElementClass,
+ public static final synchronized void registerModelElement(Class<? extends AbstractModelElement> modelElementClass,
String type) {
if (!modelElementClasses.containsKey(modelElementClass.getClass())) {
modelElementClasses.put(modelElementClass, type);
}
}
- public <T extends ModelElement> T getType(Class<T> clazz) {
+ public <T extends AbstractModelElement> T getType(Class<T> clazz) {
instantiateMissingModelElements();
String type = modelElementClasses.get(clazz);
return (type != null ? (T) modelElements.get(type) : null);
}
-
- /**
- * @return the tca
- */
- public Tca getTca() {
- if (tca == null) {
- tca = new Tca(this, modelBpmn, modelJson);
- }
- return tca;
- }
}