Exemplo n.º 1
0
        public ActionResult StartMetadataEditor()
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            ViewData["ShowOptional"] = false;

            MetadataEditorModel Model = new MetadataEditorModel();

            if (TaskManager == null) TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            if (TaskManager != null)
            {
                //load empty metadata xml if needed
                if (!TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML))
                {
                    CreateXml();
                }

                bool loaded = false;
                //check if formsteps are loaded
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.FORM_STEPS_LOADED))
                {
                    loaded = (bool)TaskManager.Bus[CreateTaskmanager.FORM_STEPS_LOADED];
                }

                // load form steps
                if (loaded == false && TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                {
                    long metadataStrutureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                    // generate all steps
                    // one step for each complex type  in the metadata structure
                    AdvanceTaskManager(metadataStrutureId);
                }

                List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();

                // foreach step and the childsteps... generate a stepModelhelper
                foreach (var stepInfo in TaskManager.StepInfos)
                {
                    StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                    if (stepModelHelper.Model == null)
                    {
                        if (stepModelHelper.Usage is MetadataPackageUsage)
                            stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);

                        if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                            stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);

                        getChildModelsHelper(stepModelHelper);
                    }

                    stepInfoModelHelpers.Add(stepModelHelper);

                }

                Model.StepModelHelpers = stepInfoModelHelpers;

                //set import
                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                {
                    long id = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                    Model.Import = IsImportAvavilable(id);
                }

                //set addtionaly functions
                Model.Actions = getAddtionalActions();
            }

            return View("MetadataEditor", Model);
        }
Exemplo n.º 2
0
        public ActionResult ReloadMetadataEditor(bool locked = false, bool show = false)
        {
            ViewData["Locked"] = locked;
            ViewData["ShowOptional"] = show;

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();

            foreach (var stepInfo in TaskManager.StepInfos)
            {

                StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                if (stepModelHelper.Model == null)
                {
                    if (stepModelHelper.Usage is MetadataPackageUsage)
                        stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);

                    if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                        stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);

                    getChildModelsHelper(stepModelHelper);
                }

                stepInfoModelHelpers.Add(stepModelHelper);

            }

            MetadataEditorModel Model = new MetadataEditorModel();
            Model.StepModelHelpers = stepInfoModelHelpers;

            #region security permissions and authorisations check
            // set edit rigths
            PermissionManager permissionManager = new PermissionManager();
            SubjectManager subjectManager = new SubjectManager();
            Security.Services.Objects.TaskManager securityTaskManager = new Security.Services.Objects.TaskManager();

            bool hasAuthorizationRights = false;
            bool hasAuthenticationRigths = false;

            User user = subjectManager.GetUserByName(GetUsernameOrDefault());
            long userid = -1;
            long entityId = -1;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
            {
                entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                Model.EditRight = hasUserEditRights(entityId);
                Model.EditAccessRight = hasUserEditAccessRights(entityId);

            }
            else
            {
                Model.EditRight = false;
                Model.EditAccessRight = false;
            }

            Model.FromEditMode = true;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
            {
                long metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);
                Model.Import = IsImportAvavilable(metadataStructureId);
            }

            #endregion
            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
Exemplo n.º 3
0
        public ActionResult LoadMetadata(long entityId, bool locked = false, bool created = false, bool fromEditMode = false, bool resetTaskManager = false, XmlDocument newMetadata = null)
        {
            bool loadFromExternal = resetTaskManager;
            long metadataStructureId = -1;

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());
            ViewData["Locked"] = locked;
            ViewData["ShowOptional"] = false;

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager == null)
            {
                TaskManager = new CreateTaskmanager();
                loadFromExternal = true;
            }

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            stepInfoModelHelpers = (List<StepModelHelper>)TaskManager.Bus[CreateTaskmanager.METADATA_STEP_MODEL_HELPER];

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_TITLE))
            {
                if (TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE] != null)
                    Model.DatasetTitle = TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE].ToString();
            }
            else
                Model.DatasetTitle = "No Title available.";

            Model.DatasetId = entityId;
            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Created = created;

            //check if a metadatastructure has a import mapping
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            if(metadataStructureId!=-1)
                Model.Import = IsImportAvavilable(metadataStructureId);

            //FromCreateOrEditMode
            TaskManager.AddToBus(CreateTaskmanager.EDIT_MODE, fromEditMode);
            Model.FromEditMode = (bool)TaskManager.Bus[CreateTaskmanager.EDIT_MODE];

            Model.EditRight = hasUserEditRights(entityId);
            Model.EditAccessRight = hasUserEditAccessRights(entityId);

            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
