コード例 #1
0
        /**
         * Translates the abstract tree to a String
         */
        public String toString()
        {
            String res = "";

            if (this.orchestration == null)
            {
                return("");
            }

            Stack <CertifierOrchestrationElement> nodes = new Stack <CertifierOrchestrationElement>();

            nodes.Push(this.root);

            while (nodes.Count != 0)
            {
                CertifierOrchestrationElement e = nodes.Pop();
                String space = "";
                for (int i = 0; i <= e.getElement().level; i++)
                {
                    space += "    ";
                }

                res += space + e + "\n";
                foreach (CertifierOrchestrationElement child in e.getChildren())
                {
                    nodes.Push(child);
                }
            }

            return(res);
        }
 public void addWorflowElement(CertifierOrchestrationElement wf)
 {
     this.children.Add(wf);
 }
コード例 #3
0
        /*public void parseorchestration(String fileName) {
         *      try {
         *              JAXBContext jc = JAXBContext
         *                              .newInstance("hpcshelf.certification.orchestration.grammar");
         *              Unmarshaller unmarshaller = jc.createUnmarshaller();
         *              Object out = unmarshaller.unmarshal(new File(fileName));
         *              JAXBElement<?> je = (JAXBElement<?>) out;
         *              this.orchestration = (XMLCertifierOperation) je.getValue();
         *              this.navigate(); // this method constructs the tree node orchestration
         *      } catch (JAXBException e) {
         *
         *              e.printStackTrace();
         *      }
         * }
         */


        private void navigate()
        {
            if (this.orchestration == null)
            {
                return;
            }
            this.root = new CertifierOrchestrationElement();
            this.root.accept(this.safeVisitor);
            int level = 1;
            int order = 100;

            Stack <Object> elementsStack = new Stack <Object>();
            Stack <CertifierOrchestrationElement> wfElements = new Stack <CertifierOrchestrationElement>();

            elementsStack.Push(this.orchestration);


            ((XMLCertifierBase)this.orchestration).level     = level; // for fun
            ((XMLCertifierBase)this.orchestration).order     = order;
            ((XMLCertifierBase)this.orchestration).oper_name = "orchestration";

            this.root.setElement(this.orchestration);
            this.root.setOperation(((XMLCertifierBase)this.orchestration).oper_name);
            wfElements.Push(this.root);

            while (elementsStack.Count != 0)
            {
                Object element = elementsStack.Pop();
                CertifierOrchestrationElement wfElement = wfElements.Pop();


                int myLevel = ((XMLCertifierBase)element).level;

                List <Object> children     = this.getChildren(element);
                int           orderCounter = children.Count;
                Console.WriteLine("count children " + orderCounter);
                for (int i = children.Count - 1; i >= 0; i--)
                {
                    Object child = children[i];
                    Console.WriteLine("Oper name " + ((XMLCertifierBase)child).oper_name);
                    if (string.Equals(((XMLCertifierBase)child).oper_name, CertifierOrchestrationOperation.OPERATION.ToString(), StringComparison.OrdinalIgnoreCase))
                    {
                        child = this.getChildren(child)[0];
                    }

                    // level control, for graphical purpouses
                    ((XMLCertifierBase)child).level = myLevel + 1;
                    ((XMLCertifierBase)child).order = (myLevel + 1) * 100 + orderCounter;

                    elementsStack.Push(child);
                    orderCounter--;

                    // wfElement
                    CertifierOrchestrationElement wfChild = new CertifierOrchestrationElement();
                    //adding visitor
                    wfChild.accept(this.safeVisitor);
                    wfChild.setElement((XMLCertifierBase)child);
                    wfChild.setOperation(((XMLCertifierBase)child).oper_name);
                    wfElement.addWorflowElement(wfChild);
                    wfElements.Push(wfChild);
                }
            }
        }