Package org.openrdf.model

Examples of org.openrdf.model.Graph


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

    Graph graph;
    RepositoryResult<Statement> statements = testCon.getStatements(null, null, null, true);
    try {
      graph = new GraphImpl(vf, statements.asList());
    }
    finally {
      statements.close();
    }

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

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

    assertFalse(deserializedGraph.isEmpty());

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


    return contextGraph.contains(statement);
  }

  public void reload() {
    try {
      Graph new_graph = repository.performGraphQuery(QueryLanguage.SERQL,
          "CONSTRUCT * FROM {s} p {o}");
     
      if(graph != null)
        graph.add(new_graph);
      else
View Full Code Here

          QueryLanguage.SERQL, RecommendationQueries.GENERAL_BNODE_LABEL_QUERY.toString("_:"+bnode, RecommendationQueries.HAS_WEIGHT_URI))[0].toString());
  }*/
 
 
  public void saveUserRecommendationPrefs(String user) {
    Graph gToAdd = SesameUtils.createGraph()
    ValueFactory vf = gToAdd.getValueFactory();
   
    Resource r = vf.createURI(user);
    BNode bn = vf.createBNode();
    URI uint = vf.createURI("http://www.w3.org/2001/XMLSchema#integer");
   
View Full Code Here

    return result;
  }
 
  public static void removeUserRecommendationPrefs(String user) {
    Graph toRemove = SesameWrapper.performGraphQuery(Repository.FOAFREALM_REPOSITORY.getLocalRepository(),
                             QueryLanguage.SERQL,
                             RecommendationQueries.GET_RECOMMENDATIONS_BNODES.toString(user));
   
    SesameWrapper.removeGraph(Repository.FOAFREALM_REPOSITORY.getLocalRepository(), toRemove);
  }
