/**
  * Determine whether the given property is recognized and treated specially by this reasoner. This
  * is a convenience packaging of a special case of getCapabilities.
  *
  * @param property the property which we want to ask the reasoner about, given as a Node since
  *     this is part of the SPI rather than API
  * @return true if the given property is handled specially by the reasoner.
  */
 @Override
 public boolean supportsProperty(Property property) {
   if (factory == null) return false;
   Model caps = factory.getCapabilities();
   Resource root = caps.getResource(factory.getURI());
   return caps.contains(root, ReasonerVocabulary.supportsP, property);
 }
 /** Answer the subset of <code>classes</code> which have no superclass in <code>m</code>. */
 private static Set<Resource> selectRootClasses(Model m, Set<RDFNode> classes) {
   Set<Resource> roots = new HashSet<Resource>();
   for (Iterator<RDFNode> it = classes.iterator(); it.hasNext(); ) {
     Resource type = (Resource) it.next();
     if (!m.contains(type, RDFS.subClassOf, (RDFNode) null)) roots.add(type);
   }
   return roots;
 }
示例#3
0
  /**
   * Check that a predicate for which no shortnames are defined in name map still gets a term
   * binding in the metadata.
   */
  @Test
  public void testTermBindingsCoverAllPredicates() throws URISyntaxException {
    Resource thisPage = ResourceFactory.createResource("elda:thisPage");
    String pageNumber = "1";
    Bindings cc = new Bindings();
    URI reqURI = new URI("");
    //
    EndpointDetails spec =
        new EndpointDetails() {

          @Override
          public boolean isListEndpoint() {
            return true;
          }

          @Override
          public boolean hasParameterBasedContentNegotiation() {
            return false;
          }
        };
    EndpointMetadata em = new EndpointMetadata(spec, thisPage, pageNumber, cc, reqURI);
    //
    PrefixMapping pm =
        PrefixMapping.Factory.create().setNsPrefix("this", "http://example.com/root#");
    Model toScan = ModelIOUtils.modelFromTurtle(":a <http://example.com/root#predicate> :b.");
    toScan.setNsPrefixes(pm);
    Resource predicate = toScan.createProperty("http://example.com/root#predicate");
    Model meta = ModelFactory.createDefaultModel();
    Resource exec = meta.createResource("fake:exec");
    ShortnameService sns = new StandardShortnameService();
    //		APIEndpoint.Request r = new APIEndpoint.Request( new Controls(), reqURI, cc );

    CompleteContext c =
        new CompleteContext(CompleteContext.Mode.PreferPrefixes, sns.asContext(), pm)
            .include(toScan);

    em.addTermBindings(toScan, meta, exec, c);

    @SuppressWarnings("unused")
    Map<String, String> termBindings = c.Do();
    Resource tb = meta.listStatements(null, API.termBinding, Any).nextStatement().getResource();
    assertTrue(meta.contains(tb, API.label, "this_predicate"));
    assertTrue(meta.contains(tb, API.property, predicate));
  }
示例#4
0
  @Test
  public void testTermbindsIncludesMetaproperties() throws URISyntaxException {
    Integer totalResults = null;
    Resource thisMetaPage = createMetadata(false, totalResults);

    for (Property p : expectedTermboundProperties) {
      Model model = thisMetaPage.getModel();
      if (!model.contains(null, API.property, p)) {
        fail("term bindings should include " + model.shortForm(p.getURI()));
      }
    }
  }
 public void testOmits(Model m, List<Statement> statements) {
   for (int i = 0; i < statements.size(); i += 1)
     assertFalse("it should not be here", m.contains(statements.get(i)));
 }
 public void testOmits(Model m, Statement[] statements) {
   for (int i = 0; i < statements.length; i += 1)
     assertFalse("it should not be here", m.contains(statements[i]));
 }