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); } } } }
/** * Checks whether a given INode is a TemplateCall. The condition for this * is stricter than for <code>asTemplateCall</code> as the node also must have * a valid template assigned to it, i.e. the type of the node must be an * instance of spin:Template. * @param node the INode to check * @return true if node is a TemplateCall */ public static bool isTemplateCall(IResource node) { ITemplateCall templateCall = asTemplateCall(node); return(templateCall != null && templateCall.getTemplate() != null); }