View Full Code Here

    sSubject1.removeAll(sValues2);
    sSubject2.removeAll(sValues1);
   
   
    try {
      Graph g = lr.getGraph();
     
      for(Value va : sSubject1)
        for(Value vz : sSubject2) {
          Graph gv = SesameWrapper.performGraphQuery(Repository.MAIN_REPOSITORY.getLocalRepository(), QueryLanguage.SERQL, RDFQuery.RDFQ_BIND.toString(va, vz));
          Graph gv2 = SesameWrapper.performGraphQuery(Repository.MAIN_REPOSITORY.getLocalRepository(), QueryLanguage.SERQL, RDFQuery.RDFQ_BIND.toString(vz, va));
         
          g.add(gv);
          g.add(gv2);
        }
     
View Full Code Here

    try {
      stmtit = tmprep.getGraph().getStatements();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to temporal graph"+e);
    }
    Graph g = null;
    try {
      g = Repository.MAIN_REPOSITORY.getLocalRepository().getGraph();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to main graph"+e);
    }
   
    if(g!=null) {
      //adding all new to the main graph
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          if(!g.contains(stmt)) {
            g.add(stmt);
          }
        }
     
      //add all to MAP_CONCEPTS_PREDEFINED
      stmtit = g.getStatements(null, property.getURI(g), null);
     
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          MAP_CONCEPTS_PREDEFINED.put(stmt.getObject().toString(), stmt.getSubject().toString());
View Full Code Here

    try {
      stmtit = tmprep.getGraph().getStatements();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to temporal graph"+e);
    }
    Graph g = null;
    try {
      g = Repository.MAIN_REPOSITORY.getLocalRepository().getGraph();
    } catch (AccessDeniedException e) {
      Repository.logger.severe("access denied to main graph"+e);
    }
   
    if(g!=null) {
      //adding all new to the main graph
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          if(!g.contains(stmt)) {
            g.add(stmt);
          }
        }
     
      //add all to MAP_CONCEPTS_PREDEFINED
      stmtit = g.getStatements(null, property.getURI(g), null);
     
      if(stmtit!=null)
        while(stmtit.hasNext()) {
          Statement stmt = stmtit.next();
          String key = stmt.getObject().toString();
View Full Code Here

    String spathAxis = this.getParams().get(2);
    AxisPath axisPath = new AxisPath(spathAxis);
   
    LocalRepository globalLr = Repository.MAIN_REPOSITORY.getLocalRepository();
   
    Graph g = lr.getGraph();
    ValueFactory vf = g.getValueFactory();
    URI context = vf.createURI(url);
   
    Graph g1 = SesameUtils.getEmptyGraph();
    Graph g2 = SesameUtils.getEmptyGraph();
   
    axisPath.getLastOnList(globalLr, context, g1, true, _usedPath);
    axisPath.getLastOnList(globalLr, context, g2, false, _usedPath);
   
    g1.remove(g2);
View Full Code Here

    String spathAxis = this.getParams().get(2);
    AxisPath axisPath = new AxisPath(spathAxis);
   
    LocalRepository globalLr = Repository.MAIN_REPOSITORY.getLocalRepository();
   
    Graph g = lr.getGraph();
    ValueFactory vf = g.getValueFactory();
    URI context = vf.createURI(url);
    Resource action = axisPath.getLastOnList(globalLr, context, lr.getGraph(), true, _usedPath);
   
    //--inferr isFollowedBy properties
    Graph ginf = SesameWrapper.performGraphQuery(lr, QueryLanguage.SERQL, RDFQuery.RDFQ_INFER_ISFOLLOWEDBY.toString());
    lr.getGraph().add(ginf);

    if(action != null) {
      String squery = RDFQuery.RDFQ_GET_ACTION_IN_CONTEXT.toString(action);
     
      Graph g2 = SesameWrapper.performGraphQuery(globalLr, QueryLanguage.SERQL, squery);
      lr.getGraph().add(g2);
    }
  }
View Full Code Here

    LocalRepository globalLr = Repository.MAIN_REPOSITORY.getLocalRepository();
   
    if(serviceUri == null)
      serviceUri = ConfigKeeper.getServiceUrl()+"/mbb/service/"+serviceId;

    Graph g = lr.getGraph();
    ValueFactory vf = g.getValueFactory();

    URI xsdString = XSD_STRING.getURI(g);
    URI xsdDateTime = XSD_DATETIME.getURI(g);
    URI xsdInt = XSD_INT.getURI(g);
    URI rdfType = vf.createURI(RDF.TYPE);
    URI context = vf.createURI(url);
    URI call = vf.createURI(serviceUri);
   
   
    String actionUri = url+"/action/";
    Resource lastAction = null;
   
   
    // --------------- BEGIN : to be removed -------------------------
//    if(axisPath.isInitial()) {
//      lastAction = AxisPath.getLastAction(globalLr, context, _usedPath);
//      if(lastAction != null)
//        _usedPath.add(0);
//    } else {
//      ///--- follows along axis
//      LocalRepository lr2 = Repository.TEMP_REPOSITORY.getLocalRepository();
//      lastAction =  axisPath.getLastOnList(globalLr, context, lr2.getGraph(), false, _usedPath);
//
//      //--inferr isFollowedBy properties
//      Graph ginf = SesameWrapper.performGraphQuery(lr2, QueryLanguage.SERQL, RDFQuery.RDFQ_INFER_ISFOLLOWEDBY.toString());
//      lr2.getGraph().add(ginf);
//    }
//   
//   
//    URI action = vf.createURI(actionUri+AxisPath.pathToString(_usedPath));
//   
//    if(globalg.contains(action,
//                globalg.getValueFactory().createURI(RDF.TYPE),
//                MBB_BROWSEACTION.getURI(globalg))) {
//      lastAction = AxisPath.getLastAction(globalLr, context, _usedPath);
//      if(lastAction != null)
//        _usedPath.add(0);
//      action = vf.createURI(actionUri+AxisPath.pathToString(_usedPath));
//    }
    // --------------- END : to be removed -------------------------
   
    Graph globalg = globalLr.getGraph();
    boolean isGetLastAction = false;
   
    //--A
    if(axisPath.isInitial()) //--A.1
      isGetLastAction = true;
    else {//--A.2
      LocalRepository lr2 = RepositoryFactory.createTempRepository();
      lastAction =  axisPath.getLastOnList(globalLr, context, lr2.getGraph(), false, _usedPath);

      //--inferr isFollowedBy properties
      Graph ginf = SesameWrapper.performGraphQuery(lr2, QueryLanguage.SERQL, RDFQuery.RDFQ_INFER_ISFOLLOWEDBY.toString());
      lr2.getGraph().add(ginf);

      //--B
      if((axisPath.getPath().size() - 1) == _usedPath.size())//--B.1
        _usedPath.add(axisPath.getPath().get(axisPath.getPath().size()-1));
View Full Code Here

TOP

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