Beispiel #1
0
        public ActionResult RemoveComplexUsage(int parentStepId, int number)
        {
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(parentStepId);
            RemoveFromXml(stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + number + "]");

            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                CreateCompoundModel(TaskManager.Current().Id, true);
            }

            if (u is MetadataPackageUsage)
            {
                stepModelHelper.Model = CreatePackageModel(TaskManager.Current().Id, true);
            }

            stepModelHelper.Childrens.RemoveAt(number - 1);

            //add stepModel to parentStepModel
            for (int i = 0; i < stepModelHelper.Childrens.Count; i++)
            {
                stepModelHelper.Childrens.ElementAt(i).Number = i + 1;
            }

            TaskManager.Remove(TaskManager.Current(), number - 1);

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);

            }
            else if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);
            }

            return null;
        }
Beispiel #2
0
        public ActionResult DownComplexUsage(int parentStepId, int number)
        {
            int newIndex = number;
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            TaskManager.SetCurrent(TaskManager.Get(parentStepId));

            StepModelHelper stepModelHelper = GetStepModelhelper(parentStepId);
            BaseUsage u = LoadUsage(stepModelHelper.Usage);

            if (newIndex <= stepModelHelper.Childrens.Count - 1)
            {

                string xPathOfSelectedElement = stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + number + "]";
                string destinationXPathElement = stepModelHelper.XPath + "//" + UsageHelper.GetNameOfType(stepModelHelper.Usage).Replace(" ", string.Empty) + "[" + (number + 1) + "]";

                ChangeInXml(xPathOfSelectedElement, destinationXPathElement);

                if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
                {
                    CreateCompoundModel(TaskManager.Current().Id, true);
                }

                if (u is MetadataPackageUsage)
                {
                    stepModelHelper.Model = CreatePackageModel(TaskManager.Current().Id, true);
                }

                StepModelHelper selectedStepModelHelper = stepModelHelper.Childrens.ElementAt(number - 1);
                stepModelHelper.Childrens.Remove(selectedStepModelHelper);

                stepModelHelper.Childrens.Insert(newIndex, selectedStepModelHelper);

                //update childrens of the parent step based on number
                for (int i = 0; i < stepModelHelper.Childrens.Count; i++)
                {
                    StepModelHelper smh = stepModelHelper.Childrens.ElementAt(i);
                    smh.Number = i + 1;
                    smh.Model.Number = i + 1;
                }

                StepInfo selectedStepInfo = stepModelHelper.Model.StepInfo.Children.ElementAt(number - 1);
                stepModelHelper.Model.StepInfo.Children.Remove(selectedStepInfo);
                stepModelHelper.Model.StepInfo.Children.Insert(newIndex, selectedStepInfo);

                for (int i = 0; i < stepModelHelper.Model.StepInfo.Children.Count; i++)
                {
                    StepInfo si = stepModelHelper.Model.StepInfo.Children.ElementAt(i);
                    si.title = (i + 1).ToString();
                }

                stepModelHelper.Model.ConvertInstance((XDocument)(TaskManager.Bus[CreateTaskmanager.METADATA_XML]), stepModelHelper.XPath);

            }

            if (u is MetadataAttributeUsage || u is MetadataNestedAttributeUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);

            }
            else if (u is MetadataPackageUsage)
            {
                return PartialView("_metadataCompoundAttributeView", stepModelHelper);
            }

            return null;
        }