Example #1
0
        /// <summary>
        /// Retorna a representação de uma planilha em memória que satisfaz o modelo passado como parâmetro
        /// </summary>
        /// <param name="classDiagramPath">caminho para o arquivo .classdiagram que contém o modelo</param>
        /// <returns>represetação da planilha em memória</returns>
        public XWorkbook createXWorkbook(string classDiagramPath)
        {
            ModelReader   reader = new VscdReader(classDiagramPath);
            CoreModelImpl model  = (CoreModelImpl)reader.getModel();

            OclTypesFactory.setEnvironment(model);

            XWorkbook xWorkbook = new XWorkbook();

            xWorkbook.setName(model.getName());

            environment = model.getEnvironmentWithoutParents();
            IEnumerable <CoreClassifier> modelClasses = getClasses(model);

            foreach (CoreClassifier coreClassifier in modelClasses)
            {
                XWorksheet xWorksheet = new XWorksheet();
                xWorksheet.setName(coreClassifier.getName());
                xWorksheet.setWorkbook(xWorkbook);
                updateWorkbook(xWorkbook, xWorksheet);

                XDataTable xDataTable = new XDataTable();
                xDataTable.setName(coreClassifier.getName());
                xDataTable.setWorksheet(xWorksheet);
                updateWorksheet(xWorksheet, xDataTable);

                createFeatureColumns(coreClassifier, xDataTable, model);
                createAssociationColumn(model, coreClassifier, xDataTable);
            }

            IEnumerable <CoreClassifier> enumerations = getEnumerations(model);
            var iEnumerable = enumerations as IList <CoreClassifier> ?? enumerations.ToList();

            if (enumerations != null && iEnumerable.Any())
            {
                foreach (CoreClassifier enumeration in iEnumerable)
                {
                    XWorksheet xWorksheet = new XWorksheet();
                    xWorksheet.setName(enumeration.getName());
                    xWorksheet.setWorkbook(xWorkbook);
                    updateWorkbook(xWorkbook, xWorksheet);

                    XDataTable xDataTable = new XDataTable();
                    xDataTable.setName(enumeration.getName());
                    xDataTable.setWorksheet(xWorksheet);
                    updateWorksheet(xWorksheet, xDataTable);

                    XDataTableColumn xDataTableColumn = new XDataTableColumn();
                    xDataTableColumn.setName(enumeration.getName());
                    xDataTableColumn.setDataTable(xDataTable);
                    updateDataTable(xDataTable, xDataTableColumn);

                    XDataArray dataArray   = new XDataArray();
                    var        arraySymbol =
                        (from CoreAttributeImpl attribute in
                         enumeration.getClassifierFeatures().Where(f => f is CoreAttributeImpl)
                         select attribute.getName()).ToList();
                    dataArray.setArray(arraySymbol);
                    xDataTableColumn.setDataContent(dataArray);
                }
            }

            return(xWorkbook);
        }