Package com.hp.hpl.jena.rdf.model

Examples of com.hp.hpl.jena.rdf.model.Model


  public void handle(Request request, Response response)
      throws HandlerException {
    MultiPartBody body = ParameterUtil.parseMultipart(request);
    final FormFile formFile = body.getFormFileParameterValues("file")[0];
    final String locationString = body.getTextParameterValues("location")[0];
    final Model editableModel = ModelFactory.createDefaultModel();
    final Resource infoBitResource = editableModel.createResource();
   
    infoBitResource.addProperty(DISCOBITS.mediaType, formFile
        .getMimeType().toString());
    infoBitResource.addProperty(DISCOBITS.bytes, editableModel
        .createTypedLiteral(formFile.getContent()));
    infoBitResource.addProperty(RDF.type, DISCOBITS.InfoBit);
    store.perform(identity, new StoreTransaction() {

      public void execute(SourceStoreView storeView) {
        NamedNode locationNode = new NamedNodeImpl(locationString);
        FCAGraph origGraph = storeView.getGraph().filter(
            Collections.singleton((GroundedNode) locationNode));
        Model origModel = ModelFactory.createModelForGraph(origGraph);
        editableModel.add(origModel);
        Resource locationResource = editableModel
            .createResource(locationString);
        locationResource.addProperty(RDF.type, DISCOBITS.InfoDiscoBit);
        locationResource.removeAll(DISCOBITS.infoBit);
View Full Code Here


        date = new SimpleDateFormat("yyyyMMddHHmmssSSS")
            .parse(dateString);
      } catch (ParseException e) {
        throw new RuntimeException(e);
      }
      Model model = ModelFactory.createDefaultModel();
      try {
        model.read(file.toURL().toString());
      } catch (MalformedURLException e) {
        throw new RuntimeException(e);
      }
      FCAGraph graph = new FCAGraphImpl(model);
      assertions.add(new Assertion(new SourceImpl(sourceString), graph,
View Full Code Here

   * @see com.hp.hpl.jena.gvs.tool.GVSToolCommand#execute(com.hp.hpl.jena.gvs.Store, com.hp.hpl.jena.gvs.tool.GVSToolArguments)
   */
  @Override
  protected void execute(Store store, UpdateAssertCommandArguments arguments) {
    File uploadFile = arguments.getUploadFile();
    Model model = ModelFactory.createDefaultModel();
    String fileURLString;
    try {
      fileURLString = uploadFile.toURL().toString();
    } catch (MalformedURLException e1) {
      throw new RuntimeException(e1);
    }
    String lang = "RDF/XML";
    if (fileURLString.endsWith(".nt")) {
      lang = "N-TRIPLE";
    } else {
      if (fileURLString.endsWith(".n3") || fileURLString.endsWith(".turtle")) {
        lang = "N3";
      }
    }
    model.read(fileURLString, lang);
    Graph graph = JenaUtil.getGraphFromModel(model, true);
    Source identity = arguments.getIdentity();
    store.assertGraph(identity, new FCAGraphImpl(graph))
  }
View Full Code Here

      throws HandlerException {
    if (sources.size() != 1) {
      throw new RuntimeException("Must PUT as exactly one source");
    }
    Source source = sources.iterator().next();
    Model bodyModel = ModelFactory.createDefaultModel();
    try {
      bodyModel.read(Channels.newInputStream(request.getMessageBody()
          .read()), source.getURIRef());
    } catch (Exception e) {
      throw new HandlerException(e);
    }
    final FCAGraph graph = new FCAGraphImpl(bodyModel);
View Full Code Here

    ParameterCollection parameters = ParameterUtil.getBodyPameters(request);
   
    Source source = sources.iterator().next();
    String assertedRDFXML = parameters.getParameteValues("assert")[0].toString();
    String revokedRDFXML = parameters.getParameteValues("revoke")[0].toString();
    Model assertedModel = ModelFactory.createDefaultModel();
    assertedModel
        .read(new StringReader(assertedRDFXML), source.getURIRef());
    FCAGraph assertedGraph = new FCAGraphImpl(assertedModel);
    Model revokedModel = ModelFactory.createDefaultModel();
    revokedModel.read(new StringReader(revokedRDFXML), source.getURIRef());
    FCAGraph revokedGraph = new FCAGraphImpl(revokedModel);
    store.changeGraph(source, revokedGraph, assertedGraph);
  }
View Full Code Here

  /**
   * Test if a model on fca is isomorphic with model converted using JenaUtil
   *
   */
  public void testComapringWithConverter() {
    Model origModel = ModelCreationUtil.createRandomModel(1000);
    Graph origGraph = JenaUtil.getGraphFromModel(origModel, true);
    Graph leanGraph = MoleculeBasedLeanifier.getLeanVersionOf(origGraph);
    Model leanModel = JenaUtil.getModelFromGraph(leanGraph);
    FCAGraph fcaGraph = new FCAGraphImpl(leanGraph);
    Model modelOnFCA = ModelFactory.createModelForGraph(fcaGraph);
    assertTrue(leanModel.isIsomorphicWith(modelOnFCA));
  }
View Full Code Here

  /**
   * test the filter-method using the model in filter-test.n3
   *
   */
  public void testFilter() {
    Model model = ModelFactory.createDefaultModel();
    model.read(getClass().getResource("filter-test.n3").toString(),
        "N3");
    FCAGraph fcaGraph = new FCAGraphImpl(model);
    FCAGraph subGraph = fcaGraph.filter(Collections.singleton((GroundedNode)new NamedNodeImpl("mailto:test@example.org")));
    assertEquals(3, subGraph.size());
    FCAGraph subGraph2 = fcaGraph.filter(Collections.singleton((GroundedNode)new NamedNodeImpl("http://example.org/foo")));
View Full Code Here

  public void testSingleLatest() throws Exception {
    testWithCannedData(new RetrievalTest() {

      public void performTest(ServerBinding serverBinding)
          throws Exception {
        Model model = ModelFactory.createDefaultModel();
        model.read(new File("testdata/danbri-20060920123618661.rdf")
            .toURL().toString());
        URL serverURL = new URL("http://"
            + serverBinding.getInetAddress().getHostName() + ":"
            + serverBinding.getPort() + "/danbri");
        Model retrievedModel = ModelFactory.createDefaultModel();
        retrievedModel.read(serverURL.toString());
        // retrievedModel = LeanDiffPatch.leanify(retrievedModel);
        model = LeanDiffPatch.leanify(model);
        log.info(model.size());
        log.info(retrievedModel.size());
        log.info(LeanDiffPatch.getDiff(model, retrievedModel));
        assertTrue(model.isIsomorphicWith(retrievedModel));

      }
View Full Code Here

  public void testSinglePrevious() throws Exception {
    testWithCannedData(new RetrievalTest() {

      public void performTest(ServerBinding serverBinding)
          throws Exception {
        Model model = ModelFactory.createDefaultModel();
        model.read(new File("testdata/danbri-19980920123600000.rdf")
            .toURL().toString());
        URL serverURL = new URL("http://"
            + serverBinding.getInetAddress().getHostName() + ":"
            + serverBinding.getPort() + "/danbri?moment=20040302");
        Model retrievedModel = ModelFactory.createDefaultModel();
        retrievedModel.read(serverURL.toString());
        // retrievedModel = LeanDiffPatch.leanify(retrievedModel);
        model = LeanDiffPatch.leanify(model);
        assertTrue(model.isIsomorphicWith(retrievedModel));

      }
View Full Code Here

  public void testMultipleLatest() throws Exception {
    testWithCannedData(new RetrievalTest() {

      public void performTest(ServerBinding serverBinding)
          throws Exception {
        Model model = ModelFactory.createDefaultModel();
        model.read(new File("testdata/danbri-20060920123618661.rdf")
            .toURL().toString());
        model.read(new File("testdata/nadia-20060919113256000.rdf")
            .toURL().toString());
        String danbriSourceURLString = "http://"
            + serverBinding.getInetAddress().getHostName() + ":"
            + serverBinding.getPort() + "/danbri";
        String naidaSourceURLString = "http://"
            + serverBinding.getInetAddress().getHostName() + ":"
            + serverBinding.getPort() + "/nadia";
        String serviceBaseURLString = "http://"
            + serverBinding.getInetAddress().getHostName() + ":"
            + serverBinding.getPort() + "/gvs?";
        URL serviceURL = new URL(serviceBaseURLString + "source="
            + URLEncoder.encode(danbriSourceURLString, "utf-8")
            + "&source="
            + URLEncoder.encode(naidaSourceURLString, "utf-8"));
        Model retrievedModel = ModelFactory.createDefaultModel();
        retrievedModel.read(serviceURL.toString());
        retrievedModel = LeanDiffPatch.leanify(retrievedModel);
        model = LeanDiffPatch.leanify(model);
        assertTrue(model.isIsomorphicWith(retrievedModel));

      }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.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.