Beispiel #1
0
 public LinkElementContainerModel(LinkElementComplexity complexity, LinkElementPostion position)
 {
     //Type = type;
     Complexity   = complexity;
     LinkElements = new List <LinkElementModel>();
     Position     = position;
 }
Beispiel #2
0
 public LinkElementRootModel(LinkElementType type, long elementId, string name, LinkElementPostion position)
 {
     Id                    = ElementId;
     ElementId             = elementId;
     Type                  = type;
     Name                  = name;
     LinkElementContainers = new List <LinkElementContainerModel>();
     LinkElements          = new List <LinkElementModel>();
     Position              = position;
 }
Beispiel #3
0
 public static LinkElementModel CreateLinkElementModel(LinkElement le, LinkElementPostion position)
 {
     return(new LinkElementModel()
     {
         Id = le.Id,
         ElementId = le.ElementId,
         XPath = le.XPath,
         Name = le.Name,
         Position = position,
         Type = le.Type,
         Complexity = le.Complexity
     });
 }
Beispiel #4
0
 public ActionResult Switch(long sourceId = 1, long targetId = 0,
                            LinkElementType sourceType  = LinkElementType.System, LinkElementType targetType = LinkElementType.System,
                            LinkElementPostion position = LinkElementPostion.Target)
 {
     return(RedirectToAction("Mapping", new
     {
         sourceId = targetId,
         targetId = sourceId,
         sourceType = targetType,
         targetType = sourceType,
         position = position
     }));
 }
Beispiel #5
0
        public static LinkElementRootModel LoadFromMetadataStructure(long id, LinkElementPostion rootModelType, MappingManager mappingManager)
        {
            MetadataStructureManager metadataStructureManager = new MetadataStructureManager();

            try
            {
                MetadataStructure metadataStructure = metadataStructureManager.Repo.Get(id);

                LinkElementRootModel model = new LinkElementRootModel(LinkElementType.MetadataStructure, id, metadataStructure.Name, rootModelType);

                if (metadataStructure != null)
                {
                    LinkElement metadataStructureLinkElement = mappingManager.GetLinkElement(metadataStructure.Id,
                                                                                             LinkElementType.MetadataStructure);

                    long metadataStructureLinkElementId = 0;
                    if (metadataStructureLinkElement != null)
                    {
                        metadataStructureLinkElementId = metadataStructureLinkElement.Id;
                    }


                    LinkElementModel LEModel = new LinkElementModel(
                        metadataStructureLinkElementId,
                        metadataStructure.Id,
                        LinkElementType.MetadataStructure,
                        metadataStructure.Name, "Metadata",
                        rootModelType,
                        LinkElementComplexity.Complex,
                        metadataStructure.Description);


                    foreach (var pUsage in metadataStructure.MetadataPackageUsages)
                    {
                        addUsageAsLinkElement(pUsage, "Metadata", model, LEModel);
                    }

                    model    = CreateLinkElementContainerModels(model);
                    model.Id = id;
                }
                return(model);
            }
            finally
            {
                metadataStructureManager.Dispose();
            }
        }
Beispiel #6
0
 public LinkElementModel(
     long id,
     long elementid,
     LinkElementType type,
     string name,
     string xpath,
     LinkElementPostion position,
     LinkElementComplexity complexity,
     string description = ""
     )
 {
     Id          = id;
     ElementId   = elementid;
     Type        = type;
     Name        = name;
     XPath       = xpath;
     Description = description;
     Position    = position;
     Children    = new List <LinkElementModel>();
     Complexity  = complexity;
 }
Beispiel #7
0
        private static List <LinkElementModel> getChildrenFromMetadataPackage(long metadataPackageId, LinkElementPostion pos)
        {
            MetadataPackageManager metadataPackageManager = new MetadataPackageManager();

            try
            {
                MetadataPackage metadataPackage = metadataPackageManager.MetadataPackageRepo.Get(metadataPackageId);

                List <LinkElementModel> tmp = new List <LinkElementModel>();
                foreach (var attr in metadataPackage.MetadataAttributeUsages)
                {
                    LinkElementComplexity complexity = LinkElementComplexity.None;
                    LinkElementType       type       = LinkElementType.ComplexMetadataAttribute;

                    complexity = attr.MetadataAttribute.Self is MetadataSimpleAttribute
                        ? LinkElementComplexity.Simple
                        : LinkElementComplexity.Complex;

                    //type = attr.Member.Self is MetadataSimpleAttribute
                    //    ? LinkElementType.SimpleMetadataAttribute
                    //    : LinkElementType.ComplexMetadataAttribute;

                    type = LinkElementType.MetadataNestedAttributeUsage;


                    tmp.Add(
                        new LinkElementModel(
                            0,
                            attr.Id,
                            type, attr.Label, "", pos, complexity, attr.Description)
                        );
                }

                return(tmp);
            }
            finally
            {
                metadataPackageManager.Dispose();
            }
        }
