/// <summary> /// constructor /// </summary> /// <param name="pPage">the visio page</param> /// <param name="pMapping">the mapping to create the objects</param> public void Initialize(Page pPage, MappingList pMapping) { //var init this.PageName = pPage.Name; //generate and initialize objects this.ObjectList = GenerateObjects(this, pPage, pMapping); this.ObjectList.ForEach(t => t.Initialize()); this.ObjectsInitialized = true; //set connections this.ObjectList.ForEach(t => { var connection = t as Connection; if (connection != null) { try { connection.SetConnections(ObjectList); } catch (ValidationFailedException ex) { ValidationFailedEvent?.Invoke(new ValidationFailedMessage(2, ex)); } } }); this.ConnectionsInitialized = true; }
public void MappingIfContainsKey(string inputEntityLogicalName, Dictionary <string, List <Item <EntityReference, EntityReference> > > inputMapping, Dictionary <string, Dictionary <Guid, Guid> > inputMapper, Form parentForm) { using (var mappingDialog = new MappingList(inputMapping[inputEntityLogicalName]) { StartPosition = FormStartPosition.CenterParent }) { if (parentForm != null) { mappingDialog.ShowDialog(parentForm); } var mapList = mappingDialog.GetMappingList(inputEntityLogicalName); var guidMapList = mappingDialog.GetGuidMappingList(); if (mapList.Count == 0) { inputMapping.Remove(inputEntityLogicalName); inputMapper.Remove(inputEntityLogicalName); } else { inputMapping[inputEntityLogicalName] = mapList; inputMapper[inputEntityLogicalName] = guidMapList; } } }
private void btnMappings_Click(object sender, EventArgs e) { var entities = Entities.ToArray(); var mappingDialog = new MappingList(entities, settings[organisationid].Mappings); mappingDialog.ShowDialog(ParentForm); settings[organisationid].Mappings = mappingDialog.GetMappingList(); InitMappings(); }
public void GetMappingListEmptyEntityLogicalName() { string entityLogicalName = string.Empty; using (var systemUnderTest = new MappingList(mappings)) { var actual = systemUnderTest.GetMappingList(entityLogicalName); actual.Count.Should().Be(0); } }
public void Setup() { _applicationPaths = Substitute.For <IApplicationPaths>(); _fileCache = Substitute.For <IFileCache>(); _mappingListData = new AnimeMappingListData(); _applicationPaths.CachePath.Returns(""); _fileCache.GetFileContentAsync(Arg.Is <MappingsFileSpec>(s => s.LocalPath == "anime-list.xml"), CancellationToken.None) .Returns(x => _mappingListData); _mappingList = new MappingList(_applicationPaths, _fileCache); }
public void PopulateMappingGrid() { var entityLogicalName = "Acoount"; var entityRef = new EntityReference(entityLogicalName); var mapping = new Item <EntityReference, EntityReference>(entityRef, entityRef); mappings.Add(mapping); using (var systemUnderTest = new MappingList(mappings)) { FluentActions.Invoking(() => systemUnderTest.PopulateMappingGrid()) .Should() .NotThrow(); } }
/// <summary> /// Configures the DAO using the given Options. /// </summary> /// <param name="options">The options with the values to be used in internal configurations.</param> /// <returns>The DAO instance to be used in fluent code.</returns> public Dao Configure(Options options) { Options = new Options { AutoTrimStrings = options.AutoTrimStrings, ConnectionStrings = options.ConnectionStrings, IsolationLevel = options.IsolationLevel, Logger = options.Logger, NamingStyle = options.NamingStyle, Schema = options.Schema, UseComposedId = options.UseComposedId }; Mappings = new MappingList(); return(this); }
public void GetMappingListPopulatedEntityLogicalName() { var entityLogicalName = "Acoount"; var entityRef = new EntityReference(entityLogicalName); var mapping = new Item <EntityReference, EntityReference>(entityRef, entityRef); mappings.Add(mapping); using (var systemUnderTest = new MappingList(mappings)) { systemUnderTest.PopulateMappingGrid(); var actual = systemUnderTest.GetMappingList(entityLogicalName); actual.Count.Should().Be(1); } }
public void GetGuidMappingList() { var totalEntityReferences = 5; for (int i = 0; i < totalEntityReferences; i++) { var entityRef = new EntityReference($"TestEntity{i}", Guid.NewGuid()); var mapping = new Item <EntityReference, EntityReference>(entityRef, entityRef); mappings.Add(mapping); } using (var systemUnderTest = new MappingList(mappings)) { systemUnderTest.PopulateMappingGrid(); var actual = systemUnderTest.GetGuidMappingList(); actual.Count.Should().Be(totalEntityReferences); } }
public void PerformMappingsCellValidationFormatedValueIsNotAGuidForIdColumn() { for (int i = 0; i < 5; i++) { var entityRef = new EntityReference($"TestEntity{i}", Guid.NewGuid()); var mapping = new Item <EntityReference, EntityReference>(entityRef, entityRef); mappings.Add(mapping); } var column = $"Id"; using (var systemUnderTest = new MappingList(mappings)) { systemUnderTest.PopulateMappingGrid(); var actual = systemUnderTest.PerformMappingsCellValidation(column, "fjkghfjk", 3, 0); actual.Should().BeTrue(); } }
private List <BaseObject> GenerateObjects(Model pParentmodel, Page pPage, MappingList pMapping) { List <BaseObject> ObjectList = new List <BaseObject>(); //transform all shapes into model objects foreach (Shape shape in pPage.Shapes) { BaseObject modelObject = ModelFactory.GetInstanceFromShape(pParentmodel, shape, pMapping); if (modelObject != null) { ObjectList.Add(modelObject); } else { //exception of no matching model object type is found ValidationFailedEvent?.Invoke(new ValidationFailedMessage(1, $"could not match shape {shape.Name}", null)); } } return(ObjectList); }
public void PerformMappingsCellValidationFormatedValueIsNotNullForClEntityColumn() { for (int i = 0; i < 5; i++) { var entityRef = new EntityReference($"TestEntity{i}", Guid.NewGuid()); var mapping = new Item <EntityReference, EntityReference>(entityRef, entityRef); mappings.Add(mapping); } var column = $"clEntity"; var entityRef1 = new EntityReference($"clEntity", Guid.NewGuid()); mappings.Add(new Item <EntityReference, EntityReference>(entityRef1, entityRef1)); using (var systemUnderTest = new MappingList(mappings)) { systemUnderTest.PopulateMappingGrid(); var actual = systemUnderTest.PerformMappingsCellValidation(column, entityRef1.Id, 6, 0); actual.Should().BeFalse(); } }
public void MappingIfKeyDoesNotExist(string inputEntityLogicalName, Dictionary <string, List <Item <EntityReference, EntityReference> > > inputMapping, Dictionary <string, Dictionary <Guid, Guid> > inputMapper, Form parentForm) { var mappingReference = new List <Item <EntityReference, EntityReference> >(); using (var mappingDialog = new MappingList(mappingReference) { StartPosition = FormStartPosition.CenterParent }) { if (parentForm != null) { mappingDialog.ShowDialog(parentForm); } var mapList = mappingDialog.GetMappingList(inputEntityLogicalName); var guidMapList = mappingDialog.GetGuidMappingList(); if (mapList.Count > 0) { inputMapping.Add(inputEntityLogicalName, mapList); inputMapper.Add(inputEntityLogicalName, guidMapList); } } }
public void UpdateAris([FromBody] MappingList model) { var token = model.Token; // deserialize the whole json to object var mappingData = model.modelToSave;// JsonConvert.DeserializeObject<List<Mapping>>(modelToSave); var locationAttributeGuid = GetAppSettings("LocationAttributeGuid"); var supervisorAttributeGuid = GetAppSettings("SupervisorAttributeGuid"); var createdItems = mappingData.Where(i => i.Status == "New").ToList(); var deletedItems = mappingData.Where(i => i.Status == "Deleted").ToList(); #region Delete data from ARIS // call the occ id connection api if there is any data in deleted items if (deletedItems != null && deletedItems.Count > 0) { // get connection id from the database for this database and model guid var modelConnectionUrl = ApiHelper.UrlBuilder(ApiTypeEnum.ModelConnection); var responseJson = GetRawResponse(token, modelConnectionUrl); var data = JsonConvert.DeserializeObject <OccsRootObject>(responseJson); //var parsed = JObject.Parse(responseJson); //var modelConnectionsJson = parsed["items"]["modelconnections"]; var modelConnections = new List <OccurenceConnection>(); foreach (var item in data.items) { foreach (var mc in item.modelconnections) { modelConnections.Add(new OccurenceConnection { kind = mc.kind, occid = mc.occid, //type = mc.type, typename = mc.typename, apiname = mc.apiname, target_guid = mc.target_guid, source_guid = mc.source_guid, //source_link = mc.source_link, //target_link = mc.target_link, source_occid = mc.source_occid, target_occid = mc.target_occid }); } } // loop through the deleted items foreach (var deletedItem in deletedItems) { var personGuid = deletedItem.PersonId; // person to job will be deleted here if (!string.IsNullOrEmpty(deletedItem.JobId)) { var jobGuid = deletedItem.JobId; var occId = modelConnections.Where(i => string.Equals(i.source_guid, personGuid, StringComparison.InvariantCultureIgnoreCase) && string.Equals(i.target_guid, jobGuid, StringComparison.InvariantCultureIgnoreCase)) .Select(i => i.occid).FirstOrDefault(); var encodedOccId = HttpUtility.UrlEncode(occId); if (!string.IsNullOrEmpty(occId)) { var jobDeleteurl = ApiHelper.UrlBuilder(ApiTypeEnum.DeleteData, encodedOccId); var response = GetRawResponse(token, jobDeleteurl, HttpTypeEnum.Delete); } } // person to role model will be deleted here if (!string.IsNullOrEmpty(deletedItem.RoleId) && string.IsNullOrEmpty(deletedItem.BackupId)) { var roleGuid = deletedItem.RoleId; var occId = modelConnections.Where(i => string.Equals(i.source_guid, personGuid, StringComparison.InvariantCultureIgnoreCase) && string.Equals(i.target_guid, roleGuid, StringComparison.InvariantCultureIgnoreCase)) .Select(i => i.occid).FirstOrDefault(); var encodedOccId = HttpUtility.UrlEncode(occId); if (!string.IsNullOrEmpty(occId)) { var roleDeleteUrl = ApiHelper.UrlBuilder(ApiTypeEnum.DeleteData, encodedOccId); var response = GetRawResponse(token, roleDeleteUrl, HttpTypeEnum.Delete); } } // role to backup will be deleted here if (!string.IsNullOrEmpty(deletedItem.BackupId)) { var roleGuid = deletedItem.RoleId; var backupId = deletedItem.BackupId; var occId = modelConnections.Where(i => string.Equals(i.source_guid, roleGuid, StringComparison.InvariantCultureIgnoreCase) && string.Equals(i.target_guid, backupId, StringComparison.InvariantCultureIgnoreCase)) .Select(i => i.occid).FirstOrDefault(); var encodedOccId = HttpUtility.UrlEncode(occId); if (!string.IsNullOrEmpty(occId)) { var roleDeleteUrl = ApiHelper.UrlBuilder(ApiTypeEnum.DeleteData, encodedOccId); var response = GetRawResponse(token, roleDeleteUrl, HttpTypeEnum.Delete); } } } } #endregion foreach (var createdItem in createdItems) { // model object for the person var modelObject = new Models.Connections.Modelobject { kind = "MODELOBJECT", occid = "#1", type = 46, symbol = (int)2, guid = createdItem.PersonId, attributes = new List <Models.Connections.Attribute> { new Models.Connections.Attribute { kind = "ATTRIBUTE", type = 1, value = createdItem.Person }, // location update new Models.Connections.Attribute { kind = "ATTRIBUTE", type = locationAttributeGuid, value = createdItem.Location }, // supervisor update new Models.Connections.Attribute { kind = "ATTRIBUTE", type = supervisorAttributeGuid, value = createdItem.Supervisor } } }; if (!string.IsNullOrEmpty(createdItem.JobId)) { var createConnections = new List <CreateConnection>(); // model for job will be created // create model object for the job here var modelObjectJob = new Models.Connections.Modelobject { kind = "MODELOBJECT", occid = "#2", type = 44, symbol = (int)299, guid = createdItem.JobId, attributes = new List <Models.Connections.Attribute> { new Models.Connections.Attribute { kind = "ATTRIBUTE", type = 1, value = createdItem.JobName } } }; var modelConnection = new Models.Connections.Modelconnection { kind = "MODELCONNECTION", type = 395, source_occid = "#1", target_occid = "#2" }; var createdConnection = new CreateConnection { modelconnections = new List <Models.Connections.Modelconnection> { modelConnection }, }; if (createdConnection.modelobjects == null) { createdConnection.modelobjects = new List <Models.Connections.Modelobject>(); } createdConnection.modelobjects.Add(modelObject); createdConnection.modelobjects.Add(modelObjectJob); createConnections.Add(createdConnection); var updateData = JsonConvert.SerializeObject(createConnections); // remove first [ updateData = updateData.Substring(1); // remove last ] updateData = updateData.Remove(updateData.Length - 1); var createUrl = UrlBuilder(ApiTypeEnum.CreateData); using (var stringContent = new StringContent(updateData, Encoding.UTF8, "application/json")) { var response = GetRawResponse(token, createUrl, HttpTypeEnum.Put, stringContent); } } // person to role model will be created here if (!string.IsNullOrEmpty(createdItem.RoleId) && string.IsNullOrEmpty(createdItem.BackupId)) { var createConnections = new List <CreateConnection>(); // model for job will be created // create model object for the job here var modelObjectRole = new Models.Connections.Modelobject { kind = "MODELOBJECT", occid = "#2", type = 78, symbol = "80f76b81-35b8-11e3-51cf-c1dbe7832b20", guid = createdItem.RoleId, attributes = new List <Models.Connections.Attribute> { new Models.Connections.Attribute { kind = "ATTRIBUTE", type = 1, value = createdItem.RoleName } } }; var modelConnection = new Models.Connections.Modelconnection { kind = "MODELCONNECTION", type = 480, source_occid = "#1", target_occid = "#2" }; var createdConnection = new CreateConnection { modelconnections = new List <Models.Connections.Modelconnection> { modelConnection }, }; if (createdConnection.modelobjects == null) { createdConnection.modelobjects = new List <Models.Connections.Modelobject>(); } createdConnection.modelobjects.Add(modelObject); createdConnection.modelobjects.Add(modelObjectRole); createConnections.Add(createdConnection); var updateData = JsonConvert.SerializeObject(createConnections); // remove first [ updateData = updateData.Substring(1); // remove last ] updateData = updateData.Remove(updateData.Length - 1); var createUrl = ApiHelper.UrlBuilder(ApiTypeEnum.CreateData); using (var stringContent = new StringContent(updateData, Encoding.UTF8, "application/json")) { var response = GetRawResponse(token, createUrl, HttpTypeEnum.Put, stringContent); } } if (!string.IsNullOrEmpty(createdItem.BackupId)) { var createConnections = new List <CreateConnection>(); // model object for the person var modelObjectRole = new Models.Connections.Modelobject { kind = "MODELOBJECT", occid = "#1", type = 46, symbol = (int)2, guid = createdItem.BackupId, attributes = new List <Models.Connections.Attribute> { new Models.Connections.Attribute { kind = "ATTRIBUTE", type = 1, value = createdItem.Backup } } }; // create the connection for the backup here // model for job will be created // create model object for the job here var modelObjectBackup = new Models.Connections.Modelobject { kind = "MODELOBJECT", occid = "#2", type = 78, symbol = "80f76b81-35b8-11e3-51cf-c1dbe7832b20", guid = createdItem.RoleId, attributes = new List <Models.Connections.Attribute> { new Models.Connections.Attribute { kind = "ATTRIBUTE", type = 1, value = createdItem.RoleName } } }; var modelConnectionBackup = new Models.Connections.Modelconnection { kind = "MODELCONNECTION", type = 61, source_occid = "#2", target_occid = "#1" }; var createdConnectionBackup = new CreateConnection { modelconnections = new List <Models.Connections.Modelconnection> { modelConnectionBackup }, }; if (createdConnectionBackup.modelobjects == null) { createdConnectionBackup.modelobjects = new List <Models.Connections.Modelobject>(); } createdConnectionBackup.modelobjects.Add(modelObjectRole); createdConnectionBackup.modelobjects.Add(modelObjectBackup); createConnections.Add(createdConnectionBackup); var updateData = JsonConvert.SerializeObject(createConnections); // remove first [ updateData = updateData.Substring(1); // remove last ] updateData = updateData.Remove(updateData.Length - 1); var createUrl = UrlBuilder(ApiTypeEnum.CreateData); using (var stringContent = new StringContent(updateData, Encoding.UTF8, "application/json")) { var response = GetRawResponse(token, createUrl, HttpTypeEnum.Put, stringContent); } } } }