예제 #1
0
 public static boolean isNativeConstraint(RDFNode node) {
   if (node != null && node.isAnon()) {
     if (((Resource) node).hasProperty(RDF.type, SH.NativeConstraint)) {
       return true;
     }
     if (!((Resource) node).hasProperty(RDF.type)) {
       return SH.NativeConstraint.equals(SHACLUtil.getDefaultTemplateType((Resource) node));
     }
   }
   return false;
 }
예제 #2
0
  private static void init(Personality<RDFNode> p) {
    p.add(
        SHACLArgument.class,
        new SimpleImplementation(SH.Argument.asNode(), SHACLArgumentImpl.class));
    p.add(
        SHACLConstraintViolation.class,
        new SimpleImplementation(
            SH.ConstraintViolation.asNode(), SHACLConstraintViolationImpl.class));
    p.add(
        SHACLFunction.class,
        new SimpleImplementation(SH.Function.asNode(), SHACLFunctionImpl.class));
    p.add(
        SHACLPropertyConstraint.class,
        new SimpleImplementation(
            SH.PropertyConstraint.asNode(), SHACLPropertyConstraintImpl.class));
    p.add(
        SHACLDerivedPropertyConstraint.class,
        new SimpleImplementation(
            SH.DerivedPropertyConstraint.asNode(), SHACLDerivedPropertyConstraintImpl.class));
    p.add(SHACLShape.class, new SimpleImplementation(SH.Shape.asNode(), SHACLShapeImpl.class));
    p.add(
        SHACLNativeConstraint.class,
        new SimpleImplementation(SH.NativeConstraint.asNode(), SHACLNativeConstraintImpl.class));
    p.add(
        SHACLNativeRule.class,
        new SimpleImplementation(SH.NativeRule.asNode(), SHACLNativeRuleImpl.class));
    p.add(
        SHACLNativeScope.class,
        new SimpleImplementation(SH.NativeScope.asNode(), SHACLNativeScopeImpl.class));
    p.add(
        SHACLTemplate.class,
        new SimpleImplementation(SH.Template.asNode(), SHACLTemplateImpl.class));
    p.add(
        SHACLTemplateCall.class,
        new SimpleImplementation(SH.Templates.asNode(), SHACLTemplateCallImpl.class));
    p.add(
        SHACLTemplateConstraint.class,
        new SimpleImplementation(
            SH.TemplateConstraint.asNode(), SHACLTemplateConstraintImpl.class));
    p.add(
        SHACLTemplateRule.class,
        new SimpleImplementation(SH.TemplateRule.asNode(), SHACLTemplateRuleImpl.class));
    p.add(
        SHACLTemplateScope.class,
        new SimpleImplementation(SH.TemplateScope.asNode(), SHACLTemplateScopeImpl.class));

    FunctionRegistry.get().put(SH.hasShape.getURI(), HasShapeFunction.class);
    PropertyFunctionRegistry.get().put(ScopeContainsPFunction.URI, ScopeContainsPFunction.class);
  }
예제 #3
0
  /**
   * 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;
  }