// GET: DIM/Mapping public ActionResult Index(long sourceId = 1, long targetId = 0, LinkElementType type = LinkElementType.System) { MappingManager mappingManager = new MappingManager(); try { MappingMainModel model = new MappingMainModel(); // load from mds example model.Source = MappingHelper.LoadFromMetadataStructure(sourceId, LinkElementPostion.Source, mappingManager); switch (type) { case LinkElementType.System: { model.Target = MappingHelper.LoadfromSystem(LinkElementPostion.Target, mappingManager); model.SelectionList = MappingHelper.LoadSelectionList(); break; } case LinkElementType.MetadataStructure: { model.Target = MappingHelper.LoadFromMetadataStructure(targetId, LinkElementPostion.Target, mappingManager); model.SelectionList = MappingHelper.LoadSelectionList(); break; } } if (model.Source != null && model.Target != null) { //get linkelements LinkElement source = mappingManager.GetLinkElement(sourceId, LinkElementType.MetadataStructure); LinkElement target = mappingManager.GetLinkElement(targetId, type); if (source != null && target != null) { //get root mapping Mapping rootMapping = mappingManager.GetMapping(source, target); if (rootMapping != null) { //get complex mappings model.ParentMappings = MappingHelper.LoadMappings(rootMapping); } } } return(View(model)); } finally { mappingManager.Dispose(); } }
public ActionResult Mapping(long sourceId = 1, long targetId = 0, LinkElementType sourceType = LinkElementType.System, LinkElementType targetType = LinkElementType.System, LinkElementPostion position = LinkElementPostion.Target) { MappingManager mappingManager = new MappingManager(); try { MappingMainModel model = new MappingMainModel(); // load from mds example //model.Source = MappingHelper.LoadFromMetadataStructure(sourceId, LinkElementPostion.Source); /* * Here the source and target will switch the sides */ #region load Source from Target switch (sourceType) { case LinkElementType.System: { model.Source = MappingHelper.LoadfromSystem(LinkElementPostion.Source, mappingManager); if (!model.SelectionList.Any()) { model.SelectionList = MappingHelper.LoadSelectionList(); } break; } case LinkElementType.MetadataStructure: { model.Source = MappingHelper.LoadFromMetadataStructure(sourceId, LinkElementPostion.Source, mappingManager); if (!model.SelectionList.Any()) { model.SelectionList = MappingHelper.LoadSelectionList(); } break; } } #endregion #region load Target switch (targetType) { case LinkElementType.System: { model.Target = MappingHelper.LoadfromSystem(LinkElementPostion.Target, mappingManager); if (!model.SelectionList.Any()) { model.SelectionList = MappingHelper.LoadSelectionList(); } break; } case LinkElementType.MetadataStructure: { model.Target = MappingHelper.LoadFromMetadataStructure(targetId, LinkElementPostion.Target, mappingManager); if (!model.SelectionList.Any()) { model.SelectionList = MappingHelper.LoadSelectionList(); } break; } } #endregion if (model.Source != null && model.Target != null) { //get linkelements LinkElement source = mappingManager.GetLinkElement(sourceId, sourceType); LinkElement target = mappingManager.GetLinkElement(targetId, targetType); if (source != null && target != null) { //get root mapping Mapping rootMapping = mappingManager.GetMapping(source, target); if (rootMapping != null) { //get complex mappings model.ParentMappings = MappingHelper.LoadMappings(rootMapping); } } } return(View("Index", model)); } finally { mappingManager.Dispose(); } }