Package org.openrdf.model

Examples of org.openrdf.model.Model


  }

  public static Model toGraph(TupleResult tqr)
    throws StoreException
  {
    Model model = new LinkedHashModel();
    DAWGTestResultSetWriter writer = new DAWGTestResultSetWriter(new StatementCollector(model));

    try {
      writer.startQueryResult(tqr.getBindingNames());
      while (tqr.hasNext()) {
View Full Code Here


    throws Exception
  {
    testCon.add(bob, name, nameBob);
    testCon.add(alice, name, nameAlice);

    Model model;
    ModelResult statements = testCon.match(null, null, null, true);
    try {
      model = new LinkedHashModel(statements.asList());
    }
    finally {
      statements.close();
    }

    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ObjectOutputStream out = new ObjectOutputStream(baos);
    out.writeObject(model);
    out.close();

    ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
    ObjectInputStream in = new ObjectInputStream(bais);
    Model deserializedGraph = (Model)in.readObject();
    in.close();

    assertFalse(deserializedGraph.isEmpty());

    for (Statement st : deserializedGraph) {
      assertTrue(model.contains(st));
      assertTrue(testCon.hasStatement(st, true));
    }
View Full Code Here

  protected final Representation getRepresentation(RDFWriterFactory factory, MediaType mediaType)
    throws ResourceException
  {
    try {
      Model config = getRepositoryManager().getRepositoryConfig(configurationID);

      if (config == null) {
        throw new ResourceException(CLIENT_ERROR_NOT_FOUND, "No such configuration: " + configurationID);
      }
View Full Code Here

  @Override
  protected Representation put(Representation entity, Variant variant)
    throws ResourceException
  {
    Model model = parseContent(entity);

    try {
      getRepositoryManager().addRepositoryConfig(configurationID, model);
      return null;
    }
View Full Code Here

    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
View Full Code Here

  protected final Representation getRepresentation(RDFWriterFactory factory, MediaType mediaType)
    throws ResourceException
  {
    try {
      Model schemas = getRepositoryManager().getConfigTemplateManager().getSchemas();
      schemas = new ModelOrganizer(schemas).organize();
      return new ModelRepresentation(schemas, factory, mediaType);
    }
    catch (StoreConfigException e) {
      throw new ResourceException(e);
View Full Code Here

  @Override
  protected Representation put(Representation entity, Variant variant)
    throws ResourceException
  {
    Model model = parseContent(entity);

    try {
      getRepositoryManager().getConfigTemplateManager().addTemplate(templateID, model);
      return null;
    }
View Full Code Here

    RDFFormat rdfFormat = Rio.getParserFormatForMIMEType(mimeType);

    try {
      RDFParser parser = Rio.createParser(rdfFormat);

      Model model = new LinkedHashModel();
      parser.setRDFHandler(new StatementCollector(model));

      parser.parse(entity.getStream(), "");

      return model;
View Full Code Here

      URIFactory uf = repository.getURIFactory();
      LiteralFactory lf = repository.getLiteralFactory();

      URI subj = uf.createURI(getRequest().getResourceRef().toString(false, false));

      Model model = new LinkedHashModel();
      for (PropertyDescriptor p : properties) {
        Object o = p.getReadMethod().invoke(data);
        if (o instanceof Object[]) {
          for (Object e : (Object[])o) {
            add(model, subj, uf, p.getName(), lf, e);
View Full Code Here

    /**
     * Test related to STANBOL-698
     */
    @Test
    public void testDouble(){
        Model graph = new TreeModel();
        URI id = vf.createURI("http://www.example.org/test");
        URI doubleTestField = vf.createURI("http://www.example.org/field/double");
        graph.add(id, doubleTestField, vf.createLiteral(Double.NaN));
        graph.add(id, doubleTestField, vf.createLiteral(Double.POSITIVE_INFINITY));
        graph.add(id, doubleTestField, vf.createLiteral(Double.NEGATIVE_INFINITY));
       
        RdfValueFactory valueFactory = new RdfValueFactory(graph,vf);
        Representation r = valueFactory.createRepresentation(id.stringValue());
        Set<Double> expected = new HashSet<Double>(Arrays.asList(
            Double.NaN, Double.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY));
View Full Code Here

TOP

Related Classes of org.openrdf.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.