private bool IsEmptyOrDefaultColumnValue(EntitySchemaColumn column, EntityColumnValue columnValue) { return( columnValue.Value == null || columnValue.Value.ToString().IsNullOrEmpty() || (column.HasDefValue && columnValue.Value.Equals(column.DefValue.Value))); }
private object FormatSourceValue(EntityColumnValue columnValue) { if (columnValue.Column.DataValueType is DateTimeDataValueType dateTimeType) { return(FormatDateTimeValue(columnValue.Value, dateTimeType.Kind)); } return(columnValue.Value); }
/// <summary> /// Default implementation of entity column value formatting. /// </summary> /// <param name="value">Source entity column value.</param> /// <param name="column">Entity schema column.</param> /// <returns></returns> public virtual string GetStringValue(EntityColumnValue columnValue) { var column = columnValue.Column; if (IsEmptyValue(columnValue.Value)) { return(string.Empty); } if (column != null && column.DataValueType is DateTimeDataValueType) { return(column.DataValueType.GetColumnDisplayValue(column, columnValue.Value)); } return(Convert.ToString(columnValue.Value)); }
private void MergeImageColumn(Entity goldRecord, EntityColumnValue winnerImageColumnValue, EntitySchemaColumn column) { var entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName("SysImage"); var entityImage = entitySchema.CreateEntity(UserConnection); entityImage.FetchFromDB(winnerImageColumnValue.Value); var newImageId = Guid.NewGuid(); var cloneEntity = entityImage.Clone() as Entity; cloneEntity.SetColumnValue("Id", newImageId); var saveResult = cloneEntity.Save(); if (saveResult) { goldRecord.SetColumnValue(column.ColumnValueName, newImageId); } }
/// <summary> /// Validates duplicate entities. /// </summary> /// <param name="schemaName">Schema name.</param> /// <param name="duplicateRecordIds">Collection of identifiers of duplicate entities.</param> /// <param name="resolvedConflicts">Config for resolving conflicts.</param> /// <returns>Validation result.</returns> public ValidateDuplicatesResponse ValidateDuplicates(string schemaName, List <Guid> duplicateRecordIds, Dictionary <string, string> resolvedConflicts) { ValidateDuplicatesResponse response = new ValidateDuplicatesResponse(); EntitySchema entitySchema = UserConnection.EntitySchemaManager.GetInstanceByName(schemaName); EntityCollection entityCollection = GetEntityDublicates(schemaName, duplicateRecordIds); Entity goldenEntity = entityCollection.FirstOrDefault(); if (goldenEntity == null) { return(response); } entityCollection.RemoveFirst(); List <string> resolvedColumns = new List <string>(); if (resolvedConflicts != null) { resolvedColumns = resolvedConflicts.Keys.ToList(); } List <string> conflictColumns = new List <string>(); foreach (EntitySchemaColumn column in goldenEntity.Schema.Columns) { if (IsColumnInIgnoreList(column.Name)) { continue; } if (GetIsSystemColumn(entitySchema, column)) { continue; } if (resolvedColumns.Contains(column.Name)) { continue; } bool isConflictColumn = false; EntityColumnValue goldenColumnValue = goldenEntity.FindEntityColumnValue(column.ColumnValueName); foreach (Entity entity in entityCollection) { EntityColumnValue columnValue = entity.FindEntityColumnValue(column.ColumnValueName); if (DataTypeUtilities.ValueIsNullOrEmpty(goldenColumnValue.Value)) { goldenColumnValue = columnValue; continue; } if (DataTypeUtilities.ValueIsNullOrEmpty(columnValue.Value)) { continue; } if (IsEquals(goldenColumnValue.Value, columnValue.Value) == false) { isConflictColumn = true; break; } } if (isConflictColumn) { conflictColumns.Add(column.Name); } } if (conflictColumns.Any()) { conflictColumns.AddRange(resolvedColumns); EntityCollection conflicts = GetEntityDublicates(schemaName, duplicateRecordIds, conflictColumns); Dictionary <string, string> columnMap = GetQueryColumns(conflicts.Schema.Columns); DataContract.EntityCollection convertedEntities = QueryExtension.GetEntityCollection(conflicts, columnMap); response.Conflicts = convertedEntities; } return(response); }
private KeyValuePair <string, object> MapToContactColumnValues(EntityColumnValue changedValue) { string key = changedValue.Name == "Contact" ? "Name" : changedValue.Name; return(new KeyValuePair <string, object>(key, changedValue.Value)); }