Exemplo n.º 4
0
        public ActionResult LoadMetadataFromExternal(long entityId, string title, long metadatastructureId, long datastructureId=-1,long researchplanId=-1, string sessionKeyForMetadata="", bool resetTaskManager = false)
        {
            bool loadFromExternal = true;
            long metadataStructureId = -1;

            //load metadata from session if exist
            XmlDocument metadata = Session[sessionKeyForMetadata] != null
                ? (XmlDocument) Session[sessionKeyForMetadata]
                : new XmlDocument();

            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant()); ;
            ViewData["Locked"] = true;
            ViewData["ShowOptional"] = false;

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];
            if (TaskManager == null || resetTaskManager)
            {
                TaskManager = new CreateTaskmanager();

            }

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            if (loadFromExternal)
            {
                string entityClassPath = "";
                //TaskManager = new CreateTaskmanager();
                Session["CreateDatasetTaskmanager"] = TaskManager;
                TaskManager.AddToBus(CreateTaskmanager.ENTITY_ID, entityId);

                if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_CLASS_PATH))
                    entityClassPath = TaskManager.Bus[CreateTaskmanager.ENTITY_CLASS_PATH].ToString();

                bool ready = true;

                // todo i case of entity "BExIS.Dlm.Entities.Data.Dataset" we need to have a check if the dataset is checked in later all enitities should support such functions over webapis
                if (entityClassPath.Equals("BExIS.Dlm.Entities.Data.Dataset"))
                {
                    DatasetManager dm = new DatasetManager();
                    //todo need a check if entity is in use
                    if (!dm.IsDatasetCheckedIn(entityId))
                    {
                        ready = false;
                    }
                }

                if (ready)
                {

                    TaskManager.AddToBus(CreateTaskmanager.METADATASTRUCTURE_ID, metadatastructureId);
                    if(researchplanId!=-1)TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, researchplanId);
                    if(datastructureId!=-1) TaskManager.AddToBus(CreateTaskmanager.DATASTRUCTURE_ID, datastructureId);

                    if (metadata != null && metadata.DocumentElement != null)
                        TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, XmlUtility.ToXDocument(metadata));

                    TaskManager.AddToBus(CreateTaskmanager.ENTITY_TITLE,title);

                    ResearchPlanManager rpm = new ResearchPlanManager();
                    TaskManager.AddToBus(CreateTaskmanager.RESEARCHPLAN_ID, rpm.Repo.Get().First().Id);

                    AdvanceTaskManagerBasedOnExistingMetadata(metadatastructureId);
                    //AdvanceTaskManager(dsv.Dataset.MetadataStructure.Id);

                    foreach (var stepInfo in TaskManager.StepInfos)
                    {

                        StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                        if (stepModelHelper.Model == null)
                        {
                            if (stepModelHelper.Usage is MetadataPackageUsage)
                            {
                                stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);
                                if (stepModelHelper.Model.StepInfo.IsInstanze)
                                    LoadSimpleAttributesForModelFromXml(stepModelHelper);
                            }

                            if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                            {
                                stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);
                                if (stepModelHelper.Model.StepInfo.IsInstanze)
                                    LoadSimpleAttributesForModelFromXml(stepModelHelper);
                            }

                            getChildModelsHelper(stepModelHelper);
                        }

                        stepInfoModelHelpers.Add(stepModelHelper);

                    }

                    if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATA_XML))
                    {
                        XDocument xMetadata = (XDocument) TaskManager.Bus[CreateTaskmanager.METADATA_XML];

                        if (String.IsNullOrEmpty(title)) title = "No Title available.";

                        if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_TITLE))
                        {
                            if(TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE]!=null)
                                Model.DatasetTitle = TaskManager.Bus[CreateTaskmanager.ENTITY_TITLE].ToString();
                        }
                        else
                            Model.DatasetTitle = "No Title available.";

                    }
                }
                else
                {
                    ModelState.AddModelError(String.Empty, "Dataset is just in processing.");
                }

            }

            Model.DatasetId = entityId;
            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Created = false;

            //check if a metadatastructure has a import mapping
            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.METADATASTRUCTURE_ID))
                metadataStructureId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.METADATASTRUCTURE_ID]);

            if (metadataStructureId != -1)
                Model.Import = IsImportAvavilable(metadataStructureId);

            //FromCreateOrEditMode
            TaskManager.AddToBus(CreateTaskmanager.EDIT_MODE, false);
            Model.FromEditMode = (bool)TaskManager.Bus[CreateTaskmanager.EDIT_MODE];

            // set edit rights
            Model.EditRight = hasUserEditRights(entityId);
            Model.EditAccessRight = hasUserEditAccessRights(entityId);

            //set addtionaly functions
            Model.Actions = getAddtionalActions();

            return PartialView("MetadataEditor", Model);
        }
