public static boolean isNativeRule(RDFNode node) { if (node != null && node.isAnon()) { if (((Resource) node).hasProperty(RDF.type, SH.NativeRule)) { return true; } if (!((Resource) node).hasProperty(RDF.type)) { return SH.NativeRule.equals(SHACLUtil.getDefaultTemplateType((Resource) node)); } } return false; }
/** * Checks if a given RDFNode represents a template call. It either needs to be an instance of an * instance of sh:Template, or be a typeless blank node that has an incoming edge via a property * such as sh:property, that has a declared sh:defaultType. * * @param node the node to check * @return true if node is a template call */ public static boolean isTemplateCall(RDFNode node) { if (node != null && node.isResource()) { Resource resource = (Resource) node; // Return true if this has sh:Template as its metaclass for (Resource type : JenaUtil.getTypes(resource)) { if (JenaUtil.hasIndirectType(type, SH.Template)) { return true; } } // If this is a typeless blank node, check for defaultType of incoming references if (resource.isAnon() && !resource.hasProperty(RDF.type)) { Resource dt = SHACLUtil.getDefaultTemplateType(resource); if (dt != null && !SH.NativeConstraint.equals(dt) && !SH.NativeScope.equals(dt) && !SH.NativeRule.equals(dt)) { return true; } } } return false; }