public EntityMapper(Dictionary <string, AttributeMetadata> attributeMetadataDictionary, DataMetadata dataMetadata, List <DataMapping> mappings, List <PicklistMapping> picklistMappings) { this.dataMetadata = dataMetadata; this.mappings = mappings; this.picklistMappings = picklistMappings; this.attributeMetadataDictionary = attributeMetadataDictionary; foreach (var column in mappings) { if (!attributeMetadataDictionary.ContainsKey(column.Target)) { throw new Exception("The attribute " + column.Target + " is mapped, but does not exist in the current customizations."); } } columnMetadataDictionary = new Dictionary <string, ColumnMetadata>(); foreach (var column in dataMetadata.Columns.Values) { if (columnMetadataDictionary.ContainsKey(column.ColumnName) == false) { columnMetadataDictionary.Add(column.ColumnName, column); } else { throw new Exception("Column " + column.ColumnName + " exists twice. Please make sure the columnnames are unique!"); } } }
private bool CheckDataConditions(object[] record, DataMetadata dataMetadata, Dictionary <string, AttributeImplementation> dataConditionAttributes) { bool conditionsResult = false; foreach (DataCondition dataCondition in this.DataConditions) { int columnIndex = dataMetadata[dataCondition.ColumnName].ColumnIndex; object objectValue = record[columnIndex]; AttributeImplementation attributeImplentation = dataConditionAttributes[dataCondition.ConditionType + dataCondition.TreatAsType.ToString()]; conditionsResult = attributeImplentation.DataConditionCheck.ConditionIsFullfilled(dataCondition, objectValue); switch (this.FilterType.Value) { case DataFilterType.AND: if (conditionsResult == false) { return(false); } break; case DataFilterType.OR: if (conditionsResult == true) { return(true); } break; default: throw new NotImplementedException("Filtertype " + this.FilterType.Value + " is not implemented!"); } } return(this.FilterType.Value == DataFilterType.OR ? false : true); }
public EntityMapper(EntityMetadata entityMetadata, DataMetadata dataMetadata, List <DataMapping> mappings, List <PicklistMapping> picklistMappings) { this.entityMetadata = entityMetadata; this.dataMetadata = dataMetadata; this.mappings = mappings; this.picklistMappings = picklistMappings; attributeMetadataDictionary = new Dictionary <string, AttributeMetadata>(); foreach (var column in mappings) { AttributeMetadata attributeMetadata = entityMetadata.Attributes.FirstOrDefault(t => t.LogicalName == column.Target); if (attributeMetadata == null) { throw new Exception("The attribute " + column.Target + " is mapped, but does not exist in the current customizations."); } if (attributeMetadataDictionary.ContainsKey(attributeMetadata.LogicalName) == false) { attributeMetadataDictionary.Add(attributeMetadata.LogicalName, attributeMetadata); } } columnMetadataDictionary = new Dictionary <string, ColumnMetadata>(); foreach (var column in dataMetadata.Columns.Values) { if (columnMetadataDictionary.ContainsKey(column.ColumnName) == false) { columnMetadataDictionary.Add(column.ColumnName, column); } else { throw new Exception("Column " + column.ColumnName + " exists twice. Please make sure the columnnames are unique!"); } } }
public EntityMapperLight(EntityMetadata entityMetadata, DataMetadata dataMetadata, List <DataMapping> mappings) { this.entityMetadata = entityMetadata; this.dataMetadata = dataMetadata; this.mappings = mappings; attributeMetadataDictionary = new Dictionary <string, AttributeMetadata>(); foreach (var column in mappings) { AttributeMetadata attributeMetadata = entityMetadata.Attributes.Where(t => t.LogicalName == column.Target).First(); attributeMetadataDictionary.Add(attributeMetadata.LogicalName, attributeMetadata); } columnMetadataDictionary = new Dictionary <string, ColumnMetadata>(); foreach (var column in dataMetadata.Columns.Values) { columnMetadataDictionary.Add(column.ColumnName, column); } }
public bool IsRecordInFilter(object[] record, DataMetadata dataMetadata, Dictionary <string, AttributeImplementation> dataConditionAttributes) { bool conditionsValid = CheckDataConditions(record, dataMetadata, dataConditionAttributes); if (conditionsValid == false) { return(false); } foreach (DataFilter subFilter in this.Filters) { bool isRecordInSubFilter = IsRecordInSubFilter(record, dataMetadata, subFilter, dataConditionAttributes); if (isRecordInSubFilter == false) { return(false); } } return(true); }
public DataStoreConverter(string targetTable, DataMetadata dataMetadata, List <DataMapping> dataMapping) { this.targetTable = targetTable; this.dataMetadata = dataMetadata; this.dataMapping = dataMapping; }
public static List <KeyValuePair <string, object> > BuildRecordIdentifiers(DbTargetCommonConfiguration configuration, object[] rowData, DataMetadata dataMetadata) { List <KeyValuePair <string, object> > recordIdentifiers = new List <KeyValuePair <string, object> >(); foreach (var primaryKeyField in configuration.PrimaryKeyFields) { var primaryKeyMapping = configuration.Mapping.FirstOrDefault(t => t.Target == primaryKeyField); if (primaryKeyMapping == null) { throw new Exception("The primarykey " + primaryKeyField + " is not mapped!"); } var recordIdentifier = new KeyValuePair <string, object>(primaryKeyField, rowData[dataMetadata[primaryKeyMapping.Source].ColumnIndex]); recordIdentifiers.Add(recordIdentifier); } return(recordIdentifiers); }
private bool IsRecordInSubFilter(object[] record, DataMetadata dataMetadata, DataFilter subFilter, Dictionary <string, AttributeImplementation> dataConditionAttributes) { return(subFilter.IsRecordInFilter(record, dataMetadata, dataConditionAttributes)); }
public static string BuildExistingCheckKey(object[] dataObject, List <DataMappingControl.DataMapping> mapping, DataMetadata dataMetadata) { string[] keyvalues = new string[mapping.Count]; for (int iMapping = 0; iMapping < mapping.Count; iMapping++) { string source = mapping[iMapping].Source; keyvalues[iMapping] = dataObject[dataMetadata[source].ColumnIndex].ToString(); } string key = string.Empty; for (int i = 0; i < keyvalues.Length; i++) { key += keyvalues[i] + "##"; } return(key); }