Beispiel #8
0
        public static LinkElementContainerModel CreateLinkeContainerModel(LinkElementComplexity complexity,
                                                                          List <LinkElementModel> linkElements, LinkElementPostion position)
        {
            if (linkElements.Any(l => l.Complexity.Equals(complexity)))
            {
                LinkElementContainerModel cModel = new LinkElementContainerModel(complexity, position);

                cModel.LinkElements = linkElements.Where(l => l.Complexity.Equals(complexity)).ToList();

                return(cModel);
            }
            else
            {
                return(null);
            }
        }
Beispiel #9
0
        public static LinkElementRootModel LoadfromSystem(LinkElementPostion rootModelType, MappingManager mappingManager)
        {
            //get all parties - complex
            PartyTypeManager partyTypeManager = new PartyTypeManager();

            try
            {
                LinkElementRootModel model = new LinkElementRootModel(LinkElementType.System, 0, "System", rootModelType);

                LinkElement SystemRoot = mappingManager.GetLinkElement(0, LinkElementType.System);

                long id        = 0;
                long elementId = 0;
                if (SystemRoot != null)
                {
                    id        = SystemRoot.Id;
                    elementId = SystemRoot.ElementId;
                }


                LinkElementModel LEParent = new LinkElementModel(
                    id,
                    elementId,
                    LinkElementType.System,
                    "System", "",
                    rootModelType,
                    LinkElementComplexity.Complex,
                    "");



                IEnumerable <PartyType> partyTypes = partyTypeManager.PartyTypeRepository.Get();

                foreach (var pt in partyTypes)
                {
                    LinkElementModel ptModel = createLinkElementModelType(pt, model, LEParent, mappingManager);
                    model.LinkElements.Add(ptModel);
                    //get all partyCustomTypeAttr -> simple
                    model.LinkElements.AddRange(createLinkElementModelPartyCustomType(pt, model, ptModel, mappingManager));
                }

                //get all keys -> simple
                foreach (Key value in Key.GetValues(typeof(Key)))
                {
                    long linkElementId = GetId((int)value, LinkElementType.Key, mappingManager);
                    //string mask = GetMask((int)value, LinkElementType.Key);

                    LinkElementModel LEModel = new LinkElementModel(
                        linkElementId,
                        (int)value,
                        LinkElementType.Key, value.ToString(), "", model.Position, LinkElementComplexity.Simple, "");

                    LEModel.Parent = LEParent;

                    model.LinkElements.Add(LEModel);
                }

                //create container
                model = CreateLinkElementContainerModels(model);

                return(model);
            }
            finally
            {
                partyTypeManager.Dispose();
            }
        }
Beispiel #10
0
        public static LinkElementRootModel LoadfromSystem(LinkElementPostion rootModelType, MappingManager mappingManager)
        {
            //get all parties - complex
            using (PartyTypeManager partyTypeManager = new PartyTypeManager())
                using (PartyRelationshipTypeManager partyRelationshipTypeManager = new PartyRelationshipTypeManager())
                    using (EntityManager entityManager = new EntityManager())
                    {
                        LinkElementRootModel model = new LinkElementRootModel(LinkElementType.System, 0, "System", rootModelType);

                        LinkElement SystemRoot = mappingManager.GetLinkElement(0, LinkElementType.System);

                        long id        = 0;
                        long elementId = 0;
                        if (SystemRoot != null)
                        {
                            id        = SystemRoot.Id;
                            elementId = SystemRoot.ElementId;
                        }

                        LinkElementModel LEParent = new LinkElementModel(
                            id,
                            elementId,
                            LinkElementType.System,
                            "System", "",
                            rootModelType,
                            LinkElementComplexity.Complex,
                            "");

                        #region get party types

                        IEnumerable <PartyType> partyTypes = partyTypeManager.PartyTypeRepository.Get();

                        foreach (var pt in partyTypes)
                        {
                            LinkElementModel ptModel = createLinkElementModelType(pt, model, LEParent, mappingManager);
                            model.LinkElements.Add(ptModel);
                            //get all partyCustomTypeAttr -> simple
                            model.LinkElements.AddRange(createLinkElementModelPartyCustomType(pt, model, ptModel, mappingManager));
                        }

                        #endregion get party types

                        #region keys

                        //get all keys -> simple
                        foreach (Key value in Key.GetValues(typeof(Key)))
                        {
                            long linkElementId = GetId((int)value, LinkElementType.Key, mappingManager);
                            //string mask = GetMask((int)value, LinkElementType.Key);

                            LinkElementModel LEModel = new LinkElementModel(
                                linkElementId,
                                (int)value,
                                LinkElementType.Key, value.ToString(), "", model.Position, LinkElementComplexity.Simple, "");

                            LEModel.Parent = LEParent;

                            model.LinkElements.Add(LEModel);
                        }

                        #endregion keys

                        #region get all relationships

                        IEnumerable <PartyRelationshipType> relationshipTypes = partyRelationshipTypeManager.PartyRelationshipTypeRepository.Get();

                        foreach (PartyRelationshipType partyRelationshipType in relationshipTypes)
                        {
                            long value         = partyRelationshipType.Id;
                            long linkElementId = GetId(partyRelationshipType.Id, LinkElementType.Key, mappingManager);

                            LinkElementModel LEModel = new LinkElementModel(
                                linkElementId,
                                partyRelationshipType.Id,
                                LinkElementType.PartyRelationshipType,
                                partyRelationshipType.DisplayName,
                                "",
                                model.Position,
                                LinkElementComplexity.Simple,
                                "");

                            LEModel.Parent = LEParent;

                            model.LinkElements.Add(LEModel);
                        }

                        #endregion get all relationships

                        #region entities

                        foreach (Entity entity in entityManager.Entities)
                        {
                            long value         = entity.Id;
                            long linkElementId = GetId(entity.Id, LinkElementType.Entity, mappingManager);

                            LinkElementModel LEModel = new LinkElementModel(
                                linkElementId,
                                entity.Id,
                                LinkElementType.Entity,
                                entity.Name,
                                "",
                                model.Position,
                                LinkElementComplexity.Simple,
                                "");

                            LEModel.Parent = LEParent;

                            model.LinkElements.Add(LEModel);
                        }

                        //test

                        #endregion entities

                        //create container
                        model = CreateLinkElementContainerModels(model);

                        return(model);
                    }
        }
