Package org.ontoware.rdf2go.model

Examples of org.ontoware.rdf2go.model.Diff


  }
 
  @Override
  public boolean isIsomorphicWith(Model other) {
    ClosableIterator<Statement> it = other.iterator();
    Diff diff = this.getDiff(it);
    it.close();
    Iterator<Statement> addIt = diff.getAdded().iterator();
    Iterator<Statement> removeIt = diff.getAdded().iterator();
    boolean result = !addIt.hasNext() && !removeIt.hasNext();
    return result;
  }
View Full Code Here


  }

  /* reifications live in the context where the statement is */
  @Override
    public Resource addReificationOf(Statement statement, Resource resource) {
    Diff diff = new DiffImpl();
    diff.addStatement(createStatement(statement.getContext(), resource,
        RDF.type, RDF.Statement));
    diff.addStatement(createStatement(statement.getContext(), resource,
        RDF.subject, statement.getSubject()));
    diff.addStatement(createStatement(statement.getContext(), resource,
        RDF.predicate, statement.getPredicate()));
    diff.addStatement(createStatement(statement.getContext(), resource,
        RDF.object, statement.getObject()));
    update(diff);
    return resource;
  }
View Full Code Here

  }

  /* delete in ALL contexts */
  @Override
    public void deleteReification(Resource reificationResource) {
    Diff diff = new DiffImpl();
    ClosableIterator<Statement> it;

    it = findStatements(Variable.ANY, reificationResource, RDF.type,
        RDF.Statement);
    while (it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    it = findStatements(Variable.ANY, reificationResource, RDF.subject,
        Variable.ANY);
    while (it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    it = findStatements(Variable.ANY, reificationResource, RDF.predicate,
        Variable.ANY);
    while (it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    it = findStatements(Variable.ANY, reificationResource, RDF.object,
        Variable.ANY);
    while (it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    update(diff);
  }
View Full Code Here

 
  @Override
  public boolean equals(Object other) {
    if(other instanceof Diff) {
     
      Diff diff = (Diff)other;
     
      try {
        log.trace("Comparing two diffs");
        // IMPROVE compare less expensive
        ModelAddRemoveMemoryImpl otherAdded = new ModelAddRemoveMemoryImpl();
        otherAdded.addAll(diff.getAdded().iterator());
       
        ModelAddRemoveMemoryImpl otherRemoved = new ModelAddRemoveMemoryImpl();
        otherRemoved.addAll(diff.getRemoved().iterator());
       
        log.trace("This diff: " + this.addedSet.size() + " added and "
                + this.removedSet.size() + " removed");
        log.trace("Other diff: " + otherAdded.set.size() + " added and "
                + otherRemoved.set.size() + " removed");
View Full Code Here

    return (BlankNode)addReificationOf(statement, bnode);
  }
 
  @Override
  public Resource addReificationOf(Statement statement, Resource resource) {
    Diff diff = new DiffImpl();
    diff.addStatement(resource, RDF.type, RDF.Statement);
    diff.addStatement(resource, RDF.subject, statement.getSubject());
    diff.addStatement(resource, RDF.predicate, statement.getPredicate());
    diff.addStatement(resource, RDF.object, statement.getObject());
    update(diff);
    return resource;
  }
View Full Code Here

    return result;
  }
 
  @Override
  public void deleteReification(Resource reificationResource) {
    Diff diff = new DiffImpl();
    diff.removeStatement(reificationResource, RDF.type, RDF.Statement);
    ClosableIterator<Statement> it = findStatements(reificationResource, RDF.subject,
            Variable.ANY);
    while(it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    it = findStatements(reificationResource, RDF.predicate, Variable.ANY);
    while(it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    it = findStatements(reificationResource, RDF.object, Variable.ANY);
    while(it.hasNext()) {
      diff.removeStatement(it.next());
    }
    it.close();
    update(diff);
  }
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.Diff

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.