Examples of RDFNode


Examples of com.hp.hpl.jena.rdf.model.RDFNode

    StmtIterator it = tplModel.listStatements();
    while (it.hasNext()) {
      Statement stmt = it.nextStatement();
      Resource subj = stmt.getSubject();
      Property pred = stmt.getPredicate();
      RDFNode  obj  = stmt.getObject();
     
      try {
        if (subj.toString().contains(metadataPlaceholderURIPrefix)){
          subj = (Resource) parsePlaceholder(subj, controller, currentTime, currentDocRepr);
          if (subj == null) {
            // create a unique blank node with a fixed id.
            subj = getModel().createResource(new AnonId(String.valueOf(stmt.getSubject().hashCode())));
          }
        }
       
        if (obj.toString().contains(metadataPlaceholderURIPrefix)){
          obj = parsePlaceholder(obj, controller, currentTime, currentDocRepr);
        }
       
        // only add statements with some objects
        if (obj != null) {
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

 
  public String getImageURL() {
    Collection<RDFNode> candidates = getValuesFromMultipleProperties(config.getImageProperties());
    Iterator<RDFNode> it = candidates.iterator();
    while (it.hasNext()) {
      RDFNode candidate = (RDFNode) it.next();
      if (candidate.isURIResource()) {
        return ((Resource) candidate.as(Resource.class)).getURI();
      }
    }
    return null;
  }
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

    Iterator<Property> it = properties.iterator();
    while (it.hasNext()) {
      com.hp.hpl.jena.rdf.model.Property property = (com.hp.hpl.jena.rdf.model.Property) it.next();
      StmtIterator labelIt = resource.listProperties(property);
      while (labelIt.hasNext()) {
        RDFNode label = labelIt.nextStatement().getObject();
        results.add(label);
      }
    }
    return results;
  }
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

  // TODO: There is some better (?) code doing the same in VocabularyStore.I18nStringValueCache
  private Literal getBestLanguageMatch(Collection<RDFNode> nodes, String lang) {
    Iterator<RDFNode> it = nodes.iterator();
    Literal aLiteral = null;
    while (it.hasNext()) {
      RDFNode candidate = it.next();
      if (!candidate.isLiteral()) continue;
      Literal literal = candidate.asLiteral();
      if (lang == null
          || lang.equals(literal.getLanguage())) {
        return literal;
      }
      aLiteral = literal;
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

            if(vars.size()!=1) {
                throw new Exception("Scalar query returns other than one column");
            }

            QuerySolution row=results.nextSolution();
            RDFNode value=row.get(vars.get(0));
            if (results.hasNext()) {
                throw new Exception("Scalar query returns more than one row");
            }
            return value;
        } finally { qe.close(); }
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

            Map<RDFNode,RDFNode> map=Maps.newHashMap();
            List<String> vars=results.getResultVars();

            while(results.hasNext()) {
                QuerySolution row=results.nextSolution();
                RDFNode key=row.get(vars.get(0));
                if(seen.contains(key)) {
                    map.remove(key);
                } else {
                    seen.add(key);
                    map.put(key,row.get(vars.get(1)));
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

    StmtIterator existingStmts = model.listStatements();
    while ( existingStmts.hasNext() ) {
      Statement o_stmt = existingStmts.nextStatement();
      Resource sbj = o_stmt.getSubject();
      Property prd = o_stmt.getPredicate();
      RDFNode obj = o_stmt.getObject();
     
      boolean any_change = false;
      Resource n_sbj = sbj;
      Property n_prd = prd;
      RDFNode  n_obj = obj;

//      if ( oldNameSpace.equals(sbj.getNameSpace()) ) {
      if ( _inNamespace(sbj, oldNameSpace) ) {
        n_sbj = model.createResource(newNameSpace + sbj.getLocalName());
        any_change = true;
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

    StmtIterator existingStmts = model.listStatements();
    while ( existingStmts.hasNext() ) {
      Statement o_stmt = existingStmts.nextStatement();
      Resource sbj = o_stmt.getSubject();
      Property prd = o_stmt.getPredicate();
      RDFNode obj = o_stmt.getObject();
     
      // will indicate that o_stmt is affected by the namespace change:
      boolean any_change = false;
     
      // the new triplet, initialized with the existing statement:
      Resource n_sbj = sbj;
      Property n_prd = prd;
      RDFNode  n_obj = obj;

      if ( oldNameSpace.equals(sbj.getNameSpace()) ) {
        // the subject is affected; create new subject
        n_sbj = model.createResource(newNameSpace + sbj.getLocalName());
        any_change = true;
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

  public static String getOntologyPropertyValue(OntModel ontModel, Property prop) {
    Ontology ontology = getOntology(ontModel);
    if ( ontology == null ) {
      return null;
    }
    RDFNode node = ontology.getPropertyValue(prop);
    if ( node == null ) {
      return null;
    }
    return node.toString();
  }
View Full Code Here

Examples of com.hp.hpl.jena.rdf.model.RDFNode

  public static String setVersionFromCreationDateIfNecessary(OntModel ontModel) {
    Ontology ontology = getOntology(ontModel);
    if ( ontology == null ) {
      return null;
    }
    RDFNode node = ontology.getPropertyValue(Omv.version);
    if ( node != null ) {
      // already assigned; keep it:
      return null;
    }
    // omv.version not assigned; try to use omv.creationDate:
    node = ontology.getPropertyValue(Omv.creationDate);
    if ( node == null ) {
      // not available, return with no changes:
      return null;
    }
   
    String creationDate = node.toString();
    String version = _getVersionFromCreationDate(creationDate);
    if ( version != null ) {
      Literal versionLit = ResourceFactory.createPlainLiteral(version);
      ontology.setPropertyValue(Omv.version, versionLit);
      return version;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.