Package org.apache.clerezza.rdf.core

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


    try {
      // throws NoSuchEntityException if a TripleCollection with that name
      // already exists
      this.getTriples(name);
    } catch (NoSuchEntityException e) {
      Graph result;
      if (triples == null) {
        result = new SimpleGraph(new SimpleMGraph());
      } else {
        if (Graph.class.isAssignableFrom(triples.getClass())) {
          result = (Graph) triples;
View Full Code Here


  @Test
  public void testBackup() throws IOException {
    //Graph downloadedTestGraphX = null;
    //Graph downloadedTestGraphY = null;
    Graph downloadedBackupContentsGraph = null;

    byte[] download = backup.createBackup();
    ByteArrayInputStream bais = new ByteArrayInputStream(download);
    ZipInputStream compressedTcs = new ZipInputStream(bais);

    Map<String, TripleCollection> extractedTc = new HashMap<String, TripleCollection>();
    String folder = "";
    ZipEntry entry;
    while ((entry = compressedTcs.getNextEntry()) != null) {
      String entryName = entry.getName();
      if (entry.isDirectory()) {
        folder = entryName;
      } else {
        Assert.assertTrue(entryName.startsWith(folder+testGraphFileName)
            || entryName.equals(backupContentFileName));
        ByteArrayOutputStream baos = new ByteArrayOutputStream(download.length);
        int count;
        byte buffer[] = new byte[2048];
        while ((count = compressedTcs.read(buffer, 0, 2048)) != -1) {
          baos.write(buffer, 0, count);
        }
        ByteArrayInputStream serializedGraph = new ByteArrayInputStream(
            baos.toByteArray());
        /*if (entryName.equals(folder+testGraphFileName + ".nt")) {
          downloadedTestGraphX = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
        } else if (entryName.startsWith(folder+testGraphFileName)) {
          downloadedTestGraphY = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
        }*/
        if (entryName.equals(backupContentFileName)) {
          downloadedBackupContentsGraph = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
        } else {
          Graph deserializedGraph = parser.parse(serializedGraph,
              SupportedFormat.N_TRIPLE, null);
          extractedTc.put(entryName, deserializedGraph);
        }
        baos.flush();
        baos.close();
View Full Code Here

        containsBNode = true;
      }
    }
    if (containsBNode) {
      GraphNode gn = new GraphNode(resource, tc);
      Graph context = gn.getNodeContext();
      msg.addAll(context);
      tc.removeAll(context);
    } else {
      msg.add(triple);
      tc.remove(triple);
View Full Code Here

  @Test
  public void serviceExecutionTest() {
    try {
      UIMARemoteResourceTaggerService service = new UIMARemoteResourceTaggerService();
      Graph graph = service.tagUri("http://incubator.apache.org/clerezza", "04490000a72fe7ec5cb3497f14e77f338c86f2fe");
      assertNotNull(graph);
    } catch (Exception e) {
      fail(e.getLocalizedMessage());
    }
  }
View Full Code Here

            logger.warn("Sessin key should not be null");
            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
        }

        long start = System.currentTimeMillis();
        Graph g;
        if (serializedGraph != null && !serializedGraph.trim().isEmpty()) {
            g = clerezzaParser.parse(new ByteArrayInputStream(serializedGraph.getBytes()),
                SupportedFormat.RDF_XML);
        } else if (url != null && !url.trim().isEmpty()) {
            URLConnection uc = (new URL(url)).openConnection();
View Full Code Here

            logger.warn("Sessin key should not be null");
            return Response.status(Status.BAD_REQUEST).entity("Session key should not be null").build();
        }

        long start = System.currentTimeMillis();
        Graph g;
        if (rdfFile != null) {
            InputStream is = new ByteArrayInputStream(FileUtils.readFileToByteArray(rdfFile));
            g = clerezzaParser.parse(is, SupportedFormat.RDF_XML);
        } else {
            logger.warn("There is RDF file specified");
View Full Code Here

  }

  @Before
  public void setUp() {

    final Graph graph = Parser.getInstance()
        .parse(getClass().getResourceAsStream("systemgraph.nt"),
            "text/rdf+n3");   
    this.permissionDefinitions = new PermissionDefinitions(
        new SimpleMGraph(graph.iterator()));

    this.allPermissions = new PermissionInfo[] {
        new PermissionInfo(
            "(java.io.FilePermission \"file:///home/foo/-\" \"read,write,delete\")"),
        new PermissionInfo(
View Full Code Here

        Set<Triple> triples = new HashSet<Triple>();

        for (UriRef iri : ontologyProvider.getStore().listTripleCollections()) {
            log.info("{}", iri.toString());
            UriRef entity = new UriRef(Constants.PEANUTS_MINOR_BASE + "#" + Constants.truffles);
            Graph ctx = new GraphNode(entity, ontologyProvider.getStore().getTriples(iri)).getNodeContext();
            Iterator<Triple> it = ctx.iterator();
            while (it.hasNext())
                triples.add(it.next());
        }

        assertFalse(ontologyProvider.getStore().listTripleCollections().isEmpty());
View Full Code Here

        Chain defaultChain = chainManager.getDefault();
        if(defaultChain == null){
            throw new IllegalStateException("Currently no enhancement chain is " +
                "active. Please configure a Chain or enable the default chain");
        }
        Graph ep;
        try {
            ep = defaultChain.getExecutionPlan();
        } catch (ChainException e) {
            throw new IllegalStateException("Unable to get Execution Plan for " +
                "default enhancement chain (name: '"+defaultChain.getName()+
View Full Code Here

        content = getClass().getResourceAsStream(path + "/tbox.owl");
        OntologyInputSource<?> custSrc = new GraphContentInputSource(content, SupportedFormat.TURTLE);
        scope.getCustomSpace().addOntology(custSrc);

        Graph g = scope.export(Graph.class, true);

        // for (Triple t : g)
        // System.out.println(t);
        //
        // OWLOntology o = scope.export(OWLOntology.class, true);
View Full Code Here

TOP

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

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.