private static void addQueryResults(List <ConstraintViolation> results, QueryOrTemplateCall qot, SpinWrapperDataset model, INode resource, bool matchValue, List <SPINStatistics> stats, IProgressMonitor monitor)
        {
            QuerySolutionMap arqBindings = new QuerySolutionMap();

            arqBindings.Add(SPIN.THIS_VAR_NAME, resource);

            IQuery query = qot.getQuery();
            SparqlParameterizedString arq = DatasetUtil.createQuery(query);

            DateTime startTime = DateTime.Now;

            if (query is IAsk)
            {
                if (((SparqlResultSet)model.Query(DatasetUtil.prepare(arq, model, arqBindings).ToString())).Result != matchValue)
                {
                    String message;
                    String comment = qot.getQuery().getComment();
                    if (comment == null)
                    {
                        message = SPINLabels.getLabel(qot.getQuery());
                    }
                    else
                    {
                        message = comment;
                    }
                    message += "\n(SPIN constraint at " + SPINLabels.getLabel(qot.getCls()) + ")";
                    List <SimplePropertyPath> paths = getPropertyPaths(resource, qot.getQuery().getWhere(), null);
                    INode source = getSource(qot);
                    results.Add(createConstraintViolation(paths, NO_FIXES, model, resource, message, source));
                }
            }
            else if (query is IConstruct)
            {
                model.UpdateInternal(DatasetUtil.prepare(DatasetUtil.convertConstructToInsert(arq, query, model._transactionUri), model, arqBindings));
                IGraph cm = new Graph();
                cm.BaseUri = model._transactionUri;
                model.LoadGraph(cm, model._transactionUri);
                addConstructedProblemReports(cm, results, model, qot.getCls(), resource, qot.getQuery().getComment(), getSource(qot));
            }
            DateTime endTime = DateTime.Now;

            if (stats != null)
            {
                TimeSpan duration = startTime - endTime;
                String   label    = qot.toString();
                String   queryText;
                if (qot.getTemplateCall() != null)
                {
                    queryText = SPINLabels.getLabel(qot.getTemplateCall().getTemplate().getBody());
                }
                else
                {
                    queryText = SPINLabels.getLabel(qot.getQuery());
                }
                INode cls = qot.getCls() != null?qot.getCls() : null;

                stats.Add(new SPINStatistics(label, queryText, duration, startTime, cls));
            }
        }
 private static INode getSource(QueryOrTemplateCall qot)
 {
     if (qot.getQuery() != null)
     {
         return(qot.getQuery());
     }
     else
     {
         return(qot.getTemplateCall());
     }
 }
        private static void addTemplateCallResults(List <ConstraintViolation> results, QueryOrTemplateCall qot,
                                                   SpinWrapperDataset model, INode resource, bool matchValue, IProgressMonitor monitor)
        {
            ITemplateCall templateCall = qot.getTemplateCall();
            ITemplate     template     = templateCall.getTemplate();

            if (template != null && template.getBody() is IQuery)
            {
                IQuery spinQuery = (IQuery)template.getBody();
                if (spinQuery is IAsk || spinQuery is IConstruct)
                {
                    SparqlParameterizedString arq = DatasetUtil.createQuery(spinQuery);
                    setInitialBindings(resource, templateCall, arq);

                    if (spinQuery is IAsk)
                    {
                        if (((SparqlResultSet)model.Query(DatasetUtil.prepare(arq, model, null).ToString())).Result != matchValue)
                        {
                            List <SimplePropertyPath> paths = getPropertyPaths(resource, spinQuery.getWhere(), templateCall.getArgumentsMapByProperties());
                            String message = SPINLabels.getLabel(templateCall);
                            message += "\n(SPIN constraint at " + SPINLabels.getLabel(qot.getCls()) + ")";
                            results.Add(createConstraintViolation(paths, NO_FIXES, model, resource, message, templateCall));
                        }
                    }
                    else if (spinQuery is IConstruct)
                    {
                        IGraph cm     = model.MonitorConstruct(DatasetUtil.prepare(DatasetUtil.convertConstructToInsert(arq, spinQuery, model._transactionUri), model, null), spinQuery, null);
                        INode  source = getSource(qot);
                        String label  = SPINLabels.getLabel(templateCall);
                        addConstructedProblemReports(cm, results, model, qot.getCls(), resource, label, source);
                    }
                }
            }
        }