Examples of GraphImpl


Examples of org.openrdf.model.impl.GraphImpl

   *
   * @param writer The Writer to write the RDF/XML document to.
   */
  public RDFXMLWriterUnique(Writer writer) {
    super(writer);
    statementsWritten = new GraphImpl();
    acceptedResources = new HashMap<Value, Boolean>();
  }
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

   * @throws RDFHandlerException
   * @throws RDFParseException
   */
  private Graph parseRdf(HttpMethod method, RDFFormat format) throws RDFParseException, RDFHandlerException, IOException {
    LimitedInputStream lis = new LimitedInputStream(method.getResponseBodyAsStream(), maxfilesize);
    Graph graph = new GraphImpl();
    URI urlContext = graph.getValueFactory().createURI(task.getURI().toString());
   
    addData(graph, lis, format, task.getURI().toString(), urlContext);
   
    return graph;
  }
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

    testCon.add(alice, name, nameAlice);

    Graph graph;
    RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true);
    try {
      graph = new GraphImpl(vf, statements.asList());
    }
    finally {
      statements.close();
    }
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

   * Provides empty in-memory graph instance
   *
   * @return instanec of Graph interface
   */
  public static Graph getEmptyGraph() {
    return new GraphImpl();
  }
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

    private ValueFactory vf;

    private Graph storageGraph;

    public SesameTripleCallback() {
        this(new GraphImpl());
    }
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

   * Convert the Jena Model to a Sesame Graph
   * @param theModel the model to convert
   * @return the set of statements in the Jena model saved in a sesame Graph
   */
  public static Graph asSesameGraph(Model theModel) {
    Graph aGraph = new GraphImpl();

    StmtIterator sIter = theModel.listStatements();
    while (sIter.hasNext()) {
      aGraph.add(asSesameStatement(sIter.nextStatement()));
    }

    sIter.close();

    return aGraph;
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

          if (aDbObj != null) {
            aExistingData = ((EmpireGenerated) aDbObj).getInstanceTriples();
          }
          else {
            aExistingData = new GraphImpl();
          }
        }
        else {
          // as a fall back, we can perform a describe to find all related triples for the individual;
          // unfortunately, describe returns more information (in fact, it probably gives us more what getAllTriples() would return
          // rather than getInstanceTriples()), but there is not much else we can do
          aExistingData = assertContainsAndDescribe(theT);
        }
      }
      catch (IllegalArgumentException e) {
        // when everything else fails, just assume that existing data was indeed empty ...
        aExistingData = new GraphImpl();
      }
    }

    try {
      preUpdate(theT);
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

    try {
      Graph aGraph = RdfGenerator.asRdf(aBob);

      // this is the set of data that would normally be in the database
      Graph aSourceGraph = new GraphImpl();
      aSourceGraph.addAll(aGraph);
      aSourceGraph.addAll(RdfGenerator.asRdf(aJoe));
      aSourceGraph.addAll(RdfGenerator.asRdf(aJane));

      TestPerson aPerson = RdfGenerator.fromRdf(TestPerson.class, aBob.getRdfId(), new TestDataSource(aSourceGraph));

      assertEquals(aBob, aPerson);

      // now lets test the round trip w/ the added trick of a circular dependency
      aBob.setSpouse(aJane);

      aGraph = RdfGenerator.asRdf(aBob);

      // this is the set of data that would normally be in the database
      aSourceGraph = new GraphImpl();
      aSourceGraph.addAll(aGraph);
      aSourceGraph.addAll(RdfGenerator.asRdf(aJoe));
      aSourceGraph.addAll(RdfGenerator.asRdf(aJane));

      aPerson = RdfGenerator.fromRdf(TestPerson.class, aBob.getRdfId(), new TestDataSource(aSourceGraph));

      // should still be equal, should have re-used Jane
      assertEquals(aBob, aPerson);
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

            klasses.add( MyRootClass.class );
            RdfGenerator.init( klasses );

            Graph aGraph = RdfGenerator.asRdf( root );

            Graph aSourceGraph = new GraphImpl();
            aSourceGraph.addAll(aGraph);

            MyRootClass aRoot = RdfGenerator.fromRdf(MyRootClass.class, "urn:id:00", new TestDataSource(aSourceGraph));
            assertSame( aRoot.getFoo().get( 0 ).getClass(), aImpl.getClass() );
        } catch ( Exception e ) {
            e.printStackTrace();
View Full Code Here

Examples of org.openrdf.model.impl.GraphImpl

      }
      endTest(ok && result); // should return sz > 0 results 
     
      // do construct
      startTest();
      Graph g = new GraphImpl();
      boolean statementFound = false;
      try {
        ok = true;
        log("Sending construct query");
        query = "CONSTRUCT {?s <http://myopenlink.net/mlo/handle> ?o} FROM <" + context + "> WHERE {?s <http://myopenlink.net/foaf/name> ?o}";
        g = doGraphQuery(con, query);
        Iterator<Statement> it = g.iterator();
        statementFound = true;
        while(it.hasNext()) {
          Statement st = it.next();
          if( !st.getPredicate().stringValue().equals("http://myopenlink.net/mlo/handle")) statementFound = false;
        }
      }
      catch (Exception e) {
        System.out.println("Error[" + e + "]");
        e.printStackTrace();
        ok = false;
      }
      endTest(ok && g.size() > 0); // should return sz > 0 results 
     
      // do describe
      startTest();
      g = new GraphImpl();
      statementFound = false;
      try {
        ok = true;
        log("Sending describe query");
        query = "DESCRIBE ?s FROM <" + context + "> WHERE {?s <http://myopenlink.net/foaf/name> ?o}";
        g = doGraphQuery(con, query);
        Iterator<Statement> it = g.iterator();
        statementFound = it.hasNext();
//        while(it.hasNext()) {
//          Statement st = it.next();
//          if( !st.getPredicate().stringValue().equals("http://myopenlink.net/mlo/handle")) statementFound = false;
//        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.