public void TestUriPublicationFail()
        {
            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString.Add("identifier", "123d");
            ConfigJsonHandler configJsonHandler = new ConfigJsonHandler();
            UriFormer         uriFormer         = new UriFormer(configJsonHandler.GetUrisConfig());

            Assert.Throws <ParametersNotConfiguredException>(() => uriFormer.GetURI("publication", queryString));
        }
        public void TestUriResearcherOK()
        {
            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString.Add("identifier", "123d");
            ConfigJsonHandler configJsonHandler = new ConfigJsonHandler();
            UriFormer         uriFormer         = new UriFormer(configJsonHandler.GetUrisConfig());
            string            uri           = uriFormer.GetURI("AcademicDegree", queryString);
            string            uriResultante = "http://graph.um.es/res/academic-degree/123d";

            Assert.True(uriResultante.Equals(uri));
        }
        public void TestUriRdfTypeOK()
        {
            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString.Add("identifier", "123d");
            ConfigJsonHandler configJsonHandler = new ConfigJsonHandler();
            UriFormer         uriFormer         = new UriFormer(configJsonHandler.GetUrisConfig());
            string            uri           = uriFormer.GetURI("http://purl.org/roh/mirror/vivo#AdvisorRole", queryString, true);
            string            uriResultante = "http://graph.um.es/res/advisor-role/123d";

            Assert.True(uriResultante.Equals(uri));
        }
Beispiel #4
0
        static void Main(string[] args)
        {
            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString.Add("identifier", "123d");
            string texto = File.ReadAllText("Config/UrisConfig.json");
            UriStructureGeneral uriStructure      = JsonConvert.DeserializeObject <UriStructureGeneral>(texto);
            ConfigJsonHandler   configJsonHandler = new ConfigJsonHandler(texto);
            UriFormer           uriFormer         = new UriFormer(configJsonHandler.GetUrisConfig());
            string uri = uriFormer.GetURI("AdvisorRole", queryString);

            Console.WriteLine(uri);
        }
Beispiel #5
0
        public IActionResult GenerateUri(string resource_class, string identifier)
        {
            Dictionary <string, string> queryDictionary = new Dictionary <string, string>();

            if (HttpContext != null)
            {
                var queryString = HttpContext.Request.Query.ToList();
                foreach (var value in queryString)
                {
                    queryDictionary.Add(value.Key, value.Value.FirstOrDefault());
                }
            }
            else
            {
                queryDictionary.Add(UriComponentsList.Identifier, identifier);
            }

            UriFormer uriFormer = new UriFormer(_configJsonHandler.GetUrisConfig());
            string    uri       = uriFormer.GetURI(resource_class, queryDictionary);

            return(Ok(uri));
        }
        public IActionResult GenerateUri(string resource_class, string identifier)
        {
            if (!System.Uri.IsWellFormedUriString(identifier, System.UriKind.Relative))
            {
                identifier = HttpUtility.UrlEncode(identifier);
            }

            Dictionary <string, string> queryDictionary = new Dictionary <string, string>();

            if (HttpContext != null)
            {
                var queryString = HttpContext.Request.Query.ToList();
                foreach (var value in queryString)
                {
                    if (value.Key == "identifier")
                    {
                        string valueAux = value.Value.FirstOrDefault();
                        if (!System.Uri.IsWellFormedUriString(valueAux, System.UriKind.Relative))
                        {
                            valueAux = HttpUtility.UrlEncode(valueAux);
                        }
                        queryDictionary.Add(value.Key, valueAux);
                    }
                    else
                    {
                        queryDictionary.Add(value.Key, value.Value.FirstOrDefault());
                    }
                }
            }
            else
            {
                queryDictionary.Add(UriComponentsList.Identifier, identifier);
            }

            UriFormer uriFormer = new UriFormer(_configJsonHandler.GetUrisConfig());
            string    uri       = uriFormer.GetURI(resource_class, queryDictionary);

            return(Ok(uri));
        }
Beispiel #7
0
        public static void Get()
        {
            UriStructureGeneral structureGeneral = new UriStructureGeneral()
            {
                Base = "http://graph.um.es"
            };
            List <Characters> characters = new List <Characters>();
            Characters        charac     = new Characters()
            {
                Character      = "resource",
                LabelCharacter = "res"
            };

            characters.Add(charac);
            structureGeneral.Characters = characters;
            Component baseC = new Component()
            {
                UriComponent      = "base",
                UriComponentValue = "base",
                UriComponentOrder = 1,
                Mandatory         = true,
                FinalCharacter    = "/"
            };
            Component character = new Component()
            {
                UriComponent      = "character",
                UriComponentValue = "character@resource",
                UriComponentOrder = 2,
                Mandatory         = true,
                FinalCharacter    = "/"
            };
            Component resource = new Component()
            {
                UriComponent      = "resourceClass",
                UriComponentValue = "resourceClass",
                UriComponentOrder = 3,
                Mandatory         = true,
                FinalCharacter    = "/"
            };
            Component identifier = new Component()
            {
                UriComponent      = "identifier",
                UriComponentValue = "@ID",
                UriComponentOrder = 4,
                Mandatory         = true,
                FinalCharacter    = ""
            };
            List <Component> componentes = new List <Component>();

            componentes.Add(baseC);
            componentes.Add(character);
            componentes.Add(resource);
            componentes.Add(identifier);
            UriStructure uriStructure = new UriStructure()
            {
                Name       = "test",
                Components = componentes
            };

            structureGeneral.UriStructures = new List <UriStructure>();
            structureGeneral.UriStructures.Add(uriStructure);
            ResourcesClass clas = new ResourcesClass()
            {
                LabelResourceClass = "project-object",
                ResourceClass      = "Project",
                ResourceURI        = "test"
            };
            ResourcesClass clas2 = new ResourcesClass()
            {
                LabelResourceClass = "researcher",
                ResourceClass      = "Researcher",
                ResourceURI        = "test"
            };

            structureGeneral.ResourcesClasses = new List <ResourcesClass>();
            structureGeneral.ResourcesClasses.Add(clas);
            structureGeneral.ResourcesClasses.Add(clas2);

            string uriSchemaJson = JsonConvert.SerializeObject(structureGeneral);

            ConfigJsonHandler           config      = new ConfigJsonHandler(uriSchemaJson);
            Dictionary <string, string> queryString = new Dictionary <string, string>();

            queryString.Add("identifier", "123d");
            UriFormer uriFormer = new UriFormer(config.GetUrisConfig());
            string    uri       = uriFormer.GetURI("Project", queryString);

            Console.WriteLine(uri);
        }