Package com.hp.hpl.jena.rdf.model

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


   * @param uri the (named) root of the XML output
   * @return XML Document
   */

  public Document drop(Model model, URI uri) throws Exception {
    Resource rez = model.getResource(uri.toString());
    return drop(rez);
  }
View Full Code Here


            }
            continue; // All is well, keep what we have
          }

          Node nodeVal;
          Resource valType = getObjectType(triple.getPredicate());
          // This attribute points to a ldap node
          if (LdapMap.ObjectProperty.equals(valType))
            nodeVal = createLdapNode((String) val);
          else if (LdapMap.EmailProperty.equals(valType))
            nodeVal = Node.createURI("mailto:" + val);
View Full Code Here

      /* Prebind object (if possible) */
      Node theObject = triple.getObject();
      if (theObject.isVariable() && binding.contains(theObject.getName()))
        theObject = binding.get(theObject.getName());

      Resource valType = getObjectType(triple.getPredicate());
      if (theObject.isVariable())
        toGet.add(attr);
      else // TODO if pred is type, map values to ldap equivalent
      {
        toGet.add(attr); /* TODO dump this! stupid! Prebinding work around */
 
View Full Code Here

  private Resource getSubject(Property property, RDFNode object)
  {
    ResIterator found = config.listSubjectsWithProperty(property, object);
    if (!found.hasNext())
      return null;
    Resource foundSubject = found.nextResource();
    found.close();
    return foundSubject;
  }
View Full Code Here

    return foundSubject;
  }

  private Resource getObjectType(Node predicate)
  {
    Resource subj = getSubject(LdapMap.property, config
        .asRDFNode(predicate));
    if (subj == null)
      return null;
    Statement s = subj.getProperty(RDF.type);
    if (s == null)
      return null;
    return s.getResource();
  }
View Full Code Here

      log.warn("There is more than one map in the config file");
   
    StmtIterator si = map.listProperties(DbMap.mapsClass);
    while (si.hasNext())
    {
      Resource aClass = si.nextStatement().getResource();
      initFromClass(aClass);
   
    si.close();
    si = configModel.listStatements(null, DbMap.foreignKey, (RDFNode) null);
    while (si.hasNext())
View Full Code Here

   */
  private void initFromClass(Resource aClass) throws ConfigException
  {
    if (class2table.containsKey(aClass)) return; // already done
   
    Resource db = aClass.getProperty(DbMap.database).getResource();
   
    Database database = getDatabase(db);
       
    Table table = new Table(aClass, database);
    class2table.put(aClass, table);
    ResIterator ri = aClass.getModel().listSubjectsWithProperty(RDFS.domain, aClass);
    while (ri.hasNext())
    {
      Resource prop = ri.nextResource();
      Col col = new Col(prop, table);
      prop2col.put(prop, col);
    }
    StmtIterator si = aClass.listProperties(DbMap.primaryKey);
    while (si.hasNext())
    {
      Resource primKey = si.nextStatement().getResource();
      Col primCol = prop2col.get(primKey);
      if (primCol == null)
        throw new ConfigException("Primary key unknown: " + primKey);
      else
        primCol.setIsPrimaryKey(true);
View Full Code Here

     
      if (predicate.equals(RDF.Nodes.type)) // RDB map is staticly typed, so this is not that useful
      {
        if (object.isConcrete())
        {
          Resource theClass = (Resource) configModel.asRDFNode(object);
          Table table = class2table.get(theClass);
          if (table == null)
            throw new InconsistentException("Unknown class: " + object);
          checkClasses(subject, theClass, nodeToClass);
          nodeToClass.put(subject, theClass);
          query.add(subject, table); // Just add the subject and table to the query.
        }
        else
          throw new UnanswerableException("No type matches (yet)");
        continue;
      }
     
      Resource prop = (Resource) configModel.getRDFNode(predicate);
      if (!prop2col.containsKey(prop))
        throw new InconsistentException("Unknown predicate: " + triple);

      /* Domain / Range checks -- subjects have types specific to tables, objects are literals */
      checkClasses(subject, prop.getProperty(RDFS.domain).getResource(), nodeToClass);
      checkClasses(object, RDFS.Literal, nodeToClass);
     
      //if (subject.isConcrete())
      //  throw new UnanswerableException("Concrete subject given: " + triple);
     
View Full Code Here

    {
      nodeToClass.put(node, aClass);
      return;
    }
   
    Resource existingClass = (Resource) nodeToClass.get(node);
    if (!existingClass.equals(aClass))
      throw new InconsistentException("Inconsistent classes for " + node +
          ": both " + existingClass + " and " + aClass);
  }
View Full Code Here

 
  public void testExtractConfig() throws SQLException, ClassNotFoundException
  {
    Model config = ExtractConfig.process("jdbc:hsqldb:mem:test", "org.hsqldb.jdbcDriver", "urn:ex:", "sa", "", new String[]{"TABLE1", "TABLE2"}, conn.getMetaData());
   
    Resource table1 = config.createResource("urn:ex:TABLE1");
    Resource table2 = config.createResource("urn:ex:TABLE2");
    Resource map = config.createResource("urn:ex:map");
    assertTrue("Found table1", config.contains(table1, RDF.type, RDFS.Class));
    assertTrue("Found table2", config.contains(table2, RDF.type, RDFS.Class));
    assertTrue("Map maps table1", config.contains(map, DbMap.mapsClass, table1));
   
    config.write(System.out, "RDF/XML-ABBREV");
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.rdf.model.Resource

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.