示例#1
0
        public void CargarPersonas(List <Person> personas, Dictionary <string, string> guidDictionary)
        {
            mResourceApi.ChangeOntoly("persona");
            List <string> guidsExistentes = new List <string>();

            try
            {
                SparqlObject resultados = mResourceApi.VirtuosoQuery("Select distinct ?o ?id  ", "Where { ?o <http://schema.org/name> ?id }", "persona");
                foreach (var resultado in resultados.results.bindings)
                {
                    guidsExistentes.Add(resultado["o"].value);
                }
            }
            catch (Exception e)
            {
                mResourceApi.Log.Error($"Error al hacer la consulta a Virtuoso: {e.Message} -> {e.StackTrace}");
            }



            foreach (Person persona in personas)
            {
                if (!guidsExistentes.Contains("http://try.gnoss.com/items/" + guidDictionary[persona.Schema_name]))
                {
                    try
                    {
                        ComplexOntologyResource complexResource = persona.ToGnossApiResource(mResourceApi, null, new Guid(guidDictionary[persona.Schema_name].Split('_')[1]), new Guid(guidDictionary[persona.Schema_name].Split('_')[2]));
                        mResourceApi.LoadComplexSemanticResource(complexResource);
                    }
                    catch (Exception e)
                    {
                        mResourceApi.Log.Error(persona.Schema_name);
                    }
                }
            }
        }
示例#2
0
        private static void SubirRutas(Dictionary <string, Entity> entityList)
        {
            List <Entity> rutas = entityList.Values.Where(ent => ent.Properties.Values.Any(prop => prop.Predicate.Equals($"{Constants.Ontologies.Rdf}type") && prop.Objects.Exists(obj => obj.Value.Equals($"{Constants.Ontologies.Route}Route")))).ToList();

            ResourceApi resourceAPI = new ResourceApi(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config", "config.xml"));

            foreach (Entity ruta in rutas)
            {
                ComplexOntologyResource resource = CreateComplexOntologyResourceRoute(entityList, ruta, resourceAPI);

                try
                {
                    resourceAPI.LoadComplexSemanticResource(resource);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }