Package org.ontoware.rdf2go.model

Examples of org.ontoware.rdf2go.model.Model


 
  public static void dump(ModelSet modelSet, String[] options) throws ModelRuntimeException {
    Iterator<? extends Model> it = modelSet.getModels();
    assert it != null;
    while(it.hasNext()) {
      Model m = it.next();
      DumpUtils.dump(m, options);
    }
  }
View Full Code Here


    w.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");
    jm.write(w, "RDF/XML", "");
  }
 
  public static void write(Model m, Writer w) throws ModelRuntimeException {
    Model jenaModel = new ModelImplJena(Reasoning.none);
    jenaModel.addAll(m.iterator());
    com.hp.hpl.jena.rdf.model.Model jm = (com.hp.hpl.jena.rdf.model.Model)jenaModel
            .getUnderlyingModelImplementation();
    try {
      writeJenaModel(jm, w);
    } catch(IOException e) {
      throw new ModelRuntimeException(e);
View Full Code Here

      throw new ModelRuntimeException(e);
    }
  }
 
  public static void write(Model m, String filename, String format) throws ModelRuntimeException {
    Model jenaModel = new ModelImplJena(Reasoning.none);
    jenaModel.addAll(m.iterator());
    com.hp.hpl.jena.rdf.model.Model jm = (com.hp.hpl.jena.rdf.model.Model)jenaModel
            .getUnderlyingModelImplementation();
    DumpUtils.addCommonPrefixesToJenaModel(jm);
   
    try {
      // encoding!
View Full Code Here

     */
    public static void generate(String schemafilename, String outdir, String packagename,
            Reasoning semantics, boolean skipbuiltins, String methodnamePrefix) throws Exception {
       
        // first step
        Model schemaDataModel = loadSchemaDataModel(schemafilename);
        File outDir = new File(outdir);
       
        generate(schemaDataModel, outDir, packagename, semantics, skipbuiltins, methodnamePrefix);
        schemaDataModel.close();
    }
View Full Code Here

     * @throws Exception
     */
    public static Model loadSchemaDataModel(String schemafilename) throws Exception {
        File schemaFile = new File(schemafilename);
        log.info("loading from " + schemaFile.getCanonicalPath());
        Model schemaDataModel = ModelReaderUtils.read(schemafilename);
        return schemaDataModel;
    }
View Full Code Here

    log.warn("Testing logging at WARN level");
  }

  @Test
  public void testDirectRepositoryAccess() throws Exception {
    Model model = getModelFactory().createModel();
    model.open();

    // fetch the Repository, a Connection and a ValueFactory
    Repository repository = (Repository) model
        .getUnderlyingModelImplementation();
    RepositoryConnection connection = repository.getConnection();
    ValueFactory factory = repository.getValueFactory();

    // add a statement
    model.addStatement(subject, predicate, object);

    // convert the statement parts to OpenRDF data types
    Resource openRdfSubject = ConversionUtil.toOpenRDF(subject, factory);
    org.openrdf.model.URI openRdfPredicate = ConversionUtil.toOpenRDF(
        predicate, factory);
    Value openRdfObject = ConversionUtil.toOpenRDF(object, factory);
    org.openrdf.model.URI context = RepositoryModel.DEFAULT_OPENRDF_CONTEXT;

    // make sure this statement is contained in this model
    assertTrue(connection.hasStatement(openRdfSubject, openRdfPredicate,
        openRdfObject, false, context));

    // make sure this statement can also be found through the Model API
    ClosableIterator<? extends Statement> sit = model.findStatements(
        subject, predicate, object);
    assertNotNull(sit);
    assertTrue(sit.hasNext());

    Statement s2 = sit.next();
    URI s2s = (URI) s2.getSubject();
    URI s2p = s2.getPredicate();
    URI s2o = (URI) s2.getObject();

    assertEquals(subject, s2s);
    assertEquals(predicate, s2p);
    assertEquals(object, s2o);

    // make sure that this statement is only returned once
    assertFalse(sit.hasNext());

    // clean-up
    sit.close();
    connection.close();
    model.close();
  }
View Full Code Here

        "uri:p1"), new URIImpl("uri:r3"));
    modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl(
        "uri:p2"), new URIImpl("uri:r5"));
    modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl(
        "uri:p2"), new URIImpl("uri:r6"));
    Model model1 = modelSet.getModel(context1);
    model1.open();
    Model model2 = modelSet.getModel(context2);
    model2.open();
    assertEquals(4, modelSet.size());
    assertEquals(2, model1.size());
    assertEquals(2, model2.size());

    model2.removeAll();

    assertEquals(2, modelSet.size());
    assertEquals(2, model1.size());
    assertEquals(0, model2.size());
    model1.close();
    model2.close();
  }
View Full Code Here

  @Test
  public void testUsingList() {

    RepositoryModelFactory repositoryModelFactory = new RepositoryModelFactory();
    Model model = repositoryModelFactory.createModel();
    model.open();

    URI a = new URIImpl("urn:test:a");
    URI b = new URIImpl("urn:test:b");
    List list = new List(model, "urn:test:list", true);
   
    //assertTrue( list instanceof URI );  --> fails

    model.addStatement(a, b, list.asURI() );
    model.close();
  }
View Full Code Here

    @Override
    public Model next() {
      URI uri = this.underlying.next();

      Model model = getModel(uri);

      this.lastURI = uri;
      return model;
    }
View Full Code Here

public class RDFReactorRuntimeTest {

  @Test
  public void testCalendarHandling() {
    Model model = RDF2Go.getModelFactory().createModel();
    model.open();
    URI s = new URIImpl("urn:test:S");
    URI p = new URIImpl("urn:test:P");
    Calendar cal = Calendar.getInstance();
    BridgeBase.add(model, s, p, cal);
  }
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.Model

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.