public IHttpActionResult Get(int id)
        {
            try
            {
                MappingOrigin mappingOrigin;
                if (id > 0)
                {
                    mappingOrigin = _repository.GetById(id);

                    if (mappingOrigin == null)
                    {
                        return(NotFound());
                    }
                }
                else
                {
                    mappingOrigin = new MappingOrigin();
                }
                return(Ok(Mapper.Map <MappingOriginViewModel>(mappingOrigin)));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        public override string GetStepParameters()
        {
            var parameters = new List <string>();

            parameters.Add(MappingOrigin != null ? MappingOrigin.ToStepValue() : "$");
            parameters.Add(MappedRepresentation != null ? MappedRepresentation.ToStepValue() : "$");

            return(string.Join(", ", parameters.ToArray()));
        }
Пример #4
0
 protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options)
 {
     base.setJSON(obj, host, options);
     obj["MappingOrigin"]        = MappingOrigin.getJson(this, options);
     obj["MappedRepresentation"] = MappedRepresentation.getJson(this, options);
     if (mHasShapeAspects.Count > 0)
     {
         obj["HasShapeAspects"] = new JArray(mHasShapeAspects.ConvertAll(x => x.getJson(this, options)));
     }
 }
Пример #5
0
 public MappingDataObject(
     Guid mappingId,
     EntityIdentifier sourceSystemEntityId,
     EntityIdentifier destinationSystemEntityId,
     string serializedEntityHash,
     MappingOrigin origin,
     MappingState state)
 {
     this.MappingId                 = mappingId;
     this.SourceSystemEntityId      = sourceSystemEntityId;
     this.DestinationSystemEntityId = destinationSystemEntityId;
     this.SerializedEntityHash      = serializedEntityHash;
     this.Origin = origin;
     this.State  = state;
 }
Пример #6
0
        /// <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));
        }
        public void DbModelToViewModel()
        {
            AutoMapperConfig.RegisterMappings();
            var mappingOrigin = new MappingOrigin {
                Name = "Manual",
                Id   = 1
            };
            var destination = new Entity
            {
                Name   = "Quality Control",
                Active = true,
                Id     = 2
            };
            var source = new Entity
            {
                Name   = "Labour",
                Active = true,
                Id     = 1
            };
            var dbModel = new EntityMapping
            {
                SourceId        = source.Id,
                Source          = source,
                DestinationId   = destination.Id,
                Destination     = destination,
                MappingOriginId = mappingOrigin.Id,
                MappingOrigin   = mappingOrigin,
                Confirmed       = true,
                Correct         = true,
                Id = 1
            };

            //act
            var viewModel = Mapper.Map <EntityMappingViewModel>(dbModel);

            //Assert
            Assert.AreEqual(viewModel.SourceEntityId, dbModel.SourceId);
            Assert.AreEqual(viewModel.DestinationEntityId, dbModel.DestinationId);
        }