Beispiel #11
0
        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();
            }
        }
Beispiel #12
0
        public ActionResult ReloadMapping(long sourceId = 1, long targetId = 0, LinkElementType sourceType = LinkElementType.System, LinkElementType targetType = LinkElementType.System, LinkElementPostion position = LinkElementPostion.Target)
        {
            MappingManager mappingManager = new MappingManager();

            try
            {
                List <ComplexMappingModel> model = new List <ComplexMappingModel>();

                // load from mds example
                LinkElementRootModel source = null;

                switch (sourceType)
                {
                case LinkElementType.System:
                {
                    source = MappingHelper.LoadfromSystem(LinkElementPostion.Source, mappingManager);

                    break;
                }

                case LinkElementType.MetadataStructure:
                {
                    source = MappingHelper.LoadFromMetadataStructure(targetId, LinkElementPostion.Source, mappingManager);
                    break;
                }
                }

                LinkElementRootModel target = null;
                switch (targetType)
                {
                case LinkElementType.System:
                {
                    target = MappingHelper.LoadfromSystem(LinkElementPostion.Target, mappingManager);

                    break;
                }

                case LinkElementType.MetadataStructure:
                {
                    target = MappingHelper.LoadFromMetadataStructure(targetId, LinkElementPostion.Target, mappingManager);
                    break;
                }
                }

                if (target != null)
                {
                    //get linkelements
                    LinkElement sourceLE = mappingManager.GetLinkElement(sourceId, sourceType);
                    LinkElement targetLE = mappingManager.GetLinkElement(targetId, targetType);

                    if (sourceLE != null && targetLE != null)
                    {
                        //get root mapping
                        Mapping rootMapping = mappingManager.GetMapping(sourceLE, targetLE);

                        if (rootMapping != null)
                        {
                            //get complex mappings
                            model = MappingHelper.LoadMappings(rootMapping);
                        }
                    }
                }


                return(PartialView("Mappings", model));
            }
            finally
            {
                mappingManager.Dispose();
            }
        }
Beispiel #13
0
        public ActionResult ReloadTarget(long sourceId = 1, long targetId = 0, LinkElementType sourceType = LinkElementType.System, LinkElementType targetType = LinkElementType.System, LinkElementPostion position = LinkElementPostion.Target)
        {
            MappingManager mappingManager = new MappingManager();

            try
            {
                LinkElementRootModel model = null;

                long            id   = position.Equals(LinkElementPostion.Source) ? sourceId : targetId;
                LinkElementType type = position.Equals(LinkElementPostion.Source) ? sourceType : targetType;


                switch (type)
                {
                case LinkElementType.System:
                {
                    model = MappingHelper.LoadfromSystem(position, mappingManager);

                    break;
                }

                case LinkElementType.MetadataStructure:
                {
                    model = MappingHelper.LoadFromMetadataStructure(id, position, mappingManager);
                    break;
                }
                }

                return(PartialView("LinkElemenRoot", model));
            }
            finally
            {
                mappingManager.Dispose();
            }
        }