public Mapping( MappingRepository <TEntity> parent, MappingDataObject mappingDataObject) { this.parent = parent; this.mappingDataObject = mappingDataObject; }
/// <summary> /// Creates a new mapping for the specified source system entity of the type that's /// currently being processed. /// </summary> /// <param name="sourceSystemEntityId"> /// The ID that uniquely identifies the entity in its source system. /// </param> /// <param name="destinationSystemEntityId"> /// The ID that uniquely identifies the entity in the destination system. /// </param> /// <param name="origin">The origin of the mapping.</param> /// <param name="serializedEntity">The serialized source system entity.</param> /// <returns>Mapping data for the mapping created.</returns> public MappingDataObject CreateMapping( EntityIdentifier sourceSystemEntityId, EntityIdentifier destinationSystemEntityId, MappingOrigin origin, Persistence.ISerializedEntity serializedEntity) { var mappingDataObject = new MappingDataObject( Guid.NewGuid(), sourceSystemEntityId, destinationSystemEntityId, serializedEntity.DataHash, origin, MappingState.Active); this.safeRepository.CreateMapping( new Mapping( mappingDataObject.MappingId, this.operationExecutive.CurrentOperation, serializedEntity, this.context.EntityType.Id, this.context.SourceSystem.Id, mappingDataObject.SourceSystemEntityId, mappingDataObject.DestinationSystemEntityId, (int)mappingDataObject.Origin, (int)mappingDataObject.State)); mappings.Add( new SourceSystemEntityIdentity( this.context.EntityType.Id, this.context.SourceSystem.Id, mappingDataObject.SourceSystemEntityId), mappingDataObject); return(mappingDataObject); }
/// <summary> /// Gets the specified entity's (of the type represented by this instance) mapping. /// </summary> /// <param name="sourceSystemEntityId"> /// The ID that uniquely identifies the entity in its source system. /// </param> /// <returns> /// The specified entity's mapping; if no mapping for the specified entity exists, /// null will be returned. /// </returns> public IMapping <TEntity> GetMapping(EntityIdentifier sourceSystemEntityId) { IMapping <TEntity> mapping = null; MappingDataObject mappingData = this.mappingDataRepository.GetMappingData( this.context.EntityType.Id, this.context.SourceSystem.Id, sourceSystemEntityId); if (mappingData != null) { mapping = new Mapping(this, mappingData); } return(mapping); }
/// <summary> /// Creates a new mapping for the specified source system entity. /// </summary> /// <param name="sourceSystemEntityId"> /// The ID that uniquely identifies the entity in its source system. /// </param> /// <param name="destinationSystemEntityId"> /// The ID that uniquely identifies the entity in the destination system. /// </param> /// <param name="origin">The origin of the mapping.</param> /// <param name="entity">The source system entity.</param> /// <returns>The mapping created.</returns> public IMapping <TEntity> CreateMapping( EntityIdentifier sourceSystemEntityId, EntityIdentifier destinationSystemEntityId, MappingOrigin origin, TEntity entity) { Persistence.ISerializedEntity serializedEntity = this.hashingSerializer.Serialize(entity); MappingDataObject mappingDataObject = this.mappingDataRepository.CreateMapping( sourceSystemEntityId, destinationSystemEntityId, origin, serializedEntity); this.operationExecutive .CurrentOperation .UpdateIdentityCorrelationId(sourceSystemEntityId); return(new Mapping(this, mappingDataObject)); }
/// <summary> /// Maps the specified source system entity ID (of the specified type) to its /// destination system counterpart. /// </summary> /// <param name="entityTypeId">The ID of the entity type.</param> /// <param name="sourceSystemId">The ID of the entity's source system.</param> /// <param name="sourceSystemEntityId"> /// The ID that uniquely identifies the entity in the specified source system. /// </param> /// <returns> /// The ID that uniquely identifies the entity in the destination system; if the /// specified source system entity ID isn't mapped, null will be returned. /// </returns> public EntityIdentifier GetDestinationSystemEntityId( Guid entityTypeId, Guid sourceSystemId, EntityIdentifier sourceSystemEntityId) { // validate the sourceSystemEntityId parameter ArgumentValidator.EnsureArgumentNotNull( sourceSystemEntityId, nameof(sourceSystemEntityId)); // get and return the destination system entity ID EntityIdentifier destinationSystemEntityId = null; MappingDataObject mappingData = this.mappingDataRepository.GetMappingData( entityTypeId, sourceSystemId, sourceSystemEntityId); if (mappingData != null) { destinationSystemEntityId = mappingData.DestinationSystemEntityId; } return(destinationSystemEntityId); }