Exemplo n.º 1
0
        /// <summary>
        /// Cria colunas na tabela em questão para cada feature do classifier
        /// </summary>
        /// <param name="coreClassifier">classifier</param>
        /// <param name="xDataTable">tabela</param>
        /// <param name="model">modelo</param>
        private void createFeatureColumns(CoreClassifier coreClassifier, XDataTable xDataTable, CoreModelImpl model)
        {
            List <object> features = new List <object>();

            features.AddRange(coreClassifier.getClassifierFeatures().Where(f => f.GetType() == typeof(CoreAttributeImpl)));

            var keyAttribute = features.FirstOrDefault(f => ((CoreAttributeImpl)f).hasStereotype("Id"));

            if (keyAttribute != null)
            {
                xDataTable.setKeyIndex(features.IndexOf(keyAttribute) + 1);
            }

            features.AddRange(coreClassifier.getClassifierFeatures().Where(f => f.GetType() == typeof(CoreOperationImpl)));

            foreach (CoreFeature feature in features)
            {
                XDataTableColumn xDataTableColumn = new XDataTableColumn();
                xDataTableColumn.setName(feature.getName());
                xDataTableColumn.setDataTable(xDataTable);
                updateDataTable(xDataTable, xDataTableColumn);

                if (feature is CoreAttributeImpl)
                {
                    var    featureImpl = (CoreAttributeImpl)feature;
                    string featureName = featureImpl.getFeatureType().getName();
                    if (coreClassifier.isEnumeration())
                    {
                        xDataTableColumn.setXReference(featureName);
                    }
                    else
                    {
                        var enumerations = getEnumerations(model);
                        if (enumerations.FirstOrDefault(e => e.getName() == featureName) != null)
                        {
                            xDataTableColumn.setXReference(featureName);
                        }
                    }
                }
            }
        }