internal IEnumerable <IUpdate> BuildUpdate(String sparqlQuery) { List <IUpdate> spinQueryList = new List <IUpdate>(); SparqlUpdateCommandSet query = new SparqlUpdateParser().ParseFromString(sparqlQuery); query.Optimise(); foreach (SparqlUpdateCommand command in query.Commands) { sparqlQuery = command.ToString(); if (queryCache.ContainsKey(sparqlQuery)) { spinQueryList.Add((IUpdate)queryCache[sparqlQuery]); } else { _currentSparqlGraph = new Graph(); _currentSparqlGraph.BaseUri = UriFactory.Create("sparql-query:" + sparqlQuery); INode q = command.ToSpinRdf(_currentSparqlGraph); if (!_currentSparqlGraph.IsEmpty) { _spinConfiguration.AddGraph(_currentSparqlGraph); IUpdate spinQuery = SPINFactory.asUpdate(Resource.Get(q, this)); queryCache[sparqlQuery] = spinQuery; spinQueryList.Add(spinQuery); } } } return(spinQueryList); }
public void PrintEnhancedSPARQL(IResource resource) { if (resource == null) { return; } IEnumerable <IResource> elements = resource.AsList(); foreach (Resource element in elements) { if (element.canAs(SP.ClassQuery)) { SPINFactory.asQuery(element).PrintEnhancedSPARQL(this); continue; } else if (element.canAs(SP.ClassCommand)) { SPINFactory.asUpdate(element).PrintEnhancedSPARQL(this); continue; } else if (element.canAs(SP.ClassVariable)) { SPINFactory.asVariable(element).PrintEnhancedSPARQL(this); continue; } else if (element.isUri()) { printURIResource(element); continue; } IElement asElement = SPINFactory.asElement(element); if (asElement != null) { asElement.PrintEnhancedSPARQL(this); } } }
internal IEnumerable <IUpdate> GetConstructorsForClass(INode cls) { List <IUpdate> constructors = GetTriplesWithSubjectPredicate(cls, SPIN.PropertyConstructor).Select(t => SPINFactory.asUpdate(Resource.Get(t.Object, this))).ToList(); return(constructors); }