示例#1
0
            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);
            }
示例#2
0
 public EntityType(
     Persistence.IEntityType entityType,
     IExternalSystem destinationSystem,
     IEnumerable <IExternalSystem> sharedIdentifierSourceSystems)
 {
     this.entityType        = entityType;
     this.destinationSystem = destinationSystem;
     this.type = this.GetEntityType(entityType);
     this.sharedIdentifierSourceSystems = sharedIdentifierSourceSystems;
 }
示例#3
0
 private void ValidateExternalSystem(
     IExternalSystem externalSystem, string methodName)
 {
     if (externalSystem.Id == Guid.Empty ||
         string.IsNullOrWhiteSpace(externalSystem.Name))
     {
         throw new InvalidOperationException(string.Format(
                                                 Resources.RepositoryMethodReturnedInvalidExternalSystem,
                                                 methodName));
     }
 }
示例#4
0
            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));
            }
示例#5
0
            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);
            }
示例#6
0
            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);
            }
示例#7
0
            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);
            }
示例#8
0
 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;
 }
示例#9
0
 /// <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);
 }
示例#10
0
 /// <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));
 }