Beispiel #1
0
        private XWorkbook createXFormulas(string expressionText, XWorkbook xWorkbook)
        {
            PSWOclCompiler oclCompiler = new PSWOclCompiler(environment, tracker);
            List <object>  nodes       = oclCompiler.compileOclStream(expressionText, "",
                                                                      new StreamWriter(Console.OpenStandardOutput()), typeof(CSTContextDeclarationCS));
            CSTOperationContextCS operationContextCS = ((CSTOperationContextCS)nodes[0]);
            var constraints = operationContextCS.getConstraintsNodesCS();
            CSTOperationConstraintCS operationConstraint = (CSTOperationConstraintCS)constraints[0];
            ExpressionInOcl          expressionInOcl     = operationConstraint.getExpressionInOCL();
            OclExpressionImpl        bodyExpression      = (OclExpressionImpl)expressionInOcl.getBodyExpression();

            XFormulaCreatorVisitor visitor = new XFormulaCreatorVisitor();

            bodyExpression.accept(visitor);
            string formula = visitor.getFormula();

            CoreClassifier classifier  = (CoreClassifier)expressionInOcl.getContextualElement();
            XDataTable     targetTable = getTargetTable(xWorkbook, classifier);

            var operation = operationContextCS.getOperationNodeCS();
            var name      = operation.getOperationName();
            XDataTableColumn targetColumn =
                targetTable.getDataTableColumns().FirstOrDefault(c => c.getName().Equals(name));

            if (targetColumn == null)
            {
                throw new Exception("Coluna não encontrada!");
            }

            XTextExp xtext = new XTextExp();

            xtext.setTextSymbol(formula);
            targetColumn.setDataContent(xtext);

            MessageBox.Show(formula);

            var extraColumns = visitor.getExtraColumns();

            foreach (KeyValuePair <string, string> pair in extraColumns)
            {
                string columnName    = pair.Key;
                string columnFormula = pair.Value;

                targetTable = getTargetTable(xWorkbook, visitor.getCurrentClassifier());

                var newTableColumn = new XDataTableColumn();
                newTableColumn.setName(columnName);
                newTableColumn.setDataTable(targetTable);
                updateDataTable(targetTable, newTableColumn);

                XTextExp xColumnFormula = new XTextExp();
                xColumnFormula.setTextSymbol(columnFormula);
                newTableColumn.setDataContent(xColumnFormula);
            }

            return(xWorkbook);
        }
Beispiel #2
0
 /* (non-Javadoc)
  * @see br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.CSTVisitor#visitOperationConstraint(br.ufrj.cos.lens.odyssey.tools.psw.parser.cst.context.CSTOperationConstraintCS)
  */
 public override void visitOperationConstraint(CSTOperationConstraintCS operationConstraintExpression)
 {
 }