Beispiel #1
0
 public IActionResult dataValidate(IFormFile rdfFile, Guid repositoryIdentifier)
 {
     try
     {
         string rdfFileContent = SparqlUtility.GetTextFromFile(rdfFile);
         return(Ok(SparqlUtility.ValidateRDF(rdfFileContent, _shapeConfigService.GetShapesConfigs().FindAll(x => x.RepositoryID == repositoryIdentifier))));
     }
     catch (Exception ex)
     {
         return(Problem(ex.ToString()));
     }
 }
Beispiel #2
0
 public IActionResult dataValidate(IFormFile rdfFile, IFormFile validationFile)
 {
     try
     {
         string rdfFileContent = SparqlUtility.GetTextFromFile(rdfFile);
         string validation     = SparqlUtility.GetTextFromFile(validationFile);
         return(Ok(SparqlUtility.ValidateRDF(rdfFileContent, validation, validationFile.FileName)));
     }
     catch (Exception ex)
     {
         return(Problem(ex.ToString()));
     }
 }
        public IActionResult ModifyShape(Guid shapeConfigID, string name, Guid repositoryID, IFormFile rdfFile)
        {
            ShapeConfig shapeconfig = new ShapeConfig();

            shapeconfig.ShapeConfigID = shapeConfigID;
            shapeconfig.Name          = name;
            shapeconfig.RepositoryID  = repositoryID;
            try
            {
                if (rdfFile != null)
                {
                    shapeconfig.Shape = SparqlUtility.GetTextFromFile(rdfFile);
                    IGraph shapeGraph = new Graph();
                    shapeGraph.LoadFromString(shapeconfig.Shape);
                }
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message));
            }
            if (!_shapeConfigService.GetShapesConfigs().Exists(x => x.ShapeConfigID == shapeConfigID))
            {
                return(BadRequest(new ErrorExample {
                    Error = $"Comprueba si el shape config con id {shapeconfig.ShapeConfigID} existe"
                }));
            }
            try
            {
                bool modified = _shapeConfigService.ModifyShapeConfig(shapeconfig);
                if (modified)
                {
                    return(Ok($"La configuración del shape {shapeconfig.ShapeConfigID} ha sido modificada"));
                }
                else
                {
                    return(BadRequest(new ErrorExample {
                        Error = $"Se ha producido un error al modificar el Shape"
                    }));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new ErrorExample {
                    Error = $"Se ha producido un error al modificar el Shape " + ex.Message
                }));
            }
        }
        public IActionResult AddShape(string name, Guid repositoryID, IFormFile rdfFile)
        {
            ShapeConfig shapeconfig = new ShapeConfig();

            shapeconfig.ShapeConfigID = Guid.NewGuid();
            shapeconfig.Name          = name;
            shapeconfig.RepositoryID  = repositoryID;
            try
            {
                shapeconfig.Shape = SparqlUtility.GetTextFromFile(rdfFile);
                IGraph shapeGraph = new Graph();
                shapeGraph.LoadFromString(shapeconfig.Shape);
            }
            catch (Exception ex)
            {
                return(Problem(ex.Message));
            }

            try
            {
                Guid addedID = _shapeConfigService.AddShapeConfig(shapeconfig);
                if (!addedID.Equals(Guid.Empty))
                {
                    return(Ok(addedID));
                }
                else
                {
                    return(Problem($"Se ha producido un error al añadir el Shape"));
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new ErrorExample {
                    Error = $"Se ha producido un error al añadir el Shape " + ex.Message
                }));
            }
        }