/// <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); } } } } }
/// <summary> /// Cria colunas na tabela em questão para cada association end com multiplicidade 1 do classifier /// </summary> /// <param name="model">modelo onde se encontra o classifier</param> /// <param name="coreClassifier">classifier</param> /// <param name="xDataTable">tabela</param> private void createAssociationColumn(CoreModel model, CoreClassifier coreClassifier, XDataTable xDataTable) { foreach (CoreAssociationEnd associationEnd in model.getAssociationEndsForClassifier(coreClassifier)) { if (associationEnd.isOneMultiplicity() && associationEnd.isMandatory()) { XDataTableColumn xDataTableColumn = new XDataTableColumn(); xDataTableColumn.setXReference(associationEnd.getType().getName()); xDataTableColumn.setName(associationEnd.getName()); xDataTableColumn.setDataTable(xDataTable); updateDataTable(xDataTable, xDataTableColumn); } } }