public IEnumerable <EntityMapping> CreateMapping(AutomatedMapping automatedMapping) { // var succesFulInserts = 0; var mappings = new List <EntityMapping>(); var mappingOrigin = _originRepository.GetAll().First(t => t.Name.Equals("Automated")); foreach (var mapping in automatedMapping.LearningResult) { try { var sourceEntity = _entityRepository.GetAll().First(t => t.SystemId == automatedMapping.SourceId && t.Name.Equals(mapping.Mapping.Source)); var destinationEntity = _entityRepository.GetAll().First(t => t.SystemId == automatedMapping.DestinationId && t.Name.Equals(mapping.Mapping.Destination)); var entityMapping = new EntityMapping { SourceId = sourceEntity.Id, Destination = destinationEntity, DestinationId = destinationEntity.Id, Confirmed = false, Correct = null, MappingOriginId = mappingOrigin.Id }; _repository.Add(entityMapping); //succesFulInserts++; mappings.Add(entityMapping); } catch (Exception ex) { _logger.Write(ex); } } return(mappings); }
public void AutomatedMapping() { var db = new EntityMapperDbContext(); var auth = new IdentityAuthAdapter(); var repository = new EfRepository <EntityMapping>(db, auth); var logger = new InMemoryLogger(); var sut = new EntityMappingRepository(repository, logger, null, null); var automatedMapping = new AutomatedMapping { DestinationId = 177, SourceId = 176, LearningResult = new LearningResult(new List <LearntMapping> { new LearntMapping { Mapping = new Mapping { Source = "qmob_commodity", Destination = "qcommodity" } } }) }; //act var result = sut.CreateMapping(automatedMapping); //assert Assert.AreEqual(1, result.Count()); }
public IHttpActionResult Automate([FromBody] AutomatedEntityMappingViewModel entityMapping) { try { if (entityMapping == null) { return(BadRequest("EntityMapping cannot be null")); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } //var learningSession = new LearningSession(new UntrainedData //{ // Sources = _entityRepo.GetAll().Where(t => t.SystemId == entityMapping.SourceSystemId).Select(t => t.Name).ToList(), // Destinations = _entityRepo.GetAll().Where(t => t.SystemId == entityMapping.DestinationSystemId).Select(t => t.Name).ToList() //}); //var result = learningSession.StartLearning(); var automatedMapping = new AutomatedMapping { DestinationId = 177, SourceId = 176, LearningResult = new LearningResult(new List <LearntMapping> { new LearntMapping { Mapping = new Mapping { Source = "qmob_commodity", Destination = "qcommodity" } } }) }; //new AutomatedMapping //{ // LearningResult = result, // SourceId = entityMapping.SourceSystemId, // DestinationId = entityMapping.DestinationSystemId //} var newMappings = _mappingRepository.CreateMapping(automatedMapping); return(Ok(Mapper.Map <IEnumerable <EntityMappingViewModel> >(newMappings))); } catch (Exception ex) { return(InternalServerError(ex)); } }
IEnumerable <EntityMapping> IMappingRepository.CreateMapping(AutomatedMapping automatedMapping) { throw new NotImplementedException(); }
public int CreateMapping(AutomatedMapping automatedMapping) { throw new NotImplementedException(); }