Package org.apache.clerezza.rdf.core

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


    throw new NoSuchEntityException(name);
  }

  @Override
  public MGraph getMGraph(UriRef name) throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else if (MGraph.class.isAssignableFrom(tripleCollection.getClass())) {
      return (MGraph) tripleCollection;
    }
    throw new NoSuchEntityException(name);
  }
View Full Code Here


  }

  @Override
  public TripleCollection getTriples(UriRef name)
      throws NoSuchEntityException {
    TripleCollection tripleCollection = tripleMap.get(name);
    if (tripleCollection == null) {
      throw new NoSuchEntityException(name);
    } else {
      return tripleCollection;
    }
View Full Code Here

    final SimpleMGraph resultGraph = new SimpleMGraph();
    GraphNode graphNode = new GraphNode(new BNode(), resultGraph);
    Set<UriRef> tripleCollections = tcManager.listTripleCollections();
    for (UriRef uriRef : tripleCollections) {
      graphNode.addProperty(GRAPHMANAGEMENT.tripleCollection, uriRef);
      final TripleCollection tripleCollection = tcManager.getTriples(uriRef);
      resultGraph.add(new TripleImpl(uriRef,GRAPHMANAGEMENT.size,
          LiteralFactory.getInstance().createTypedLiteral(
          tripleCollection.size())));
      if (tripleCollection instanceof Graph) {
        resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.Graph));
      } else {
        resultGraph.add(new TripleImpl(uriRef,RDF.type, TCPROVIDER.MGraph));
      }
View Full Code Here

    Assert.assertTrue(triples.hasNext());

    String fileName0 = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
    Assert.assertTrue(fileName0.startsWith(folder+testGraphFileName));

    TripleCollection extracted0 = extractedTc.get(fileName0);
    Assert.assertNotNull(extracted0);
    Assert.assertTrue(extracted0.filter(uri0, uri0, uri0).hasNext());

    Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
        testMGraphUri1, RDF.type, BACKUP.MGraph)));

    triples = downloadedBackupContentsGraph.filter(
        testMGraphUri1, BACKUP.file, null);
    Assert.assertTrue(triples.hasNext());

    String fileName1 = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
    Assert.assertTrue(fileName1.startsWith(folder+testGraphFileName));

    TripleCollection extracted1 = extractedTc.get(fileName1);
    Assert.assertNotNull(extracted1);

    Assert.assertTrue(extracted1.filter(uri1, uri1, uri1).hasNext());
 


    Assert.assertTrue(downloadedBackupContentsGraph.contains(new TripleImpl(
        testGraphUriA, RDF.type, BACKUP.Graph)));

    triples = downloadedBackupContentsGraph.filter(
        testGraphUriA, BACKUP.file, null);
    Assert.assertTrue(triples.hasNext());

    String fileNameA = ((TypedLiteral) triples.next().getObject()).getLexicalForm();
    Assert.assertTrue(fileNameA.startsWith(folder+testGraphFileName));
    TripleCollection extractedA = extractedTc.get(fileNameA);
    Assert.assertNotNull(extractedA);

    Assert.assertTrue(extractedA.filter(uriA, uriA, uriA).hasNext());

  }
