Package org.apache.clerezza.rdf.core

Examples of org.apache.clerezza.rdf.core.Resource


          readLock.lock();
          try {
            Iterator<Triple> values = contentGraph.filter(user,
                property, null);
            while (values.hasNext()) {
              Resource value = values.next().getObject();
              resultGraph.add(new TripleImpl(customField,
                  CUSTOMPROPERTY.actualvalues, value));
            }
          } finally {
            readLock.unlock();
View Full Code Here


    if (subject instanceof UriRef) {
      subject = replacePlaceHolder((UriRef) subject);
    }
    UriRef predicate = replacePlaceHolder(triple.getPredicate());

    Resource object = triple.getObject();
    if (object instanceof UriRef) {
      object = replacePlaceHolder((UriRef) object);
    } else if (object instanceof TypedLiteral) {
      TypedLiteral literal = (TypedLiteral) object;
      if (literal.getDataType().equals(XML_LITERAL)) {
View Full Code Here

    Literal value = new TypedLiteralImpl("<elem>value</elem>",xmlLiteralType);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    Resource gotValue = tripleIter.next().getObject();
    Assert.assertEquals(value, gotValue);
  }
View Full Code Here

    Literal value = new PlainLiteralImpl("<elem>value</elem>",language);
    final TripleImpl triple1 = new TripleImpl(uriRef1, uriRef2, value);
    graph.add(triple1);
    Iterator<Triple> tripleIter = graph.filter(uriRef1, uriRef2, null);
    Assert.assertTrue(tripleIter.hasNext());
    Resource gotValue = tripleIter.next().getObject();
    Assert.assertEquals(value, gotValue);
    Assert.assertEquals(language, ((PlainLiteral)gotValue).getLanguage());
  }
View Full Code Here

          if (accept(subject, tc)) {
            result.add(subject);
          }
        }
        {
          Resource object = triple.getObject();
          if (accept(object, tc)) {
            result.add(object);
          }
        }
      }
View Full Code Here

  //called withiong write-lock
  private void removeExistingRequiredReadPermissions(UriRef tripleCollectionUri,
      LockableMGraph permissionMGraph) {
    try {
      Triple t = permissionMGraph.filter(tripleCollectionUri, readPermissionListProperty, null).next();
      Resource list = t.getObject();
      removeList((NonLiteral) list, permissionMGraph);
      permissionMGraph.remove(t);
    } catch (NoSuchElementException e) {
      //There was no existing to remove
    }
View Full Code Here

  }

  private void removeList(NonLiteral list, LockableMGraph permissionMGraph) {
    try {
      Triple t = permissionMGraph.filter(list, rest, null).next();
      Resource restList = t.getObject();
      removeList((NonLiteral) restList, permissionMGraph);
      permissionMGraph.remove(t);
      Iterator<Triple> iter = permissionMGraph.filter(list, first, null);
      iter.next();
      iter.remove();
View Full Code Here

    MGraph result = new SimpleMGraph();
    Iterator<Triple> forwardProperties = graph.filter(node, null, null);
    while (forwardProperties.hasNext()) {
      Triple triple = forwardProperties.next();
      result.add(triple);
      Resource object = triple.getObject();
      if (object instanceof BNode) {
        BNode bNodeObject = (BNode) object;
        if (!dontExpand.contains(bNodeObject)) {
          dontExpand.add(bNodeObject);
          result.addAll(getContextOf(bNodeObject, dontExpand, graph));
View Full Code Here

    String getDescription() {
      StringBuffer result = new StringBuffer();
      Iterator<Triple> titleStatements = graph.filter(
          uri, DCTERMS.title, null);
      while (titleStatements.hasNext()) {
        Resource object = titleStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("title: ");
          result.append (((Literal) object).getLexicalForm());
          result.append("\n");
        }
      }
      Iterator<Triple> descriptionStatements = graph.filter(
          uri, DCTERMS.description, null);
      while (descriptionStatements.hasNext()) {
        Resource object = descriptionStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("description: ");
          result.append (((Literal) object).getLexicalForm());
          result.append("\n");
        }
      }
      Iterator<Triple> skosDefStatements = graph.filter(
          uri, SKOS.definition, null);
      while (skosDefStatements.hasNext()) {
        Resource object = skosDefStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("definition: ");
          result.append (((Literal) object).getLexicalForm());
          result.append("\n");
        }
      }
      Iterator<Triple> rdfsCommentStatements = graph.filter(
          uri, RDFS.comment, null);
      while (rdfsCommentStatements.hasNext()) {
        Resource object = rdfsCommentStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("comment: ");
          result.append(((Literal) object).getLexicalForm());
          result.append("\n");
        }
      }
      Iterator<Triple> skosNoteStatements = graph.filter(
          uri, SKOS.note, null);
      while (skosNoteStatements.hasNext()) {
        Resource object = skosNoteStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("note: ");
          result.append (((Literal) object).getLexicalForm());
          result.append("\n");
        }
      }
      Iterator<Triple> skosExampleStatements = graph.filter(
          uri, SKOS.example, null);
      while (skosExampleStatements.hasNext()) {
        Resource object = skosExampleStatements.next().getObject();
        if (object instanceof Literal) {
          result.append("example: ");
          result.append (((Literal) object).getLexicalForm());
          result.append("\n");
        } else if (object instanceof UriRef) {
View Full Code Here

    if (size() == 0) {
      random = 0;
    }
    switch (random) {
      case 0: // create new NonLiteral
        Resource newResource;
        do {
          newResource = createRandomResource();
        } while (!(newResource instanceof NonLiteral));
        return (NonLiteral) newResource;
      default: // get existing NonLiteral
        Resource existingResource;
        do {
          existingResource = getExistingResource();
          if (existingResource == null) {
            random = 0;
          }
View Full Code Here

TOP

Related Classes of org.apache.clerezza.rdf.core.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.