Exemplo n.º 5
0
        public ActionResult ImportMetadata(long metadataStructureId, bool edit = true, bool created = false, bool locked = false)
        {
            ViewBag.Title = PresentationModel.GetViewTitleForTenant("Create Dataset", this.Session.GetTenant());

            TaskManager = (CreateTaskmanager)Session["CreateDatasetTaskmanager"];

            XmlDocument newMetadata = (XmlDocument)TaskManager.Bus[CreateTaskmanager.METADATA_XML];

            List<StepModelHelper> stepInfoModelHelpers = new List<StepModelHelper>();
            MetadataEditorModel Model = new MetadataEditorModel();

            TaskManager.AddToBus(CreateTaskmanager.METADATA_XML, XmlUtility.ToXDocument(newMetadata));

            AdvanceTaskManagerBasedOnExistingMetadata(metadataStructureId);

            foreach (var stepInfo in TaskManager.StepInfos)
            {

                StepModelHelper stepModelHelper = GetStepModelhelper(stepInfo.Id);

                if (stepModelHelper.Model == null)
                {
                    if (stepModelHelper.Usage is MetadataPackageUsage)
                    {
                        stepModelHelper.Model = CreatePackageModel(stepInfo.Id, false);
                        if (stepModelHelper.Model.StepInfo.IsInstanze)
                            LoadSimpleAttributesForModelFromXml(stepModelHelper);
                    }

                    if (stepModelHelper.Usage is MetadataNestedAttributeUsage)
                    {
                        stepModelHelper.Model = CreateCompoundModel(stepInfo.Id, false);
                        if (stepModelHelper.Model.StepInfo.IsInstanze)
                            LoadSimpleAttributesForModelFromXml(stepModelHelper);
                    }

                    getChildModelsHelper(stepModelHelper);
                }

                stepInfoModelHelpers.Add(stepModelHelper);

            }

            Model.StepModelHelpers = stepInfoModelHelpers;
            Model.Import = IsImportAvavilable(metadataStructureId);
            //set addtionaly functions
            Model.Actions = getAddtionalActions();
            Model.FromEditMode = edit;
            Model.Created = created;

            if (TaskManager.Bus.ContainsKey(CreateTaskmanager.ENTITY_ID))
            {
                long entityId = Convert.ToInt64(TaskManager.Bus[CreateTaskmanager.ENTITY_ID]);
                Model.EditRight = hasUserEditRights(entityId);
                Model.EditAccessRight = hasUserEditAccessRights(entityId);
                //Model.DatasetId = entityId;

            }
            else
            {
                Model.EditRight = false;
                Model.EditAccessRight = false;
                Model.DatasetId = -1;
            }

            ViewData["Locked"] = locked;

            return PartialView("MetadataEditor", Model);
        }