toXmlDocument működés javítás 0 variable esetén
authorOmar Sweidan <omar.sweidan@userrendszerhaz.hu>
Fri, 3 Jun 2022 17:11:34 +0000 (19:11 +0200)
committerOmar Sweidan <omar.sweidan@userrendszerhaz.hu>
Fri, 3 Jun 2022 18:48:23 +0000 (20:48 +0200)
server/user.jobengine.osgi.server/src/user/jobengine/server/ast/JobTemplate.java

index bee3a695f664b7e798d57da59d0e1c5de46a4439..8835f0bc33798bd40a89d7b735e65b217b035aa4 100644 (file)
@@ -248,13 +248,10 @@ public class JobTemplate extends AST implements Serializable {
                                root.appendChild(declarations);\r
                                Element parameters = document.createElement("parameters");\r
                                Element variables = document.createElement("variables");\r
-                               declarations.appendChild(parameters);\r
-                               declarations.appendChild(variables);\r
-                               \r
-                               List<Declaration> declarationsList = getDeclarationSequence().getDeclarations();\r
-                               for (int i = 0; i < declarationsList.size(); i++) {\r
+\r
+                               for (int i = 0; i < getDeclarationSequence().getDeclarations().size(); i++) {\r
                                        Element declarationElement = null;\r
-                                       Declaration declaration = declarationsList.get(i);\r
+                                       Declaration declaration = getDeclarationSequence().getDeclarations().get(i);\r
 \r
                                        if (declaration.getClass().getSimpleName().equals("ParameterDeclaration")) {\r
                                                declarationElement = document.createElement("parameter");\r
@@ -268,13 +265,16 @@ public class JobTemplate extends AST implements Serializable {
                                                variables.appendChild(declarationElement);\r
                                        }\r
                                }\r
+                               declarations.appendChild(parameters);\r
+                               if (variables.hasChildNodes()) {\r
+                                       declarations.appendChild(variables);\r
+                               }\r
                        }\r
                        if (getCommandSequence() != null) {\r
                                Element commands = document.createElement("commands");\r
                                root.appendChild(commands);\r
-                               List<Command> commandsList = getCommandSequence().getCommands();\r
-                               for (int i = 0; i < commandsList.size(); i++) {\r
-                                       CallJobStepCommand cjs = (CallJobStepCommand) commandsList.get(i);\r
+                               for (int i = 0; i < getCommandSequence().getCommands().size(); i++) {\r
+                                       CallJobStepCommand cjs = (CallJobStepCommand) getCommandSequence().getCommands().get(i);\r
                                        Element command = document.createElement("calljobstep");\r
                                        command.setAttribute("type", cjs.getType());\r
                                        command.setAttribute("weight", Integer.toString(cjs.getWeight()));\r
@@ -298,12 +298,11 @@ public class JobTemplate extends AST implements Serializable {
                                        }\r
                                        command.appendChild(inputs);\r
 \r
-                                       if (cjs.getOutputParameterSequence() != null) {\r
-                                               OutputParameterSequence ops = (OutputParameterSequence) cjs.getOutputParameterSequence();\r
+                                       OutputParameterSequence ops = (OutputParameterSequence) cjs.getOutputParameterSequence();\r
+                                       if (ops != null) {\r
                                                Element outputs = document.createElement("outputs");\r
-                                               List<Parameter> outputParameters = ops.getParameters();\r
-                                               for (int j = 0; j < outputParameters.size(); j++) {\r
-                                                       OutputParameter op = (OutputParameter) (outputParameters.get(j));\r
+                                               for (int j = 0; j < ops.getParameters().size(); j++) {\r
+                                                       OutputParameter op = (OutputParameter) (ops.getParameters().get(j));\r
                                                        Element output = document.createElement("output");\r
                                                        Element variable = document.createElement("variable");\r
                                                        variable.setAttribute("name", op.getVariableName().getName());\r