public IContext CreateContext( IBootstrapper bootstrapper, SegmentConfiguration segmentConfiguration, int segmentIndex, int segmentCount, IDictionary <string, object> runData) { IContext context; IEnumerable <IExternalSystem> externalSystems = this.CreateExternalSystems(); IExternalSystem sourceSystem = this.GetSourceSystem(segmentConfiguration, externalSystems); IEnumerable <IEntityType> entityTypes = this.CreateEntityTypes(sourceSystem, externalSystems); IEntityType entityType = this.GetEntityType(segmentConfiguration.EntityType, entityTypes); IReadOnlyDictionary <string, string> parameters = this.AssembleParameters(bootstrapper, entityType, sourceSystem); context = new Context( segmentConfiguration.Type, segmentIndex, segmentCount, sourceSystem, entityType, externalSystems, entityTypes, parameters, runData); return(context); }
public EntityType( Persistence.IEntityType entityType, IExternalSystem destinationSystem, IEnumerable <IExternalSystem> sharedIdentifierSourceSystems) { this.entityType = entityType; this.destinationSystem = destinationSystem; this.type = this.GetEntityType(entityType); this.sharedIdentifierSourceSystems = sharedIdentifierSourceSystems; }
private void ValidateExternalSystem( IExternalSystem externalSystem, string methodName) { if (externalSystem.Id == Guid.Empty || string.IsNullOrWhiteSpace(externalSystem.Name)) { throw new InvalidOperationException(string.Format( Resources.RepositoryMethodReturnedInvalidExternalSystem, methodName)); } }
private IReadOnlyDictionary <string, string> AssembleParameters( IBootstrapper bootstrapper, IEntityType entityType, IExternalSystem sourceSystem) { IParametersAssembler parametersAssembler = bootstrapper.Get <IParametersAssembler>(); return(parametersAssembler.AssembleParameters( entityType.DestinationSystem.Id, entityType.Id, sourceSystem != null ? (Guid?)sourceSystem.Id : null)); }
private IEnumerable <IEntityType> CreateEntityTypes( IExternalSystem sourceSystem, IEnumerable <IExternalSystem> externalSystems) { IEnumerable <IEntityType> entityTypes; IDictionary <Guid, IExternalSystem> externalSystemsById = externalSystems .ToDictionary(externalSystem => externalSystem.Id); if (sourceSystem != null) { IDictionary <Guid, IEnumerable <Guid> > sharedIdentifierSourceSystemIds = this .sharedIdentifierSourceSystems .Where(siss => siss.SourceSystemId == sourceSystem.Id) .GroupBy(siss => siss.EntityTypeId) .ToDictionary( group => group.Key, group => group.Select( siss => siss.SharedIdentifierSourceSystemId)); entityTypes = this .entityTypes .Select(entityType => new EntityType( entityType, this.GetExternalSystem( entityType.DestinationSystemId, externalSystemsById), this.GetSharedIdentifierSourceSystems( entityType.Id, sharedIdentifierSourceSystemIds, externalSystemsById))) .ToArray(); } else { entityTypes = this .entityTypes .Select(entityType => new EntityType( entityType, this.GetExternalSystem( entityType.DestinationSystemId, externalSystemsById), null)) .ToArray(); } return(entityTypes); }
private IEnumerable <IExternalSystem> GetSharedIdentifierSourceSystems( Guid entityTypeId, IDictionary <Guid, IEnumerable <Guid> > sharedIdentifierSourceSystemIds, IDictionary <Guid, IExternalSystem> externalSystemsById) { var sharedIdentifierSourceSystems = new IExternalSystem[0]; if (sharedIdentifierSourceSystemIds .TryGetValue(entityTypeId, out IEnumerable <Guid> sourceSystemIds)) { sharedIdentifierSourceSystems = sourceSystemIds .Select(id => this.GetExternalSystem(id, externalSystemsById)) .ToArray(); } return(sharedIdentifierSourceSystems); }
private IExternalSystem GetSourceSystem( SegmentConfiguration segmentConfiguration, IEnumerable <IExternalSystem> externalSystems) { IExternalSystem sourceSystem = null; string sourceSystemName = this.GetSourceSystemName(segmentConfiguration); if (sourceSystemName != null) { sourceSystem = this.parent.Single( externalSystems, this.GetSourceSystemName(segmentConfiguration), externalSystem => externalSystem.Name, Resources.SourceSystemNotFound); } return(sourceSystem); }
public Context( SegmentType segmentType, int segmentIndex, int segmentCount, IExternalSystem sourceSystem, IEntityType entityType, IEnumerable <IExternalSystem> externalSystems, IEnumerable <IEntityType> entityTypes, IReadOnlyDictionary <string, string> parameters, IDictionary <string, object> runData) { this.segmentType = segmentType; this.segmentIndex = segmentIndex; this.segmentCount = segmentCount; this.sourceSystem = sourceSystem; this.entityType = entityType; this.externalSystems = externalSystems; this.entityTypes = entityTypes; this.parameters = parameters; this.runData = runData; }
/// <summary> /// Creates or updates the specified external system. /// </summary> /// <param name="externalSystem">The external system to create or update.</param> public void CreateOrUpdateExternalSystem(IExternalSystem externalSystem) { this.context.CreateOrUpdateExternalSystem( externalSystem.Id, externalSystem.Name); }
/// <summary> /// Creates or updates the specified external system. /// </summary> /// <param name="externalSystem">The external system to create or update.</param> public void CreateOrUpdateExternalSystem(IExternalSystem externalSystem) { this.Invoke( () => this.repository.CreateOrUpdateExternalSystem(externalSystem), nameof(this.repository.CreateOrUpdateExternalSystem)); }