View Full Code Here

        if (serverSide != null && serverSide.equals("on")){
            applyServerSide = true;
        } else {
            applyServerSide = false;
        }
    TripleCollection defaultGraph = null;
    Object result = null;
    try {
      if (defaultGraphUri == null
          || defaultGraphUri.getUnicodeString().equals("")) {
        defaultGraph = contentGraph;
View Full Code Here

    }
  }

  private List<MSG> decomposeGraphToMSGs(TripleCollection tc) {

    TripleCollection tmp = new SimpleMGraph();
    tmp.addAll(tc);

    List<MSG> msgSet = new LinkedList<MSG>();

    while (tmp.size() > 0) {
      Triple triple = tmp.iterator().next();
      TripleCollection msgTc = new SimpleMGraph();

      boolean containsBNode = fillMSG(triple, tmp, msgTc);
      MSG msg = new MSG(msgTc);
      msg.containsBlankNodes = containsBNode;
      msgSet.add(msg);
View Full Code Here

    private void validateEntity(ClerezzaYard yard, Entry<UriRef,TripleCollection> entity) {
        Representation rep = yard.getRepresentation(entity.getKey().getUnicodeString());
        assertNotNull("The Representation for "+entity.getKey()
            + "is missing in the "+yard.getId(), rep);
        assertTrue("RdfRepresentation expected", rep instanceof RdfRepresentation);
        TripleCollection repGraph = ((RdfRepresentation)rep).getRdfGraph();
        for(Iterator<Triple> triples = entity.getValue().iterator();triples.hasNext();){
            Triple triple = triples.next();
            assertTrue("Data of Representation "+entity.getKey()
                + "is missing the triple "+triple, repGraph.remove(triple));
        }
        assertTrue(repGraph.size()+" unexpected Triples are present in the "
            + "Representation of Entity "+entity.getKey(),repGraph.isEmpty());
    }
View Full Code Here

            else recipeIndexLocation = _RECIPE_INDEX_LOCATION_DEFAULT;
        }

        recipes = new ArrayList<UriRef>();

        TripleCollection tripleCollection = null;
        try {
            tripleCollection = tcManager.getMGraph(new UriRef(recipeIndexLocation));
        } catch (NoSuchEntityException e) {
            tripleCollection = tcManager.createMGraph(new UriRef(recipeIndexLocation));
        }
View Full Code Here

     * Moved form AddRecipe class. The AddRecipe should not be used anymore.
     */
    @Override
    public Recipe createRecipe(UriRef recipeID, String recipeDescription) throws AlreadyExistingRecipeException {

        TripleCollection tripleCollection;
        try {
            // create the MGraph in the TcManager
            tripleCollection = tcManager.createMGraph(recipeID);
        } catch (EntityAlreadyExistsException e) {
            throw new AlreadyExistingRecipeException(e.getMessage());
        }

        Triple recipeTriple = new TripleImpl(recipeID, RDF.type, Symbols.Recipe);

        TripleCollection recipeIndexTripleCollection = tcManager.getMGraph(new UriRef(recipeIndexLocation));
        recipeIndexTripleCollection.add(recipeTriple);

        if (recipeDescription != null && !recipeDescription.isEmpty()) {
            Triple descriptionTriple = new TripleImpl(recipeID, Symbols.description, new PlainLiteralImpl(
                    recipeDescription));
            tripleCollection.add(descriptionTriple);

            recipeIndexTripleCollection.add(descriptionTriple);
        }

        // add the recpe ID to the list of known recipes
        recipes.add(recipeID);

View Full Code Here

        log.debug("Adding rule to recipe " + recipe);
        log.info("Rule : " + rule.toString());

        UriRef recipeID = recipe.getRecipeID();

        TripleCollection tripleCollection = tcManager.getMGraph(recipeID);

        // add the rule object to the graph representation of the recipe by the TcManager
        tripleCollection.add(new TripleImpl(recipeID, Symbols.hasRule, rule.getRuleID()));

        /*
         * extract the rule body and head and add them to the rule object existing in the graph representation
         * of the recipe.
         */
        String stanbolSyntax = rule.toString();
        int indexOfLPar = stanbolSyntax.indexOf("[");
        int indexOfRPar = stanbolSyntax.indexOf("]");
        stanbolSyntax = stanbolSyntax.substring(indexOfLPar + 1, indexOfRPar);

        String[] parts = stanbolSyntax.split("->");

        String body = parts[0].trim();
        String head = parts[1].trim();

        tripleCollection.add(new TripleImpl(rule.getRuleID(), Symbols.ruleName, new PlainLiteralImpl(rule
                .getRuleName())));
        if (description != null && !description.isEmpty()) {
            tripleCollection.add(new TripleImpl(rule.getRuleID(), Symbols.description, new PlainLiteralImpl(
                    description)));
        }
        tripleCollection.add(new TripleImpl(rule.getRuleID(), Symbols.ruleBody, new PlainLiteralImpl(body)));
        tripleCollection.add(new TripleImpl(rule.getRuleID(), Symbols.ruleHead, new PlainLiteralImpl(head)));

        if (description != null) {
            rule.setDescription(description);
        }

View Full Code Here

TOP

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

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.