1 package org.onap.sdc.dcae.checker;
5 import org.onap.sdc.dcae.checker.annotations.Checks;
8 import java.util.Iterator;
11 public class Workflows {
13 @Checks(path="/topology_template/workflows")
14 public void check_workflows(Map theDefinition, Checker.CheckContext theContext) {
16 theContext.enter("workflows");
19 if(!theContext.checker().checkDefinition("workflows", theDefinition, theContext))
22 for (Iterator<Map.Entry<String,Map>> i = theDefinition.entrySet().iterator(); i.hasNext(); ) {
23 Map.Entry<String,Map> e = i.next();
24 check_workflow_definition(e.getKey(), e.getValue(), theContext);
33 public void check_workflow_definition(String theName, Map theDef, Checker.CheckContext theContext) {
35 theContext.enter("workflow", Construct.Workflow);
37 if (theDef.containsKey("inputs")) {
40 .checkProperties((Map<String,Map>)theDef.get("inputs"), theContext);
43 if (theDef.containsKey("preconditions")) {
44 check_workflow_preconditions_definition((List<Map>)theDef.get("preconditions"), theContext);
47 if (theDef.containsKey("steps")) {
48 check_workflow_steps_definition((Map<String, Map>)theDef.get("steps"), theContext);
55 public void check_workflow_steps_definition(Map theSteps, Checker.CheckContext theContext) {
57 theContext.enter("steps");
60 for (Iterator<Map.Entry<String,Map>> i = theSteps.entrySet().iterator(); i.hasNext(); ) {
61 Map.Entry<String,Map> e = i.next();
62 check_workflow_step_definition(e.getKey(), e.getValue(), theContext);
71 public void check_workflow_step_definition(String theName, Map theDef, Checker.CheckContext theContext) {
73 theContext.enter(theName);
75 //requireed entry, must be a node or group template
76 String target = (String)theDef.get("target");
77 Construct targetConstruct = null;
79 if (theContext.catalog().hasTemplate(theContext.target(), Construct.Group, target)) {
80 targetConstruct = Construct.Group;
82 else if (theContext.catalog().hasTemplate(theContext.target(), Construct.Node, target)) {
83 targetConstruct = Construct.Node;
86 theContext.addError("The 'target' entry must contain a reference to a node template or group template, '" + target + "' is none of those", null);
89 String targetRelationship = (String)theDef.get("target_relationship");
90 if (targetConstruct.equals(Construct.Node)) {
91 if (targetRelationship != null) {
92 //must be a requirement of the target Node
103 public void check_workflow_preconditions_definition(List<Map> thePreconditions, Checker.CheckContext theContext) {
105 theContext.enter("preconditions");
108 for (Map precondition: thePreconditions) {
109 check_workflow_precondition_definition(precondition, theContext);
117 public void check_workflow_precondition_definition(Map theDef, Checker.CheckContext theContext) {