Package org.ontoware.rdf2go.model.node

Examples of org.ontoware.rdf2go.model.node.Node


                    target);
          } else {
            s = stmt.getSubject();
          }
         
          Node o;
          // use mapping from node-IDs in impl-source to blank nodes
          // in impl-target
          if(blankObject) {
            o = transform(stmt.getObject().asBlankNode(), bnodeSourceId2bnodeTarget,
                    target);
View Full Code Here


      if(s.getSubject() instanceof BlankNode) {
        badStatements.add(s);
        subject = bnodeToUri((BlankNode)subject, replacement, counter);
        counter++;
      }
      Node object = s.getObject();
      if(object instanceof BlankNode) {
        badStatements.add(s);
        object = bnodeToUri((BlankNode)object, replacement, counter);
        counter++;
      }
View Full Code Here

        Model remove = RDF2Go.getModelFactory().createModel();
        remove.open();
        for (Statement stmt : model) {
            Resource subj = stmt.getSubject();
            URI pred = stmt.getPredicate();
            Node obj = stmt.getObject();
            boolean match = false;
            if (subj instanceof BlankNode) {
                match = true;
                URI newSubj = nodeMap.get(subj);
                if (newSubj == null) {
                    newSubj = URIGenerator.createNewRandomUniqueURI();
                    nodeMap.put(subj.asBlankNode(), newSubj);
                }
                subj = newSubj;
            }
            if (obj instanceof BlankNode) {
                match = true;
                URI newObj = nodeMap.get(obj);
                if (newObj == null) {
                    newObj = URIGenerator.createNewRandomUniqueURI();
                    nodeMap.put(obj.asBlankNode(), newObj);
                }
                obj = newObj;
            }
            if (match) {
                remove.addStatement(stmt);
View Full Code Here

                model.findStatements(
                Variable.ANY, NIE.plainTextContent, Variable.ANY);
            StringBuilder text = new StringBuilder(10000);
            while (statements.hasNext()) {
                Statement statement = statements.next();
                Node value = statement.getObject();
                if (value instanceof Literal) {
                    text.append(((Literal)value).getValue());
                }
            }
            result = text.toString().trim();
View Full Code Here

  private String[] readFromStorage(Person person, BookmarkingSource bookmarkingSource) {
    ClosableIterator<Statement> statements = model.findStatements(null,person.getResource(), new URIImpl(S3B_SYNCHRONIZATION.hasBookmarkingSource), null);
    String[] result = null;
    while(statements.hasNext()){
      Statement statement = statements.next();
      Node value = statement.getObject();
      if(value != null && value.toString().startsWith(bookmarkingSource.getSourceServerURI())){
        result = restoreCredentialsFromURI(value.toString());
      }
    }
    statements.close();
    return result;
  }
View Full Code Here

  private void writeToStorage(Person person, String bookmarkingSourceURI, String loginToStore, String passwordToStore) {
    URI usersBookmarkinSourceURI = createCredentialsURI(bookmarkingSourceURI, loginToStore, passwordToStore);
    ClosableIterator<Statement> statements = model.findStatements(null,person.getResource(), new URIImpl(S3B_SYNCHRONIZATION.hasBookmarkingSource), null);
    while(statements.hasNext()){
      Statement statement = statements.next();
      Node value = statement.getObject();
      if(value != null && value.toString().startsWith(bookmarkingSourceURI)){
        model.removeStatement(statement);
      }
    }
    model.addStatement(null,person.getResource(), new URIImpl(S3B_SYNCHRONIZATION.hasBookmarkingSource), usersBookmarkinSourceURI);
    statements.close();
View Full Code Here

    URI type = RDF.type;
   
    ClosableIterator<Statement> results = DbFace.getModel().findStatements(null,res, type, null);
    while(results.hasNext())
    {
      Node val = results.next().getObject();
      if(val.toString().equals(S3B_SSCF.WebResource))
      {
        results.close();
        return true;
      }
    }
View Full Code Here

   * @param value
   */
  public void setEvaluation(Person person, Float value) {
    this.synchronize();
    synchronized (this) {
      Node eval = null;
 
      if (this.mapIsEvaluated.get(person) != null) {
       
        try
        {
          QueryResultTable results = model.querySelect(RdfQuery.RDFQ_EVAL_QUERY.toString(
              this.resource, S3B_SSCF.isEvaluatedWith,
              SIOC.postedBy, person.getResource()),"SPARQL");
         
          for(QueryRow qr: results){
            eval = qr.getValue(results.getVariables().get(0));
          }
        }
        catch (Exception e)
        {
          eval = null;
        }
      }

      try {
        if (eval == null) {
          BlankNode bnodeEval = model.createBlankNode();
          model.addStatement(null,bnodeEval, RDF.type, model.createURI(S3B_SSCF.Evaluation));
          model.addStatement(null,bnodeEval, model.createURI(SIOC.postedBy),person.getResource());
          model.addStatement(null,bnodeEval, model.createURI(S3B_SSCF.value),model.createDatatypeLiteral(value.toString(),XSD._string));
          model.addStatement(null,this.resource,model.createURI(S3B_SSCF.isEvaluatedWith),bnodeEval);
        } else {
         
          model.removeStatements(null,eval.asBlankNode(), model.createURI(S3B_SSCF.value), null);
          //XXX: not sure if it will be working...
          model.addStatement(null,eval.asBlankNode(),model.createURI(S3B_SSCF.value),model.createDatatypeLiteral(value.toString(),XSD._string));
        }
       

        this.mapIsEvaluated.put(person, value);
      } catch (Exception e) {
View Full Code Here

            this.resource, S3B_SSCF.isEvaluatedWith,
            SIOC.postedBy, person.getResource()),"SPARQL");
         
         
          for(QueryRow qr: results) {
            Node eval = qr.getValue(results.getVariables().get(0));
            if(eval!=null) {
              removeGraphProperty(new URIImpl(S3B_SSCF.isEvaluatedWith), eval);
              model.removeStatements(null,eval.asBlankNode(), null, null);
              this.mapIsEvaluated.remove(person);
            }
          }
        }
        catch (Exception e)
View Full Code Here

     
          String litIssueDate = getStringProperty(S3B_SSCF.issueDate);
          this.issueDate = (litIssueDate != null) ? new Date(Long
              .parseLong(litIssueDate)) : null;

          Node indIssued = getGraphPropertyValue(S3B_SSCF.issuedBy);
          this.issuedBy = null;
          if(indIssued!=null)
            this.issuedBy = PersonFactory.getPerson(indIssued.asURI());
             
          if(this.issuedBy==null)
          {
            this.issuedBy = (indIssued != null) ? SscfTagger.getSscfTagger(indIssued.toString()) : null;
          }
         
          //TODO: should be with datatype
          Integer litResourceHits = getIntegerProperty(S3B_SSCF.resourceHits);
          try
          {
            this.resourceHits = (litResourceHits != null) ? litResourceHits : 0;
          }
          catch(Exception e)
          {
            this.resourceHits = 0;
          }
           
          ClosableIterator<Statement> it = model.findStatements(null,this.resource, RDF.type,new URIImpl(S3B_SSCF.Directory));
          isDir = it.hasNext();
          it.close();
         
          this.tags = BookmarksHelper.listTags(this.getStringURI());
         
          QueryResultTable results = model.querySelect(RdfQuery.RDFQ_PERSON_VALUE_QUERY.toString(
              this.resource, S3B_SSCF.isEvaluatedWith,
              SIOC.postedBy, S3B_SSCF.value),"SPARQL");
         
          for(QueryRow qr : results) {
            try
            {
              Node person = qr.getValue(results.getVariables().get(0));
              //XXX: here may be something wrong
              float val = Float.parseFloat(qr.getValue(results.getVariables().get(1)).toString());
              this.mapIsEvaluated.put(PersonFactory.getPerson(person.asURI()), val);
            }
            catch (Exception e)
            {
              //in case of any error - put nothing
            }
View Full Code Here

TOP

Related Classes of org.ontoware.rdf2go.model.node.Node

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.