예제 #1
0
        public ActionResult Create(MetadataCreateViewModel model)
        {
            string organization = GetSecurityClaim("organization");

            model.MetadataContactOrganization = organization;
            if (ModelState.IsValid)
            {
                string username = GetUsername();
                string uuid     = _metadataService.CreateMetadata(model, username);
                Log.Info(string.Format("Created new metadata: {0} [uuid = {1}] for user: {2} on behalf of {3} ", model.Title, uuid, username, organization));
                return(RedirectToAction("Edit", new { uuid = uuid, metadatacreated = true }));
            }
            return(View(model));
        }
예제 #2
0
        private void InsertOpenMetadata(string identifier, Dataset dataset, OpenMetadataEndpoint openMetadataEndpoint)
        {
            var newMetadata = new MetadataCreateViewModel();

            newMetadata.Uuid  = identifier;
            newMetadata.Type  = "dataset";
            newMetadata.Title = dataset.title;
            newMetadata.MetadataContactOrganization =
                !string.IsNullOrEmpty(openMetadataEndpoint.OrganizationName)
                    ? openMetadataEndpoint.OrganizationName
                    : dataset.publisher.name;
            newMetadata.MetadataContactName  = dataset.contactPoint.fn;
            newMetadata.MetadataContactEmail = dataset.contactPoint.hasEmail.Replace("mailto:", "");
            var uuid = _metadataService.CreateMetadata(newMetadata, SecurityClaim.GetUsername());

            Log.Info("Created open metadata uuid: " + uuid);
        }
예제 #3
0
        public async Task <ActionResult> CreateProcess(MetadataModel viewModel)
        {
            if (viewModel == null)  //Se o modelo de dados estiver vazio, redirecciona para a mesma página;
            {
                return(await Task.Run(() => RedirectToAction("Create", "Metadata")));
            }

            _Connection.DatabaseConnection();
            _GetBranchById.SetDatabase(_Connection.GetDatabase());
            _GetStateById.SetDatabase(_Connection.GetDatabase());
            _Metadata.SetDatabase(_Connection.GetDatabase());
            _Validation.SetDatabase(_Connection.GetDatabase());
            _Log.SetDatabase(_Connection.GetDatabase());

            if (_Validation.ProcessExits(viewModel.Name)) //Se o nome já existir na base de dados, redirecciona para a mesma página;
            {
                //Default message:
                string Message = "The process Name already exists in database. \n" +
                                 "Insert a diferent Name.";

                //Alert Message:
                TempData["AlertMessage"] = Message;

                //Redirect to create page:
                return(await Task.Run(() => RedirectToAction("Create", "Metadata")));
            }

            //Defines the properties model key
            _KeyID.SetKey(); //Sets a new properties ObjectID collection;
            string modelId = _KeyID.GetKey();

            List <string> branchList = new List <string>();

            foreach (var item in viewModel.Branch)
            {
                branchList.Add(_GetBranchById.GetBranchID(item));
            }

            MetadataModel model = new MetadataModel()
            {
                Id      = modelId,
                Name    = viewModel.Name,
                Version = Convert.ToInt32(viewModel.Version),
                Date    = Convert.ToDateTime(viewModel.Date),
                State   = _GetStateById.GetStateID(viewModel.State),
                Field   = new List <string>()
                {
                },
                Branch = branchList
            };

            ViewBag.ID = viewModel.Id;

            /*
             * -------------------------------------------------------------------------------------
             * Log section
             * -------------------------------------------------------------------------------------
             */
            _KeyID.SetKey(); //Generates a log model object id (unique key)
            _Log.CreateProcessLog(_KeyID.GetKey(), model.Id, model.Name, 1, "Create");
            //--------------------------------------------------------------------------------------

            _Metadata.CreateMetadata(model);
            //return await Task.Run(() => RedirectToAction("Display", "Field", new { ID = modelId }));
            return(await Task.Run(() => RedirectToAction("Read", "Field", new { ProcessId = modelId } )));
        }